-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroe.py
More file actions
71 lines (57 loc) · 1.84 KB
/
Copy pathroe.py
File metadata and controls
71 lines (57 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
Rules of Engagement (ROE) module.
Defines engagement boundaries, scope constraints, and authorization checks
for penetration testing activities.
"""
import json
import os
from pathlib import Path
ROE_PROFILES_DIR = Path(__file__).parent / "roe_profiles"
def load_roe_profile(name: str) -> dict:
"""Load a ROE profile by name."""
path = ROE_PROFILES_DIR / f"{name}.json"
if not path.exists():
return {"error": f"ROE profile '{name}' not found"}
with open(path, "r") as f:
return json.load(f)
def list_roe_profiles() -> list[str]:
"""List available ROE profiles."""
if not ROE_PROFILES_DIR.exists():
return []
return [p.stem for p in ROE_PROFILES_DIR.glob("*.json")]
def check_scope(target: str, roe: dict) -> bool:
"""Check if a target is within the engagement scope."""
scope = roe.get("scope", {})
in_scope = scope.get("in_scope", [])
out_of_scope = scope.get("out_of_scope", [])
# Check exclusions first
for excluded in out_of_scope:
if excluded in target or target in excluded:
return False
# Check inclusions
if not in_scope:
return True # No scope defined = everything allowed
for included in in_scope:
if included in target or target in included:
return True
return False
def get_default_roe() -> dict:
"""Return default ROE for demo/testing."""
return {
"engagement": "ModTester Demo",
"scope": {
"in_scope": ["*"],
"out_of_scope": []
},
"rules": {
"dos_allowed": False,
"social_engineering": False,
"physical_access": False,
"data_exfiltration": False,
"max_threads": 10,
},
"timeframe": {
"start": "2026-01-01",
"end": "2026-12-31"
}
}