Skip to content

test(security): the scanners stop looking for mocks, and their tests run on the scanner fake #2542

Closed

Description

@dan-petty

Problem or Motivation

Part 1 of #1332. The security scanners look for test mocks in product code, which AGENTS.md rule 2 forbids ("make product code detect tests"). Measured on origin/main 1244cbf:

Proposed Solution & Architectural Design

Target Subsystem

src/devops_cli/security/ and the scanner tests.

Existing Tool Considered

The fakes exist: tests/support/fakes/tool_executor.py and tests/support/fakes/scanners.py (#772, #1666, #1982). Nothing new is built; the change deletes the accommodations.

Acceptance criteria

  • security/base.py has no NonCallableMock, _is_mocked or _patched_run_subprocess, and no scanner module has a # noqa: F401 re-import of run_subprocess, is_dry_run or shutil.
  • No test patches run_subprocess, is_dry_run, check_binary or shutil on security.base or on a scanner module.
  • The rewritten tests pass on the fakes, offline.

Related

Parent: #1332. Owner of the accommodation: #1332 (#2512 named it). Bans at zero: #1336.

Source: #1332

Activity

  1. added
    source/agent
    type/refactor
    status/new
    value/medium
    effort/medium
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor. The change removes mock-detection branches and re-imports from product code and rewrites tests onto existing fakes.
    • Priority: P2-Medium. It enforces an existing project rule but does not fix a defect or add user-facing behaviour.
    • Value: Medium. It removes 9 code violations of the no-test-accommodation rule and makes 62 test sites use the approved fakes.
    • Effort: Medium. It touches base.py, seven scanner modules, and 62 patch sites across 11 test files, but no new code is written.
    • Related: refactor(cli): product code holds no test accommodations, and Ruff and ast-grep ban them in src #2512, which asks for a different change. Both remove test accommodations from product code; #2512 delivers the general ban and CI enforcement, while the candidate delivers the specific cleanup of security/base.py and seven scanner modules plus their 62 test sites.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. removed
    status/new
    on Oct 30, 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

    effort/mediumpriority/p2-mediumsource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions