Commit graph

769 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
34a5e391f0
Merge pull request #1604 from tredondo/fix/getclientconfig-rules-race
daemon: fix data race in getClientConfig iterating rules during load
2026-07-08 14:43:01 +02:00
Gustavo Iñiguez Goia
d487124e93
Merge pull request #1622 from kudashevs/feature/trailing
fix: remove trailing spaces
2026-07-08 02:08:20 +02:00
Gustavo Iñiguez Goia
052d8192ab
Merge pull request #1616 from workturnedplay/patch-1
fix "font rendering" due to 000-allow-localhost6.json 's description
2026-07-08 01:26:36 +02:00
Gustavo Iñiguez Goia
847df747f5
updated fw port tests 2026-07-06 21:05:14 +02:00
Gustavo Iñiguez Goia
8bd8f59fb5
fixed "non-constant format string" error 2026-07-06 14:56:26 +02:00
Gustavo Iñiguez Goia
eca05a9cd1
Bumped cilium/ebpf version to 0.22
- added compatibility with Linux 7.1 and above.
- global BTF cache no longer enabled by default, which should reduce
  daemon mem usage by ~20MB.

https://github.com/cilium/ebpf/releases#release-v0.22.0
2026-07-06 11:46:34 +02:00
Gustavo Iñiguez Goia
df8390e57f
minor performance improvements
Replaced calls Sprint/Sprintf in hot paths with internal ConcatStrings,
improving string concatenation performance by approximately ~2x-~10x.
2026-07-06 01:46:11 +02:00
Gustavo Iñiguez Goia
fe16723145
fixed minor leak when logging debug messages 2026-07-03 22:25:48 +02:00
Kudashev Sergey
1672bde4ed fix: remove trailing spaces 2026-06-15 23:42:54 +02:00
workturnedplay
17428ae483
fix UI due to 000-allow-localhost6.json description
the description for this rule, in the UI, vertically centers the 3 lines(2 text and one empty newline in the middle) thus showing only a few pixels of the first and last lines' text as the description for this rule making you believe there's something wrong with the font rendering. Removing one `\n` allows the two text lines to remain visible enough to be readable.
2026-06-08 21:12:54 +02:00
Ted Robertson
5e12a0baef daemon: fix data race in getClientConfig iterating rules during load
Loader.GetAll() returned the loader internal map by reference under an

RLock that was released as the call returned. getClientConfig() then

called GetAll() twice -- once for len() to size a slice, once to range

over the entries -- without holding any lock. A concurrent goroutine

(e.g. the loader still synchronously processing rules during

reloadConfiguration) writing to the map between the two calls makes the

iteration yield more entries than the pre-sized slice, panicking with

"index out of range [N] with length N". On bad luck the Go runtime

trips "concurrent map iteration and map write" instead.

The race is reachable on real systems whenever the UI poller, started

by reloadConfiguration via c.Connect(), reconnects before

c.rules.Reload(path) finishes loading rules from disk. Consistently

reproducible with ~2100 rules on disk.

Make GetAll() return a shallow snapshot of the rule map under the read

lock so length and iteration are guaranteed consistent for the caller.

Update the one caller (getClientConfig) to take the snapshot once.

Add a regression test running concurrent writers and readers against

the loader; -race catches the original bug, and the new GetAll

contract makes it pass.
2026-05-19 02:03:26 -07:00
nvdx
f78177d6a5
daemon: rule lists operators caching + lists matching enhancements (#1567)
* daemon-go: port layered list caching and matching strategies

* daemon-go: use immutable rule/list snapshots and add load benchmarks

* daemon-go: dropped gobwas, rule/list now use go filepath.Match for globbing
2026-04-18 00:35:31 +02:00
Gustavo Iñiguez Goia
f1e5ba94fa Bumped version to v1.9.0 2026-02-10 23:05:45 +01:00
Gustavo Iñiguez Goia
3040507e7b restrict network rules type to operand network
Restrict the use of network type to network operand:

  "operator": {
    "type": "network",
    "operand": "dest.network",
    "sensitive": false,
    "data": "LAN",
    "list": []
  }
2026-02-07 12:19:26 +01:00
Gustavo Iñiguez Goia
e1b961aec0 rules: added range operand
Allow to create rules to mach a range of source or destination ports.

  "operator": {
    "operand": "dest.port",
    "data": "30000-65500",
    "type": "range",
    "list": [],
    "sensitive": false
  },

see: #960, #1516
2026-01-30 01:33:36 +01:00
Gustavo Iñiguez Goia
f9b3d58be0 /rules/operator minor change
lock just the operation, without using defer. In this case is not
needed.
The difference is minimal:

BenchmarkDefer-4     	100000000	        50.94 ns/op
BenchmarkNoDefer-4   	131769184	        45.35 ns/op
2026-01-18 23:35:05 +01:00
Gustavo Iñiguez Goia
442b466b63
tasks: improved scheduler
Restart the daily timers appropiately if the clock has drifted, for
example when the computer is put to sleep.
2026-01-12 00:04:54 +01:00
Gustavo Iñiguez Goia
e3cf78c004
Merge pull request #1493 from themighty1/tests/netfilter_tests
tests: added netfilter tests
2026-01-03 01:40:28 +01:00
Gustavo Iñiguez Goia
e8976086cd
rules checking improvement
Originally we had one single function to check connection properties
against rules, which accepted only strings.

As we've added new functionality, this single function has been made
generic, to accept any type of data. From a code readability point of
view, it has worked well, but at the cost of a slight performance
penalty.

Now in order to gain a little bit of performance by avoiding types
conversion, we'll use 2 callbacks:
 - a generic callback that accepts data of any type.
 - and a simple one that accepts strings.
2026-01-02 23:57:15 +01:00
Gustavo Iñiguez Goia
74d42ab7c5 operator minor improvements 2026-01-02 14:04:07 +01:00
Gustavo Iñiguez Goia
51a8a0f04e regexp rule operand improvement
Save a dozen of nanoseconds when evaluating regexp rules.

Rel: #1448
2026-01-02 14:04:07 +01:00
Gustavo Iñiguez Goia
91efdb55dc operator tests updated 2026-01-02 14:04:07 +01:00
dan
9c0c2545fe tests: added netfilter tests 2026-01-01 19:49:30 +02:00
dan
2c01e9dd56 tests: added ebpf integration tests 2026-01-01 11:32:47 +02:00
Gustavo Iñiguez Goia
42600fc163 add the current process to the tree when re-using it
When re-using the tree of a process, we were not adding the current
process to the tree.
2025-12-30 17:14:20 +01:00
Gustavo Iñiguez Goia
481dc1cd53
avoid to send empty stats to the GUI (server)
By default, every second we send to the GUI the collected statistics by
the daemon: metrics + events (connections).

This call has a hard-coded timeout of one second, and if it reaches the
deadline, a warning message is printed to the log.

After several timeouts, the daemon closes the connection and tries to
reconnect again.

The daemon invokes this call even if there're no statistics to send.
With one daemon and one GUI, it's not much of a problem. But if there're
n nodes, the GUI will receive a minimum of n connections every second.
In many scenarios, these empty calls are unnecessary.

So, in order to optimize this behaviour, if the daemon has not collected
new statistics, we won't invoke this call. This will slightly reduce the
load on the GUI (server) when managing multiple nodes, and will save
some CPU cycles on the daemon side.

The connection status between the daemon and the GUI is managed with the
following gRPC options:

 - The server and the daemon configures a 5-seconds keepalive to keep
   the channel open:
   'grpc.keepalive_time_ms', 5000
 - If after 5 seconds the keepalive msg is not received, then after 20
   seconds the connection with the daemon will be closed if the server
   doesn't receive a response:
   'grpc.keepalive_timeout_ms', 20000

So after about 30 seconds, if the daemon can't communicate with the GUI
(server), it'll close the connection and retry it every second.
2025-12-11 12:07:10 +01:00
Gustavo Iñiguez Goia
f2e2e52aef removed parameters from init services
The daemon no longer requires the parameter -rules-path.

The default path is /etc/opensnitchd/rules, and it's configurable from
the configuration.
2025-12-10 21:31:33 +01:00
Gustavo Iñiguez Goia
9b33f7bdc8 discard notification replies if channel is closed
Sometimes, when closing the notifications channel, we could end up
trying to reply to a notification after the channel was already
closed. For example when changing the server address of a node.

In that scenario, the goroutine never finished and attempted to
reply to the notification.
2025-12-09 23:35:32 +01:00
Gustavo Iñiguez Goia
5b67e2e53e stop notifications at the server's request 2025-12-07 13:14:50 +01:00
Gustavo Iñiguez Goia
8270be1278
check TaskMgr validity 2025-12-05 23:12:51 +01:00
Gustavo Iñiguez Goia
fefbf385f1
lower ping() log level to DEBUG
When sending the events to the GUI (server), there's a hardcoded timeout
of one second. If the call takes longer, we were writing a warning to
the logs for each call, which in some cases could be excessive.

Hitting the timeout can be normal under some circumstances, such as when
connecting to a GUI with multiple nodes and a lot of activity.

More info: #1453
2025-12-05 22:45:42 +01:00
Gustavo Iñiguez Goia
7a0c96c17e initiate Ping() timeout after collecting the stats
We have a hardcoded timeout of one second to send the daemon stats to
the GUI. In some cases it's not unusual to hit the deadline.

So in order to just measure the network call, we now initiate the
timeout after collecting the daemon statistics.

See: #1453
2025-12-05 15:32:18 +01:00
Gustavo Iñiguez Goia
528091f513 avoid crashing when executing fw tests
Found while debugging an issue with several Verdict errors on kernel
6.17.x. Something has changed.
2025-12-03 22:33:15 +01:00
Gustavo Iñiguez Goia
55ac4b7fa4
tasks improvements
- fixed some race conditions.
- added more errors logging.
2025-11-28 00:02:52 +01:00
Gustavo Iñiguez Goia
7224acc7bd print the notifications type on error 2025-11-27 21:32:39 +01:00
Gustavo Iñiguez Goia
9891d106cc
init services moved to data/init/ 2025-11-24 00:07:07 +01:00
Gustavo Iñiguez Goia
fbc72bb96a
mount tracefs path if it's not mounted
Some kernels or systems may not have tracefs mounted or available
by default.

We need the path /sys/kernel/tracing to be mounted, in order to add
syscalls ebpf probes.

So from now on we'll try to mount /sys/kernel/tracing if it's not
already mounted.

-check-requirements parameter updated to check if this option is
available.

Closes #1450.
2025-11-23 23:40:37 +01:00
Gustavo Iñiguez Goia
c57114deed
Bumped versions to v1.8.0 2025-11-23 23:18:35 +01:00
Gustavo Iñiguez Goia
2c142620c4
daemon default configuration files moved to data/ 2025-11-23 23:11:31 +01:00
Gustavo Iñiguez Goia
543241f7cd
improved tasks stopping
We don't need to close the channels on stopping a task. We use a Context
to exit from the task results loop.
2025-11-20 01:25:31 +01:00
Gustavo Iñiguez Goia
2c3120b936
tasks: send results to the loggers
elastic, grafana, syslog, etc.
2025-11-20 01:16:33 +01:00
Gustavo Iñiguez Goia
c719c34de3
tasks,iocscanner: scheduler improvements
note: if the pc is suspended, the timers do not take into account the
time spent suspended.
2025-11-19 21:36:20 +01:00
Gustavo Iñiguez Goia
24f7e6ff1b
tasks,iocscanner: improved running cmds
Sometimes we never reset the running status of the command.
2025-11-14 01:12:57 +01:00
Gustavo Iñiguez Goia
906ad17b12
tasks, iocscanner: minor changes
added tools name as constants, and explain how to use them.

The name of a tool identifies an instance of that tool. Each tool has
its own configuration and logic.

In order to create multiple instances of a tool (for example to run
multiple commands or scripts), just append details to the tool name:

 "name": "script",
 "cmd": ["/usr/bin/clamscan"]

 "name": "script-unhide",
 "cmd": ["/usr/sbin/unhide"]
2025-11-14 00:52:39 +01:00
Gustavo Iñiguez Goia
ab6638f9a0
tasks, iocscanner: simplify messages to the GUI 2025-11-14 00:35:08 +01:00
Gustavo Iñiguez Goia
450adf6485
tasks, iocscanner: updated README 2025-11-12 01:11:08 +01:00
Gustavo Iñiguez Goia
3d2d99648f
tasks: iocscanner minor improvements
- stop scheduler properly.
 - skip closing channels for now.
2025-11-12 00:52:12 +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