mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-12 19:55:14 +02:00
Dynamic (#77)
This commit is contained in:
parent
55247b7fcd
commit
991c84a1eb
1464 changed files with 225448 additions and 1985 deletions
28
tests/dynamic_fixtures/python/generic/benign.py
Normal file
28
tests/dynamic_fixtures/python/generic/benign.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""Phase 12 — generic shape, benign.
|
||||
|
||||
Validates the input against a strict allow-list (alphanumerics + dots
|
||||
only — RFC-1035 hostname character set) and refuses to shell out when
|
||||
the input contains anything outside the allow-list. The CMDI marker
|
||||
substring (`NYX_PWN_CMDI`) never reaches stdout because the function
|
||||
returns before any subprocess call when the validation fails.
|
||||
"""
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
_VALID_HOST = re.compile(r"^[A-Za-z0-9.-]{1,253}$")
|
||||
|
||||
|
||||
def run_ping(host):
|
||||
"""Safe: allow-list validation; refuse and return on mismatch."""
|
||||
if not _VALID_HOST.fullmatch(host or ""):
|
||||
print("invalid host")
|
||||
return
|
||||
result = subprocess.run(
|
||||
["ping", "-c", "1", host],
|
||||
shell=False,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5,
|
||||
)
|
||||
print(result.stdout)
|
||||
print(result.stderr, end="")
|
||||
Loading…
Add table
Add a link
Reference in a new issue