Skip to content

fix(security): scanner failure reasons are masked and capped before sarif and the cli print them #915

Closed

Description

@dan-petty

Problem

5d34541 (#708, #763) made a scanner that raises report ScanOutcome("failed", [], str(exc)), and 36b2bee (#708, #785) writes every non-ran outcome's reason into SARIF toolExecutionNotifications[].message.text (security/sarif.py:167-174). Nothing masks the reason, and some paths don't cap it either:

  • commands/scan.py:905, the live devops scan report loop, and its unused twin security/registry.py:84: str(exc), with no mask and no cap. ScannerRegistry.scan_all has no production caller; only tests/test_consolidation_security_scanner_base.py:125, 131 call it.
  • security/base.py:146 and :182: scanner stderr capped at 256 but not masked. :312: str(exc)[:256], also not masked. :310: Scanner error: {exc}; used built-in patterns, neither masked nor capped.
  • The same reasons reach the CLI through print_warning (scan.py:96-98, :793-795). print_warning does not mask, and it is called without safe=True, so the text is parsed as Rich markup.

Checked against release/v0.2.24 at d5eb2f4:

  • A mocked scanner raising RuntimeError with a user:password@ URL, a ghp_ token and 5,000 characters gave a 5,135-character SARIF notification and a CLI warning, both containing both secrets.
  • A TimeoutExpired with a token in its argv reached the base.py:312 reason, which was capped but still held the token.
  • No realistic secret source was found among the 11 built-in scanners: exceptions that escape scan() are mostly OSError naming a path. Unbounded length always happens.
  • scan report --json is safe, because ScanReport.as_dict (pipeline.py:74-98) leaves reasons out.
  • A reason containing [/x] made devops scan report exit 1 with Rich's MarkupError after the SARIF file was written.

Copilot raised this reviewing release PR #905 (thread on security/registry.py:84). It is not a critical fix, so it goes to the backlog rather than into v0.2.24.

Acceptance criteria

  • ScanOutcome.__init__ (security/base.py) stores mask_secrets(reason)[:CONST_MAX_ERROR_DETAIL_LENGTH], masking before the cap, so every producer is covered. The [:256] slices at base.py:146, :182 and :312 go, because cutting before masking can leave a partial credential the patterns no longer match.
  • print_warning calls that print a reason (scan.py:98, :793, :795) pass safe=True.
  • scan report and ScannerRegistry share one handler that turns a scanner exception into an outcome. Either scan_all gains a names parameter that scan report uses, or scan_all is deleted.
  • Tests, offline with no real scanners, in tests/test_scan_outcomes_and_gating.py:
    • a scanner that raises with a ghp_ token, a user:password@ URL and 5,000 characters yields a reason with neither secret, at most CONST_MAX_ERROR_DETAIL_LENGTH long, in the outcome, the SARIF notification and the CLI output;
    • the same holds for the base.py:310 built-in-patterns branch;
    • a reason containing [/x] prints literally and scan report exits 0.
  • uv run devops ci passes.

Scope added 2026-10-02, and moved into v0.2.25 as a critical fix: #1009 (79e1e93) added a third unmasked producer and a new sink in this release. _non_json_failure_reason (security/base.py:146-158) quotes up to 100 characters of a failed scanner's stdout and caps the reason at CONST_SCANNER_FAILURE_REASON_CHARS = 300 (config/constants.py:1884), without mask_secrets. The review's Static Analyzers table then writes that reason into review.md (ai/review/pipeline.py, _build_static_analyzers_section), a file people share and attach to pull requests. A scanner that prints a matched secret before failing would put it in review.md (.data/review-evaluation-20261002-s6.md, section 4.1).

  • The review.md Static Analyzers row for a failed analyzer carries the masked reason. A test drives a fake scanner whose non-JSON stdout holds a ghp_ token through the review's analyzer reporting and asserts the token is not in the rendered review.md section.
  • One cap applies to every scanner reason. CONST_SCANNER_FAILURE_REASON_CHARS goes, ScanOutcome caps at CONST_MAX_ERROR_DETAIL_LENGTH after masking, and fix(security): bandit reports failed on every review of more than 50 python files #1009's tests that pin 300 are updated to the shared cap.

Activity

  1. added
    type/security
    scope/security
    priority/p2-medium
    on Oct 1, 2026
  2. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    More evidence for this issue from the devsecops review session 20261001-224227 (2026-10-02). Each finding below was triaged against release/v0.2.25 (c279c18), judged real and covered by this issue, and then upheld by a second agent that tried to refute it.

    • Trivy Scan Result Handling Vulnerable to Uncontrolled Data Exposure (src/devops_cli/commands/scan.py:164, re-rated LOW): The findings themselves carry nothing secret. trivy.py:79-91 maps secret hits to a fixed description ('Plaintext secret or token identified in workspace file.') without the match, and printing file paths is the purpose of a local scanner. The proposed hasattr filter is meaningless. The only unsanitized output on this path is in _handle_single_scanner_result (scan.py:95-99): print_warning(f"{tool_name} was not run{detail}.") prints the outcome reason without masking and without safe=True, so markup like [/x] crashes. Issue fix(security): scanner failure reasons are masked and capped before sarif and the cli print them #915 tracks exactly that.
  3. added
    priority/p1-high
    and removed
    priority/p2-medium
    on Oct 2, 2026
  4. added this to the v0.2.25 milestone on Oct 2, 2026
  5. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Closed by #1033, merged into release/v0.2.25.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

  6. added a commit that references this issue on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/securitytype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions