Commit graph

1622 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
e5787aef65
structs fields reorganized
Structs' fields reorganized based on fieldalignment tool output
2024-01-14 20:44:49 +01:00
Gustavo Iñiguez Goia
9446d191f0
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.
2024-01-08 01:33:54 +01:00
Gustavo Iñiguez Goia
bb95a77c58
sys-fw: load default config path if non supplied
By default load the system fw config file from
/etc/opensnitchd/system-fw.json.

There're these options to specify the file to load:

 - via cli option with -fw-config-file
 - writing it in the default-config.json file:
   "FwOptions": { "ConfigPath": "..." }

If both options are empty, then the default one is used.

FIXME:
 When the cli option is used to load the fw configuration, and the main
preferences are saved, the fw is reloaded but the path to the fw config
is lost.
2024-01-08 00:34:28 +01:00
Gustavo Iñiguez Goia
b2bd56d7e2
updated TestProcIOStats test
On this test we assumed that there would always be reading stats for our
own process /proc/self, but on restricted environments that might not
alwys be the case. Anyway, a value of 0 is not an error in itself.

Closes #1075
2024-01-05 15:31:00 +01:00
Gustavo Iñiguez Goia
1518cb39de
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.
2024-01-05 13:33:56 +01:00
Gustavo Iñiguez Goia
d9287bf601
ui: display alert details by double-clicking on it 2024-01-04 12:15:39 +01:00
Gustavo Iñiguez Goia
159494d1e2
fixed loading dns ebpf module
Closes #1076
2024-01-04 01:12:03 +01:00
Gustavo Iñiguez Goia
dc48d392f2
ui: save and display alerts/events from the daemon
New option to save and display alerts/events received from the daemon,
like system fw errors or eBPF modules errors.

Until now we only displayed a desktop message, making it difficult to
review the message in detail, or other actions.
2024-01-03 20:22:45 +01:00
Gustavo Iñiguez Goia
050e3c51b0
fixed leak dispatching alerts
Fixed potential leak when disconnecting from the GUI, and at the same
time dispatching an alert/message to the GUI.
2023-12-31 20:12:44 +01:00
Gustavo Iñiguez Goia
68c2c8ae1a
ebpf: fixed getting ppid, skip failed execve's
- Fixed getting ppid (precompiled .o won't probably work).
 - Skip failed execve* calls.
2023-12-26 14:04:19 +01:00
Gustavo Iñiguez Goia
ffb76683aa
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
2023-12-22 23:27:18 +01:00
Gustavo Iñiguez Goia
090bb0e2a4
updated sys-fw tests 2023-12-20 23:02:45 +01:00
Gustavo Iñiguez Goia
54ac5a3549
fw: allow to configure config file/ check interval
- Allow to configure system firewall configuration file path:
   * via cli (-fw-config-file).
   * via global configuration file.
 - Allow to configure fw rules check interval.

The system fw config file contains regular iptables/nftables rules.
Previously it was hardcoded to /etc/opensnitchd/system-fw.json

The interval to check if the interception rules were added was also
hardcoded to 10 seconds. Now it's possible to configure it.
A value of "0s" disables the interval, while "" defaults to 10 seconds.
2023-12-20 21:32:45 +01:00
Gustavo Iñiguez Goia
e905163a03
ui: make fw dialog status label selectable
- Allow to select by mouse or keyboard the status messages of the
   firewall.
 - Enable word wrapping.
2023-12-20 01:08:49 +01:00
Gustavo Iñiguez Goia
290ed40e8d
procmon: fixed leak reading proc's environ vars 2023-12-17 23:29:27 +01:00
Gustavo Iñiguez Goia
94492f0a71
ui: fixed config option 2023-12-17 20:52:39 +01:00
Gustavo Iñiguez Goia
6006717b86
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
2023-12-17 20:19:40 +01:00
Gustavo Iñiguez Goia
6873fd3a2d
updated ui/client tests 2023-12-17 00:39:41 +01:00
Gustavo Iñiguez Goia
211c864d76
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
2023-12-17 00:22:07 +01:00
Gustavo Iñiguez Goia
9cee3b3a73
fixed leak checking fw status 2023-12-15 11:49:16 +01:00
Gustavo Iñiguez Goia
0207e3a55f
cache of events improvement
don't reset/recalculate checksums on every configuration change, only if
the checksums config item has changed.
2023-12-12 18:11:46 +01:00
Gustavo Iñiguez Goia
431e2d3ed9
procmon/cache improvements
- Fixed several leaks.
 - Cache of events reorganized and improved.
   * items are added faster.
   * proc details are rebuilt if needed (checksums, proc tree, etc)
   * proc's tree is reused if we've got the parent in cache.

rel: #413
2023-12-12 14:48:17 +01:00
Gustavo Iñiguez Goia
9efaa37098 fixed leak serializing rules' operator
mainly when connecting by the first time to the GUI, and at the same
time asking to allow/deny a connection.
2023-12-09 19:06:40 +01:00
Gustavo Iñiguez Goia
250dcb1f6d
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).
2023-12-06 12:57:59 +01:00
Gustavo Iñiguez Goia
17c8ec8484
fixed leak getting proc parents 2023-12-06 00:12:41 +01:00
Gustavo Iñiguez Goia
430c280687
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
2023-12-05 01:16:38 +01:00
Gustavo Iñiguez Goia
d7c7a08d6f
ui,popups: fixes and refactoring 2023-12-03 12:38:55 +01:00
Gustavo Iñiguez Goia
daa5ebbd1c
ui: updated translations generation
include the new prompt dialog files.
2023-12-03 11:53:35 +01:00
Gustavo Iñiguez Goia
1cb52afbf9
ui, popups: internal changes 2023-12-03 01:50:28 +01:00
Gustavo Iñiguez Goia
fb2c9893d0
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.
2023-12-03 01:13:55 +01:00
Gustavo Iñiguez Goia
d3ba9d65ce
ui, popups: refactoring 2 2023-12-01 23:58:00 +01:00
Gustavo Iñiguez Goia
c297b0b539
ui, popups: refactoring
will help to write unit tests more easily.
2023-12-01 23:05:40 +01:00
Gustavo Iñiguez Goia
86d3f54247
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
2023-11-29 22:54:02 +01:00
Gustavo Iñiguez Goia
4f9b69961c
ui,pop-ups: updated AppImage pattern
rel: #1066
2023-11-25 01:09:59 +01:00
Gustavo Iñiguez Goia
198595a2b8
ui, popups: minor refactoring 2023-11-25 00:54:28 +01:00
Gustavo Iñiguez Goia
56775cd62a
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
2023-11-25 00:12:29 +01:00
Gustavo Iñiguez Goia
827d7398f5
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
2023-11-24 23:23:49 +01:00
Gustavo Iñiguez Goia
02cf65ac33
ui,popups: allow to update checksums
When the checksum of a binary changes, due to an update or something
else, you'll be prompted to allow the outbound connection if the
previous checksum of the rule doesn't match the new one.

Without a visual warning was almost impossible to know what was going
on. Besides, you had to dismiss that pop-up, find the rule, and update
the checksum.

Now there's a warning message, and you can update the rule from
the pop-up.

Related: #413
2023-11-24 00:57:13 +01:00
Gustavo Iñiguez Goia
ffd70836f6
ui, pop-ups: set details scrollbar position correctly
When adding the details of a connection, the scrollbar was always at the
bottom of the view.
2023-11-22 01:34:09 +01:00
Gustavo Iñiguez Goia
2f04d0f27f
ui: added option to save checksum settings 2023-11-20 00:47:00 +01:00
Gustavo Iñiguez Goia
afe92de45e
ui,prefs: added checksum option to the popup section
Added option to select by default on the pop-ups checksum verification.
2023-11-19 23:12:15 +01:00
Gustavo Iñiguez Goia
4499a5aaf0
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
2023-11-15 00:59:01 +01:00
Gustavo Iñiguez Goia
2fc9ed276b
deserialize rules operator list correctly
In b93051026e we disabled sending/parsing
list operators as JSON strings. Instead, now it's sent/parsed as
protobuf Rule, and saved to disk as JSON array, which ease the task of
manually creating new rules if needed.

This change was missing in the previous commit.
2023-11-11 02:16:08 +01:00
Gustavo Iñiguez Goia
6b3a5da343
Control checksums feature from a global cfg item
Previously it was enabled only if at least 1 rule had a checksum item
configured.
Enable by default md5.
2023-11-10 11:28:54 +01:00
Gustavo Iñiguez Goia
6d056b8a7b
Bump daemon and GUI versions
Current changes are no longer compatible with 1.6.x.
2023-11-09 01:05:46 +01:00
Gustavo Iñiguez Goia
9528fb0e6b
ui: use single quotes for raw strings
part of the previous commit. Missed this change.
2023-11-08 14:28:45 +01:00
Gustavo Iñiguez Goia
e6ae9ca6ef
ui: use raw strings notation to for regexps
and silence python3.12 warnings.
2023-11-08 13:58:59 +01:00
Gustavo Iñiguez Goia
2d96ec1fc7
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:48:44 +01:00
Gustavo Iñiguez Goia
d08da08431
ui,prefs: set db in-memory name correctly
Instead of :memory:, use file::memory:

Related: #1030
2023-11-06 15:40:01 +01:00
Gustavo Iñiguez Goia
de58e099ec
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-04 00:27:50 +01:00