Download tests/conftest.py from Kolgrim/hades: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/Kolgrim/hades/resolve/main/tests/conftest.py
- Command line
-
hf download hf://Kolgrim/hades/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/Kolgrim/hades/resolve/main/tests/conftest.py
1.21 kB
| import random | |
| import pytest | |
| def _fixture_text() -> str: | |
| rng = random.Random(42) | |
| words = ( | |
| "the attacker gained access to the server after a brute force attack " | |
| "against the ssh service authentication failure was logged for user root " | |
| "a vulnerability in the kernel allows local privilege escalation via a " | |
| "crafted request defenders should rotate credentials and review sudo logs" | |
| ).split() | |
| lines = [] | |
| for i in range(700): | |
| if i % 3 == 0: | |
| ip = ".".join(str(rng.randint(1, 254)) for _ in range(4)) | |
| lines.append( | |
| f"Oct 28 01:{rng.randint(0, 59):02d}:{rng.randint(0, 59):02d} web01 " | |
| f"sshd[{rng.randint(1000, 99999)}]: Failed password for root from {ip} port {rng.randint(1024, 65535)} ssh2" | |
| ) | |
| else: | |
| lines.append(" ".join(rng.choice(words) for _ in range(rng.randint(5, 15))).capitalize() + ".") | |
| return "\n".join(lines) | |
| FIXTURE_TEXT = _fixture_text() | |
| FIXTURE_LINES = FIXTURE_TEXT.splitlines() | |
| def trained_small(): | |
| from hades.tokenizer.bpe import train_bpe | |
| return train_bpe([FIXTURE_TEXT], vocab_size=600) | |