Skip to content

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

Merged
google-oss-prow[bot] merged 7 commits into
kubeflow:mainfrom
Kartikeya-trivedi:feat/osv-scanner
Jul 18, 2026
Merged

feat(ci): replace pip-audit with OSV-Scanner for CVE detection#30
google-oss-prow[bot] merged 7 commits into
kubeflow:mainfrom
Kartikeya-trivedi:feat/osv-scanner

Conversation

@Kartikeya-trivedi

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

Copy link
Copy Markdown
Contributor

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

Copilot AI review requested due to automatic review settings June 5, 2026 20:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 Outdated

@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
Contributor 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

@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
Contributor 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?

@abhijeet-dhumal

Copy link
Copy Markdown
Member

OSV-Scanner replacement for pip-audit is release-critical. Branch has merge conflicts with main — please rebase. Once rebased I'll review.

/assign @Kartikeya-trivedi

@Kartikeya-trivedi

Copy link
Copy Markdown
Contributor Author

Hi @abhijeet-dhumal, I have rebased my branch and it is free of merge conflicts now, Feel free to review!

@Kartikeya-trivedi

Copy link
Copy Markdown
Contributor Author

quicknote: I rebased on main - picked up the [dependency-groups] layout, removed the security-audit job that landed with #3, kept the constraint-dependencies pins per the issue.

@abhijeet-dhumal

Copy link
Copy Markdown
Member

/ok-to-test

@google-oss-prow google-oss-prow Bot added the ok-to-test Approve CI for external contributors label Jul 12, 2026
@abhijeet-dhumal

Copy link
Copy Markdown
Member

@Kartikeya-trivedi can you resolve merge conflicts?

@abhijeet-dhumal

Copy link
Copy Markdown
Member

Thanks for the contribution, @Kartikeya-trivedi ! 🙏
A few comments below. Note: this review was performed with the help of AI tools.

Comment thread .github/workflows/osv-scanner.yaml Outdated
Comment thread .github/workflows/osv-scanner.yaml Outdated
Comment thread .github/workflows/osv-scanner.yaml
Comment thread .github/workflows/osv-scanner.yaml Outdated
@abhijeet-dhumal

abhijeet-dhumal commented Jul 12, 2026

Copy link
Copy Markdown
Member

@Kartikeya-trivedi can you confirm and verify workflow adds uv sync before running helper scripts (or confirm uv run auto-syncs in GHA context) ?
and do we need OSV-Scanner auto-bump job too ?

@Kartikeya-trivedi

Kartikeya-trivedi commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Hello @abhijeet-dhumal, thanks for the review, for your questions above yes uv run auto-syncs acc to docs: "uv will ensure that the project environment is up-to-date before running the given command" and the fork run already exercised compare_versions.py (imports packaging) across ~8 packages with no import errors. That said, I'm still applying --with packaging per your other comment, because there's a subtle failure mode: if packaging weren't resolved, the script exits 1 (ModuleNotFoundError), which the fixer would misread as "upgrade sufficient" and silently skip a needed override. --with closes that.

auto-bump job: I'd keep it out of this PR and track it as a follow-up (filing now) — v2.3.8 is current so nothing's stale, this PR is the release unblock so I'd rather not grow its scope, and it's self-contained (same nightly-PR mechanism). I'll mirror it to kubeflow/sdk too so both stay in sync. Can pick it up right after this merges.

@abhijeet-dhumal

abhijeet-dhumal commented Jul 18, 2026

Copy link
Copy Markdown
Member

/ok-to-test
@Kartikeya-trivedi can you rebase this PR on latest main and resolve merge conflicts?

@abhijeet-dhumal

Copy link
Copy Markdown
Member

@Kartikeya-trivedi Update SECURITY.md ,.. it still says pip-audit runs in CI; should point at the OSV-Scanner nightly workflow after this lands.

Nits (can be same push or quick follow-up):

  • Auto-fix PR body: table header + bullet fix_details still won’t render as a table : emit | pkg | advisory | rows or use a list only.
  • After merge we’ll need the area/security label + Actions “create PRs” setting for the auto-fix path.

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>
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>
Run: uv run pytest .github/scripts/test_scripts.py -v
Signed-off-by: Kartikeya Trivedi <kartikeyatrivedi4oct2004@gmail.com>
…ixer

Drop continue-on-error from the SARIF scan so an unexpected exit (e.g. 2) fails the job instead of being swallowed; add if: always() to the JSON scan so a SARIF crash still doesn't block the independent auto-fix path. Invoke compare_versions.py via 'uv run --with packaging' so it no longer relies on packaging being a transitive lockfile dep (a missing packaging would exit 1 and be misread as 'upgrade sufficient').

Signed-off-by: Kartikeya Trivedi <kartikeyatrivedi4oct2004@gmail.com>
The PR body declares a two-column table but fix_details lines were bullets, so they rendered outside the table. Emit '| pkg | advisory |' rows instead.

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

Copy link
Copy Markdown
Contributor Author

hi @abhijeet-dhumal , Fixed the table in 2970f30 — the rows now come out as | pkg | advisory | so they actually render inside the table instead of dangling under the header as bullets.

On SECURITY.md — small catch: it's not on main yet, it's coming in via #14, and the "pip-audit runs in CI" line is in that PR's diff. If I touch it here we'd just conflict with #14. if this merges first I'll do a quick 2-line follow-up.

And yep, the label + "allow Actions to create PRs" setting are called out in the PR description as the post-merge admin checklist, only the auto-fix step needs them, scan + SARIF work either way.

@abhijeet-dhumal

Copy link
Copy Markdown
Member

@Kartikeya-trivedi Almost ready. Direction matches sdk, prior crash/packaging/table issues look fixed. Two blockers before /lgtm:

Two things before /lgtm:

  1. Wire .github/scripts/test_scripts.py into the Makefile the way sdk does (make test-scripts), so CI actually runs them .. right now they only exist on disk.
  2. OSV pin is still 2.3.8; latest is v2.4.0. Please bump version + checksum in this PR

Comment thread pyproject.toml
Comment thread .github/workflows/osv-scanner.yaml Outdated
Add a test-scripts Makefile target mirroring kubeflow/sdk and invoke it in the test job so the OSV-Scanner helper script tests actually gate CI.

Signed-off-by: Kartikeya Trivedi <kartikeyatrivedi4oct2004@gmail.com>
Pin v2.4.0 with the linux_amd64 checksum from the release's official SHA256SUMS, cross-verified against the downloaded binary. Use printf instead of echo when piping multi-line uv tree output, and reword the pyproject constraint comment now that pip-audit is gone.

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

Copy link
Copy Markdown
Contributor Author

Both blockers + nits done:

make test-scripts added (mirrors sdk's target) and wired into the test job right after Verify, so the script tests now gate CI — 8f09847
bumped the pin to v2.4.0 — checksum taken from the release's official SHA256SUMS and cross-verified against the downloaded binary before pinning — 0ad89f6
same commit: printf for the multi-line tree output, and the pyproject comment now says OSV-Scanner instead of pip-audit
should be good for another look 🙏

cc @abhijeet-dhumal

@abhijeet-dhumal

Copy link
Copy Markdown
Member

/lgtm
/approve
Thanks @Kartikeya-trivedi for your contribution and addressing recursive reviews promptly 😄
Great work 🚀

@google-oss-prow google-oss-prow Bot added the lgtm Looks good to me — approved by a reviewer label Jul 18, 2026
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhijeet-dhumal

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

The pull request process is described 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

@google-oss-prow google-oss-prow Bot added the approved Approved by an approver in OWNERS label Jul 18, 2026
@google-oss-prow
google-oss-prow Bot merged commit e89648a into kubeflow:main Jul 18, 2026
12 of 13 checks passed
@google-oss-prow google-oss-prow Bot added this to the v0.1 milestone Jul 18, 2026
@Kartikeya-trivedi

Copy link
Copy Markdown
Contributor Author

Thanks @abhijeet-dhumal learned a lot, looking forward to contribute more :)

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

Labels

approved Approved by an approver in OWNERS lgtm Looks good to me — approved by a reviewer ok-to-test Approve CI for external contributors size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use osv-scanner for CVE detection

4 participants