Add cargo-vet and cargo-deny supply-chain security#30
Open
jerrysxie wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds supply-chain security tooling by introducing a cargo-vet configuration/audit scaffold plus CI workflows to run cargo vet on PRs and post a PR comment on failures/success-after-failure.
Changes:
- Add
cargo-vetconfiguration plus empty local audit/import lock scaffolding undersupply-chain/. - Add a
cargo-vetPR workflow that runscargo vet --lockedand uploads the PR number as an artifact. - Add a
workflow_runworkflow that posts/updates a PR comment based on thecargo-vetworkflow result.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| supply-chain/imports.lock | Initializes cargo-vet imports lock sections for upstream audit sources. |
| supply-chain/config.toml | Configures cargo-vet and upstream audit import URLs. |
| supply-chain/audits.toml | Adds an (empty) local audits file stub for cargo-vet. |
| .github/workflows/cargo-vet.yml | Runs cargo-vet in CI and uploads PR metadata for follow-on workflows. |
| .github/workflows/cargo-vet-pr-comment.yml | Posts/updates a PR comment based on the cargo-vet workflow outcome. |
Comments suppressed due to low confidence (2)
.github/workflows/cargo-vet.yml:44
- The
if:condition is written as two separate expression blocks (${{ failure() }} || ${{ success() }}), which GitHub Actions does not evaluate as a single expression and can cause the step to be skipped or the workflow to error. Use a single expression (e.g.,if: always()orif: success() || failure()) so the PR number is reliably saved.
- name: Save PR number
# PR number is saved as an artifact so it can be used to determine the PR to comment on by the vet-pr-comment workflow
# vet-pr-comment workflow is triggered by the workflow_run event so it runs in the context of the base branch and not the PR branch
if: ${{ failure() }} || ${{ success() }}
run: |
.github/workflows/cargo-vet.yml:50
- Same issue as above:
if: ${{ failure() }} || ${{ success() }}is not a single valid expression. Switch toif: always()(orif: success() || failure()) to ensure the artifact is uploaded on both success and failure, otherwise the downstreamworkflow_runjob may not find theprartifact.
- uses: actions/upload-artifact@v4
# Need to upload the artifact in both success and failure cases so comment can be updated in either case
if: ${{ failure() }} || ${{ success() }}
with:
| # Cargo Vet Audit Failed | ||
|
|
||
| `cargo vet` has failed in this PR. Please run `cargo vet --locked` locally to check for new or updated unvetted dependencies. | ||
| Details about the vetting process can be found in [supply-chain/README.md](../blob/main/supply-chain/README.md) |
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
Comment on lines
+22
to
+53
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: true | ||
|
|
||
| - uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ runner.tool_cache }}/cargo-vet | ||
| key: cargo-vet-bin-${{ env.CARGO_VET_VERSION }} | ||
|
|
||
| - name: Add the tool cache directory to the search path | ||
| run: echo "${{ runner.tool_cache }}/cargo-vet/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Ensure that the tool cache is populated with the cargo-vet binary | ||
| run: cargo install --root ${{ runner.tool_cache }}/cargo-vet --version ${{ env.CARGO_VET_VERSION }} cargo-vet | ||
|
|
||
| - name: Invoke cargo-vet | ||
| run: cargo vet --locked | ||
|
|
||
| - name: Save PR number | ||
| # PR number is saved as an artifact so it can be used to determine the PR to comment on by the vet-pr-comment workflow | ||
| # vet-pr-comment workflow is triggered by the workflow_run event so it runs in the context of the base branch and not the PR branch | ||
| if: ${{ failure() }} || ${{ success() }} | ||
| run: | | ||
| mkdir -p ./pr | ||
| echo ${{ github.event.number }} > ./pr/NR | ||
| - uses: actions/upload-artifact@v4 | ||
| # Need to upload the artifact in both success and failure cases so comment can be updated in either case | ||
| if: ${{ failure() }} || ${{ success() }} | ||
| with: | ||
| name: pr | ||
| path: pr/ | ||
| overwrite: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds supply-chain security tooling based on the
embedded-rust-template:
supply-chain/) – dependency audit tracking with importsfrom ODP shared audits, Google, and Mozilla.
deny.toml) – license, advisory, ban, and source checks.cargo-vet.yml+ PR comment workflow, and thedenyjob incheck.yml.After merging, run
cargo vetlocally to populate exemptions for anyexisting unaudited dependencies: