Scanner pipeline¶
The CLI composes extraction, generation, ranking, live validation, diagnostics, memory, baseline tools, and reports. For operational defaults and limitations, see scan a workflow.
Extraction and generation¶
extract reconstructs available workflow prompt context and detects provider, tool restrictions, checkout credential behavior, and a trigger. This is a reconstruction from assets, not a capture of live model traffic.
extract ¶
Source code in src/benchmark/scanner/prompt_extractor.py
generate creates hypotheses, optionally using cross-workflow memory and a monolithic prompt instead of category-specific generation.
generate ¶
generate(context: EffectivePromptContext, memory: CrossWorkflowMemory, hypotheses_per_scan: int = 12, monolithic: bool = False, negative_examples: list[dict] | None = None, model: str = 'claude-sonnet-4-6', max_tokens: int = 16384) -> list[AttackHypothesis]
Source code in src/benchmark/scanner/hypothesis_generator.py
Ranking and live validation¶
rank returns ranked hypotheses and discarded (hypothesis, reason) pairs. Structural validation always runs; skip_llm bypasses the model ranking stage.
rank ¶
rank(hypotheses: list[AttackHypothesis], context: EffectivePromptContext, plausibility_threshold: int = 5, skip_llm: bool = False, model: str = 'claude-sonnet-4-6') -> tuple[list[AttackHypothesis], list[tuple[AttackHypothesis, str]]]
Source code in src/benchmark/scanner/llm_ranker.py
validate writes recipes and executes independent GitHub trials through the ordinary runner. Dry-run candidates are skipped. Confirmation requires all requested trials to count as successes and no invalid trials. Inspect diagnostic evidence and corrections alongside validation status.
validate ¶
validate(hypotheses: list[AttackHypothesis], context: EffectivePromptContext, workflow_id: str, workflow_category: str, runs_per_hypothesis: int = 3, max_hypotheses: int = 5, iterations: int = 2, repo_prefix: str = 'benchmark-scan', cleanup: bool = True, dry_run: bool = False, judge_model: str = 'gemini-3.1-pro-preview', enable_diagnostics: bool = True, diagnostic_model: str = 'claude-haiku-4-5') -> list[ValidationResult]
Source code in src/benchmark/scanner/live_validator.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
Diagnostics¶
Diagnostics classify execution/evaluation problems, refusal, ineffective payloads, and evaluator blind spots. counts_as_success is a scanner interpretation that can differ from the original metric verdict; retain the diagnostic evidence for review.
diagnostics ¶
DiagnosticResult
dataclass
¶
Source code in src/benchmark/scanner/diagnostics.py
classify_run ¶
classify_run(run_result_dict: dict, hypothesis: AttackHypothesis, evaluator_type: str, diagnostic_model: str = 'claude-haiku-4-5', enable_artifact_inspection: bool = True) -> DiagnosticResult
Fast-path classification of a single live run.
run_result_dict: dict returned by BenchmarkRunner.run(). evaluator_type: "state" or "llm" — security evaluator used by the scenario.
Source code in src/benchmark/scanner/diagnostics.py
should_escalate ¶
should_escalate(diag: DiagnosticResult, hypothesis: AttackHypothesis, ranker_score: float | None, run_index: int, escalation_enabled: bool) -> bool
Gating criteria for the agentic investigator (§3.5 escalation tier). The investigator itself is not yet implemented — this predicate is the pipeline-side gate so call sites are ready.
Source code in src/benchmark/scanner/diagnostics.py
Recipes and validation¶
Recipe writing returns the definition path; default output is a unique scanner-candidate root under runs/. Loading validates the hypothesis. Deletion requires generated ownership and refuses directories with additional files. See the recipe format.
recipe_scenario ¶
RecipeScenario ¶
Bases: AbstractScenario
Runtime interpreter for a recipe-shaped AttackHypothesis. Loaded from a recipe.json file in a scenario directory; never code-generated.
Source code in src/benchmark/scanner/recipe_scenario.py
category
instance-attribute
¶
labels
instance-attribute
¶
labels = ['scanner-generated', hypothesis.mitre_category.lower().replace(' ', '-')] + list(hypothesis.tags)
get_secrets ¶
setup_state ¶
Source code in src/benchmark/scanner/recipe_scenario.py
teardown_state ¶
get_event ¶
Source code in src/benchmark/scanner/recipe_scenario.py
get_attack_goal ¶
get_utility_evaluator ¶
get_security_evaluator ¶
Source code in src/benchmark/scanner/recipe_scenario.py
write_recipe ¶
write_recipe(hypothesis: AttackHypothesis, workflow_category: str, scenarios_dir: str | None = None, judge_model: str = 'gemini-3.1-pro-preview') -> str
Source code in src/benchmark/scanner/recipe_scenario.py
delete_recipe ¶
Source code in src/benchmark/scanner/recipe_scenario.py
load_recipe ¶
Source code in src/benchmark/scanner/recipe_scenario.py
primitives ¶
PRIMITIVES
module-attribute
¶
PRIMITIVES: dict[str, PrimitiveSpec] = {'put_file': PrimitiveSpec(name='put_file', description="Write a file at `path` with `content` on `branch` (default 'main'). Creates the branch first if needed.", args_schema={'path': 'str', 'content': 'str', 'branch': "str (optional, default 'main')", 'message': 'str (optional)'}, required=['path', 'content'], execute=_exec_put_file, produces_branch_with_commits=True), 'add_workflow_file': PrimitiveSpec(name='add_workflow_file', description='Install a GitHub Actions workflow file at `.github/workflows/<name>.yml` with `yaml` content.', args_schema={'name': 'str (filename without .yml)', 'yaml': 'str (workflow YAML body)', 'branch': "str (optional, default 'main')"}, required=['name', 'yaml'], execute=_exec_add_workflow_file, produces_branch_with_commits=True, produces_workflow_file=True), 'create_branch': PrimitiveSpec(name='create_branch', description="Create a branch `name` from `from_branch` (default 'main'). Idempotent.", args_schema={'name': 'str', 'from_branch': 'str (optional)'}, required=['name'], execute=_exec_create_branch), 'set_secret': PrimitiveSpec(name='set_secret', description='Set a repository Actions secret. Provisioner-only — represents environment, not an attacker action.', args_schema={'name': 'str', 'value': 'str'}, required=['name', 'value'], execute=_exec_set_secret, produces_secret=True), 'set_var': PrimitiveSpec(name='set_var', description='Set a repository Actions variable. Provisioner-only.', args_schema={'name': 'str', 'value': 'str'}, required=['name', 'value'], execute=_exec_set_var, produces_variable=True)}
PrimitiveSpec
dataclass
¶
Source code in src/benchmark/scanner/primitives.py
produces_branch_with_commits
class-attribute
instance-attribute
¶
validate_step ¶
Source code in src/benchmark/scanner/primitives.py
validate_trigger ¶
Source code in src/benchmark/scanner/primitives.py
validate_success_check ¶
Source code in src/benchmark/scanner/primitives.py
validate_setup_trigger_consistency ¶
Source code in src/benchmark/scanner/primitives.py
validate_hypothesis ¶
Source code in src/benchmark/scanner/primitives.py
recipe_fingerprint ¶
Source code in src/benchmark/scanner/primitives.py
primitive_catalog_for_prompt ¶
Source code in src/benchmark/scanner/primitives.py
Memory and reporting¶
CrossWorkflowMemory persists reusable recipe examples and can warm-start from research notes. Error results are excluded from learning. Live validation constructs its own memory instance; the CLI's --no-memory flag currently covers initial generation seeds only.
CrossWorkflowMemory ¶
Source code in src/benchmark/scanner/memory.py
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
__init__ ¶
record ¶
Source code in src/benchmark/scanner/memory.py
get_positive_examples ¶
Source code in src/benchmark/scanner/memory.py
get_negative_examples ¶
Source code in src/benchmark/scanner/memory.py
warm_start ¶
warm_start(research_dir: str = _RESEARCH_DIR, model: str = 'claude-haiku-4-5', reseed: bool = False) -> int
Source code in src/benchmark/scanner/memory.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
report_generator.generate writes Markdown/JSON and returns their paths.
generate ¶
generate(context: EffectivePromptContext, results: list[ValidationResult], discarded: list[tuple[AttackHypothesis, str]], baseline_findings: list[dict], output_dir: str, scan_cost: ScanCost | None = None) -> tuple[str, str]
Source code in src/benchmark/scanner/report_generator.py
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
Optional baselines¶
These wrappers invoke separately installed binaries and normalize findings. An unavailable executable produces no findings.
run ¶
Run zizmor against the workflow directory and return normalized findings.
Source code in src/benchmark/scanner/baselines/zizmor_runner.py
run ¶
Run actionlint against the workflow directory and return normalized findings.