Skip to content

feat(ci): replace pip-audit with OSV-Scanner for CVE detection#30

Open
Kartikeya-trivedi wants to merge 3 commits into
kubeflow:mainfrom
Kartikeya-trivedi:feat/osv-scanner
Open

feat(ci): replace pip-audit with OSV-Scanner for CVE detection#30
Kartikeya-trivedi wants to merge 3 commits into
kubeflow:mainfrom
Kartikeya-trivedi:feat/osv-scanner

Conversation

@Kartikeya-trivedi

@Kartikeya-trivedi Kartikeya-trivedi commented Jun 5, 2026

Copy link
Copy Markdown

Description

We were using pip-audit for the security scan, but it's fairly limited ie it only checks PyPI's advisory database, never opens fix PRs, and nothing shows up in GitHub's Security tab. This swaps it out for OSV-Scanner, ported over from kubeflow/sdk.

What changes:

  • A nightly scan of uv.lock (also runnable on demand from the Actions tab)
  • Findings upload as SARIF, so they land in the Security tab
  • If a vuln is fixable, it opens a PR bumping the package, a normal upgrade where that works, or a [tool.uv] override when a plain upgrade isn't enough

The auto-fix part pulls in three small helper scripts (extract_version, compare_versions, update_overrides). pip-audit is dropped from the dev dependencies and the lockfile is regenerated.

Heads-up, since the repo wasn't quite in the state the issue's task list assumed:

  • No security-audit job existed in test-python.yaml to remove, pip-audit was only a dev dependency, never run in CI.
  • pip-audit lived under [project.optional-dependencies].dev, not [dependency-groups].dev; removed from there.
  • No [tool.uv] constraint-dependencies section exists yet, so nothing to keep. The scanner only writes override-dependencies when it needs to.

For a maintainer with admin access: the auto-fix PR step needs an area/security label to exist and "Allow GitHub Actions to create and approve pull requests" enabled (Settings -> Actions -> General). Scanning and the Security-tab upload work without either.

Workflow link = https://github.com/Kartikeya-trivedi/mcp-server/actions/runs/27156215089

Type of Change

  • feat: New feature
  • fix: Bug fix
  • revert: Revert a change
  • chore: Maintenance / tooling

Checklist

  • Tests pass locally (make test-python)
  • Linting passes (make verify)
  • Documentation updated (if applicable)
  • Commit messages follow conventional format

Related Issues

Fixes #29

Port the nightly OSV-Scanner workflow from kubeflow/sdk: scan uv.lock, upload SARIF to the GitHub Security tab, and open automated fix PRs. Add the helper scripts it invokes (extract_version, compare_versions, update_overrides).

Drop pip-audit from the dev dependencies and relock; it only queried PyPI's advisory DB, opened no fix PRs, and surfaced nothing in the Security tab.

Fixes kubeflow#29

Signed-off-by: Kartikeya Trivedi <kartikeyatrivedi4oct2004@gmail.com>
Copilot AI review requested due to automatic review settings June 5, 2026 20:30
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign andreyvelich for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a scheduled OSV-Scanner-based vulnerability scanning and auto-remediation workflow, shifting security auditing away from the pip-audit dev dependency.

Changes:

  • Removed pip-audit from Python dev dependencies.
  • Added a nightly GitHub Actions workflow to run OSV-Scanner, upload SARIF, and open automated PRs with dependency fixes.
  • Added helper scripts to parse uv tree output, compare PEP 440 versions, and manage [tool.uv] override-dependencies in pyproject.toml.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pyproject.toml Drops pip-audit from the dev extras.
.github/workflows/osv-scanner.yaml New scheduled OSV scan workflow with SARIF upload + auto-fix PR creation.
.github/scripts/update_overrides.py Adds/updates override-dependencies in pyproject.toml for security pinning.
.github/scripts/extract_version.py Extracts resolved package version from uv tree output.
.github/scripts/compare_versions.py Compares versions using PEP 440 semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/osv-scanner.yaml
Comment thread .github/scripts/update_overrides.py
Comment thread .github/workflows/osv-scanner.yaml
The removal regex was anchored at column 0, so an indented (yet valid TOML) override-dependencies key survived and the script wrote a duplicate key, producing invalid TOML. Allow leading horizontal whitespace in the removal patterns.

Signed-off-by: Kartikeya Trivedi <kartikeyatrivedi4oct2004@gmail.com>

@Krishna-kg732 Krishna-kg732 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Kartikeya-trivedi , thanks for picking up this work !

overall LGTM , pretty well aligned with sdk ,
can you also please include a unit test for the scripts as well , like we have in sdk :
https://github.com/kubeflow/sdk/blob/main/.github/scripts/test_scripts.py

edit : Please provide a link to the workflow test run on your fork if possible

cc : @abhijeet-dhumal

@google-oss-prow

Copy link
Copy Markdown

@Krishna-kg732: changing LGTM is restricted to collaborators

Details

In response to this:

Hey @Kartikeya-trivedi , thanks for picking up this work !

overall LGTM , pretty well aligned with sdk ,
can you also please include a unit test for the scripts as well , like we have in sdk :
https://github.com/kubeflow/sdk/blob/main/.github/scripts/test_scripts.py

cc : @abhijeet-dhumal

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Kartikeya-trivedi

Copy link
Copy Markdown
Author

Hi @Krishna-kg732 thanks for the review, I am adding the tests, btw the workflow link is https://github.com/Kartikeya-trivedi/mcp-server/actions/runs/27156215089 will also update it in pr aswell

Run: uv run pytest .github/scripts/test_scripts.py -v
Signed-off-by: Kartikeya Trivedi <kartikeyatrivedi4oct2004@gmail.com>
@google-oss-prow google-oss-prow Bot added size/XXL and removed size/XL labels Jun 9, 2026

@Krishna-kg732 Krishna-kg732 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Kartikeya-trivedi , OSV-Scanner version pinning: The hardcoded OSV_VERSION="2.3.8" and checksum require manual monthly updates , I think we should automate this process wdyt?

overall looks good

@Kartikeya-trivedi

Copy link
Copy Markdown
Author

HI @Krishna-kg732 yeah agreed, the manual bump is a known annoyance, it's inherited from the sdk version (Dependabot can't bump curl-installed binaries, and we keep the pin + checksum since the workflow runs with write permissions, so blindly pulling latest isn't great supply-chain-wise).

Good news is osv-scanner releases ship an official osv-scanner_SHA256SUMS asset, so this is automatable without losing the checksum verification: a tiny scheduled job that checks the latest release, pulls the version + matching checksum from the SHA256SUMS file, updates the two lines, and opens a PR for review. Same pattern as the security-fix PRs this workflow already creates.

I'd keep this PR aligned with sdk as-is (v2.3.8 is actually the latest release right now, so nothing's stale) and do the auto-bump as a follow-up issue that way it can be contributed to kubeflow/sdk too instead of the two copies drifting. Happy to pick that up. wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use osv-scanner for CVE detection

3 participants