Repository navigation
Description
What happened
#2098 removed every direct Path.cwd() and os.getcwd() read from ai/review/, review/ and security/, and the ast-grep rule review-cwd-read keeps them out. Some reads of the working directory still happen through a default, outside what that rule sees:
core.repo.get_repo_origin_name()with no path names the repository of the process's working directory. The PR review calls it to name the reviewed repository.run_trivy_scan,run_kubelinter_scan,run_pluto_scan,run_bandit_scanandrun_dive_scantake the relative path.as their default target, so a call with no target scans the process's working directory.
A caller that runs in another directory (a test, the MCP server, a worktree) thus reviews or scans the wrong tree when it gives no path.
What should happen
The command layer reads the working directory one time and gives it down, as #2098 does for the orchestrator and the other scanners. get_repo_origin_name and each scanner entry point require their directory, and a rule or a test fails when one of them takes a relative default again.
Evidence
- Found while refactor(review): the review orchestrator and the scanners take the reviewed workspace from their caller, and no review or scanner module reads Path.cwd() #2098 was delivered (2026-10-24):
grep -n 'def run_\(trivy\|kubelinter\|pluto\|bandit\|dive\)_scan' -A4 src/devops_cli/security/*.pyshows the.defaults, andget_repo_origin_namereads the working directory when it gets no path. - test(cli): devops pr, gh and repos are thin adapters tested over edge fakes, and merge readiness is tested in its package #1324 changes how tests double
get_repo_origin_name; it does not change its default.
Acceptance criteria
-
get_repo_origin_nameand the five scanner entry points take no relative default for their directory, and every caller gives one. - A rule or a test fails when one of them gets a default that reads the working directory again.
Source: #2098
Proposed design
Problem statement
The PR review and five scanner entry points read the working directory through a default parameter. A caller that runs in another directory reviews or scans the wrong tree. The command layer must read the working directory once and pass it down. A guard must fail when a relative default returns.
Acceptance criteria
- Criterion 1: get_repo_origin_name and the five scanner entry points take no relative default for their directory, and every caller gives one.
Verification: Inspect the signatures in src/devops_cli/core/repo.py and src/devops_cli/security/*.py. Confirm no parameter defaults to '.' or to a value that resolves to the working directory. Run the full test suite and confirm all callers pass an explicit path. - Criterion 2: A rule or a test fails when one of these functions gets a default that reads the working directory again.
Verification: Add a default of '.' to one scanner function. Run the guard rule or test. Confirm it fails. Remove the default. Confirm it passes.
Key questions
- Where is get_repo_origin_name defined and what is its current signature?: It is in src/devops_cli/core/repo.py. It takes no path argument and reads the working directory via git remote get-url origin. [sources: src/devops_cli/core/repo.py]
- What are the current default targets of the five scanner entry points?: run_trivy_scan, run_kubelinter_scan, run_pluto_scan, run_bandit_scan and run_dive_scan all default their target to the relative path '.'. [sources: src/devops_cli/security/dive.py:240]
- Which callers invoke these functions without giving a path?: The command layer, the PR review pipeline, and tests. The pipeline at src/devops_cli/ai/review/pipeline.py:1981 calls run_bandit_scan. The agent scan adapters also call the run_*_scan functions over a workspace path. [sources: src/devops_cli/ai/review/pipeline.py:1981, openspec/changes/archive/2026-10-24-1435-agent-scan-tools-run-the-adapters/proposal.md]
- Should the guard be an extension of the existing review-cwd-read ast-grep rule or a new unit test?: The existing review-cwd-read rule covers ai/review/, review/ and security/ but not core/repo/. The issue states 'a rule or a test' without specifying which. The implementer chooses the mechanism. A test that asserts no default of '.' in the six signatures is the simplest option and covers all locations. (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 24, 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 candidate proposes a refactor to improve how directory paths are handled in review and scanner entry points.The change improves correctness of directory handling but does not fix a bug or add new functionality.The change prevents incorrect behavior when running reviews or scans from different directories, which affects test reliability and user experience.The change requires modifying multiple entry points and updating callers to pass directory paths explicitly, but does not introduce new logic.Both items deal with directory handling in reviews, but the candidate focuses on removing default working directory reads while item #1038 addresses path review directory resolution.refactor(review): the review orchestrator and the scanners take the r…
dan-petty commentedon Oct 28, 2026
Status set to Ready at bb46660 (see proposed design in issue body).