Skip to content

fix(security): a review's isolated Semgrep scan hands Semgrep only targets under its working directory, so it finishes instead of rediscovering each file across the checkout #1079

Closed

Description

@dan-petty

Problem

Since #972 (PR #1063, merged 2026-10-03 06:14Z) every review scanner runs from a fresh temporary working directory (security/base.py:405-412, called for Semgrep from ai/review/pipeline.py:1229). Semgrep 1.178.0 takes its fast path only for a target that is a regular file under its working directory (target_manager.py:716-727 in Semgrep). Every other target starts its own semgrep-core -rpc process (rpc.py:323-345), and that process walks the whole checkout, nested worktrees and repos/ included.

Measured (.data/review-evaluation-20261003-loop-s12-s21.md, section 7):

Acceptance criteria

  • An isolated Semgrep run names only targets that lie under its working directory, so no per-target get_targets RPC runs. A test with a fake runner captures the argv and cwd for a 333-path review and asserts every target is a relative path under the cwd.
  • fix(security): reviews take config, data, contracts, scanner config and probe suppressions from the tree under review #972 still holds: the working directory contains no config, ignore or rule file from the reviewed tree. A test puts a .semgrepignore, a .semgrep.yml and a .semgrep/ rule in the reviewed tree and shows none reaches the scan; the existing fix(security): reviews take config, data, contracts, scanner config and probe suppressions from the tree under review #972 tests pass unchanged.
  • No symlink in the reviewed tree makes the scan read outside it.
  • Findings carry the reviewed tree's paths and line numbers (mapped back from the working directory), pinned by a test.
  • A scanner timeout reads "timed out after N s" in review.md and the profile, not a truncated command.
  • Measured on this tree (recorded in the task file): Semgrep's time for a full branch review's targets with the fix, and whether Bandit, kube-linter, Pluto, Trivy and gitleaks pay any per-target cost from the temporary working directory. If the Semgrep run takes more than half its timeout at the measured host load, the targets are split into batches with their own timeout, so one timeout loses only its batch (the D16 concern from session 20261003-060647); otherwise the measurement is recorded and batching is left out.
  • Tests are offline and run no real scanner; new tests take well under 1 s together; uv run devops ci passes.
  • Pending a person: a branch review of release/v0.2.25 reports Semgrep as ran, with its runtime in the profile and its findings in candidates.json.

Key questions

Strategic alignment

Activity

  1. added this to the v0.2.25 milestone on Oct 3, 2026
  2. added
    type/bug
    scope/review
    priority/p1-high
    on Oct 3, 2026
  3. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Closed by #1091, 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.

  4. 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/reviewtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions