Commit graph

2,297 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
7a5484523a
i18n: added new languages
Hebrew and Albanian.
2025-11-11 01:26:53 +01:00
Gustavo Iñiguez Goia
d13e023895 i18n: updated translations
de, ro and uk.
2025-11-11 01:24:58 +01:00
Gustavo Iñiguez Goia
cb2feeb6a3
tasks: updated iocscanner README.md 2025-09-24 12:50:16 +02:00
Gustavo Iñiguez Goia
be34c8e84f
tasks: added iocscanner README 2025-09-22 19:11:44 +02:00
Gustavo Iñiguez Goia
98595eae5b tasks: dont exit until stop signal 2025-09-22 02:01:37 +02:00
Gustavo Iñiguez Goia
9f26ba0a6f ui: use nanoseconds to store alerts time
Otherwise when selecting a row, it may select multiple rows if they have
the same time.
2025-09-22 01:29:03 +02:00
Gustavo Iñiguez Goia
1673856037
tasks: added IOC scanner
Preliminary version of a task for scanning IOCs in background
(Indicator Of Compromise).

It can execute scripts and commands in background periodically.

 - Added a new task scheduler to configure when the task is launched.
   Previously we only had an "Interval" field to run the task
periodically. Now it's possible to select the day of the week, specify
multiple times, hours or minutes.

        "schedule": [
            {
                "weekday": [5,6],
                "time": ["09:55:00", "20:15:20"],
            },
            {
                "weekday": [0,1,2,3,4],
                "time": ["15:00:00"],
            }
        ],
   Used only in this task for now.

 - This task supports 4 "tools": yara, scripts and debsums/dpkg.

   * The "yara" tool acts as a frontend to the yara cli tool, used to scan
     for IOCs with YARA rules.
   * The "debsums"/"dpkg" tools can be used to:
     - report changes in the MD5 checksums of installed Debian
       packages (debsums -c).
     - report changes in configuration files of installed Debian
       packages (debsums -ce).
     - verify the integrity of Debian packages (dpkg --verify, dpkg
       --verify <package1> <packag2>).
       The output of the format (rpm) is not parsed yet.

Configuration example of the task to report the output of the command
debsums:
{
  "name": "IOC-scanner",
  "data": {
     "interval": "15s",
     "schedule": [
         {
             "weekday": [0,1,2,3,4,5,6],
             "time": ["22:00:00"]
         }
     ],
     "tools": [
     {
         "name": "debsums",
         "msgStart": "IOC scanner debsums started",
         "msgEnd": "IOC scanner debsums finished",
         "enabled": false,
         "cmd": ["debsums", "-c"],
         "options": {
             "dirs": [],
             "files": [],
             "reports": {
                 "path": "/etc/opensnitchd/tasks/iocscanner/reports",
                 "format": ""
             }
         }
     }
   ]
}

The field "name" defines which tool to use. It's also used to parse and
format the output of the specified command.

The output of the command is sent to the GUI as an alert, and the
results can be reviewed under the Rules tab -> Alerts.
2025-09-22 00:11:28 +02:00
Gustavo Iñiguez Goia
4b22fde120
pkgs: distribute default tasks config file 2025-09-12 16:14:45 +02:00
Gustavo Iñiguez Goia
ed23f48723
tasks: created Downloader README.md 2025-09-12 12:34:13 +02:00
Gustavo Iñiguez Goia
afa0500539
rules: updated default localhost rules
Restrict permissions to 127.0.0.1 and ::1 instead of the whole loopback
range.

This way, we allow localhost connections from common processes (dirmngr,
kdeinit5, xbrlapi, etc.), while giving users control to allow or deny
DNS queries to the local DNS stub resolver (which for example usually
listens on 127.0.0.53).

More info: #1416.
2025-09-12 11:19:12 +02:00
Gustavo Iñiguez Goia
cad02ae320
Merge pull request #1423 from alice945/master
Use application specific nft table
2025-09-12 00:45:09 +02:00
Gustavo Iñiguez Goia
149e0f61b8
tasks: added downloader task
Added a new task to schedule files downloads.

Whenever the task is loaded, the files will be downloaded. From that on,
files will be downloaded according to the duration specified in the
"interval" field.
The format of the interval field is time.Duration:
https://pkg.go.dev/time#Duration

configuration example:

/etc/opensnitchd/tasks/tasks.json:
{
    "tasks":[
        {
            "enabled": false,
            "name": "downloader",
            "configfile": "/etc/opensnitchd/tasks/downloader/downloader.json"
        }
    ]
}

/etc/opensnitchd/downloader/downloader.json:
{
  "name": "downloader",
  "parent": "downloader",
  "description": "",
  "data": {
      "interval": "6h",
      "timeout": "5s",
      "urls": [
          {
              "name": "adaway",
              "enabled": true,
              "remote": "https://adaway.org/hosts.txt",
              "localfile": "/tmp/bl3/ads-adaway-hosts.txt"
          }
      ],
      "notify": {
          "enabled": true
      }
}
2025-09-12 00:24:59 +02:00
Gustavo Iñiguez Goia
be80bd140a
tasks: added new example task
Added an example of a task that simply prints/sends a message to
stdout/the GUI.

Configuration example:

/etc/opensnitchd/tasks/tasks.json:
{
    "tasks": [
        {
            "enabled": true,
            "name": "looper",
            "configfile": "/etc/opensnitchd/tasks/looper/looper.json"
        }
    ]
}

/etc/opensnitchd/tasks/looper/looper.json:
{
    "name": "looper",
    "parent": "looper",
    "data": {
        "interval": "5s"
    }
}
2025-09-11 14:17:25 +02:00
Gustavo Iñiguez Goia
8e5bbb0d1b
tasks: updated tests 2025-09-11 13:41:01 +02:00
alice945
369c035558 Don't use seperate interception chains 2025-09-11 11:30:14 +00:00
Gustavo Iñiguez Goia
66ee50bf7d
tasks: allow to load tasks from disk
Now it's possible to load tasks from disk.

There's a central file which contains the defined tasks:
/etc/opensnitchd/tasks/tasks.json

with this format:
{
    "tasks": [
        {
            "enabled": false,
            "name": "downloader",
            "configfile":
"/etc/opensnitchd/tasks/downloader/downloader.json",
        }
    ]
}

The field "name" defines the type of task to load, defined in each task.
It's static.

Whenever the tasks.json is modified, if the tasks are enabled, the task
configuration file defined in the "configfile" field will be loaded.

Configuration format of each task:

{
  "name": "downloader",
  "parent": "downloader",
  "data": {}
}

The field "name" is dynamic, unique, and identifies the instance of the
task. If there're two tasks configured with the same name, only one will
be loaded.
The "parent" field is used to know what's the base task. If it's not
specified, we'll try to use the "name" as the base task.

This allows you to run multiple instances of the same task with
different configurations: a downloader to update malware blocklists,
another to update IP blocklists, etc.

The "data" field depends of each task. It's generic, and each task is
responsible for defining it. For example for the Downloader task:

"data": {
    "interval": "1h",
    "timeout": "5s",
    "urls": [
        {
            "name": "adaway",
            "enabled": true,
            "remote": "https://adaway.o/hosts.txt",
            "localfile": "/tmp/blocklist/ads-adaway-hosts.txt"
        }
    ]
}

The tasks configuration file are also monitored for changes, and
whenever a change is detected the task is reloaded.

----

Notifications (WIP)

It's not yet fully defined and it'll change, but this is the state as
of today.

For real-time tasks, like pid-monitor, sockets monitor and node monitor,
the GUI initiates the task with a unique ID (a timestamp), to know who
is sending what, and display the data properly on the GUI.

For permanent tasks we use a unique ID defined for each task.

Right now, if we don't have the notifications channel opened and the
notification ID corresponds with one of the tasks, we'll post an alert
to the GUI, to display a desktop notification.

Each task can define if send notifications or not. For example:

{
  "name": "downloader",
  "data": {
      (...)
      "notify": {
          "enabled": true
      }
  }
}

then in each task, act accordingly to what is defined in the
configuration.
2025-09-11 12:19:38 +02:00
alice945
24079ae209
Keep iptables rule 2025-09-11 00:20:25 +00:00
Gustavo Iñiguez Goia
4b38ca1260
config tests: added missing comma 2025-09-11 00:29:02 +02:00
Gustavo Iñiguez Goia
f9358a464f
Merge pull request #1418 from LordGrimmauld/audit-socket-path-config
daemon/audit: allow configuring audispd_events socket path
2025-09-11 00:24:21 +02:00
alice945
1e2f594911 Use application specific nft table
Implements #1260, fixes #1393
2025-09-06 12:47:21 +00:00
Gustavo Iñiguez Goia
85635051aa
tasks: improved sending first results
Don't wait until the timer fires to send the results of a task.
2025-09-04 23:42:02 +02:00
Gustavo Iñiguez Goia
0e80970035
tasks: fixed stop 2025-09-04 01:34:38 +02:00
Gustavo Iñiguez Goia
970f8c356b
minor tasks notification change
Simplify tasks' notifications handling.
2025-09-03 17:45:33 +02:00
Gustavo Iñiguez Goia
ee1678d7c3
removed unused channel 2025-09-03 17:42:51 +02:00
Grimmauld
ec75833dd5
daemon/audit: allow configuring audispd_events socket path 2025-08-26 20:30:02 +02:00
Gustavo Iñiguez Goia
1e3893997c
Merge pull request #1413 from LordGrimmauld/python-slugify
ui: switch to python-slugify
2025-08-19 20:41:22 +02:00
Gustavo Iñiguez Goia
1883cf13eb
ui: updated i18n update procedure
With PyQt5 we used plupdate5 + *.pro file to update the translations
file with new strings, extracted from the source code and UI forms.

In PyQt6, pylupdate6 doesn't support parsing .pro files, so we need to do it
manually.
2025-08-19 01:29:37 +02:00
Gustavo Iñiguez Goia
0e6ed5f6b6
pkgs: updated GUI dependencies
qt6-sql-sqlite no available on Fedora as package.
python3-qt6 is called python3-pyqt6 on Fedora.
2025-08-18 19:36:55 +02:00
Gustavo Iñiguez Goia
0f4f3b0f9e
Bumped versions to v1.7.3 2025-08-18 17:30:23 +02:00
Gustavo Iñiguez Goia
e8d8641f53 pkgs: updated GUI PyQt6 dependencies 2025-08-18 17:29:13 +02:00
Gustavo Iñiguez Goia
807ba02bb9 ui: fixed .ui designers files
Debian's QtDesigner 6.8.2 defines horizontal/vertical spacers as
Qt::Orientation::Horizontal, but the Qt definitions since 6.5 is
Qt::Horizontal: https://doc.qt.io/qt-6.5/qt.html#Orientation-enum

Due to this problem, the GUI fails to load on some Qt versions, like
6.6.x (Mint 22.1). It doesn't fail on Arch with PyQt6 6.9 though.

Discussion: #1222
2025-08-18 14:03:44 +02:00
Grimmauld
a0f5a6ea54
ui: switch to python-slugify
unicode-slugify is basically abandoned upstream. Its repository [1] has seen
the last actual code change in 2018. It uses the deprecated `nose` testing framework.

In nixpkgs, we patched it to use pytest, but made some mistakes in those patches,
resulting in no tests actually executing. I actually fixed the tests to run,
but most of the tests fail: unicode does not reliably get replaced with a slugified version.

There does exist an actual need for slugification. However, the used slugify
package should actually work and be reasonably maintained. The replacement proposed here is
`python-slugify` [2], which sees active development in its repository while the
used API (both import name and the basic function signature `slugify(str)`) is identical.

The version requirement of >=7.0.0 is from their official support matrix for py >= 3.7,
though i did my testing with python-slugify 8.0.4.

[1] https://github.com/mozilla/unicode-slugify
[2] https://pypi.org/project/python-slugify/
2025-08-18 12:02:16 +02:00
Gustavo Iñiguez Goia
a7a41e4ead
Merge pull request #1411 from munix9/find_lrelease
Update generate_i18n.sh - find lrelease
2025-08-17 00:05:28 +02:00
munix9
1957c6f270
Update generate_i18n.sh - find lrelease
This should simplify the search for the lrelease binary:
lrelease - Debian/Ubuntu (?)
lrelease6 - openSUSE
lrelease-qt6 - Fedora

In addition, you can specify the path to an lrelease binary with LRELEASE, e.g.:
export LRELEASE="/usr/local/bin/my-lrelease-v6"
2025-08-16 11:09:31 +02:00
Gustavo Iñiguez Goia
e5d1702bd3
ui: ported to PyQt6
The GUI has been ported to PyQt6.

New dependencies:
 - python3-pyqt6
 - python3-pyqt6.qtsvg (otherwise, the svg icons are not loaded)
   On Arch and other systems qt6-svg is neeeded.
 - pyqt6-dev-tools (for uic calls, .ui loading).
 - libqt6sql6

Known issues:
 - pylupdate6 not longer update .pro files.
   It doesn't affect existing translations.
 - There might be a delay closing the GUI. Reason still unknown.

Closes: #1009

Discussion: #1222
2025-08-15 21:27:04 +02:00
Gustavo Iñiguez Goia
4691fa5353
i18n: updated German translation 2025-08-13 21:01:52 +02:00
Gustavo Iñiguez Goia
8c3fa40cf4
distribute default rules with the pkgs
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.7.2
- distribute daemon/data/rules/ with the daemon packages.
 - added a new system fw rule to allow localhost connections (disabled
   by default).

Closes: #965.
2025-08-08 13:45:26 +02:00
Gustavo Iñiguez Goia
d513c9312a
updated predefined rules description 2025-08-08 01:33:53 +02:00
Gustavo Iñiguez Goia
d2fbdd9700
task pid monitor: fixed stopping the monitor 2025-08-08 01:27:00 +02:00
Gustavo Iñiguez Goia
a188df210b
Bumped pkg verions to v1.7.2 2025-08-08 00:23:44 +02:00
Gustavo Iñiguez Goia
b635778f67 i18n: updated ru and id translations 2025-08-07 21:51:56 +02:00
Gustavo Iñiguez Goia
4041fa3089 ui: show nodes widget only when there're multiple nodes 2025-08-06 23:35:22 +02:00
Gustavo Iñiguez Goia
3f63a0844e
bumped versions to v1.7.2 2025-08-06 20:51:27 +02:00
Gustavo Iñiguez Goia
e9319716e7
ui: avoid reconfiguring fw rules
When the daemon connects to the GUI, the firewall dialog is configured
based on the system firewall configuration (inbound/outbpund policies).

Due to an error, a fw-change notification was being triggered, causing
unnecessary firewall rules reloads.
2025-08-06 01:02:47 +02:00
Gustavo Iñiguez Goia
72fb80f206
i18n: updated translation definitions 2025-08-05 00:12:56 +02:00
Gustavo Iñiguez Goia
9bc7868586
ui: avoid crashing if notify2 pkg is not available 2025-08-01 19:10:03 +02:00
Gustavo Iñiguez Goia
2a60d17ede
ui, rules editor: hide/show regexp checks on demand 2025-07-31 01:06:08 +02:00
Gustavo Iñiguez Goia
f671aa4e68
ui, rules editor: allow to use commas
Allow to use commas to specify multiple data:

 - src/dst ip: 1.2.3.4, 5.6.7.8
 - dst host: www.a-b-c.org, www.abcd.org
 - proto: tcp, udp
 - net ifaces: eth0, eth1
 - src/dst port: 123, 456

The data will be translated to ^(..|..|..)$ when saving the rule, and
back to "..,..,.." when loading it.

Closes: #1392.
2025-07-31 00:52:15 +02:00
Gustavo Iñiguez Goia
f71f42b54e
fw,config: use context pkg instead of channels
Stop monitoring file changes using the context package instead of
channels.
2025-07-30 18:14:16 +02:00
Gustavo Iñiguez Goia
ca2c56d5cd cache: improved replacing processes
When replacing a process with the same PID (fork/clone),
and ebpf.QueueEventsSize is > 0 we may receive out or order events.
For example if the checksum calculation takes too much time.

Now we avoid updating the process in this scenario.
2025-07-30 16:57:32 +02:00