mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 15:33:56 +08:00
test(cyclonedx): share Rust report fixture (#17312)
This commit is contained in:
@@ -108,12 +108,7 @@ const projectGo = (report: GoBinary) => {
|
||||
return result.value;
|
||||
};
|
||||
|
||||
const rustMetadata = (
|
||||
packages: NonNullable<RustBinary["auditable_metadata"]>["packages"],
|
||||
edges: NonNullable<RustBinary["auditable_metadata"]>["dependency_edges"],
|
||||
cycles: number[],
|
||||
root: number | null,
|
||||
) =>
|
||||
const rustReport = (auditableMetadata: RustBinary["auditable_metadata"]) =>
|
||||
rustBinarySchema.parse({
|
||||
artifact: {
|
||||
path: "/artifacts/rustapp",
|
||||
@@ -127,18 +122,26 @@ const rustMetadata = (
|
||||
byte_order: "little",
|
||||
limitations: [],
|
||||
rustc_commit: null,
|
||||
auditable_metadata: {
|
||||
section_name: ".dep-v0",
|
||||
file_offset: 32,
|
||||
section_bytes: 64,
|
||||
compressed_bytes: 64,
|
||||
uncompressed_bytes: 128,
|
||||
format_version: 1,
|
||||
packages,
|
||||
root_package_index: root,
|
||||
dependency_edges: edges,
|
||||
cyclic_dependency_indices: cycles,
|
||||
},
|
||||
auditable_metadata: auditableMetadata,
|
||||
});
|
||||
|
||||
const rustMetadata = (
|
||||
packages: NonNullable<RustBinary["auditable_metadata"]>["packages"],
|
||||
edges: NonNullable<RustBinary["auditable_metadata"]>["dependency_edges"],
|
||||
cycles: number[],
|
||||
root: number | null,
|
||||
) =>
|
||||
rustReport({
|
||||
section_name: ".dep-v0",
|
||||
file_offset: 32,
|
||||
section_bytes: 64,
|
||||
compressed_bytes: 64,
|
||||
uncompressed_bytes: 128,
|
||||
format_version: 1,
|
||||
packages,
|
||||
root_package_index: root,
|
||||
dependency_edges: edges,
|
||||
cyclic_dependency_indices: cycles,
|
||||
});
|
||||
|
||||
const refusedAllowance = (operation: string, report: unknown) => {
|
||||
@@ -852,21 +855,7 @@ it("links the binary to its recorded Rust root and leaves a null root unknown",
|
||||
});
|
||||
|
||||
it("keeps missing Rust metadata unknown instead of an empty inventory", () => {
|
||||
const report = rustBinarySchema.parse({
|
||||
artifact: {
|
||||
path: "/artifacts/rustapp",
|
||||
file_name: "rustapp",
|
||||
sha256: SHA,
|
||||
bytes: 512,
|
||||
},
|
||||
format: "elf",
|
||||
architecture: "amd64",
|
||||
bits: 64,
|
||||
byte_order: "little",
|
||||
limitations: [],
|
||||
rustc_commit: null,
|
||||
auditable_metadata: null,
|
||||
});
|
||||
const report = rustReport(null);
|
||||
const view = projectRust(report);
|
||||
expect(view.unknowns).toEqual(
|
||||
expect.arrayContaining([...rustBinaryUnknowns(report).values]),
|
||||
|
||||
Reference in New Issue
Block a user