This commit was merged in pull request #333.
This commit is contained in:
1 parent
44a48957c1
commit
c6d2d07999
9 files changed
+282
-136
No files matched your search
+9
-7
@@ -131,13 +131,15 @@ BREAKPILOT_SNAPSHOT_DIR=/data/compliance-scanner/oscal
|
||||
# BREAKPILOT_SEMANTIC_MAPPING=false
|
||||
# BREAKPILOT_GROUNDED_CHECKS=true
|
||||
|
||||
# Execute code from the repositories being scanned? A few stages do: cargo
|
||||
# clippy compiles the repo (build.rs, proc macros), ESLint runs from the repo's
|
||||
# own node_modules, pip-compile builds sdists (setup.py), and the firmware
|
||||
# reproducible build shells out to Nix with sandbox=false. They are OFF unless
|
||||
# this is set, and a staging/production APP_ENV ignores it — the agent holds
|
||||
# every tenant's data. Firmware SBOMs come from an imported Firmwerk bundle
|
||||
# instead.
|
||||
# Execute code from the repositories being scanned, or fetch from hosts they
|
||||
# name? A few stages do: cargo clippy compiles the repo (build.rs, proc
|
||||
# macros), ESLint runs from the repo's own node_modules, pip-compile builds
|
||||
# sdists (setup.py), the firmware reproducible build shells out to Nix with
|
||||
# sandbox=false, and npm / cargo lockfile generation and cargo metadata fetch
|
||||
# whatever the manifests name (#330). They are OFF unless this is set, and a
|
||||
# staging/production APP_ENV ignores it — the agent holds every tenant's data.
|
||||
# Without them, commit a lockfile; firmware SBOMs come from an imported
|
||||
# Firmwerk bundle.
|
||||
# PW_ALLOW_UNTRUSTED_CODE_EXEC=1
|
||||
|
||||
# Deployment feature flags (comma list). `source_only` = static analysis only:
|
||||
|
||||
@@ -20,21 +20,22 @@ pub(super) async fn run_cargo_audit(
|
||||
|
||||
// Reads Cargo.lock against the advisory DB; it does not build, so no
|
||||
// `build.rs` runs. Bounded and stripped of the agent's environment.
|
||||
let output = crate::pipeline::tool_cmd::run_bounded(
|
||||
crate::pipeline::tool_cmd::tool_in(
|
||||
"cargo",
|
||||
repo_path,
|
||||
crate::pipeline::tool_cmd::CARGO_ENV,
|
||||
)
|
||||
.args(["audit", "--json"])
|
||||
.env("RUSTC_WRAPPER", ""),
|
||||
"cargo audit",
|
||||
)
|
||||
.await
|
||||
.map_err(|e| CoreError::Scanner {
|
||||
//
|
||||
// It runs from an empty directory, never the repository: cargo-audit reads
|
||||
// `.cargo/audit.toml` from where it runs, and a committed one could point it
|
||||
// at an advisory database of the repository's choosing, or `ignore` the
|
||||
// repository's own advisories — silencing findings in our report (#330).
|
||||
let neutral = NeutralDir::new().map_err(|e| CoreError::Scanner {
|
||||
scanner: "cargo-audit".to_string(),
|
||||
source: Box::new(e),
|
||||
})?;
|
||||
let mut cmd = audit_command(&cargo_lock, neutral.path());
|
||||
let output = crate::pipeline::tool_cmd::run_bounded(&mut cmd, "cargo audit")
|
||||
.await
|
||||
.map_err(|e| CoreError::Scanner {
|
||||
scanner: "cargo-audit".to_string(),
|
||||
source: Box::new(e),
|
||||
})?;
|
||||
|
||||
let result: CargoAuditOutput =
|
||||
serde_json::from_slice(&output.stdout).unwrap_or_else(|_| CargoAuditOutput {
|
||||
@@ -77,3 +78,65 @@ struct CargoAuditAdvisory {
|
||||
package: String,
|
||||
url: String,
|
||||
}
|
||||
|
||||
/// `cargo audit` over `cargo_lock`, run from `cwd` so no configuration from the
|
||||
/// scanned repository is read.
|
||||
fn audit_command(cargo_lock: &Path, cwd: &Path) -> tokio::process::Command {
|
||||
let mut cmd = crate::pipeline::tool_cmd::tool("cargo", crate::pipeline::tool_cmd::CARGO_ENV);
|
||||
cmd.arg("audit")
|
||||
.arg("--json")
|
||||
.arg("--file")
|
||||
.arg(cargo_lock)
|
||||
.env("RUSTC_WRAPPER", "")
|
||||
.current_dir(cwd);
|
||||
cmd
|
||||
}
|
||||
|
||||
/// A fresh, empty working directory, removed on drop.
|
||||
struct NeutralDir(std::path::PathBuf);
|
||||
|
||||
impl NeutralDir {
|
||||
fn new() -> std::io::Result<Self> {
|
||||
let dir = std::env::temp_dir().join(format!("cs-audit-{}", uuid::Uuid::new_v4()));
|
||||
std::fs::create_dir_all(&dir)?;
|
||||
Ok(Self(dir))
|
||||
}
|
||||
|
||||
fn path(&self) -> &Path {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for NeutralDir {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::expect_used, clippy::unwrap_used)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn audit_runs_outside_the_repository() {
|
||||
let repo = std::path::Path::new("/work/tenant/repo");
|
||||
let lock = repo.join("Cargo.lock");
|
||||
let neutral = NeutralDir::new().expect("neutral dir");
|
||||
let cmd = audit_command(&lock, neutral.path());
|
||||
let std = cmd.as_std();
|
||||
// A `.cargo/audit.toml` in the repository must not be in reach.
|
||||
assert_eq!(std.get_current_dir(), Some(neutral.path()));
|
||||
let args: Vec<_> = std
|
||||
.get_args()
|
||||
.map(|a| a.to_string_lossy().into_owned())
|
||||
.collect();
|
||||
assert_eq!(
|
||||
args,
|
||||
["audit", "--json", "--file", "/work/tenant/repo/Cargo.lock"]
|
||||
);
|
||||
let path = neutral.path().to_path_buf();
|
||||
drop(neutral);
|
||||
assert!(!path.exists(), "the neutral directory is cleaned up");
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ impl Scanner for SbomScanner {
|
||||
}
|
||||
|
||||
// Enrich Cargo entries with license info from cargo metadata
|
||||
enrich_cargo_licenses(repo_path, &mut entries).await;
|
||||
enrich_cargo_licenses(repo_path, &mut entries, self.exec).await;
|
||||
|
||||
// Run cargo-audit for Rust-specific vulns
|
||||
match cargo_audit::run_cargo_audit(repo_path, repo_id).await {
|
||||
@@ -114,10 +114,7 @@ pub(crate) fn unlocked_ecosystems(repo_path: &Path) -> Vec<UnlockedEcosystem> {
|
||||
.into_iter()
|
||||
.find(|f| has(f));
|
||||
if let Some(manifest) = python_manifest {
|
||||
if !["requirements.txt", "poetry.lock", "Pipfile.lock", "uv.lock"]
|
||||
.iter()
|
||||
.any(|f| has(f))
|
||||
{
|
||||
if !PIP_LOCKFILES.iter().any(|f| has(f)) {
|
||||
out.push(UnlockedEcosystem {
|
||||
manifest,
|
||||
problem: "declares dependencies but no lockfile pins them",
|
||||
@@ -135,91 +132,97 @@ pub(crate) fn unlocked_ecosystems(repo_path: &Path) -> Vec<UnlockedEcosystem> {
|
||||
out
|
||||
}
|
||||
|
||||
/// Generate missing lock files so Syft can resolve the full dependency tree.
|
||||
/// This handles repos that gitignore their lock files (common for Rust libraries).
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn generate_lockfiles(repo_path: &Path, exec: ExecPolicy) {
|
||||
// Cargo: generate Cargo.lock if Cargo.toml exists without it
|
||||
if repo_path.join("Cargo.toml").exists() && !repo_path.join("Cargo.lock").exists() {
|
||||
tracing::info!("generating Cargo.lock for SBOM scan");
|
||||
// Resolution only: this reads manifests and the registry index, it does
|
||||
// not compile, so no `build.rs` runs.
|
||||
let result = run_bounded(
|
||||
tool_in("cargo", repo_path, CARGO_ENV)
|
||||
.args(["generate-lockfile"])
|
||||
.env("RUSTC_WRAPPER", ""),
|
||||
"cargo generate-lockfile",
|
||||
)
|
||||
.await;
|
||||
match result {
|
||||
Ok(o) if o.status.success() => tracing::info!("Cargo.lock generated"),
|
||||
Ok(o) => tracing::warn!(
|
||||
"cargo generate-lockfile failed: {}",
|
||||
String::from_utf8_lossy(&o.stderr)
|
||||
),
|
||||
Err(e) => tracing::warn!("cargo generate-lockfile error: {e}"),
|
||||
/// Lockfiles that pin a Python project. A tree with any of them is left alone:
|
||||
/// generating another would add a fresh resolution beside the pinned one.
|
||||
const PIP_LOCKFILES: &[&str] = &[
|
||||
"requirements.txt",
|
||||
"requirements-lock.txt",
|
||||
"poetry.lock",
|
||||
"Pipfile.lock",
|
||||
"uv.lock",
|
||||
];
|
||||
|
||||
/// A lockfile generator the SBOM stage runs when a manifest has no lockfile.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum Generator {
|
||||
/// `cargo generate-lockfile`: fetches every dependency the manifest names.
|
||||
Cargo,
|
||||
/// `pip-compile`: builds source distributions, which runs `setup.py`.
|
||||
PipCompile,
|
||||
/// `npm install --package-lock-only`: fetches every dependency the manifest
|
||||
/// names, including URL dependencies.
|
||||
Npm,
|
||||
}
|
||||
|
||||
impl Generator {
|
||||
/// Why this deployment does not run it.
|
||||
fn skip_reason(self, exec: ExecPolicy) -> String {
|
||||
match self {
|
||||
Generator::Cargo => exec.resolution_skip_reason("cargo generate-lockfile"),
|
||||
Generator::Npm => exec.resolution_skip_reason("npm install --package-lock-only"),
|
||||
Generator::PipCompile => exec.skip_reason("pip-compile"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pip: generate a requirements lock if only pyproject.toml / setup.py exists
|
||||
let has_pip_manifest = repo_path.join("pyproject.toml").exists()
|
||||
|| repo_path.join("setup.py").exists()
|
||||
|| repo_path.join("setup.cfg").exists();
|
||||
let has_pip_lock = repo_path.join("requirements.txt").exists()
|
||||
|| repo_path.join("requirements-lock.txt").exists()
|
||||
|| repo_path.join("poetry.lock").exists()
|
||||
|| repo_path.join("Pipfile.lock").exists();
|
||||
if has_pip_manifest && !has_pip_lock {
|
||||
// Try pip-compile (pip-tools) first, fall back to pip freeze approach
|
||||
tracing::info!("attempting to generate pip requirements for SBOM scan");
|
||||
// pip-compile builds source distributions to read their metadata,
|
||||
// which executes the project's own `setup.py`.
|
||||
if repo_path.join("pyproject.toml").exists() && !exec.untrusted_code_allowed() {
|
||||
tracing::info!("{}", exec.skip_reason("pip-compile"));
|
||||
} else if repo_path.join("pyproject.toml").exists() {
|
||||
let result = run_bounded(
|
||||
tool_in("pip-compile", repo_path, &[]).args([
|
||||
/// The generators a tree would need: a manifest whose ecosystem has no lockfile.
|
||||
fn needed_generators(repo_path: &Path) -> Vec<Generator> {
|
||||
let has = |name: &str| repo_path.join(name).exists();
|
||||
let mut out = Vec::new();
|
||||
if has("Cargo.toml") && !has("Cargo.lock") {
|
||||
out.push(Generator::Cargo);
|
||||
}
|
||||
if has("pyproject.toml") && !PIP_LOCKFILES.iter().any(|f| has(f)) {
|
||||
out.push(Generator::PipCompile);
|
||||
}
|
||||
if has("package.json") && !NPM_LOCKFILES.iter().any(|f| has(f)) {
|
||||
out.push(Generator::Npm);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Generate missing lock files so Syft can resolve the full dependency tree.
|
||||
///
|
||||
/// Every generator either runs the tenant's code or fetches from hosts the
|
||||
/// tenant's manifest names, so none runs unless the deployment allows it
|
||||
/// (#330). Where one does not run, [`unlocked_ecosystems`] reports the gap.
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn generate_lockfiles(repo_path: &Path, exec: ExecPolicy) {
|
||||
for generator in needed_generators(repo_path) {
|
||||
if !exec.untrusted_code_allowed() {
|
||||
tracing::info!("{}", generator.skip_reason(exec));
|
||||
continue;
|
||||
}
|
||||
let (mut cmd, name) = match generator {
|
||||
// Resolution only: reads manifests and the registry index, compiles
|
||||
// nothing, so no `build.rs` runs.
|
||||
Generator::Cargo => {
|
||||
let mut cmd = tool_in("cargo", repo_path, CARGO_ENV);
|
||||
cmd.args(["generate-lockfile"]).env("RUSTC_WRAPPER", "");
|
||||
(cmd, "cargo generate-lockfile")
|
||||
}
|
||||
Generator::PipCompile => {
|
||||
let mut cmd = tool_in("pip-compile", repo_path, &[]);
|
||||
cmd.args([
|
||||
"--quiet",
|
||||
"--output-file",
|
||||
"requirements.txt",
|
||||
"pyproject.toml",
|
||||
]),
|
||||
"pip-compile",
|
||||
)
|
||||
.await;
|
||||
match result {
|
||||
Ok(o) if o.status.success() => {
|
||||
tracing::info!("requirements.txt generated via pip-compile")
|
||||
}
|
||||
_ => tracing::warn!(
|
||||
"pip-compile not available or failed, Syft will parse pyproject.toml directly"
|
||||
),
|
||||
]);
|
||||
(cmd, "pip-compile")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// npm: generate package-lock.json if package.json exists without it
|
||||
let has_npm_lock = NPM_LOCKFILES.iter().any(|f| repo_path.join(f).exists());
|
||||
if repo_path.join("package.json").exists() && !has_npm_lock {
|
||||
tracing::info!("generating package-lock.json for SBOM scan");
|
||||
// `--package-lock-only --ignore-scripts`: resolve versions, write the
|
||||
// lockfile, run none of the package's lifecycle scripts.
|
||||
let result = run_bounded(
|
||||
tool_in("npm", repo_path, NPM_ENV).args([
|
||||
"install",
|
||||
"--package-lock-only",
|
||||
"--ignore-scripts",
|
||||
]),
|
||||
"npm install --package-lock-only",
|
||||
)
|
||||
.await;
|
||||
match result {
|
||||
Ok(o) if o.status.success() => tracing::info!("package-lock.json generated"),
|
||||
Ok(o) => tracing::warn!(
|
||||
"npm install --package-lock-only failed: {}",
|
||||
String::from_utf8_lossy(&o.stderr)
|
||||
),
|
||||
Err(e) => tracing::warn!("npm lock generation error: {e}"),
|
||||
// `--ignore-scripts`: resolve and write the lockfile, run none of the
|
||||
// packages' lifecycle scripts.
|
||||
Generator::Npm => {
|
||||
let mut cmd = tool_in("npm", repo_path, NPM_ENV);
|
||||
cmd.args(["install", "--package-lock-only", "--ignore-scripts"]);
|
||||
(cmd, "npm install --package-lock-only")
|
||||
}
|
||||
};
|
||||
match run_bounded(&mut cmd, name).await {
|
||||
Ok(o) if o.status.success() => tracing::info!("{name}: lockfile generated"),
|
||||
Ok(o) => tracing::warn!("{name} failed: {}", String::from_utf8_lossy(&o.stderr)),
|
||||
Err(e) => tracing::warn!("{name} error: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,10 +230,16 @@ async fn generate_lockfiles(repo_path: &Path, exec: ExecPolicy) {
|
||||
/// Enrich Cargo SBOM entries with license info from `cargo metadata`.
|
||||
/// Syft doesn't read license data from Cargo.lock, so we fill it in.
|
||||
#[tracing::instrument(skip_all)]
|
||||
async fn enrich_cargo_licenses(repo_path: &Path, entries: &mut [SbomEntry]) {
|
||||
async fn enrich_cargo_licenses(repo_path: &Path, entries: &mut [SbomEntry], exec: ExecPolicy) {
|
||||
if !repo_path.join("Cargo.toml").exists() {
|
||||
return;
|
||||
}
|
||||
// `cargo metadata` downloads every dependency to read its licence, from
|
||||
// whatever registry or git host the manifest names (#330).
|
||||
if !exec.untrusted_code_allowed() {
|
||||
tracing::info!("{}", exec.resolution_skip_reason("cargo metadata"));
|
||||
return;
|
||||
}
|
||||
|
||||
let has_cargo_entries = entries.iter().any(|e| e.package_manager == "cargo");
|
||||
if !has_cargo_entries {
|
||||
@@ -389,6 +398,35 @@ mod unlocked_tests {
|
||||
assert!(names(&both).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_generator_is_needed_only_where_nothing_pins_the_ecosystem() {
|
||||
let plan = |files: &[&str]| needed_generators(&Tree::new(files).0);
|
||||
assert_eq!(plan(&["Cargo.toml"]), [Generator::Cargo]);
|
||||
assert_eq!(plan(&["package.json"]), [Generator::Npm]);
|
||||
assert_eq!(plan(&["pyproject.toml"]), [Generator::PipCompile]);
|
||||
// A project another manager already pinned is never re-resolved:
|
||||
// a second resolution would report versions it does not ship.
|
||||
assert!(plan(&["pyproject.toml", "uv.lock"]).is_empty());
|
||||
assert!(plan(&["package.json", "bun.lockb"]).is_empty());
|
||||
assert!(plan(&["package.json", "pnpm-lock.yaml"]).is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn the_default_policy_resolves_nothing() {
|
||||
// Manifests that name dependencies but pin none: under the default
|
||||
// policy no resolver may run, so no lockfile appears (#330).
|
||||
let tree = Tree::new(&["Cargo.toml", "package.json", "pyproject.toml"]);
|
||||
std::fs::write(
|
||||
tree.0.join("package.json"),
|
||||
r#"{"name":"t","version":"1.0.0","dependencies":{"x":"http://127.0.0.1:9/x.tgz"}}"#,
|
||||
)
|
||||
.expect("write package.json");
|
||||
generate_lockfiles(&tree.0, ExecPolicy::default()).await;
|
||||
for lock in ["Cargo.lock", "package-lock.json", "requirements.txt"] {
|
||||
assert!(!tree.0.join(lock).exists(), "{lock} was generated");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_tree_without_manifests_reports_nothing() {
|
||||
assert!(names(&Tree::new(&["README.md"])).is_empty());
|
||||
|
||||
@@ -12,6 +12,19 @@
|
||||
//! `setup.py`;
|
||||
//! * the firmware reproducible build shells out to Nix with `sandbox = false`.
|
||||
//!
|
||||
//! A second kind of stage runs nothing of the tenant's but lets the tenant choose
|
||||
//! **where the scanner connects**. Dependency resolvers fetch whatever the
|
||||
//! manifest names — a URL dependency in `package.json`, a git dependency in
|
||||
//! `Cargo.toml`, a registry in a committed `.npmrc` — so resolving a tenant's
|
||||
//! manifest is egress to hosts the tenant picks, outside `net_guard` (#330):
|
||||
//!
|
||||
//! * `npm install --package-lock-only` and `cargo generate-lockfile`, which
|
||||
//! create a lockfile the repository did not commit;
|
||||
//! * `cargo metadata`, which downloads every dependency to read its licence.
|
||||
//!
|
||||
//! The same policy gates both kinds: the question in each case is whether this
|
||||
//! deployment is a boundary a tenant may act across.
|
||||
//!
|
||||
//! Scanning hostile code is the product's whole job, so those stages are off
|
||||
//! wherever a deployment holds more than one tenant's data, and the findings
|
||||
//! they produced (lint quality warnings, a firmware build SBOM) are worth less
|
||||
@@ -71,6 +84,16 @@ impl ExecPolicy {
|
||||
self.allow_untrusted_code
|
||||
}
|
||||
|
||||
/// The line to log when a dependency resolver is skipped: it would fetch from
|
||||
/// hosts the scanned repository names.
|
||||
pub fn resolution_skip_reason(self, tool: &str) -> String {
|
||||
format!(
|
||||
"{tool} fetches from hosts the scanned repository names (registries, URL and git \
|
||||
dependencies) and is disabled in this deployment (set PW_ALLOW_UNTRUSTED_CODE_EXEC=1 \
|
||||
on a single-tenant or sandboxed deployment to enable it)"
|
||||
)
|
||||
}
|
||||
|
||||
/// The line to log when a stage is skipped, naming what to do instead.
|
||||
pub fn skip_reason(self, stage: &str) -> String {
|
||||
format!(
|
||||
@@ -92,6 +115,14 @@ mod tests {
|
||||
assert!(ExecPolicy::allow_untrusted_code().untrusted_code_allowed());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_resolution_skip_reason_says_why_it_is_not_code_execution() {
|
||||
let r = ExecPolicy::trusted_only().resolution_skip_reason("npm install");
|
||||
assert!(r.starts_with("npm install "), "{r}");
|
||||
assert!(r.contains("hosts the scanned repository names"), "{r}");
|
||||
assert!(r.contains("PW_ALLOW_UNTRUSTED_CODE_EXEC"), "{r}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_skip_reason_names_the_stage_and_the_escape_hatch() {
|
||||
let r = ExecPolicy::trusted_only().skip_reason("clippy");
|
||||
|
||||
+31
-8
@@ -101,8 +101,9 @@ platform's own services.
|
||||
## What the scanner runs on your code
|
||||
|
||||
Nearly every stage only *reads* your code: Semgrep, gitleaks, Syft, Ruff and the
|
||||
PLC parser parse files and never execute them. Four stages are different, because
|
||||
the tool has to run the project to do its job:
|
||||
PLC parser parse files and never execute them, and they connect nowhere your
|
||||
repository chooses. Two kinds of stage are different. Four have to run the
|
||||
project to do their job:
|
||||
|
||||
| Stage | What it executes |
|
||||
|---|---|
|
||||
@@ -111,12 +112,34 @@ the tool has to run the project to do its job:
|
||||
| `pip-compile` | builds source distributions to read their metadata, running `setup.py` |
|
||||
| Firmware reproducible build | the project's build system, through Nix |
|
||||
|
||||
In a shared deployment those stages are **off**: the scanner holds many
|
||||
tenants' data, and a lint warning is worth less than the blast radius of
|
||||
running a stranger's build. Lockfile-based dependency resolution still happens —
|
||||
npm runs with `--ignore-scripts`, and `cargo generate-lockfile` and
|
||||
`cargo metadata` resolve without compiling — so your SBOM is unaffected. For a
|
||||
complete firmware SBOM, build with Firmwerk on your side and import the bundle.
|
||||
Three more run nothing of yours, but fetch from whatever hosts your manifests
|
||||
name — a registry in a committed `.npmrc`, a URL dependency in `package.json`,
|
||||
a git dependency in `Cargo.toml`:
|
||||
|
||||
| Stage | What it fetches |
|
||||
|---|---|
|
||||
| `npm install --package-lock-only` | every dependency `package.json` names, to write a missing lockfile |
|
||||
| `cargo generate-lockfile` | every dependency `Cargo.toml` names, to write a missing `Cargo.lock` |
|
||||
| `cargo metadata` | every dependency's sources, to read its licence |
|
||||
|
||||
In a shared deployment all of these stages are **off**: the scanner holds many
|
||||
tenants' data, and a lint warning or a generated lockfile is worth less than the
|
||||
blast radius of running a stranger's build or connecting where a stranger
|
||||
chooses.
|
||||
|
||||
**Commit your lockfile.** The SBOM is built from `package-lock.json`,
|
||||
`yarn.lock`, `pnpm-lock.yaml`, `bun.lock`, `Cargo.lock`, `requirements.txt`,
|
||||
`poetry.lock`, `Pipfile.lock` or `uv.lock`. A manifest without one gets no
|
||||
dependency versions, and the scan run records a skipped `sbom_dependencies`
|
||||
stage naming the file to commit. Bun's binary `bun.lockb` cannot be read;
|
||||
commit the text `bun.lock` (`bun install --save-text-lockfile`).
|
||||
|
||||
`cargo audit` still runs over a committed `Cargo.lock`. It reads configuration
|
||||
from the directory it runs in, so it runs from an empty one: a committed
|
||||
`.cargo/audit.toml` can neither point it at another advisory database nor
|
||||
silence advisories.
|
||||
|
||||
For a complete firmware SBOM, build with Firmwerk on your side and import the bundle.
|
||||
|
||||
A single-tenant or sandboxed deployment can turn them on with
|
||||
`PW_ALLOW_UNTRUSTED_CODE_EXEC=1`; a hardened deployment ignores it. The stages
|
||||
|
||||
@@ -1,25 +1,15 @@
|
||||
{
|
||||
"scan_status": "completed",
|
||||
"skipped_stages": [],
|
||||
"sbom": [
|
||||
"npm:checkout-no-lockfile@2.1.0",
|
||||
"npm:lodash@4.17.20",
|
||||
"npm:minimist@1.2.0"
|
||||
"skipped_stages": [
|
||||
"sbom_dependencies"
|
||||
],
|
||||
"sbom": [],
|
||||
"findings": [
|
||||
"gitleaks:generic-api-key session.ts:8",
|
||||
"gitleaks:npm-access-token .env.local:3",
|
||||
"gitleaks:stripe-access-token .env.local:2"
|
||||
],
|
||||
"cves": [
|
||||
"GHSA-29mw-wpgm-hmr9",
|
||||
"GHSA-35jh-r3h4-6jhm",
|
||||
"GHSA-f23m-r3pf-42rh",
|
||||
"GHSA-r5fr-rjxr-66jc",
|
||||
"GHSA-vh95-rmgr-6w4m",
|
||||
"GHSA-xvch-5gv4-984h",
|
||||
"GHSA-xxjr-mmjv-4gpg"
|
||||
],
|
||||
"cves": [],
|
||||
"registry_rules": [
|
||||
"generic.secrets.security.detected-generic-secret.detected-generic-secret",
|
||||
"generic.secrets.security.detected-stripe-api-key.detected-stripe-api-key"
|
||||
|
||||
@@ -11,7 +11,7 @@ shipping an SBOM that is missing dependencies.
|
||||
| `js-yarn-classic` | `yarn.lock` v1 | 3 npm components |
|
||||
| `js-yarn-berry` | `yarn.lock` with `__metadata` + `npm:` resolutions | 3 npm components |
|
||||
| `js-pnpm` | `pnpm-lock.yaml` v9 | 3 npm components |
|
||||
| `js-no-lockfile` | nothing — npm resolves one for the SBOM | 3 npm components |
|
||||
| `js-no-lockfile` | nothing — records a skipped `sbom_dependencies` stage | none |
|
||||
| `js-bun` | `bun.lock` (Bun's text lockfile, default since 1.2) | 3 npm components |
|
||||
| `js-bun-binary` | `bun.lockb` only — Bun's binary lockfile, unreadable | none; a recorded `sbom_dependencies` skip |
|
||||
| `py-requirements` | `requirements.txt` exact pins | 4 pip components |
|
||||
@@ -52,13 +52,12 @@ only by `bun.lockb` records why its dependencies were not read and that the text
|
||||
|
||||
## The two without a lockfile
|
||||
|
||||
They are not the same case, and the difference is the point:
|
||||
`js-no-lockfile` and `py-bare-pyproject` both record a skipped
|
||||
`sbom_dependencies` stage naming the lockfiles to commit, instead of returning
|
||||
an empty SBOM that looks complete.
|
||||
|
||||
- **npm** resolves a lockfile itself, so `js-no-lockfile` still gets an SBOM. Its
|
||||
dependencies are dependency-free and exactly pinned, so that resolution is the
|
||||
same every night. (That resolution reads registry configuration out of the
|
||||
scanned repository — see #330.)
|
||||
- **Python** resolution would run the project's own build backend, which this
|
||||
deployment does not do, so `py-bare-pyproject` records a skipped
|
||||
`sbom_dependencies` stage naming the lockfiles to commit instead of returning
|
||||
an empty SBOM that looks complete.
|
||||
Generating a lockfile is off in a shared deployment (#330). pip-compile runs
|
||||
the project's own build backend. npm and cargo run nothing of the project's,
|
||||
but fetch from whatever hosts the manifest names — a URL dependency in
|
||||
`package.json` is fetched even with no `.npmrc` and the registry forced — so
|
||||
resolving a tenant's manifest is egress to hosts the tenant picks.
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "checkout-no-lockfile",
|
||||
"version": "2.1.0",
|
||||
"private": true,
|
||||
"description": "No lockfile committed: npm resolves one for the SBOM. Dependency-free pins keep that resolution deterministic.",
|
||||
"description": "No lockfile committed: the SBOM stage records sbom_dependencies as skipped rather than resolving one (#330).",
|
||||
"dependencies": {
|
||||
"lodash": "4.17.20",
|
||||
"minimist": "1.2.0"
|
||||
|
||||
@@ -353,7 +353,7 @@
|
||||
"key": "js-no-lockfile",
|
||||
"name": "JavaScript/TypeScript · no lockfile",
|
||||
"target_type": "web_app",
|
||||
"description": "Uploaded as a source archive. package.json alone: nothing pins the versions, and generating a lockfile runs the project's code, which this deployment does not. Plants a vulnerable pinned dependency, a SAST sink, a committed secret and OAuth/PII patterns.",
|
||||
"description": "Uploaded as a source archive. package.json alone: nothing pins the versions, and resolving the manifest would fetch from hosts it names, which a shared deployment does not do (#330), so the run records a skipped sbom_dependencies stage. Plants a vulnerable pinned dependency, a SAST sink, a committed secret and OAuth/PII patterns.",
|
||||
"artifacts": [
|
||||
{
|
||||
"kind": "source_archive",
|
||||
|
||||
Reference in new issue
Block a user