Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove generate-lockfile To Prevent Overwriting Checked-In Lock Files #20

Merged
merged 1 commit into from
May 10, 2024

Conversation

tillmann-crabnebula
Copy link

In CI builds, Rust applications or libraries are usually built with --locked or --frozen which uses the checked-in Cargo.lock file in the repository to decide which exact dependency version is used.

The current audit-check action does not respect this checked-in Cargo.lock file as it automatically overwrites the versions based on the Cargo.toml policies. This means the audited library or application is using different dependencies than the release/production build in most cases.

The cargo audit readme mentions to use cargo generate-lockfile but we couldn't figure out why this should be done in CI builds or in cases when the application or library is built with the --locked or --freeze argument.

cargo-audit implements logic to generate a Cargo.lock file if not already existing in locate_or_generate. The additional lock file generation seems not needed and causes checked-in lock files to be ignored and overwritten.

We tested the behavior of cargo audit with and without lock files in the following action runs:

Unmodified Action

outdated lock file is ignored, no vulns are found
no lock file exists, no vulns are found

Modified Action

Removed generate-lockfile invocation from audit-check action.

outdated lock file is respected, vulns are found
no lock file exists, no vulns are found

Manual Action

This action uses dtolnay/rust-toolchain to install Rust and runs plain cargo audit. It was used to compare behavior.

outdated lockfile is respected, vulns are found

@sveitser
Copy link

We also just experienced the action missing a potential vulnerability in our binaries because the lock file was regenerated.

However, I think it may make sense to regenerate a lock file for library crates because the lock file will be ignored if the library is used as a dependency. How about making the lock file (re)generation optional?

@tillmann-crabnebula
Copy link
Author

However, I think it may make sense to regenerate a lock file for library crates because the lock file will be ignored if the library is used as a dependency. How about making the lock file (re)generation optional?

It is generally recommended to check in lock files for binaries but not for libraries.
If you don't check in the lock file (for libraries as mentioned) it will automatically generate the Cargo.lock file when calling the cargo audit binary.

For checked in lock files in binary projects and CI actions I don't think it should be re-generated during auditing workflows and absolutely respected.

@sveitser
Copy link

The official recommendations regarding checking in lock files for libraries were changed last year: https://blog.rust-lang.org/2023/08/29/committing-lockfiles.html

My thinking was that as a library author you may want to know if using your library may leave a project vulnerable regardless of whether you choose to commit the lock file or not.

@tillmann-crabnebula
Copy link
Author

Ah yeah this change is still encouraging to check in for binaries but does not use "enforcing" language from my perspective.

My thinking was that as a library author you may want to know if using your library may leave a project vulnerable regardless of whether you choose to commit the lock file or not.

Totally agree on this and it was not part of my perspective previously.
Making it configurable would be a good addition to this PR but to be fair I am also happy if it is part of another PR, so we get the "more correct" behavior into this action rather sooner than later - the original issue is over 3 years old.

@tillmann-crabnebula
Copy link
Author

Re-built with latest upstream changes (upgrade to node 20) to resolve merge conflicts.

@tarcieri
Copy link
Member

tarcieri commented May 8, 2024

Why are there changes to index.js and package-lock.js?

@tillmann-crabnebula
Copy link
Author

tillmann-crabnebula commented May 9, 2024

As far as I understand how this action works is that the minified and bundled index.js is used to create the action in the first place (See https://github.com/rustsec/audit-check/blob/fe0359b3e165e4d83e11ffab7715e56c43cc2d76/action.yml#L16C1-L17C24), so all changes to actions behavior need to be built and checked into the repo (you merged this in #16 as well).

I mentioned in Zulip that this makes review harder and is whacky for concurrent PRs and would be open to contribute another PR where the repository workflows automatically builds the dist/index.js on merges to main.

I also updated the package-lock.json with running npm audit fix as there was a vulnerability in one of the dependencies ( I didn't really investigate if affected).
If it's better to review I can undo the package update but not the dist/index.js.

Copy link
Member

@tarcieri tarcieri left a comment

Choose a reason for hiding this comment

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

Okay, in the future it would be good to keep any changes to dependencies completely isolated and with a rationale for why they're being changed/updated, as they're an easy to introduce surreptitious supply chain attacks.

Automating the index.js builds (and more generally, automating deployments) would be good as well.

That said, approved.

@tarcieri tarcieri merged commit 6dc762e into rustsec:main May 10, 2024
1 check passed
@elichai
Copy link

elichai commented Sep 11, 2024

@tarcieri Can we get a release with this change please?

@tarcieri
Copy link
Member

@elichai see #22

I just need to figure out how to do a release, but am very, very busy

robert3005 referenced this pull request in spiraldb/vortex Sep 23, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rustsec/audit-check](https://redirect.github.com/rustsec/audit-check)
| action | major | `v1.4.1` -> `v2.0.0` |

---

### Release Notes

<details>
<summary>rustsec/audit-check (rustsec/audit-check)</summary>

###
[`v2.0.0`](https://redirect.github.com/rustsec/audit-check/releases/tag/v2.0.0)

[Compare
Source](https://redirect.github.com/rustsec/audit-check/compare/v1.4.1...v2.0.0)

#### What's Changed

- Run on Node 20.x by
[@&#8203;clechasseur](https://redirect.github.com/clechasseur) in
[https://github.com/rustsec/audit-check/pull/16](https://redirect.github.com/rustsec/audit-check/pull/16)
- Remove `generate-lockfile` To Prevent Overwriting Checked-In Lock
Files by
[@&#8203;tillmann-crabnebula](https://redirect.github.com/tillmann-crabnebula)
in
[https://github.com/rustsec/audit-check/pull/20](https://redirect.github.com/rustsec/audit-check/pull/20)
- Added support for `working-directory` by
[@&#8203;ranger-ross](https://redirect.github.com/ranger-ross) in
[https://github.com/rustsec/audit-check/pull/21](https://redirect.github.com/rustsec/audit-check/pull/21)
- fix: security fix for vulnerability in `braces` library by
[@&#8203;clechasseur](https://redirect.github.com/clechasseur) in
[https://github.com/rustsec/audit-check/pull/23](https://redirect.github.com/rustsec/audit-check/pull/23)
- npm audit fix by
[@&#8203;tarcieri](https://redirect.github.com/tarcieri) in
[https://github.com/rustsec/audit-check/pull/24](https://redirect.github.com/rustsec/audit-check/pull/24)
- v2.0.0 release prep by
[@&#8203;tarcieri](https://redirect.github.com/tarcieri) in
[https://github.com/rustsec/audit-check/pull/25](https://redirect.github.com/rustsec/audit-check/pull/25)

#### New Contributors

- [@&#8203;clechasseur](https://redirect.github.com/clechasseur) made
their first contribution in
[https://github.com/rustsec/audit-check/pull/16](https://redirect.github.com/rustsec/audit-check/pull/16)
-
[@&#8203;tillmann-crabnebula](https://redirect.github.com/tillmann-crabnebula)
made their first contribution in
[https://github.com/rustsec/audit-check/pull/20](https://redirect.github.com/rustsec/audit-check/pull/20)
- [@&#8203;ranger-ross](https://redirect.github.com/ranger-ross) made
their first contribution in
[https://github.com/rustsec/audit-check/pull/21](https://redirect.github.com/rustsec/audit-check/pull/21)
- [@&#8203;tarcieri](https://redirect.github.com/tarcieri) made their
first contribution in
[https://github.com/rustsec/audit-check/pull/24](https://redirect.github.com/rustsec/audit-check/pull/24)

**Full Changelog**:
rustsec/audit-check@v1.4.1...v2.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/spiraldb/vortex).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6ImRldmVsb3AiLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
simonsan referenced this pull request in rustic-rs/rustic_core Sep 23, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rustsec/audit-check](https://redirect.github.com/rustsec/audit-check)
| action | major | `v1.4.1` -> `v2.0.0` |

---

### Release Notes

<details>
<summary>rustsec/audit-check (rustsec/audit-check)</summary>

###
[`v2.0.0`](https://redirect.github.com/rustsec/audit-check/releases/tag/v2.0.0)

[Compare
Source](https://redirect.github.com/rustsec/audit-check/compare/v1.4.1...v2.0.0)

#### What's Changed

- Run on Node 20.x by
[@&#8203;clechasseur](https://redirect.github.com/clechasseur) in
[https://github.com/rustsec/audit-check/pull/16](https://redirect.github.com/rustsec/audit-check/pull/16)
- Remove `generate-lockfile` To Prevent Overwriting Checked-In Lock
Files by
[@&#8203;tillmann-crabnebula](https://redirect.github.com/tillmann-crabnebula)
in
[https://github.com/rustsec/audit-check/pull/20](https://redirect.github.com/rustsec/audit-check/pull/20)
- Added support for `working-directory` by
[@&#8203;ranger-ross](https://redirect.github.com/ranger-ross) in
[https://github.com/rustsec/audit-check/pull/21](https://redirect.github.com/rustsec/audit-check/pull/21)
- fix: security fix for vulnerability in `braces` library by
[@&#8203;clechasseur](https://redirect.github.com/clechasseur) in
[https://github.com/rustsec/audit-check/pull/23](https://redirect.github.com/rustsec/audit-check/pull/23)
- npm audit fix by
[@&#8203;tarcieri](https://redirect.github.com/tarcieri) in
[https://github.com/rustsec/audit-check/pull/24](https://redirect.github.com/rustsec/audit-check/pull/24)
- v2.0.0 release prep by
[@&#8203;tarcieri](https://redirect.github.com/tarcieri) in
[https://github.com/rustsec/audit-check/pull/25](https://redirect.github.com/rustsec/audit-check/pull/25)

#### New Contributors

- [@&#8203;clechasseur](https://redirect.github.com/clechasseur) made
their first contribution in
[https://github.com/rustsec/audit-check/pull/16](https://redirect.github.com/rustsec/audit-check/pull/16)
-
[@&#8203;tillmann-crabnebula](https://redirect.github.com/tillmann-crabnebula)
made their first contribution in
[https://github.com/rustsec/audit-check/pull/20](https://redirect.github.com/rustsec/audit-check/pull/20)
- [@&#8203;ranger-ross](https://redirect.github.com/ranger-ross) made
their first contribution in
[https://github.com/rustsec/audit-check/pull/21](https://redirect.github.com/rustsec/audit-check/pull/21)
- [@&#8203;tarcieri](https://redirect.github.com/tarcieri) made their
first contribution in
[https://github.com/rustsec/audit-check/pull/24](https://redirect.github.com/rustsec/audit-check/pull/24)

**Full Changelog**:
rustsec/audit-check@v1.4.1...v2.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/rustic-rs/rustic_core).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiQS1kZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: simonsan <[email protected]>
renovate bot referenced this pull request in smartive/zitadel-rust Sep 23, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rustsec/audit-check](https://redirect.github.com/rustsec/audit-check)
| action | major | `v1.4.1` -> `v2.0.0` |

---

### Release Notes

<details>
<summary>rustsec/audit-check (rustsec/audit-check)</summary>

###
[`v2.0.0`](https://redirect.github.com/rustsec/audit-check/releases/tag/v2.0.0)

[Compare
Source](https://redirect.github.com/rustsec/audit-check/compare/v1.4.1...v2.0.0)

#### What's Changed

- Run on Node 20.x by
[@&#8203;clechasseur](https://redirect.github.com/clechasseur) in
[https://github.com/rustsec/audit-check/pull/16](https://redirect.github.com/rustsec/audit-check/pull/16)
- Remove `generate-lockfile` To Prevent Overwriting Checked-In Lock
Files by
[@&#8203;tillmann-crabnebula](https://redirect.github.com/tillmann-crabnebula)
in
[https://github.com/rustsec/audit-check/pull/20](https://redirect.github.com/rustsec/audit-check/pull/20)
- Added support for `working-directory` by
[@&#8203;ranger-ross](https://redirect.github.com/ranger-ross) in
[https://github.com/rustsec/audit-check/pull/21](https://redirect.github.com/rustsec/audit-check/pull/21)
- fix: security fix for vulnerability in `braces` library by
[@&#8203;clechasseur](https://redirect.github.com/clechasseur) in
[https://github.com/rustsec/audit-check/pull/23](https://redirect.github.com/rustsec/audit-check/pull/23)
- npm audit fix by
[@&#8203;tarcieri](https://redirect.github.com/tarcieri) in
[https://github.com/rustsec/audit-check/pull/24](https://redirect.github.com/rustsec/audit-check/pull/24)
- v2.0.0 release prep by
[@&#8203;tarcieri](https://redirect.github.com/tarcieri) in
[https://github.com/rustsec/audit-check/pull/25](https://redirect.github.com/rustsec/audit-check/pull/25)

#### New Contributors

- [@&#8203;clechasseur](https://redirect.github.com/clechasseur) made
their first contribution in
[https://github.com/rustsec/audit-check/pull/16](https://redirect.github.com/rustsec/audit-check/pull/16)
-
[@&#8203;tillmann-crabnebula](https://redirect.github.com/tillmann-crabnebula)
made their first contribution in
[https://github.com/rustsec/audit-check/pull/20](https://redirect.github.com/rustsec/audit-check/pull/20)
- [@&#8203;ranger-ross](https://redirect.github.com/ranger-ross) made
their first contribution in
[https://github.com/rustsec/audit-check/pull/21](https://redirect.github.com/rustsec/audit-check/pull/21)
- [@&#8203;tarcieri](https://redirect.github.com/tarcieri) made their
first contribution in
[https://github.com/rustsec/audit-check/pull/24](https://redirect.github.com/rustsec/audit-check/pull/24)

**Full Changelog**:
rustsec/audit-check@v1.4.1...v2.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9pm,before 6am" in timezone
Europe/Zurich, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/smartive/zitadel-rust).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
github-merge-queue bot referenced this pull request in rustic-rs/rustic Sep 25, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rustsec/audit-check](https://redirect.github.com/rustsec/audit-check)
| action | major | `v1.4.1` -> `v2.0.0` |

---

### Release Notes

<details>
<summary>rustsec/audit-check (rustsec/audit-check)</summary>

###
[`v2.0.0`](https://redirect.github.com/rustsec/audit-check/releases/tag/v2.0.0)

[Compare
Source](https://redirect.github.com/rustsec/audit-check/compare/v1.4.1...v2.0.0)

#### What's Changed

- Run on Node 20.x by
[@&#8203;clechasseur](https://redirect.github.com/clechasseur) in
[https://github.com/rustsec/audit-check/pull/16](https://redirect.github.com/rustsec/audit-check/pull/16)
- Remove `generate-lockfile` To Prevent Overwriting Checked-In Lock
Files by
[@&#8203;tillmann-crabnebula](https://redirect.github.com/tillmann-crabnebula)
in
[https://github.com/rustsec/audit-check/pull/20](https://redirect.github.com/rustsec/audit-check/pull/20)
- Added support for `working-directory` by
[@&#8203;ranger-ross](https://redirect.github.com/ranger-ross) in
[https://github.com/rustsec/audit-check/pull/21](https://redirect.github.com/rustsec/audit-check/pull/21)
- fix: security fix for vulnerability in `braces` library by
[@&#8203;clechasseur](https://redirect.github.com/clechasseur) in
[https://github.com/rustsec/audit-check/pull/23](https://redirect.github.com/rustsec/audit-check/pull/23)
- npm audit fix by
[@&#8203;tarcieri](https://redirect.github.com/tarcieri) in
[https://github.com/rustsec/audit-check/pull/24](https://redirect.github.com/rustsec/audit-check/pull/24)
- v2.0.0 release prep by
[@&#8203;tarcieri](https://redirect.github.com/tarcieri) in
[https://github.com/rustsec/audit-check/pull/25](https://redirect.github.com/rustsec/audit-check/pull/25)

#### New Contributors

- [@&#8203;clechasseur](https://redirect.github.com/clechasseur) made
their first contribution in
[https://github.com/rustsec/audit-check/pull/16](https://redirect.github.com/rustsec/audit-check/pull/16)
-
[@&#8203;tillmann-crabnebula](https://redirect.github.com/tillmann-crabnebula)
made their first contribution in
[https://github.com/rustsec/audit-check/pull/20](https://redirect.github.com/rustsec/audit-check/pull/20)
- [@&#8203;ranger-ross](https://redirect.github.com/ranger-ross) made
their first contribution in
[https://github.com/rustsec/audit-check/pull/21](https://redirect.github.com/rustsec/audit-check/pull/21)
- [@&#8203;tarcieri](https://redirect.github.com/tarcieri) made their
first contribution in
[https://github.com/rustsec/audit-check/pull/24](https://redirect.github.com/rustsec/audit-check/pull/24)

**Full Changelog**:
rustsec/audit-check@v1.4.1...v2.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/rustic-rs/rustic).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC45NC4zIiwidXBkYXRlZEluVmVyIjoiMzguOTQuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiQS1kZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit to astriaorg/astria that referenced this pull request Sep 30, 2024
## Summary
This is an upgrade of the `audit-check` package used in CI for running
`cargo audit`.

## Background
This upgrade includes [a
fix](rustsec/audit-check#20) for an issue where
`audit-check` would not respect the committed `Cargo.lock` file.

## Changes
- Upgrade `audit-check`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants