Skip to content

Commit dffa761

Browse files
authored
Merge pull request #26 from mathiscapart/prod
Prod
2 parents b53683c + 510b003 commit dffa761

7 files changed

Lines changed: 56 additions & 51 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,54 @@ jobs:
2626
- run: pip install bandit
2727
- run: bandit -r honeypots/ pipeline/ dashboard/ -ll -ii
2828

29+
# Tests unitaires PAR COMPOSANT. Les honeypots embarquent des modules à plat
30+
# (config.py, events.py, server.py, detection.py) avec des noms IDENTIQUES
31+
# entre ssh et ftp : les lancer dans le même process pytest provoque des
32+
# collisions de modules top-level. On exécute donc chaque suite isolément,
33+
# dans son propre dossier — exactement comme l'image Docker les importe
34+
# (WORKDIR /app, `python server.py`). L'attacker tourne depuis la racine
35+
# (son module local `logging.py` masquerait la stdlib autrement).
2936
test:
3037
needs: lint
3138
runs-on: ubuntu-latest
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
include:
43+
- name: honeypot-ssh
44+
dir: honeypots/ssh
45+
target: tests/
46+
- name: honeypot-ftp
47+
dir: honeypots/ftp
48+
target: tests/
49+
- name: honeypot-http
50+
dir: honeypots/http
51+
target: tests/
52+
- name: analyzer
53+
dir: analyzer
54+
target: tests/
55+
- name: attacker
56+
dir: .
57+
target: attacker/tests/
3258
steps:
3359
- uses: actions/checkout@v4
34-
35-
- name: Set up Python 3.12
36-
uses: actions/setup-python@v5
60+
- uses: actions/setup-python@v5
3761
with:
3862
python-version: "3.12"
39-
40-
- name: Install dependencies
63+
- name: Install test deps (${{ matrix.name }})
64+
working-directory: ${{ matrix.dir }}
4165
run: |
42-
pip install --upgrade pip
43-
pip install pytest
44-
find . -name "requirements*.txt" \
45-
-not -path "./.git/*" \
46-
| xargs -I {} pip install -r {}
47-
48-
- name: Run all tests
49-
run: pytest --tb=short -v
66+
python -m pip install --upgrade pip
67+
if [ -f requirements-dev.txt ]; then
68+
pip install -r requirements-dev.txt
69+
else
70+
pip install pytest
71+
fi
72+
- name: pytest (${{ matrix.name }})
73+
working-directory: ${{ matrix.dir }}
74+
# `python -m pytest` met le cwd sur sys.path => imports à plat OK,
75+
# comme en conteneur. Pas de pytest.ini racine (collecte globale = collisions).
76+
run: python -m pytest ${{ matrix.target }} -q
5077

5178
# Valide que les secrets d'enrichissement sont montes et fonctionnels
5279
# (AbuseIPDB, GreyNoise) sans monter la stack.

‎honeypots/ftp/server.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,17 @@
2323
import uuid
2424

2525
from config import Config, load_config
26-
from events import EventSink, build_event
27-
from filesystem import is_canary, materialize
28-
from pyftpdlib.authorizers import DummyAuthorizer
29-
from pyftpdlib.handlers import FTPHandler
30-
from pyftpdlib.servers import FTPServer
31-
32-
from ftp.detection import (
26+
from detection import (
3327
SessionProfiler,
3428
classify_command,
3529
classify_credential_reuse,
3630
classify_download,
3731
)
32+
from events import EventSink, build_event
33+
from filesystem import is_canary, materialize
34+
from pyftpdlib.authorizers import DummyAuthorizer
35+
from pyftpdlib.handlers import FTPHandler
36+
from pyftpdlib.servers import FTPServer
3837

3938
# Commandes d'authentification : journalisées via les callbacks on_login* (avec
4039
# le couple identifiant/mot de passe), jamais comme événement "command" — on

‎honeypots/ftp/tests/test_ftp_honeypot.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
import pytest
1616
from config import Credential, load_config
17-
from events import build_event, normalize_ipv4
18-
from filesystem import DECOY_TREE, decoy_dirs, is_canary, materialize
19-
from ftp.detection import (
17+
from detection import (
2018
SessionProfiler,
2119
classify_command,
2220
classify_credential_reuse,
2321
classify_download,
2422
is_recon,
2523
)
24+
from events import build_event, normalize_ipv4
25+
from filesystem import DECOY_TREE, decoy_dirs, is_canary, materialize
2626
from jsonschema import Draft7Validator
2727

2828
SCHEMA_PATH = Path(__file__).resolve().parents[3] / "docs" / "event.schema.json"

‎honeypots/http/requirements-dev.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
-r requirements.txt
33
pytest==8.3.4
44
jsonschema==4.23.0
5+
# Client HTTP requis par starlette.TestClient (fastapi.testclient) — absent
6+
# sinon en CI : "starlette.testclient requires the httpx package".
7+
httpx==0.28.1

‎honeypots/ssh/server.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
import asyncssh
2525
from commands import ShellState, run_command
2626
from config import Config, load_config
27+
from detection import SessionProfiler, classify_command, is_escalation
2728
from events import EventSink, build_event
2829

29-
from ssh.detection import SessionProfiler, classify_command, is_escalation
30-
3130
# Version annoncée : OpenSSH Debian plausible plutôt que la bannière asyncssh
3231
# (réduit le fingerprinting trivial du honeypot).
3332
SERVER_VERSION = "OpenSSH_9.2p1 Debian-2+deb12u2"

‎honeypots/ssh/tests/test_ssh_honeypot.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
import pytest
1212
from commands import ShellState, run_command
1313
from config import Credential, load_config
14-
from events import build_event, normalize_ipv4
15-
from jsonschema import Draft7Validator
16-
from ssh.detection import (
14+
from detection import (
1715
SessionProfiler,
1816
classify_command,
1917
detect_malware,
2018
is_escalation,
2119
)
20+
from events import build_event, normalize_ipv4
21+
from jsonschema import Draft7Validator
2222

2323
SCHEMA_PATH = Path(__file__).resolve().parents[3] / "docs" / "event.schema.json"
2424

‎pytest.ini‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)