Commit graph

1,596 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
9a605d3ef3
ui: versions comparing improvements
Some checks failed
CI - build eBPF modules / build (6.0, 1.6.0) (push) Has been cancelled
Test resources validation / Install tools (push) Has been cancelled
Build status / Build (push) Has been cancelled
v1.6.5.1
When comparing UI/daemon versions to see if they're compatible, we only
use the first 2 components (1.7.xxx), so discard the rest to allow
different versions (1.6.5.1, 1.6.5-1, 1.6.5-rc1, etc)
2024-02-09 17:01:55 +01:00
Gustavo Iñiguez Goia
b05eace022
Bump GUI versions to 1.6.5.1 2024-02-09 14:51:17 +01:00
Gustavo Iñiguez Goia
6809776393
pop-ups: fixed regression for remote nodes
When a new pop-up is triggered from a remote node, the GUI crashed.
This error was introduced by this commit 9fc1da5.

Thanks to @zero77 for reporting it super fast (#1093).
2024-02-09 13:21:01 +01:00
Gustavo Iñiguez Goia
1d2c0703ff
pop-ups: filter by absolute path+cmdline on some cases
Some checks failed
CI - build eBPF modules / build (6.0, 1.6.0) (push) Has been cancelled
Test resources validation / Install tools (push) Has been cancelled
Build status / Build (push) Has been cancelled
v1.6.5
If the pop-ups' target is to filter by cmdline, but the typed/launched
command is not absolute or it starts with /proc, also filter by the
absolute path to the binary.
2024-02-08 17:53:07 +01:00
Gustavo Iñiguez Goia
dd3aba1a6a
ui:use appimages pattern as default target if found
If the path of a process starts with /tmp/.mount_*, which is the common
path for appimages, use it as the default target on the popups.

Previously it was only added to the list of targets, but preselecting it
will help users to create rules for appimages.

(cherry picked from commit 016f4842ff)
2024-02-08 15:34:05 +01:00
Gustavo Iñiguez Goia
b99714ff59
pkgs: improved rpm upgrades
We were not handling configuration upgrades properly on rpm based
systems.

Now local changes to default-config.json and system-fw.json are kept,
and if the distributed files changes in the future, new files will be
created with the extension .rpmnew

(cherry picked from commit dddfdc924e)
2024-02-02 14:21:25 +01:00
Gustavo Iñiguez Goia
da99686ab0
clean dns ebpf hooks on exit
We were not reacting to common exit signals, only to kill/interrupt
signals, so the DNS uprobes were never properly removed. Each uprobe
has the PID of the daemon in the identifier, so in theory, there
shouldn't be conflicts, but better clean our probes on exit.

previous to this commit with the daemon running
(and lot of starts/stops):

~ # cat /sys/kernel/debug/tracing/uprobe_events |wc -l
367

after stopping the daemon:
~ # cat /sys/kernel/debug/tracing/uprobe_events |wc -l
364

~ # > /sys/kernel/debug/tracing/uprobe_events
~ # cat /sys/kernel/debug/tracing/uprobe_events |wc -l
0

~ # cp opensnitchd-new /usr/bin/opensnitchd ; service opensnitchd start
~ # cat /sys/kernel/debug/tracing/uprobe_events |wc -l
3
~ # service opensnitchd stop
~ # cat /sys/kernel/debug/tracing/uprobe_events |wc -l
0

(cherry picked from commit 785500cd08)
2024-01-28 01:14:15 +01:00
Gustavo Iñiguez Goia
d2d89e2359 on aarch64 send exec events directly to userspace
On 68c2c8ae1a we excluded failed execve*
calls from being delivered to userspace, in order to get the binary that
was executed and avoid errors/confusion.

But on aarch64, it seems that we fail to save the exec event to a map,
so the event is never delivered to userspace.

So for the time being, send the exec events as soon as they arrive on
aarch64, without checking if the call failed.

(cherry picked from commit c118058dd8)
2024-01-26 21:10:56 +01:00
Gustavo Iñiguez Goia
9a6dfe7797 ebpf,dns: initialized structs
On the previus commit we just disabled dns uprobes for armhf/i386 to
avoid loading errors. A better fix is to initialized the structs used.
On armhf still fails after loading it, when attaching to the uprobes
(offsets?), and on i386 it doesn't seem to send anything to userspace
(more analysis needed).

- Increased the number of IPs associated with a domain that are
  delivered to userspace. (getfedora.org returns 30 ipv4+ipv6).
- Fixed getting the aliases of a domain when using gethostbyname().

(cherry picked from commit 27509d6fe0)
2024-01-26 20:55:07 +01:00
Gustavo Iñiguez Goia
0a8827d051 added more debug info to the dns ebpf hook
Added the path to the libc as well as the calculated offset for the
uprobe.
Don't return on the first error found loading a uprobe, instead try all
the uprobes and return if the loaded uprobes are 0.

(cherry picked from commit 55678b4d3b)
2024-01-26 14:53:43 +01:00
Gustavo Iñiguez Goia
c514946f61 fixed dns ebpf module for i386/arm architecture
The opensnitch-dns module was not loading on i386/arm architectures.
With the following changes it loads and some uprobes are attached.

for-loops unrolling doesn't still work though on i386/armhf (help
needed).

And on armhf the perf_output channel fails to load for some uprobes.

(cherry picked from commit d55e567dd8)
2024-01-26 14:24:41 +01:00
Gustavo Iñiguez Goia
2906470ea0
updated modules action to build 1.6.0 branch only 2024-01-24 23:56:41 +01:00
Gustavo Iñiguez Goia
34b595e50a
updated daemon/ui tests
They were failing when building the deb packages.
2024-01-24 20:22:34 +01:00
Gustavo Iñiguez Goia
5912b8e9d7
Bump packages versions to 1.6.5 2024-01-24 20:09:26 +01:00
Gustavo Iñiguez Goia
871238e07a
on errors stop established conns monitor
There's a long running task that monitors established connections every
~2s.

When a connection is not found via ebpf or proc, sometimes it's found
there so we can use the inode to search for the process.

However on some systems the netlink call to dump the sockets may fail
continuously, wasting resources. It'll also fail if you block connections
to port 0 (common case for ICMP packets).

So if there're too many errors dumpng the sockets, stop this task for
these cases.
2024-01-21 11:13:07 +01:00
Gustavo Iñiguez Goia
43477ebcbe
rules: fixed typo checking proc arguments 2024-01-15 21:56:55 +01:00
Gustavo Iñiguez Goia
b9ec5242f2
strings concatenation improvements
Use strings.Join() to concatenate strings, instead of Sprint*(), for
better performance.
2024-01-15 17:44:32 +01:00
Gustavo Iñiguez Goia
0340e77aa1
added go.sum 2024-01-14 19:15:53 +01:00
Gustavo Iñiguez Goia
fdba19c0c3
structs fields reorganized
Structs' fields reorganized based on fieldalignment tool feedback.
2024-01-13 22:15:23 +01:00
Gustavo Iñiguez Goia
60c6ac4aa8
Bump daemon and ui versions to 1.6.5 2024-01-10 01:05:34 +01:00
Gustavo Iñiguez Goia
4bff5c3037
ebpf: delete pid from exec maps if it exists
We track new processes execution by intercepting the enter and exit
of the functions, but sometimes the exit hook is not called, so the
corresponding entry was not being removed from the map.
In this situation the map becomes full and accepts no new entries.

Now the entry is deleted from the map once the process exits, if it
still exists in the map.

(cherry picked from commit 9446d191f0)
2024-01-09 12:42:48 +01:00
Gustavo Iñiguez Goia
5d33f41717
ebpf: fixed dns uprobes
We were not deleting DNS entries from the hash map, so when it reached
the maximum capacity (12k entries), we couldn't allocate new entries,
resulting in events not being sent to userspace.

(cherry picked from commit 1518cb39de)
2024-01-09 12:42:20 +01:00
Gustavo Iñiguez Goia
1ae20c3aa3
ebpf: fixed getting ppid, skip failed execve's
- Fixed getting ppid (precompiled .o won't probably work).
 - Skip failed execve* calls.

(cherry picked from commit 68c2c8ae1a)
2024-01-09 11:53:23 +01:00
Gustavo Iñiguez Goia
eafb70fb55
fixed loading dns ebpf module
Closes #1076

(cherry picked from commit 159494d1e2)
2024-01-09 10:16:23 +01:00
Gustavo Iñiguez Goia
5c6da0a8ab
allow to configure ebpf modules path
Now it's possible to configure eBPF modules path from the
default-config.json file:
 "Ebpf": {
   "ModulesPath": "..."
 }

If the option is not provided, or if it's empty, we'll keep loading from
the default directories:

 - /usr/local/lib/opensnitchd/ebpf
 - /usr/lib/opensnitchd/ebpf
 - /etc/opensnitchd/ebpf (deprecated, will be removed in the future).

Closes #928

(cherry picked from commit ffb76683aa)
2024-01-08 23:49:36 +01:00
Gustavo Iñiguez Goia
946799b5e9
removed checksum references 2024-01-08 22:15:08 +01:00
Gustavo Iñiguez Goia
f93825a550
ui: make fw dialog status label selectable
- Allow to select by mouse or keyboard the status messages of the
   firewall.
 - Enable word wrapping.

(cherry picked from commit e905163a03)
2024-01-08 20:53:31 +01:00
Gustavo Iñiguez Goia
af121bb8e6
ui: fixed config option
(cherry picked from commit 94492f0a71)
2024-01-08 20:52:45 +01:00
Gustavo Iñiguez Goia
435dffc0a1
ui: allow to configure refresh interval
Up until now, the GUI was refreshed if:
 - it was not minimized or hidden.
 - if there were new events (even if we received events from the daemon,
   they were filtered out if they were duplicated).

But still, there were scenarios where refreshing the views every second
(more or less) was too much, like when monitoring multiple machines.

Now it's possible to configure the views' refresh interval, regardless
of what the daemon sends.

Asked here: #1073

(cherry picked from commit 6006717b86)
2024-01-08 19:26:17 +01:00
Gustavo Iñiguez Goia
f16b27afb9
updated ui/client tests
(cherry picked from commit 6873fd3a2d)
2024-01-08 18:23:18 +01:00
Gustavo Iñiguez Goia
6bd1fe8b1e
allow to configure rules and config file paths
- Added cli option -config-file to specify an alternate path to the
   config file.
 - Allow to configure rules path from the configuration file (cli option
   takes precedence).
 - Default options are now /etc/opensnitchd/rules and
   /etc/opensnitchd/default-config.json. Previously the default rules
   directory was "rules" (relative path).

Closes #449

(cherry picked from commit 211c864d76)
2024-01-08 18:21:43 +01:00
Gustavo Iñiguez Goia
1608ab7730
fixed proc/self/exe path 2024-01-08 17:10:09 +01:00
Gustavo Iñiguez Goia
88aec87595
updated go version to 1.20 on the build workflow 2024-01-08 16:52:11 +01:00
Gustavo Iñiguez Goia
0dde6f57ea fixed leak checking fw status
(cherry picked from commit 9cee3b3a73)
2024-01-08 15:56:25 +01:00
Gustavo Iñiguez Goia
cc203a4a12 ui,popups: fixed adding rules when there's no path
Fixed creating rules when there's no path nor cmdline reported (with [x]
Debug invalid connections).

(cherry picked from commit 250dcb1f6d)
2024-01-08 15:56:14 +01:00
Gustavo Iñiguez Goia
24fd94c168 netfilter: do not unbind the queues on exit
On exit we were calling nfq_unbind_pf for AF_INET and AF_INET6, which
usually stcuked the daemon for a very long time, and other times
caused a segfault.

According to the docs (..), calling nfq_destroy_queue() is enough to
exit cleanly:
"This call also unbind from the nfqueue handler, so you don't have to
call nfq_unbind_pf."
https://netfilter.org/projects/libnetfilter_queue/doxygen/html/group__Queue.html#ga32a1461e9a36c95a03cb4476109f33bb

Closes #919

(cherry picked from commit 430c280687)
2024-01-08 15:55:58 +01:00
Gustavo Iñiguez Goia
f82431b642 replace /proc/self from bin paths
Sometimes we receive /proc/self/exe as the path of the process (electron
apps).
Since a couple of systemd versions ago, some processes spawned by
systemd are reported as /proc/self/fd/<number>.

In these cases reading the symbolic link /proc/<pid>/exe points to the
file on disk.

(cherry picked from commit fb2c9893d0)
2024-01-08 15:55:32 +01:00
Gustavo Iñiguez Goia
53c0f1dd91 rpm pkgs: changed autostart path
Previously after installing the rpm GUI package, we created a symlink to
our .desktop file for all users, under /home/*/.config/autostart/

If the path didn't exist we created it, unfortunately as root, which
caused some problems with other applications like Gnome Tweaks.

Now a link is created under /etc/xdg/autostart/, which is what we use
with the debian packages.

Closes: #1068
(cherry picked from commit 86d3f54247)
2024-01-08 15:52:48 +01:00
Gustavo Iñiguez Goia
e033cbc342 ui,pop-ups: updated AppImage pattern
rel: #1066
(cherry picked from commit 4f9b69961c)
2024-01-08 15:51:42 +01:00
Gustavo Iñiguez Goia
9fc1da509a ui,popups: add AppImages' path pattern to the options
If the path of the process starts with /tmp/.mount, it typically
indicates that the application is an AppImage.

These apps create a random directory under /tmp, with the pattern
/tmp/.mount_<appId>XXXXXX, where the AppImage is mounted (it's not
always the case, but it usually is).

a0373541c1/runtime.c (L202)

The problem is that if you allow the path to the executable, the next
time you launch the AppImage, the path won't match the rule, and you'll
be prompted again to allow the outbound connection.

So as a helper for the users, if we find the path of the process starts
with /tmp/.mount_, we add an option to the combo box to select the path,
which creates a regular expression to match the AppImage.

Requested here: #1066, #543, #408

(cherry picked from commit 56775cd62a)
2024-01-08 15:51:35 +01:00
Gustavo Iñiguez Goia
f0437a179f ui: print a warning if XDG_SESSION_TYPE is not set
If XDG_SESSION_TYPE is not set there're no icons on the GUI.
More info: #999

(cherry picked from commit 827d7398f5)
2024-01-08 15:51:29 +01:00
Gustavo Iñiguez Goia
ec3f515980 ui,stats: fixed adding rules to the db from context menu
When cloning a rule, or applying a rule to a node, if the rule was of
type List (had multiple operators), the operators were not saved to the
DB.

Closes: #1027
(cherry picked from commit 4499a5aaf0)
2024-01-08 15:51:22 +01:00
Gustavo Iñiguez Goia
c3dc1fcc4a
ui: use single quotes for raw strings
Some checks failed
CI - build eBPF modules / build (6.0, 1.5.0) (push) Has been cancelled
CI - build eBPF modules / build (6.0, master) (push) Has been cancelled
Test resources validation / Install tools (push) Has been cancelled
Build status / Build (push) Has been cancelled
v1.6.4
part of the previous commit. Missed this change.
2023-11-08 14:36:59 +01:00
Gustavo Iñiguez Goia
6c25be1176
ui: use raw strings notation to for regexps
and silence python3.12 warnings.
2023-11-08 14:14:07 +01:00
Gustavo Iñiguez Goia
f29e6dcc14
ui: restrict unix socket to the current user
By default, restrict reading from the unix socket to the user who
launched the GUI.
2023-11-08 00:57:14 +01:00
Gustavo Iñiguez Goia
6e08629fed
ui,prefs: set db in-memory name correctly
Instead of :memory:, use file::memory:

Related: #1030
2023-11-06 21:49:35 +01:00
Gustavo Iñiguez Goia
c35baf364e
Bump ui version to v1.6.4
Added qgnomeplatform-qt5 as dependency for rpm packages. Otherwise on
Fedora 29 there's no window decorations.
2023-11-06 01:14:38 +01:00
Gustavo Iñiguez Goia
bcbfe3bbe2 ui: allow to delete old events of the in-memory db
Not deleting events from in-memory db can lead to a high mem usage under
certain scenarios.

Previous attempt to solve this issue wrote events to disk in a temporal
file (when using file::memory:?cache=shared).

Related issues: #844 #857

Closes: #1030
2023-11-06 00:01:14 +01:00
Gustavo Iñiguez Goia
ad896b47a7 ui,prefs: enable/disable max days db checkbox
When selecting to store events on disk, the max days db checkbox must be
clickable.
2023-11-06 00:01:01 +01:00
Gustavo Iñiguez Goia
afa235d1a9 ui: preserve rules' columns width
Preserve rules' columns width when selecting rules left panel items.

Closes: #822
2023-11-06 00:00:41 +01:00