Commit graph

1805 commits

Author SHA1 Message Date
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
Gustavo Iñiguez Goia
9d1182a48f
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-03 23:02:42 +01:00
Gustavo Iñiguez Goia
e63f4c13c8
ui: preserve rules' columns width
Preserve rules' columns width when selecting rules left panel items.

Closes: #822
2023-10-31 01:19:01 +01:00
Gustavo Iñiguez Goia
5b2cec0d4b
go.mod: updated deps, minimum required go version 2023-10-23 20:50:24 +02:00
Gustavo Iñiguez Goia
13e06b0ed9
Merge pull request #1036 from Huoxi-any/oscs_fix_cjri7kgau51vtpiu8un0
fix(sec): upgrade golang.org/x/net to 0.7.0
2023-10-23 18:41:58 +00:00
Gustavo Iñiguez Goia
7d8eb36f60
Merge branch 'master' into oscs_fix_cjri7kgau51vtpiu8un0 2023-10-23 18:41:48 +00:00
Gustavo Iñiguez Goia
0a01e44870
Merge pull request #992 from chncaption/oscs_fix_cit2hp0au51ueorq4bpg
fix(sec): upgrade golang.org/x/sys to 0.1.0
2023-10-23 18:40:53 +00:00
Gustavo Iñiguez Goia
fe181b14dd
ci: use go1.20 compiler 2023-10-23 20:32:29 +02:00
Gustavo Iñiguez Goia
1b26acbd21
ui: fixed crash while refreshing views
There was a problem while refreshing and reconfiguring the views'
columns, which caused segfaults.
2023-10-18 11:19:08 +02:00
Gustavo Iñiguez Goia
174c63c3ff
ui: improved views behaviour
- Fixed painting rows while scrolling using the mouse.
   Sometimes blank lines were inserted at the bottom of the views when
   scrolling with the mouse.
 - Avoid to rerepaint rows when switching views or scrolling.
 - Selecting a row marks it for tracking, ensuring it's deselected when
   the row is not visible, and reselected when the row becomes visible
   during scrolling.

The following behaviour has not changed:
 - Selecting a row that was previously selected, deselects it.
 - Keyboard navigation.

Not fixed yet:
 - Selecting all the rows of a view with the mouse, visibles and not visibles.
 - Entering into a detailed view, going back to the previous view, and
   select (restore) the row that was previously selected (causes a
   segfault in a particular case).

Related: #1037
2023-10-17 17:13:10 +02:00
Gustavo Iñiguez Goia
5fd7da8ef5
ui,stats: improved rules deletion
When selecting rules with CTRL+A it was not deleting all the rules.
Besides rules with the name empty was sent to the daemon.

Related: #1037
2023-10-13 23:51:37 +02:00
Gustavo Iñiguez Goia
4493c86bc3
pop-ups: avoid exceptions with old protobuf libs
reverse() doesn't exist on old protobuf libs.
2023-10-13 22:50:26 +02:00
Gustavo Iñiguez Goia
177d67d0a6
ui,rules: fixed refrehsing list, fixed typos
- Fixed refreshing list when deleting rules.
- Fixed typos that were preventing errors from being displayed correctly.

Closes: #1056
2023-10-12 23:11:52 +02:00
Gustavo Iñiguez Goia
72756c85b8
ui,rules: fixed typo
It was preventing from diplaying an error when trying to open the
ruleseditor to edit a rule.
2023-10-12 01:45:38 +02:00
Gustavo Iñiguez Goia
67149269cd
ui,ruleseditor: add rules correctly to the db
Operator list was not converted to JSON string when saving the rule to
the DB.

Related: #1047
2023-10-11 00:21:59 +02:00
Gustavo Iñiguez Goia
32e73257f9
ui,stats: fixed typo 2023-10-09 23:12:41 +02:00
Gustavo Iñiguez Goia
40b738ffea
updated rules tests 2023-10-09 18:07:48 +02:00
Gustavo Iñiguez Goia
b93051026e
rules: improved operator list parsing and conversion
Previously when creating a new rule we followed these steps:
 - Create a new protobuf Rule object from the ruleseditor or the
   pop-ups.
 - If the rule contained more than one operator, we converted the
   list of operators to a JSON string.
 - This JSON string was sent back to the daemon, and saved to the
   DB.
 - The list of operators were never expanded on the GUI, i.e., they
   were not saved as a list of protobuf Operator objects.
 - Once received in the daemon, the JSON string was parsed and
   converted to a protobuf Operator list of objects.
   Both, the JSON string and the list of protobuf Operator objects were
   saved to disk, but the JSON string was ignored when loading the
   rules.

Saving the list of operators as a JSON string was a problem if you
wanted to create or modify rules without the GUI.

Now when creating or modifying rules from the GUI, the list of operators
is no longer converted to JSON string. Instead the list is sent to the
daemon as a list of protobuf Operators, and saved as JSON objects.

Notes:
 - The JSON string is no longer saved to disk as part of the rules.
 - The list of operators is still saved as JSON string to the DB.
 - About not enabled rules:
   Previously, not enabled rules only had the list of operators as JSON
   string, with the field list:[] empty.
   Now the list of operators is saved as JSON objects, but if the rule
   is not enabled, it won't be parsed/loaded.

Closes #1047
2023-10-09 14:55:15 +02:00