Skip to content

Commit

Permalink
Run cargo audit on committed Cargo.lock (#1315)
Browse files Browse the repository at this point in the history
* Run cargo audit on committed Cargo.lock

The current audit action regenerates the lock file which may hide
vulnerabilities in our binaries.

Ensure binaries are built with committed lock file by adding the
`--locked` flag. Note the `--locked` flag is currently documented in a
confusing way in `cargo --help`.

A fix for that has been merged into cargo recently:

rust-lang/cargo#13665

* Add --locked to cargo test invocations
  • Loading branch information
sveitser authored Apr 18, 2024
1 parent aef9cae commit 752608b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ jobs:
- uses: actions/checkout@v4

# See https://github.com/rustsec/audit-check for docs
- uses: rustsec/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
# TODO: re-enable if https://github.com/rustsec/audit-check/pull/20 is merged
# - uses: rustsec/audit-check@v1
# with:
# token: ${{ secrets.GITHUB_TOKEN }}

# Currently the rustsec/audit-check action regenerates the Cargo.lock
# file. Our binaries are built using the committed lock file.
# Re-generating the lock file can hide vulnerabilities. We therefore run
# cargo audit directly which respects our lock file.
- run: cargo audit
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Build
# Build in release without `testing` feature, this should work without `hotshot_example` config.
run: |
cargo build --release --workspace
cargo build --locked --release --workspace
- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:

- name: Build
run: |
cargo build --release --workspace
cargo build --locked --release --workspace
- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Compile all executables
# timeout-minutes: 120
run: |
nix develop $DEVSHELL --accept-flake-config --option sandbox relaxed -c cargo build --release
nix develop $DEVSHELL --accept-flake-config --option sandbox relaxed -c cargo build --locked --release
- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Build diff-test
run: |
nix develop --accept-flake-config -c cargo build --bin diff-test --release
nix develop --accept-flake-config -c cargo build --locked --bin diff-test --release
- name: Run tests (quick version for PR)
if: ${{ github.event_name == 'pull_request' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Enable Rust Caching
uses: Swatinem/rust-cache@v2

- run: cargo +nightly test --all-features --no-fail-fast --release --workspace --exclude contract-bindings --exclude gen-vk-contract --exclude hotshot-contract-adapter --exclude diff-test-hotshot -- --skip service::test::test_
- run: cargo +nightly test --locked --all-features --no-fail-fast --release --workspace --exclude contract-bindings --exclude gen-vk-contract --exclude hotshot-contract-adapter --exclude diff-test-hotshot -- --skip service::test::test_
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests -Cdebuginfo=2 --cfg async_executor_impl="async-std" --cfg async_channel_impl="async-std" --cfg hotshot_example'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-demo-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Build
run: cargo build --release
run: cargo build --locked --release

- name: Test Demo
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
export PATH="$PWD/target/release:$PATH"
export AZTEC_SRS_PATH="$PWD/data/aztec20/kzg10-aztec20-srs-65544.bin"
./scripts/download_srs_aztec.sh
cargo build --bin diff-test --release
cargo test --release --workspace --all-features --no-run
cargo test --release --workspace --all-features --verbose -- --test-threads 1 --nocapture
cargo build --locked --bin diff-test --release
cargo test --locked --release --workspace --all-features --no-run
cargo test --locked --release --workspace --all-features --verbose -- --test-threads 1 --nocapture
timeout-minutes: 30

0 comments on commit 752608b

Please sign in to comment.