Skip to content

fix(security): scan_uv_audit runs a uv audit adapter that audits the lockfile as it is - #2446

Merged
dan-petty merged 8 commits into
mainfrom
fix/2106-uv-audit-adapter
Oct 28, 2026
Merged

dan-petty merged 8 commits into
mainfrom
fix/2106-uv-audit-adapter

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The agent tool scan_uv_audit and the MCP tool scan_uv_audit run the uv audit adapter, devops_cli.security.uv_audit, and keep no command line of their own.

Before this change, the tools ran their own command lines. With a requirements_file, they ran uv pip audit, but uv has no such subcommand, so that path always failed. Without a requirements_file, they ran uv audit, did not read its exit code, and replied "No known security vulnerabilities identified by uv audit." when the output was empty. Thus a missing uv, or an audit that could not run, read as a clean audit. Also, uv audit without --frozen locks the project again and can rewrite a stale uv.lock, but the MCP tool has readOnlyHint.

The adapter starts uv audit --frozen --quiet --output-format json in the scanned directory through the tool executor, and reads the JSON report of uv:

  • Each vulnerability is a finding at uv.lock:<package>. Its title has the advisory id and the summary, and its fix names the releases that fix it. Each adverse project status (archived, deprecated or quarantined) is a finding too. uv gives no severity, so each finding has the severity MEDIUM.
  • A run that writes no report is a failed scan, with the stderr of uv as the reason. Examples are a project with no uv.lock and an advisory service that uv cannot reach. A report with no vulnerabilities list or no adverse_statuses list is a failed scan, and not a clean scan.
  • A path that is not a directory, for example a directory that does not exist or a file, is a not_applicable scan, and uv does not start. If uv starts there, it audits the project of a parent directory, and the scan gives that audit as the audit of the path.
  • --frozen audits the lockfile as it is, and does not write it. --quiet removes the preview warnings that uv writes on stderr before an error. These warnings filled the reason of a failed scan, which is cut at 256 characters.

Both tools take only directory, and reply as the other agent scan tools reply, with the scanner named uv audit. The requirements_file parameter, the uv pip audit and uv audit command lines, the clean fallback message and the helper _run_workspace_security_scan are removed. docs/MCP_TOOLS.md gives the new description and parameters of the MCP tool.

Closes #2106

Change: openspec/changes/archive/2026-10-28-2106-uv-audit-adapter/

Plan #2106 as the OpenSpec change 2106-uv-audit-adapter. The tests
expect an adapter in devops_cli.security that starts
`uv audit --frozen --quiet --output-format json` in the project
directory and reads each vulnerability and adverse project status of
its JSON report as a finding. A run with no report, and a report of
another layout, are failed scans.
`devops_cli.security.uv_audit` starts
`uv audit --frozen --quiet --output-format json` in the project
directory through the ToolExecutor and gives a ScanOutcome. Each
vulnerability is a finding at `uv.lock:<package>` with the releases
that fix it, and each adverse project status is a finding too.
`--frozen` keeps uv from writing a stale `uv.lock`. `--quiet` keeps the
preview warnings of uv out of the reason of a failed scan.
…apter

Record a run of uv audit 0.12.23 over a project that pins idna 3.6. The
agent tool and the MCP tool scan_uv_audit must start uv audit through
the adapter in the directory, reply as the other agent scan tools
reply, and take only `directory`.
…t command goes

The agent tool and the MCP tool scan_uv_audit ran a command line of
their own. For a requirements file, they ran `uv pip audit`, which uv
does not have, so that path always failed. Without one, they read a
missing uv or an audit that could not run as a clean audit.

Both tools now take only `directory` and run the uv audit adapter
through `_run_adapter_scan`, as the other agent scan tools do. The
`requirements_file` parameter, both command lines, the fallback message
and `_run_workspace_security_scan` go.

Closes #2106
…at is not a directory

uv finds the project from the directory that it starts in and from each parent directory. The scan of a directory that does not exist started uv in the nearest parent directory, and the reply gave the audit of that project as the audit of the named directory.
…e project of a parent directory

uv finds the project from the directory that it starts in and from each parent directory. For a path that does not exist, the scan started uv in the nearest parent directory, and for a file, in its directory. Thus the reply gave the audit of that project as the audit of the path. The adapter now gives the outcome not_applicable for a path that is not a directory, before uv starts.

Issue #2440 holds the project that uv finds outside the workspace.
… uv audit report of another layout

The expected reason named the private model _Report and the count of Pydantic errors. A change of the model would fail the test with no change of behavior.
@dan-petty dan-petty added scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak labels Oct 28, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results for head 14509f0d, after the rebase onto origin/main:

  • uv run devops ci test tests/test_security_uv_audit.py tests/test_command_builders.py tests/test_builtin_tools.py tests/test_mcp.py: 229 passed.
  • uv run devops openspec archive 2106-uv-audit-adapter: every spec and change validates.
  • The pre-push hook (fast static checks of devops ci) passed.

Fail-to-pass: devops ci fail-to-pass --base origin/main exited 0 on this head. On the base, 6 tests failed and 6 errored, and tests.test_security_uv_audit did not collect. The agent and MCP uv audit tests, the agent test of a directory that does not exist, and the uv-audit cases of the not-installed and failed-scan tests failed, because the old tools started a real uv outside the tool executor. test_command_builders failed, because the old command was ['uv', 'audit']. All pass on the head. The fail-to-pass check of CI runs the same replay.

The lines that did not pass on the base:

  errored on base: tests.test_security_uv_audit (collection failure)
  failed on base: tests.test_mcp::test_the_mcp_uv_audit_tool_takes_a_directory_and_runs_the_uv_audit_adapter_there (Failed: process edge reached without a fake: uv audit (A test started a real uv: fake it through its seam or mark @pytest.mark.live))
  errored on base: tests.test_mcp::test_the_mcp_uv_audit_tool_takes_a_directory_and_runs_the_uv_audit_adapter_there (failed on teardown with "Failed: network edge reached without a fake — Connected to a loopback port no socket in this test process binds or reached an unfaked edge: process edge rea
  failed on base: tests.test_command_builders::test_command_builders (AssertionError: assert (['kube-linte...uv', 'audit']) == (['kube-linte...mat', 'json']))
  failed on base: tests.test_builtin_tools::test_the_agent_uv_audit_tool_over_a_directory_that_does_not_exist_gives_no_result (Failed: process edge reached without a fake: uv audit (A test started a real uv: fake it through its seam or mark @pytest.mark.live))
  errored on base: tests.test_builtin_tools::test_the_agent_uv_audit_tool_over_a_directory_that_does_not_exist_gives_no_result (failed on teardown with "Failed: network edge reached without a fake — Connected to a loopback port no socket in this test process binds or reached an unfaked edge: proce
  failed on base: tests.test_builtin_tools::test_an_agent_scan_tool_whose_scanner_fails_with_no_output_says_failed_and_not_clean[uv-audit] (Failed: process edge reached without a fake: uv audit (A test started a real uv: fake it through its seam or mark @pytest.mark.live))
  errored on base: tests.test_builtin_tools::test_an_agent_scan_tool_whose_scanner_fails_with_no_output_says_failed_and_not_clean[uv-audit] (failed on teardown with "Failed: network edge reached without a fake — Connected to a loopback port no socket in this test process binds or reached an unfake
  failed on base: tests.test_builtin_tools::test_an_agent_scan_tool_whose_scanner_is_not_installed_says_so_and_not_clean[uv-audit] (Failed: process edge reached without a fake: uv audit (A test started a real uv: fake it through its seam or mark @pytest.mark.live))
  errored on base: tests.test_builtin_tools::test_an_agent_scan_tool_whose_scanner_is_not_installed_says_so_and_not_clean[uv-audit] (failed on teardown with "Failed: network edge reached without a fake — Connected to a loopback port no socket in this test process binds or reached an unfaked edge: 
  failed on base: tests.test_builtin_tools::test_the_agent_uv_audit_tool_runs_the_uv_audit_adapter_over_the_directory (Failed: process edge reached without a fake: uv audit (A test started a real uv: fake it through its seam or mark @pytest.mark.live))
  errored on base: tests.test_builtin_tools::test_the_agent_uv_audit_tool_runs_the_uv_audit_adapter_over_the_directory (failed on teardown with "Failed: network edge reached without a fake — Connected to a loopback port no socket in this test process binds or reached an unfaked edge: process edge 
6 failed on base (6 failed and 217 passed in tests/test_builtin_tools.py, tests/test_command_builders.py, tests/test_mcp.py, tests/test_security_uv_audit.py; 6 errored).
Elapsed: 28s

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 16:26
@dan-petty
dan-petty merged commit 0b2d005 into main Oct 28, 2026
16 of 18 checks passed
@dan-petty
dan-petty deleted the fix/2106-uv-audit-adapter branch October 28, 2026 16:32
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.9.0](v0.8.3...v0.9.0)
(2026-10-28)


### Features

* **ai:** observe the Ollama slot wait by priority and chart its p95
([#2404](#2404))
([ffeeda4](ffeeda4))
* **github:** send GitHub request, throttle and GraphQL point metrics,
and show them on the devops-cli dashboard
([#2406](#2406))
([bded64b](bded64b))
* **k8s:** gpu row panels for clock-event reasons, power against the
enforced limit and pcie throughput
([#2409](#2409))
([21f023c](21f023c)),
closes [#821](#821)
* **review:** a review session records its head commit and clean tree,
and says whether it is on merged code
([#2434](#2434))
([8b4ed46](8b4ed46))
* **review:** an issue filed from a review finding carries its
fingerprint, and the review leaves out a finding that an issue already
carries ([#2428](#2428))
([acace03](acace03))
* **review:** the feedback export counts each review subject once and
keeps every human verdict
([#2417](#2417))
([73d1807](73d1807))
* **roadmap:** act as GitHub App devops-roadmap instead of a machine
account ([#2411](#2411))
([d739a47](d739a47)),
closes [#1647](#1647)
* **roadmap:** labels and milestones hold each item's status, priority,
value and effort, and no roadmap job reads or writes the project board
([#2435](#2435))
([84f02a1](84f02a1)),
closes [#2399](#2399)
* **roadmap:** refine investigates open questions with code and web
tools and decides design questions by the best practice
([#2410](#2410))
([890e228](890e228)),
closes [#2398](#2398)
* **telemetry:** count embedding cache lookups and send every metric
through a declared instrument
([#2416](#2416))
([19412fa](19412fa))


### Bug Fixes

* **git:** ignore missing files when measuring directory size during
reclaim ([#2438](#2438))
([4226904](4226904))
* **security:** scan all namespaces with Popeye when no namespace is
given ([#2436](#2436))
([4d5f789](4d5f789))
* **security:** scan_uv_audit runs a uv audit adapter that audits the
lockfile as it is
([#2446](#2446))
([0b2d005](0b2d005)),
closes [#2106](#2106)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(security): scan_uv_audit runs a uv audit adapter, and the uv pip audit command that uv does not have goes

1 participant