Skip to content

Commit 91d5ec5

Browse files
Update Rules.md
1 parent 5b4a59d commit 91d5ec5

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

wiki/Rules.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
### Format
99

10-
Rules are stored as JSON files inside the `-rule-path` folder, in the simplest case a rule looks like this:
10+
Rules are stored as JSON files inside the `-rule-path` directory (by default `/etc/opensnitchd/rules`), in the simplest case a rule looks like this:
1111

1212
```json
1313
{
@@ -159,7 +159,6 @@ Example of a complex rule using the operator _list_, saved from the GUI (Note: v
159159
"operator": {
160160
"type": "list",
161161
"operand": "list",
162-
"data": "[{\"type\": \"simple\", \"operand\": \"dest.ip\", \"data\": \"1.1.0.1\"}, {\"type\": \"simple\", \"operand\": \"dest.port\", \"data\": \"23\"}, {\"type\": \"simple\", \"operand\": \"user.id\", \"data\": \"1000\"}, {\"type\": \"simple\", \"operand\": \"process.path\", \"data\": \"/usr/bin/telnet.netkit\"}]",
163162
"list": [
164163
{
165164
"type": "simple",
@@ -206,16 +205,16 @@ Here's a rule to allow localhost connections:
206205
{
207206
"created": "2023-07-05T10:46:47.904024069+01:00",
208207
"updated": "2023-07-05T10:46:47.921828104+01:00",
209-
"name": "000-aallow-localhost",
208+
"name": "000-allow-localhost",
210209
"enabled": true,
211210
"precedence": true,
212211
"action": "allow",
213212
"duration": "always",
214213
"operator": {
215-
"type": "regexp",
216-
"operand": "dest.ip",
214+
"type": "network",
215+
"operand": "dest.network",
217216
"sensitive": false,
218-
"data": "^(127\\.0\\.0\\.1|::1)$",
217+
"data": "127.0.0.0/8",
219218
"list": []
220219
}
221220
}
@@ -267,4 +266,24 @@ If you want to restrict it further, under the `Addresses` tab you can review wha
267266
[x] From this executable: ^(/memfd|/tmp/|/var/tmp/|/dev/shm/|/var/run|/var/lock).*
268267
```
269268

269+
/etc/opensnitchd/rules/000-deny-tmp.json:
270+
```
271+
{
272+
"created": "2025-04-26T09:58:03.704090244+02:00",
273+
"updated": "2025-04-26T09:58:03.704216578+02:00",
274+
"name": "000-deny-tmp",
275+
"enabled": true,
276+
"precedence": true,
277+
"action": "reject",
278+
"duration": "always",
279+
"operator": {
280+
"type": "regexp",
281+
"operand": "process.path",
282+
"sensitive": false,
283+
"data": "^(/var/tmp|/dev|/memfd|/tmp).*",
284+
"list": []
285+
}
286+
}
287+
```
288+
270289
**Note** that the default policy should be deny everything unless explicitely allowed. But by creating a rule to deny specifically these directories, you can have a place where to monitor these executions.

0 commit comments

Comments
 (0)