Skip to content

Commit a29d62c

Browse files
authored
Merge pull request #1871 from stratosphereips/alya/immune/improve_logging
Improve logging and fix log rotation
2 parents 7cad615 + 80716ee commit a29d62c

232 files changed

Lines changed: 3572 additions & 2305 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ slack_bot_token_secret
1818
# Ignore daemon output files
1919
daemon/
2020

21+
# Ignore private AGENTS.md, may contain private paths
22+
private/AGENTS.md
23+
24+
2125
# Ignore the results folders
2226
2019-
2327
2020-

.secrets.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
"filename": "config/slips.yaml",
150150
"hashed_secret": "4cac50cee3ad8e462728e711eac3e670753d5016",
151151
"is_verified": false,
152-
"line_number": 278
152+
"line_number": 295
153153
}
154154
],
155155
"dataset/test14-malicious-zeek-dir/http.log": [
@@ -7185,5 +7185,5 @@
71857185
}
71867186
]
71877187
},
7188-
"generated_at": "2026-03-27T14:25:16Z"
7188+
"generated_at": "2026-04-08T14:13:03Z"
71897189
}

AGENTS.md

Lines changed: 134 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,136 @@
11
# AGENTS.md
22

3-
## Project overview
4-
- Entry point: `slips.py` (starts the main process, spawns modules, runs in interactive/daemon modes).
5-
- Core framework code lives in `slips/`, `slips_files/`, and `managers/`.
6-
- Detection/analysis modules are in `modules/` (implement the `IModule` interface).
7-
- Configuration is in `config/` (main config: `config/slips.yaml`).
8-
- Tests live under `tests/` (unit + integration suites).
9-
- Documentation is in `docs/` (see `docs/contributing.md` for contribution workflow, branching, and PR expectations).
10-
- UIs/tools: `SlipsWeb/`, `webinterface/`, `webinterface.sh`, and `kalipso.sh`.
11-
12-
## Build and test commands
13-
- Run locally (no build step):
14-
- `./slips.py -e 1 -f dataset/test7-malicious.pcap -o output_dir`
15-
- Build the Docker image (from `docs/installation.md`):
16-
- `docker build --no-cache -t slips -f docker/Dockerfile .`
17-
- If build networking fails: `docker build --network=host --no-cache -t slips -f docker/Dockerfile .`
18-
- Run the Docker image:
19-
- `docker run -it --rm --net=host slips`
20-
21-
## Code style guidelines
22-
- Python formatting is enforced via pre-commit:
23-
- Black with `--line-length 79` (see `.pre-commit-config.yaml`).
24-
- Ruff is used for linting and autofixes.
25-
- Keep docstrings at the top of files where present (pre-commit `check-docstring-first`).
26-
- Maintain clean whitespace (no trailing whitespace, final newline).
27-
- Follow existing module patterns (`IModule` in `slips_files/common/abstracts/module.py`).
28-
29-
## Testing instructions
30-
- The canonical test runner is `tests/run_all_tests.sh` (runs unit tests then integration tests).
31-
- Equivalent manual sequence (from `tests/run_all_tests.sh`):
32-
- `./slips.py -cc`
33-
- `printf "0" | ./slips.py -k`
34-
- `python3 -m pytest tests/ --ignore="tests/integration_tests" -n 7 -p no:warnings -vvvv -s`
35-
- `python3 tests/destrctor.py`
36-
- `./slips.py -cc`
37-
- `printf "0" | ./slips.py -k`
38-
- `python3 -m pytest -s tests/integration_tests/test_portscans.py -p no:warnings -vv`
39-
- `python3 -m pytest -s tests/integration_tests/test_dataset.py -p no:warnings -vv`
40-
- `python3 -m pytest -s tests/integration_tests/test_config_files.py -p no:warnings -vv`
41-
- `printf "0" | ./slips.py -k`
42-
- `./slips.py -cc`
3+
## 1. Project Overview
4+
5+
- Entry point: `slips.py`
6+
- Starts the main process
7+
- Spawns modules
8+
- Supports interactive and daemon modes
9+
10+
- Core code directories:
11+
- `slips/`
12+
- `slips_files/`
13+
- `managers/`
14+
15+
- Detection modules:
16+
- Located in `modules/`
17+
- Must implement `IModule` from:
18+
`slips_files/common/abstracts/module.py`
19+
20+
- Configuration:
21+
- Main file: `config/slips.yaml`
22+
23+
- Tests:
24+
- Located in `tests/`
25+
- Includes unit and integration tests
26+
27+
- Documentation:
28+
- Located in `docs/`
29+
- Contribution guide: `docs/contributing.md`
30+
31+
- UI / tools:
32+
- `SlipsWeb/`
33+
- `webinterface/`
34+
- `webinterface.sh`
35+
- `kalipso.sh`
36+
37+
- Repository root:
38+
- All commands MUST be executed from `StratosphereLinuxIPS/`
39+
40+
---
41+
42+
## 2. Build and Run
43+
44+
### to run slips locally
45+
./slips.py -e 1 -f dataset/test7-malicious.pcap -o output_dir
46+
47+
### Build Docker image
48+
docker build --no-cache -t slips -f docker/Dockerfile .
49+
50+
- If networking fails:
51+
52+
docker build --network=host --no-cache -t slips -f docker/Dockerfile .
53+
54+
### Run Docker container
55+
docker run -it --rm --net=host slips
56+
57+
## 3. Code Style Rules
58+
59+
These rules MUST be followed:
60+
61+
- No trailing whitespace
62+
- File must end with a newline
63+
- Docstring must be the first statement in a file (if present)
64+
- Avoid using environment variables, use variables from slips/config.yaml instead.
65+
66+
### Paths:
67+
- NEVER use absolute paths
68+
- ALWAYS use relative paths
69+
### Files:
70+
- If a non-debug file is created → MUST be added with git add
71+
### Documentation:
72+
If a feature is added → MUST update relevant docs in docs/
73+
### Functions:
74+
- Every new function MUST include a docstring
75+
Docstrings MUST include:
76+
- Short description
77+
- Parameters (if applicable)
78+
- Return value (if applicable)
79+
80+
## 4. Testing
81+
- Canonical test runner
82+
tests/run_all_tests.sh
83+
## 5. Unit Test Update Workflow
84+
85+
When instructed to "update unit tests", follow EXACTLY:
86+
87+
Step 1 — Run tests
88+
python3 -m pytest tests/unit/ \
89+
--ignore="tests/integration_tests" \
90+
-n 7 -p no:warnings -vvvv -s
91+
92+
Step 2 — Identify failures
93+
Collect ALL failing tests
94+
95+
Step 3 — Fix tests
96+
Update failing tests ONE BY ONE
97+
Do NOT batch fixes
98+
99+
Step 4 — Add missing tests for new files
100+
For every new source file in the branch:
101+
102+
- Mirror its directory under tests/unit/
103+
104+
- C/reate file:
105+
test_<filename>.py
106+
- Add unit tests for that file
107+
108+
Step 5 — Add tests for new functions
109+
- Identify functions added in this branch (not in origin/develop)
110+
- Add unit tests for each new function
111+
112+
Step 6 — Test structure rules
113+
- MUST use @pytest.mark.parametrize when applicable
114+
115+
EACH test MUST:
116+
Start with object creation using module_factory
117+
118+
Step 7 — Re-run tests
119+
Run the same pytest command again
120+
Ensure ALL tests pass
121+
122+
Step 8 — Git tracking
123+
If new test files were created → run:
124+
git add <files>
125+
126+
Step 9 — Failure fallback
127+
If tests are still failing and cannot be fixed:
128+
STOP
129+
Report the issue
130+
131+
## 6. Custom Instructions
132+
ALSO apply rules from:
133+
private/AGENTS.md
134+
135+
If conflicts occur:
136+
Prefer private/AGENTS.md

config/slips.yaml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# This configuration file controls several aspects of the working of Slips.
22

33
---
4-
modes:
4+
output:
55
# Define the file names for the default output.
66
stdout: slips.log
77
stderr: errors.log
8-
logsfile: slips.log
8+
logs: slips.log
99

1010
#############################
11-
# Parameters that can be also specified with modifiers in the command line
1211

1312
parameters:
1413
# The verbosity is related to how much data you want to see about the
@@ -77,6 +76,11 @@ parameters:
7776
# whitelist file, current commit and date
7877
metadata_dir: true
7978

79+
# This directory stores databases and runtime-generated files that must
80+
# persist across different slips runs and should not be overwritten.
81+
# this dir is inside slips root dir.
82+
permanent_dir: permanent
83+
8084
# Default pcap packet filter. Used with zeek pcapfilter : 'ip or not ip'
8185
# If you want more important traffic and forget the multicast and broadcast
8286
# traffic, you can use
@@ -112,7 +116,7 @@ parameters:
112116
# label: malicious
113117
# label: unknown
114118
label: normal
115-
# If Zeek files are rotated or not to avoid running out of disk.
119+
# determines if Zeek files are rotated or not to avoid running out of disk.
116120
# Zeek rotation is enabled by default when using an interface,
117121
# which means Slips will delete all Zeek log files after 1 day
118122
# of running
@@ -126,17 +130,16 @@ parameters:
126130
# Whitespace between the numeric constant and time unit is optional.
127131
# Appending the letter s to the time unit in order to
128132
# pluralize it is also optional
129-
# rotation_period = 30min
130-
# rotation_period = 2hr
131-
# rotation_period = 30sec
132-
rotation_period: 1day
133+
# default_rotation_interval: 30min
134+
# default_rotation_interval: 2hr
135+
default_rotation_interval: 30sec
136+
#default_rotation_interval: 1day
133137

134138
# How many days Slips keeps the rotated Zeek files before deleting them.
135139
# Value should be in days
136140
# set it to 0 day if you want to delete them immediately
137-
# keep_rotated_files_for : 1 day
141+
# keep_rotated_files_for : 0 day
138142
# keep_rotated_files_for : 2 day
139-
# keep_rotated_files_for : 3 day
140143
keep_rotated_files_for: 1 day
141144

142145
# How many minutes to wait for all modules to finish before killing them
@@ -201,9 +204,9 @@ modules:
201204
# List of modules to ignore. By default we always ignore the template,
202205
# do not remove it from the list
203206
# Add the names of other modules that you want to disable
204-
# (they all should be lowercase with no special characters). Example,
205-
# threatintelligence, blocking, networkdiscovery, timeline, virustotal,
206-
# rnnccdetection, flowmldetection, updatemanager
207+
# (use module snake_case names). Example,
208+
# threat_intelligence, blocking, network_discovery, timeline, virustotal,
209+
# rnn_cc_detection, flow_ml_detection, update_manager
207210
disable: [template]
208211

209212
# For each line in timeline file there is a timestamp.
@@ -212,10 +215,10 @@ modules:
212215
timeline_human_timestamp: true
213216

214217
#############################
215-
flowmldetection:
218+
flow_ml_detection:
216219
# This is a module that uses machine learning for detection.
217220
# It can be used in train mode or test mode.
218-
# The mode 'train' should be used to tell the flowmldetection module
221+
# The mode 'train' should be used to tell the flow_ml_detection module
219222
# that the flows received are all for training.
220223
# A label should be provided in the [Parameters] section
221224
# mode : train
@@ -226,7 +229,7 @@ flowmldetection:
226229
mode: test
227230

228231
#############################
229-
bruteforcing:
232+
brute_force_detector:
230233
# Minimum number of SSH attempts from one source to one destination
231234
# before Slips considers it brute forcing.
232235
ssh_attempt_threshold: 9
@@ -299,7 +302,7 @@ virustotal:
299302
#############################
300303
threatintelligence:
301304

302-
# By default, slips starts without the TI files, and runs the Update Manager
305+
# By default, slips starts without the TI files, and runs the update_manager
303306
# in the background. If this option is set to true, slips will not start
304307
# analyzing the flows until the update manager finished and all TI files are
305308
# loaded successfully.
@@ -325,7 +328,7 @@ threatintelligence:
325328
# The remote TI files will be temporaly stored in this directory
326329
download_path_for_remote_threat_intelligence: modules/threat_intelligence/remote_data_files/
327330

328-
# Update period of Threat Intelligence files. How often should Slips update
331+
# Update period of threat_intelligence files. How often should Slips update
329332
# the IoCs.
330333
# The expected value is in seconds.
331334
# 1 day = 86400 seconds
@@ -389,8 +392,8 @@ whitelists:
389392
local_whitelist_path: config/whitelist.conf
390393

391394
#############################
392-
flowalerts:
393-
# For the flowalerts module
395+
flow_alerts:
396+
# For the flow_alerts module
394397
# We need a thrshold to determine a long connection in seconds.
395398
# In Slips by default is 25 minutes
396399
long_connection_threshold: 1500
@@ -487,7 +490,7 @@ exporting_alerts:
487490
taxii_timeout: 10
488491

489492
#############################
490-
CESNET:
493+
cesnet:
491494
# Slips also supports exporting and importing evidence in the IDEA format to/from
492495
# warden servers of CESNET organization in Czech Republic.
493496
send_alerts: false
@@ -597,7 +600,7 @@ global_p2p:
597600
use_global_p2p: False
598601
iris_conf: config/iris_config.yaml
599602
bootstrapping_node: False
600-
bootstrapping_modules: ["fidesModule", "irisModule"]
603+
bootstrapping_modules: ["fides", "iris"]
601604

602605
#############################
603606
local_p2p:

conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
parent_dir = os.path.dirname(current_dir)
2424
sys.path.insert(0, parent_dir)
2525

26-
2726
# Suppress TensorFlow logs from C++ backend
2827
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" # 3 = ERROR
2928
# TensorFlow logs oneDNN messages even with TF_CPP_MIN_LOG_LEVEL=3.

docs/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If the tensorflow version you're using isn't compatible with your architecture,
1212
you will get the "Illegal instruction" error and slips will terminate.
1313

1414
To fix this you can disable the modules that use tensorflow by adding
15-
```rnn-cc-detection, flowmldetection``` to the ```disable``` key in ```config/slips.yaml```
15+
```rnn-cc-detection, flow_ml_detection``` to the ```disable``` key in ```config/slips.yaml```
1616

1717

1818
## Docker time is not in sync with that of the host

docs/P2P.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ development of new trust models and modelling behavior of the P2P network.
112112

113113
To use the experiments, clone
114114
the https://github.com/stratosphereips/p2p4slips-experiments repository into
115-
`modules/p2ptrust/testing/experiments`.
115+
`modules/p2p_trust/testing/experiments`.
116116

117117
The experiments run independently (outside of Slips) and start all processes that are needed, including relevant parts
118118
of Slips.
@@ -148,6 +148,8 @@ The network then replies with a score and confidence for the IP. The higher the
148148
Once we get the score of the IP, we store it in the database,
149149
and we alert if the score of this IP is more than 0 (threat level=info).
150150

151+
The persistent local P2P runtime directory is stored under the directory configured by ```parameters.permanent_dir``` in ```config/slips.yaml```. By default, this is ```permanent/p2p_trust_runtime/```.
152+
151153

152154
### Answering the network's request about an IP
153155

0 commit comments

Comments
 (0)