File size: 699 Bytes
5f02c05 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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
|