Download tests/analyze/test_cli.py from Kolgrim/hades: direct link, hf CLI and curl.
- Browser
- Download file 699 Bytes
-
https://huggingface.co/Kolgrim/hades/resolve/main/tests/analyze/test_cli.py
- Command line
-
hf download hf://Kolgrim/hades/tests/analyze/test_cli.py
-
curl -L -o test_cli.py https://huggingface.co/Kolgrim/hades/resolve/main/tests/analyze/test_cli.py
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 | |