INNER CODE UNIT · Python

_enforcer_for_engagement

0xSteph/pentest-ai · cli/main.py:313

def _enforcer_for_engagement(eng: dict):
    """Build the ScopeEnforcer for resume/retest/live. Prefer the scope the
    operator confirmed on the original `ptai start` (persisted as scope_json)
    so exclusions and explicit allows are preserved exactly; fall back to the
    stored target host + config.scope only for engagements created before scope
    was persisted."""
    from engine.scope import ScopeEnforcer, build_enforcer
    eng = eng or {}
    raw = eng.get("scope_json")
    if raw:
        try:
            d = json.loads(raw)
            return ScopeEnforcer(
                allowed_targets=d.get("allowed") or None,
                excluded_targets=d.get("excluded") or None,
                allowed_ports=d.get("allowed_ports") or None,
                mode=d.get("mode", "strict"),
            )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…