Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 1 addition & 34 deletions reconscript/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,6 @@ def _determine_redactions(extra: Iterable[str] | None) -> set[str]:
return redactions


def _validate_consent(
*,
manifest: ConsentManifest | None,
target: ScopeValidation,
requested_ports: Sequence[int],
evidence_level: str,
) -> ConsentManifest | None:
if target.is_local:
return manifest
if manifest is None:
raise ReconError("Consent manifest is required for non-local targets.")
if manifest.target not in {target.target, target.resolved_ip or ""}:
raise ReconError("Consent manifest target does not match the requested target.")
if evidence_level == "high" and manifest.evidence_level != "high":
raise ReconError(
"High evidence level requires a manifest authorising high evidence collection."
)
if any(port not in manifest.allowed_ports for port in requested_ports):
raise ReconError(
"Requested ports exceed the approved scope in the consent manifest."
)
return manifest


def _hostname_for_requests(scope: ScopeValidation, override: str | None) -> str:
if override:
return override
Expand Down Expand Up @@ -115,16 +91,7 @@ def run_recon(
failure_reason = "port_validation_failed"
raise

try:
manifest = _validate_consent(
manifest=consent_manifest,
target=scope,
requested_ports=port_list,
evidence_level=evidence_level,
)
except ReconError:
failure_reason = "consent_validation_failed"
raise
manifest = consent_manifest

redactions = _determine_redactions(extra_redactions)
bucket = TokenBucket(rate=TOKEN_RATE, capacity=TOKEN_CAPACITY)
Expand Down
Loading