Files
rengine/shared/services/scan_scope.py
T
Yogesh OjhaandClaude Fable 5.1 ca32cc62f3 feat(connectors): browsing lands in the endpoints inventory
Proxy observations are written as endpoint rows with source proxy into the
target's covering scan; a target without a census scan gets a Browsing run,
and finalize replays recorded shapes into a new census scan. "Seen by a
scan" is host plus path shape (new endpoints.shape column, backfilled),
with parameter differences reported as their own notice and unseen claimed
only when a settled scan covers the target.

Removed the scan trigger, sessions and coverage surfaces. The jar is served
from binaries/, the setup dialog derives the endpoint from the browser
origin, scans dispatch one run per target with the chosen scan context, and
manual findings mask credential headers. Endpoints page gains Browsed and
Not browsed filters; the Burp tab gains a host line, a notices table with
Open in reNgine, and a report dialog with notes and a result.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PMmqqNaMMjCJWzGG49Xc1i
2026-09-12 16:39:23 +05:30

42 lines
1.4 KiB
Python

"""A focused rescan is evidence, not a census — every surface rollup filters on this."""
from __future__ import annotations
from functools import lru_cache
from sqlalchemy import exists, select
from shared.definitions.surface import SURFACE_KINDS, SURFACE_ORDER
from shared.enums.scan import ScanActivityStatus, ScanScope
from shared.models.scan import Scan
from shared.models.scan_activity import ScanActivity
def census_only(model=Scan):
"""Runs that describe a target's whole surface."""
return model.scope == ScanScope.FULL.value
@lru_cache(maxsize=1)
def covering_stages() -> dict[str, frozenset[str]]:
"""Dimension -> the stage names whose success means the dimension was scanned."""
from stages.registry import stages # noqa: PLC0415
out: dict[str, set[str]] = {key: set() for key in SURFACE_ORDER}
for spec in stages():
for key, kinds in SURFACE_KINDS.items():
if spec.produces & kinds:
out[key].add(spec.name)
return {key: frozenset(names) for key, names in out.items()}
def covers(model, dimension: str, scan=Scan):
"""The scan wrote rows for the dimension, or a producing stage succeeded."""
return exists(select(1).where(model.scan_id == scan.id)) | exists(
select(1).where(
ScanActivity.scan_id == scan.id,
ScanActivity.status == ScanActivityStatus.SUCCESS.value,
ScanActivity.name.in_(covering_stages()[dimension]),
)
)