Repository navigation
Description
Problem
After the change of #2427 (pull request #2712), no scanner of the registry has a hand-written fallback. The scanner base class in src/devops_cli/security/base.py still has the machinery for one:
BaseSecurityScanner.fallback_scanand the class variablehas_builtin_patterns._has_builtin_patternsand the branches that callscanner.fallback_scan(...)in_handle_non_json_output,_handle_json_outputand the missing-binary path ofscan.- The scan status
built-in patterns, whichCONST_SCAN_NO_RESULT_STATUSES,_RAN_STATUSESinsecurity/pipeline.pyand the status words ofconfig/constants.pyname. has_builtin_patterns: ClassVar[bool] = Falsein the adapters that set it (trivy, mypy, golangci_lint, gitleaks, osv_scanner, kubelinter, semgrep).
No scanner overrides fallback_scan and none sets has_builtin_patterns to True (checked with grep -rn "has_builtin_patterns\|fallback_scan" src/devops_cli). So each of these branches is dead code, and a status that no scan can give is still in the reports.
Proposed remedy
Delete the fallback path from the base class, the status built-in patterns and every reference, with their tests. Write no shim. A test that fails when a scanner of the registry has built-in patterns already exists in tests/test_scanner_contract.py; adapt it to check that the class has no such attribute.
Existing Tool Considered
None needed: the change deletes code and builds nothing.
Acceptance criteria
-
grep -rn "fallback_scan\|has_builtin_patterns\|built-in patterns" src/devops_clifinds nothing. - The scanner base tests, the pipeline tests and the SARIF tests pass with no status
built-in patterns.
Alternatives check of 2026-11-04: not-applicable.
Class: refactor, no search.
Tool: none found.
Proposed design
Problem statement
After #2427 every scanner in the registry runs its pinned binary, so no scanner has a hand-written fallback. The scanner base class in src/devops_cli/security/base.py still carries the fallback: fallback_scan, has_builtin_patterns, _has_builtin_patterns, the branches in _evaluate_preflight, _handle_non_json_output, _handle_json_output and _failed_run, and the built-in patterns status in CONST_SCAN_STATUS_PRECEDENCE and _RAN_STATUSES. The status also feeds a dead built-in patterns analyzer state in the AI review report, and 11 adapters, not the 7 the body names, still declare the class variable. This change deletes the fallback, the status and every reference, with no shim, and adapts the tests that exercise them.
Acceptance criteria
Requirement: No fallback code in source
Every file under src/devops_cli, including the knowledge-base Markdown, SHALL hold no occurrence of fallback_scan, has_builtin_patterns, _has_builtin_patterns, built-in patterns or built-in fallback.
Scenario: Source search finds no match
- WHEN A test reads every file under
src/devops_cliand searches for the five names - THEN The search finds no occurrence.
Requirement: Failed run gives failed outcome
The scanner base class SHALL return a failed outcome with the error or timeout reason when the tool run raises or times out.
Scenario: Timeout and exception give failed
- WHEN A scanner run with a fake tool executor reports a timeout or raises an exception
- THEN The outcome status is
failedand its reason holds no text about built-in patterns.
Requirement: Non-zero exit gives failed outcome
The scanner base class SHALL return a failed outcome when the tool exits with a non-zero code and gives no finding.
Scenario: Non-JSON output with exit code 2
- WHEN A fake tool executor returns exit code 2 and output that is not JSON
- THEN The outcome status is
failedand the reason names the exit code.
Requirement: Missing binary is unavailable
The scanner base class SHALL return the status unavailable with no finding when the binary of the scanner is not on PATH.
Scenario: Binary not found
- WHEN A scan runs and the binary check returns false
- THEN The outcome status is
unavailableand the reason names the binary.
Requirement: Status constants have no removed status
CONST_SCAN_STATUS_PRECEDENCE and _RAN_STATUSES SHALL contain no status built-in patterns.
Scenario: Status constants checked
- WHEN A test reads both constants
- THEN Neither holds
built-in patterns, and_RAN_STATUSESequals("ran",).
Requirement: Review report has no built-in patterns state
The AI review pipeline SHALL hold no analyzer state, constant or report label for built-in patterns, and SHALL name an analyzer with no binary not installed.
Scenario: Missing analyzer is not installed
- WHEN
static_analyzer_statesruns for an analyzer whose binary is absent and no outcome is observed - THEN The state is
not installed, and the module defines noANALYZER_BUILTIN_PATTERNS.
Requirement: Contract test guards against return
The scanner contract test SHALL fail when a scanner class of the registry has the attribute has_builtin_patterns or defines fallback_scan.
Scenario: Registry scanners have no fallback attribute
- WHEN The test iterates over every scanner class of the registry
- THEN No class of the registry has either name, and a class that adds either makes the test fail.
Requirement: SDLC doc names no removed status
docs/SDLC.md SHALL describe the static analysis line without the status built-in patterns.
Scenario: Documentation search
- WHEN A test reads
docs/SDLC.md - THEN The file names no built-in patterns.
Existing Tool Considered
None adopted. The alternatives check of 2026-11-04 returned not-applicable for the class refactor, so no tool was proposed. The open, maintained tool for this job is vulture (https://github.com/jendrikseipp/vulture), and the project tried it and rejected it (CHANGELOG.md:2374): on src it left 720 findings, and a functions-and-methods-only check left 26 with two live framework hooks, needing 12 decorator patterns and 7 name patterns first. It also cannot see fallback_scan, which the base class still calls, or has_builtin_patterns, which getattr reads, and it cannot delete the branches, the adapters' class variables or the status. The change therefore deletes by hand, roughly 150 lines across security/base.py, config/constants.py, security/pipeline.py, ai/review/pipeline.py, ai/review/runner.py, ai/review/profile.py, the knowledge base, docs/SDLC.md, 11 adapters and the tests that exercise the fallback.
Key questions
- Does the issue's premise hold at the commit: does the fallback machinery still exist, and does any scanner set it to True?: Yes.
_has_builtin_patternsis atbase.py:43, the base class declareshas_builtin_patternsatbase.py:532andfallback_scanatbase.py:640, and the branches call them atbase.py:390,440,450,469and788. Every adapter that declares the variable sets it False, and no module undersrcoverridesfallback_scan; the onlyfallback_scandefinitions are the base one and a test fake. [sources: src/devops_cli/security/base.py:43, src/devops_cli/security/base.py:532, src/devops_cli/security/base.py:640, src/devops_cli/security/base.py:390, src/devops_cli/security/base.py:788, src/devops_cli/security/trivy.py:145] - Does the fallback path exist in more places than the body lists?: Yes.
_failed_runcalls_has_builtin_patternsand returns the statusbuilt-in patterns(base.py:783-790);_run_scanner_commandpasses aScanner error: ...; used built-in patternstext for exceptions (base.py:755-760);_outcome_ofpasses atimed out ...; used built-in patternstext for timeouts (base.py:772-774). The body lists only the missing-binary branch ofscan,_handle_non_json_outputand_handle_json_output, so its plan missed_failed_runand both reason texts. [sources: src/devops_cli/security/base.py:756, src/devops_cli/security/base.py:774, src/devops_cli/security/base.py:783, src/devops_cli/security/base.py:390, src/devops_cli/security/base.py:440, src/devops_cli/security/base.py:469] - Which constant holds the status
built-in patterns, and which one does not?:CONST_SCAN_STATUS_PRECEDENCEholds it atconstants.py:679;CONST_SCAN_NO_RESULT_STATUSES(constants.py:686-688) does not, so the body names the wrong constant for the no-result set._RAN_STATUSESinsecurity/pipeline.py:203holds it too.CONST_AGENT_SCAN_STATUS_WORDS(constants.py:692-696) names onlyran,cleanandunavailable, so it needs no change. [sources: src/devops_cli/config/constants.py:673, src/devops_cli/config/constants.py:679, src/devops_cli/config/constants.py:686, src/devops_cli/config/constants.py:692, src/devops_cli/security/pipeline.py:203] - Which adapter files still declare
has_builtin_patterns, and does the body name them all?: No. Eleven adapters declare it, all as False: bandit, gitleaks, golangci_lint, kubelinter, mypy, osv_scanner, pluto, popeye, ruff, semgrep and trivy. The body names seven and omitsbandit.py,pluto.py,popeye.pyandruff.py;base.py:532is the base declaration. [sources: src/devops_cli/security/bandit.py:95, src/devops_cli/security/gitleaks.py:115, src/devops_cli/security/golangci_lint.py:121, src/devops_cli/security/kubelinter.py:114, src/devops_cli/security/mypy.py:101, src/devops_cli/security/osv_scanner.py:296, src/devops_cli/security/pluto.py:69, src/devops_cli/security/popeye.py:69, src/devops_cli/security/ruff.py:233, src/devops_cli/security/semgrep.py:251, src/devops_cli/security/trivy.py:145, src/devops_cli/security/base.py:532] - Does anything outside the security package read the
built-in patternsstatus?: Yes.ai/review/pipeline.pymaps a ScanOutcome status to a review analyzer state:ANALYZER_BUILTIN_PATTERNS = "built-in patterns"at line 1018, the branch at 1045, the empty_ANALYZERS_WITH_BUILTIN_PATTERNSat 1035 with its branch at 1064, and the report lines at 1153, 1272, 1274, 1301, 1330 and 2704.ai/review/runner.py:399counts the state as ran,ai/review/profile.py:152names it, andsrc/devops_cli/ai/knowledge_base/devops_cli/tasks/ai_code_review.md:48anddocs/SDLC.md:268describe it. The body's grep oversrc/devops_clicannot pass without removing this state too. [sources: src/devops_cli/ai/review/pipeline.py:1018, src/devops_cli/ai/review/pipeline.py:1035, src/devops_cli/ai/review/pipeline.py:1045, src/devops_cli/ai/review/pipeline.py:1301, src/devops_cli/ai/review/runner.py:399, src/devops_cli/ai/review/profile.py:152, src/devops_cli/ai/knowledge_base/devops_cli/tasks/ai_code_review.md:48, docs/SDLC.md:268] - Does the change also remove the
built-in patternsanalyzer state from the AI review pipeline?: Yes. RemoveANALYZER_BUILTIN_PATTERNS, its branch in_static_analyzer_state_from_outcome, the empty_ANALYZERS_WITH_BUILTIN_PATTERNSand its branch in_predict_analyzer_state, the state's entries in the reason, summary, line-list and canary code, and therunner.pytuple. No scan can produce the status, and a missing analyzer then predictsnot installed. (best practice) [sources: src/devops_cli/ai/review/pipeline.py:1018, src/devops_cli/ai/review/pipeline.py:1035, src/devops_cli/ai/review/pipeline.py:1064, src/devops_cli/ai/review/pipeline.py:1301, src/devops_cli/ai/review/pipeline.py:1330, src/devops_cli/ai/review/pipeline.py:2704, src/devops_cli/ai/review/runner.py:399, tests/ai/review/test_review_report_integrity.py:232, tests/ai/review/test_review_report_summary.py:210]- Chosen: Remove the review analyzer state with the status. No ScanOutcome can carry the status after the deletion,
_ANALYZERS_WITH_BUILTIN_PATTERNSis already empty, and the body's grep oversrc/devops_clirequires every reference gone. - Rejected: Keep the review state as an unreachable branch. It leaves a state that no scan can produce, which is the dead code the issue removes, and it keeps the status string in source.
- Rejected: Defer the review state to a separate issue. The removal is mechanical and needs no outside input; deferring it would leave the status string in
srcand the grep criterion failing.
- Chosen: Remove the review analyzer state with the status. No ScanOutcome can carry the status after the deletion,
- What happens to
_failed_runafter the removal?: Drop thefallen_backparameter and keep the method, which returns only thefailedoutcome. Update both callers: the exception path passesScanner execution failed: {exc}and the timeout path passestimed out after {timeout:g} s. (best practice) [sources: src/devops_cli/security/base.py:756, src/devops_cli/security/base.py:774, src/devops_cli/security/base.py:783]- Chosen: Delete the
fallen_backparameter and keep_failed_run. The method keeps its single job and its log line, and both callers become shorter. - Rejected: Inline
_failed_runinto its callers. It spreads the log line and the failure text over two places.
- Chosen: Delete the
- Should the change keep a shim or a deprecation for the removed names?: No. AGENTS.md says the project is pre-1.0 and removes the old path without a shim; ADR 0005 records
Deleted, not kept behind flags (pre-1.0);docs/TESTING.md:185says a line that no public behaviour reaches is dead code and is deleted. The body also says to write no shim. (best practice) [sources: AGENTS.md:3, docs/adr/0005-review-findings-come-from-tools-not-models.md:49, docs/TESTING.md:185, CONTRIBUTING.md:30]- Chosen: Delete with no shim. It follows AGENTS.md, ADR 0005 and the body, and no outside consumer exists.
- Rejected: Keep a deprecated
fallback_scan. It keeps dead code and adds a warning that nobody can act on.
- How does the contract test change?: The body's path is wrong: the test is
tests/security/test_scanner_contract.py:113, nottests/test_scanner_contract.py. Adapt it to iterate the registry and assert that no scanner class hashas_builtin_patternsor definesfallback_scan, and keep the missing-program behaviour check that every pinned scanner isunavailablewith no finding. Also update the fakes and tests attests/security/test_scanner_base_and_registry.py:58,90and101andtests/commands/test_scan_outcomes_and_gating.py:370and493. (best practice) [sources: tests/security/test_scanner_contract.py:113, tests/security/test_scanner_contract.py:134, tests/security/test_scanner_base_and_registry.py:58, tests/security/test_scanner_base_and_registry.py:90, tests/security/test_scanner_base_and_registry.py:101, tests/commands/test_scan_outcomes_and_gating.py:493]- Chosen: Adapt the contract test to assert the names are absent and a missing program is unavailable. It follows the body, keeps a guard against a later return, and keeps the missing-program behaviour the test protected.
- Rejected: Delete the test. The guard against a return of the machinery and the missing-program check would be lost.
- Rejected: Check only the attribute absence. It loses the check that a pinned program missing from PATH gives
unavailablewith no finding.
- Which open tool covers the dead-code removal, and does the project adopt it?: No tool is adopted.
vultureis the open, maintained dead-code finder, but the project tried it and rejected it: onsrcit left 720 findings, and a functions-and-methods-only check left 26 with two live framework hooks, needing 12 decorator patterns and 7 name patterns first. It also cannot see a method the base class calls or a class variable read throughgetattr. The change deletes by hand, asdocs/TESTING.md:185requires. (best practice) [sources: CHANGELOG.md:2374, docs/TESTING.md:185]- Chosen: Delete by hand. The project's trial of
vulturerejected it, and the fallback names are reached through calls andgetattr, which it cannot see. - Rejected: Adopt
vultureas a dead-code check. The recorded trial left 720 findings onsrc, and even a functions-and-methods check needed 12 decorator patterns and 7 name patterns and still flagged live framework hooks.
- Chosen: Delete by hand. The project's trial of
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 29, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
The change deletes dead code from the base class and related files without altering behaviour.Dead code removal has no user-facing impact and no time-sensitive risk.Users see no change; the value is code clarity and reduced maintenance surface.Deletion spans base.py, pipeline.py, constants.py, seven adapter files, and their tests, but no new logic is written.Both work on the security scanner fallback path; #2427 removes the tflint and dive adapters that used it, while this candidate removes the now-dead base-class infrastructure.devops-cli-service commentedon Oct 30, 2026
Status set to Ready at 18a6e2b (see proposed design in issue body).
devops-cli-service commentedon Nov 3, 2026
The stage job returned the item to New. The premise of the issue does not hold at the staging commit, so the job planned no change and opened no pull request.
Evidence:
placeholder
devops-cli-service commentedon Nov 4, 2026
Alternatives check: not-applicable
Class: refactor. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-04. A person decides what this means for the item. The check changes no label and closes no issue.
[-]refactor(security): the scanner base class keeps a fallback path that no scanner uses[/-][+]refactor(security): Remove the unused fallback path from the scanner base class[/+]dan-petty commentedon Nov 6, 2026
The job shortened the title of this item. The summary had 65 characters, and the limit is 60. The type and the scope stay.
refactor(security): the scanner base class keeps a fallback path that no scanner usesrefactor(security): Remove the unused fallback path from the scanner base classdevops-cli-service commentedon Nov 9, 2026
Status set to Ready at 2f20244 (see proposed design in issue body).
devops-cli-service commentedon Nov 28, 2026
Released in v0.234.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.234.0
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 17:56 UTC