Skip to content

Dependency pinning

Ensure that every compilation of SONAR relies on a strictly determined, reproducible and auditable set of dependencies, regardless of:

  • the build machine
  • network connectivity
  • the moment of compilation

Without this step:

  • the build is not deterministic
  • the chain of trust is broken
  • the (Cosign) signature loses its value

Pinning covers:

  • Rust dependencies (direct + transitive)
  • Deno dependencies (remote modules)
  • version resolution
  • dependency sources
  • build configuration

The Cargo.lock file must:

  • be present
  • be versioned
  • never be modified implicitly
  • not contain ’^’ in version numbers

all versions are fixed (no ^, no ~) → so no automatic supply-chain drift

Fenêtre de terminal
cargo build --locked

Recommended strict mode:

Fenêtre de terminal
cargo build --frozen

Every compilation must be:

  • without network access
  • without implicit updates

👉 Any download attempt must fail the build


Updates must be:

  • explicit (cargo update)
  • traced (dedicated commit)
  • validated (review)
  • tested offline

Fenêtre de terminal
cargo generate-lockfile

Fenêtre de terminal
cargo fetch --locked

Fenêtre de terminal
cargo vendor vendor > .cargo/config.toml

[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"

Fenêtre de terminal
cargo build --frozen

Create the deno.json file with the following elements:

{
"vendor": true,
"lock": {
"frozen": true
},
"nodeModulesDir": "auto"
}

so: vendor: true → you cache dependencies locally → excellent for air-gapped lock.frozen: true → you prevent any dependency drift → very good


Fenêtre de terminal
set DENO_DIR=.deno-cache
deno cache deno.json

The build must:

  • contain no unpinned dynamic import
  • never trigger an implicit download

Mandatory in the repository:

  • Cargo.lock
  • .cargo/config.toml
  • vendor/
  • deno.lock
  • deno.json

  • deleting Cargo.lock
  • building without --locked or --frozen
  • depending on non-vendored crates
  • using Deno without --cached-only
  • importing unpinned dynamic dependencies

The step is validated if:

  • build succeeds without network
  • no download attempt
  • cargo build --frozen passes
  • no modification of Cargo.lock during the build


Chosen option:

➡️ Targeted vendoring (cargo vendor)

Reasons:

  • simpler to audit
  • reproducible
  • compatible with strict offline
  • no need for a crates.io mirror

This step guarantees:

  • build reproducibility
  • dependency traceability
  • resistance to supply-chain attacks
  • a reliable basis for Cosign signing

Before the next step:

  • Cargo.lock frozen
  • vendor present
  • config.toml valid
  • deno.lock present
  • Deno cache generated
  • offline build validated

👉 Step 2 — Freezing the build environment (toolchain & OS)