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.
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.
* 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
Restrict the use of network type to network operand:
"operator": {
"type": "network",
"operand": "dest.network",
"sensitive": false,
"data": "LAN",
"list": []
}
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
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
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.
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.
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.
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
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
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.
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"]