-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use `PackageIdSpec` instead of only `PackageId` in SBOM output * change `version` of a dependency to `Option<Version>` * output `Vec<CrateType>` instead of only the first found crate type * output rustc workspace wrapper * update 'warning' string in test using `[WARNING]` * use `serde_json::to_writer` to serialize SBOM
- Loading branch information
Showing
3 changed files
with
52 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ fn build_sbom_without_passing_unstable_flag() { | |
.masquerade_as_nightly_cargo(&["sbom"]) | ||
.with_stderr( | ||
"\ | ||
warning: ignoring 'sbom' config, pass `-Zsbom` to enable it\n\ | ||
[WARNING] ignoring 'sbom' config, pass `-Zsbom` to enable it\n\ | ||
[COMPILING] foo v0.5.0 ([..])\n\ | ||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", | ||
) | ||
|
@@ -74,7 +74,9 @@ fn build_sbom_using_cargo_config() { | |
"kind": [ | ||
"bin" | ||
], | ||
"crate_type": "bin", | ||
"crate_types": [ | ||
"bin" | ||
], | ||
"name": "foo", | ||
"edition": "2015" | ||
}, | ||
|
@@ -100,6 +102,7 @@ fn build_sbom_using_cargo_config() { | |
"rustc": { | ||
"version": "[..]", | ||
"wrapper": null, | ||
"workspace_wrapper": null, | ||
"commit_hash": "[..]", | ||
"host": "[..]" | ||
} | ||
|
@@ -171,7 +174,10 @@ fn build_sbom_with_simple_build_script() { | |
.file("src/main.rs", "#[cfg(foo)] fn main() {}") | ||
.file( | ||
"build.rs", | ||
r#"fn main() { println!("cargo::rustc-cfg=foo"); }"#, | ||
r#"fn main() { | ||
println!("cargo::rustc-check-cfg=cfg(foo)"); | ||
println!("cargo::rustc-cfg=foo"); | ||
}"#, | ||
) | ||
.build(); | ||
|
||
|
@@ -187,15 +193,17 @@ fn build_sbom_with_simple_build_script() { | |
r#" | ||
{ | ||
"format_version": 1, | ||
"package_id": "path+file:///[..]/foo#0.0.1", | ||
"package_id": "path+file://[ROOT]/foo#0.0.1", | ||
"name": "foo", | ||
"version": "0.0.1", | ||
"source": "[ROOT]/foo", | ||
"target": { | ||
"kind": [ | ||
"bin" | ||
], | ||
"crate_type": "bin", | ||
"crate_types": [ | ||
"bin" | ||
], | ||
"name": "foo", | ||
"edition": "2015" | ||
}, | ||
|
@@ -223,18 +231,18 @@ fn build_sbom_with_simple_build_script() { | |
{ | ||
"features": [], | ||
"name": "foo", | ||
"package_id": "foo 0.0.1 (path+file:///[..]/foo)", | ||
"package_id": "path+file://[ROOT]/foo#0.0.1", | ||
"version": "0.0.1" | ||
} | ||
], | ||
"extern_crate_name": "build_script_build", | ||
"features": [], | ||
"package": "foo", | ||
"package_id": "foo 0.0.1 (path+file:///[..]/foo)", | ||
"package_id": "path+file://[ROOT]/foo#0.0.1", | ||
"version": "0.0.1" | ||
}, | ||
{ | ||
"package_id": "foo 0.0.1 (path+file:///[..]/foo)", | ||
"package_id": "path+file://[ROOT]/foo#0.0.1", | ||
"package": "foo", | ||
"version": "0.0.1", | ||
"features": [], | ||
|
@@ -247,6 +255,7 @@ fn build_sbom_with_simple_build_script() { | |
"rustc": { | ||
"version": "[..]", | ||
"wrapper": null, | ||
"workspace_wrapper": null, | ||
"commit_hash": "[..]", | ||
"host": "[..]" | ||
} | ||
|
@@ -274,7 +283,10 @@ fn build_sbom_with_build_dependencies() { | |
.file("src/lib.rs", "pub fn bar() -> i32 { 2 }") | ||
.file( | ||
"build.rs", | ||
r#"fn main() { println!("cargo::rustc-cfg=foo"); }"#, | ||
r#"fn main() { | ||
println!("cargo::rustc-check-cfg=cfg(foo)"); | ||
println!("cargo::rustc-cfg=foo"); | ||
}"#, | ||
) | ||
.publish(); | ||
|
||
|
@@ -312,7 +324,9 @@ fn build_sbom_with_build_dependencies() { | |
"kind": [ | ||
"bin" | ||
], | ||
"crate_type": "bin", | ||
"crate_types": [ | ||
"bin" | ||
], | ||
"name": "foo", | ||
"edition": "2015" | ||
}, | ||
|
@@ -335,7 +349,7 @@ fn build_sbom_with_build_dependencies() { | |
}, | ||
"packages": [ | ||
{ | ||
"package_id": "bar 0.1.0 (registry+[..])", | ||
"package_id": "registry+[..]#[email protected]", | ||
"package": "bar", | ||
"version": "0.1.0", | ||
"features": [], | ||
|
@@ -344,14 +358,14 @@ fn build_sbom_with_build_dependencies() { | |
"dependencies": [ | ||
{ | ||
"name": "bar", | ||
"package_id": "bar 0.1.0 (registry+[..])", | ||
"package_id": "registry+[..]#[email protected]", | ||
"version": "0.1.0", | ||
"features": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"package_id": "bar 0.1.0 (registry+[..])", | ||
"package_id": "registry+[..]#[email protected]", | ||
"package": "bar", | ||
"version": "0.1.0", | ||
"features": [], | ||
|
@@ -360,14 +374,14 @@ fn build_sbom_with_build_dependencies() { | |
"dependencies": [ | ||
{ | ||
"name": "bar", | ||
"package_id": "bar 0.1.0 (registry+[..])", | ||
"package_id": "registry+[..]#[email protected]", | ||
"version": "0.1.0", | ||
"features": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"package_id": "bar 0.1.0 (registry+[..])", | ||
"package_id": "registry+[..]#[email protected]", | ||
"package": "bar", | ||
"version": "0.1.0", | ||
"features": [], | ||
|
@@ -376,14 +390,14 @@ fn build_sbom_with_build_dependencies() { | |
"dependencies": [ | ||
{ | ||
"name": "baz", | ||
"package_id": "baz 0.1.0 (registry+[..])", | ||
"package_id": "registry+[..]#[email protected]", | ||
"version": "0.1.0", | ||
"features": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"package_id": "baz 0.1.0 (registry+[..])", | ||
"package_id": "registry+[..]#[email protected]", | ||
"package": "baz", | ||
"version": "0.1.0", | ||
"features": [], | ||
|
@@ -396,6 +410,7 @@ fn build_sbom_with_build_dependencies() { | |
"rustc": { | ||
"version": "[..]", | ||
"wrapper": null, | ||
"workspace_wrapper": null, | ||
"commit_hash": "[..]", | ||
"host": "[..]" | ||
} | ||
|