`generate-lockfile` overwrites a checked-in Cargo.lock
See original GitHub issueDescription
I have a repo where I’ve checked in Cargo.lock, since it’s producing a binary which I’m shipping. I’ve just started getting audit violations in CI for this that I cannot reproduce locally. I’ve tracked this down to the generate-lockfile
call at the beginning; this updates the checked-in Cargo-lock
. In my case, it brings in a new vulnerability due to a transitive dependency update.
Workflow code
name: Security audit
on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expected behavior
If a Cargo.lock is in source control, it should be used as-is.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
cargo generate-lockfile - The Cargo Book
This command will create the Cargo.lock lockfile for the current package or workspace. If the lockfile already exists, it will be rebuilt with...
Read more >Project-specific override for Cargo - Stack Overflow
We can generate the missing .cargo-checksum.json like so: cd ~/.cargo-overlay index_file=$(find crates.io-index -type f -name foo) ...
Read more >cargo-package(1) - Arch manual pages
Either of these flags requires that the Cargo.lock file is up-to-date. If the lock file is missing, or it needs to be updated,...
Read more >1525-cargo-workspace - The Rust RFC Book
Lockfile and override interactions ... One of the main features of a workspace is that only one Cargo.lock is generated for the entire...
Read more >The Cargo Book
lock in your .gitignore . If you're building an executable like a command-line tool or an application, check Cargo.lock into git ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Rather than
generate-lockfile
this should callcargo metadata --format-version=1 >/dev/null
as a relatively quick no-op “ensure the lockfile is up to date”. It would be good for the action to also take alocked: boolean
flag to determine whether to pass--locked
to this call for repositories that expect the lockfile to always be up to date.Another problem this behavior incurres:
Cargo.lock
that works perfectly fine.cargo generate-lockfile
just will not be able to createCargo.lock
.And it doesn’t need to, because a working
Cargo.toml
is already there.