Repository navigation
Description
Problem
A review starts one sandboxed Gitleaks run for each file that it reviews, so the static stage of a review grows with the number of files.
Measured on 2026-10-25 on the devcontainer, with the default sandbox of a review (#2096) and no model:
devops review path src/devops_cli/security --static-scan-only(37 Python files): 3 min 10 s. Bandit, Semgrep and Gitleaks ran.- The Gitleaks part alone,
run_gitleaks_scan(paths, ignore_tests=True, isolated=True)withSandboxToolExecutorover the same 37 files, as the review starts it (src/devops_cli/ai/review/pipeline.py): 37 runs, 65 s, about 1.8 s for each run. devops review path . --static-scan-only(1514 files) did not finish in 30 minutes.
GitleaksScanner.scan runs Gitleaks one time for each file of a list target (src/devops_cli/security/gitleaks.py), because a Gitleaks scan takes one path. Each run makes its own scratch directory, isolation files and sandbox.
Proposed remedy
Run Gitleaks one time over a scratch directory that holds the reviewed files, as Semgrep does with materialize_targets (#1079), and map each finding back to its file. Then measure the other tools of the static stage (Bandit, Semgrep) the same way, and give each one run for all files where the tool takes many paths.
Existing Tool Considered
Gitleaks dir scans a directory in one run. The review already links its files under a scratch directory for Semgrep.
Acceptance criteria
- A review of N files starts Gitleaks one time, and a test counts the runs on the tool executor fake.
- Each finding names the reviewed file, not the scratch directory.
- The static stage of the 37-file review above takes less time, measured before and after in the pull request.
Source: #772
Proposed design
Problem statement
A review starts one sandboxed Gitleaks run for each file it reviews. For 37 files, this takes 65 seconds. The fix is to run Gitleaks once over a scratch directory that holds all reviewed files, following the Semgrep materialize_targets pattern, and map each finding back to its original reviewed file.
Acceptance criteria
- Criterion 1: A review of N files starts Gitleaks exactly one time.
Verification: A test uses a fake tool executor and asserts the Gitleaks run count equals 1 for N > 1 files. - Criterion 2: Each Gitleaks finding names the reviewed file path, not the scratch directory path.
Verification: A test creates a file with a known secret, runs the scan, and asserts the finding location contains the reviewed file path and not the scratch directory. - Criterion 3: The static stage of the 37-file review takes less time than before the change.
Verification: The pull request records a before-and-after measurement ofdevops review path src/devops_cli/security --static-scan-onlyshowing reduced wall-clock time.
Key questions
- How does the Semgrep materialize_targets pattern work in this codebase?: The _scan_semgrep function passes all paths and a reviewed_tree to run_semgrep_scan. Semgrep links or copies files under the working directory and runs once. Gitleaks should follow the same approach: materialize files under a scratch directory and run Gitleaks dir once. [sources: src/devops_cli/ai/review/pipeline.py]
- What is the current Gitleaks per-file invocation?: run_gitleaks_scan is called from _scan_secrets with all paths, ignore_tests=True, isolated=True, and a tool_executor. Inside, GitleaksScanner.scan runs Gitleaks one time per file, each with its own scratch directory, isolation files, and sandbox. [sources: src/devops_cli/security/gitleaks.py, src/devops_cli/ai/review/pipeline.py]
- How should findings be mapped back to reviewed files after a single directory scan?: Use the same approach as the existing _match_static_findings_to_files and _find_matching_file functions in the pipeline. After the single Gitleaks run, map each finding's scratch-directory path back to the corresponding reviewed file path. (proposed) [sources: src/devops_cli/ai/review/pipeline.py]
Open questions
- Can Gitleaks scan a directory in one run? (missing verified source)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-03: not-applicable.
Class: perf, no search.
Tool: none found.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 25, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The change improves performance by optimizing how Gitleaks runs during reviews without changing functionality.Improves performance of security scanning but does not block other work or introduce critical bugs.Reduces review time significantly from minutes to seconds for large codebases, improving developer productivity.Requires changes to how Gitleaks is called and how findings are mapped back to files, but follows existing patterns like Semgrep's materialize_targets approach.Both items address performance issues in security scanning, but the candidate focuses on Gitleaks optimization while item #1666 addresses slow test suite execution involving real scanners.dan-petty commentedon Oct 28, 2026
Refine cannot set this item to Ready at bb46660 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
devops-cli-service commentedon Nov 3, 2026
Alternatives check: not-applicable
Class: perf. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-03. A person decides what this means for the item. The check changes no label and closes no issue.
[-]perf(review): a review starts one sandboxed Gitleaks run for each file, so 37 files spend 65 s in Gitleaks[/-][+]perf(review): Run Gitleaks once per review instead of per file[/+]dan-petty commentedon Nov 6, 2026
The job shortened the title of this item. The summary had 92 characters, and the limit is 60. The type and the scope stay.
perf(review): a review starts one sandboxed Gitleaks run for each file, so 37 files spend 65 s in Gitleaksperf(review): Run Gitleaks once per review instead of per fileperf(review): run Gitleaks once per review instead of per file
devops-cli-service commentedon Nov 10, 2026
Released in v0.103.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.103.2
devops-cli-service commentedon Nov 10, 2026
Live since 2026-11-10 01:00 UTC