hades / tests /analyze /test_cli.py
Kolgrim's picture
HADES pipeline code, tokenizer, tests, docs
5f02c05 verified
Raw History Blame Contribute Delete
699 Bytes
from hades.analyze.__main__ import main
def test_cli_reports_attack_window(tmp_path, capsys):
log = tmp_path / "auth.log"
log.write_text("\n".join(
f"Jan 1 00:00:{i:02d} h sshd[1]: Failed password for root from 203.0.113.9 port 22 ssh2" for i in range(8)))
assert main([str(log)]) == 0
out = capsys.readouterr().out
assert "VERDICT: brute_force" in out and "lines 1-8" in out
def test_cli_quiet_on_normal(tmp_path, capsys):
log = tmp_path / "auth.log"
log.write_text("\n".join(["Jan 1 00:00:00 h CRON[2]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)"] * 5))
main([str(log)])
assert "No findings" in capsys.readouterr().out