mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-10-20 15:21:30 +02:00
A scan no longer needs a saved engine. The launch dialog has two configuration modes: Scan Engine (default, runs a saved engine exactly as configured, shown as a pipeline and its YAML) and Custom Scan (pick the capabilities to run; dependent and supporting stages are included automatically). Targets are created on launch from typed values, the scan context is a first-class field, and "Run again" restores the engine or the selection that ran. Backend - scans.engine_id is nullable; an absent engine resolves through AdHocEngine and the run is named after its capabilities (plan_label) - ScanCreate/ScanBatchCreate accept target_value(s) (create or reuse via TargetService.ensure_targets), a per-run intensity, and preview works for a target that does not exist yet - every stage declares consumes/produces (AssetKind), group (StageGroup) and role (capability | support); the registry validates them and the catalog serves them with groups and seed_produces - stage_effects walks levels so a producer only feeds later levels and marks an unfed consumer skipped_no_input Frontend - components/scans/launch/: launch-dialog, launch-state, target-picker, plan-picker (segmented Scan Engine | Custom Scan, pipeline + YAML Config views, capability pills with full per-stage settings), stage-pill, stage-config-popover, launch-summary + what-runs, launch-context-field, launch-context-form, save-engine-dialog - utilities/launch-plan.ts resolves implied producers and following support stages; the last engine and last custom selection persist - quick-scan-fields offers presets and engines in one select; the command palette offers "Scan <value>"; scan list action is "Run again" - effect-panel drops its explanatory header; NO_CONTEXT_LABEL is "No scan context"; launch-modal and execution-preview are removed Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014erb6Jbm6v9sxPgYFBxB7E
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Mapping
|
|
from dataclasses import dataclass, field
|
|
|
|
from shared.definitions.constants import DEFAULT_GLOBAL_THREADS
|
|
from shared.definitions.launch import (
|
|
DEFAULT_LAUNCH_INTENSITY,
|
|
MAX_LABEL_STAGES,
|
|
QUICK_SCAN_LABEL,
|
|
)
|
|
from shared.services.scan_resolve import ResolvedScanConfig
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class AdHocEngine:
|
|
"""Engine-shaped defaults for a launch that names no saved engine."""
|
|
|
|
name: str = QUICK_SCAN_LABEL
|
|
intensity: str = DEFAULT_LAUNCH_INTENSITY
|
|
global_threads: int = DEFAULT_GLOBAL_THREADS
|
|
global_http_crawl: bool = True
|
|
global_headers: tuple[str, ...] = ()
|
|
stages: Mapping[str, dict] = field(default_factory=dict)
|
|
tool_options: Mapping[str, str] = field(default_factory=dict)
|
|
id: None = None
|
|
|
|
|
|
def plan_label(resolved: ResolvedScanConfig) -> str:
|
|
"""Name an ad hoc run after the capabilities it runs; support stages only count when nothing else does."""
|
|
from shared.enums.scan import StageRole # noqa: PLC0415
|
|
from stages.registry import stages # noqa: PLC0415
|
|
|
|
running = [
|
|
spec
|
|
for spec in stages()
|
|
if resolved.target_type in spec.applies_to
|
|
and resolved.stage(spec.name).get("enabled")
|
|
]
|
|
picked = [s for s in running if s.role == StageRole.CAPABILITY.value]
|
|
titles = [spec.title for spec in (picked or running)]
|
|
if not titles:
|
|
return QUICK_SCAN_LABEL
|
|
if len(titles) == 1:
|
|
return titles[0]
|
|
if len(titles) <= MAX_LABEL_STAGES:
|
|
return f"{', '.join(titles[:-1])} and {titles[-1]}"
|
|
return f"{QUICK_SCAN_LABEL} · {len(titles)} stages"
|