Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain multiple SrcFile and identity evidences #1484

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,22 @@
pkg.evidence.identity &&
!Array.isArray(pkg.evidence.identity)
) {
// Automatically add concludedValue
if (pkg.evidence.identity?.methods?.length === 1) {
pkg.evidence.identity.concludedValue =
pkg.evidence.identity.methods[0].value;
}
component.evidence.identity = [pkg.evidence.identity];
}
// Convert evidence.identity section to an object for 1.5
if (
options.specVersion === 1.5 &&
pkg.evidence &&
pkg.evidence.identity &&
Array.isArray(pkg.evidence.identity)
) {
component.evidence.identity = pkg.evidence.identity[0];
}
}
// Upgrade authors section
if (options.specVersion >= 1.6 && component.author) {
Expand Down Expand Up @@ -4947,6 +4961,7 @@
const retMap = parseComposerLock(f, rootRequires);
if (retMap.pkgList?.length) {
pkgList = pkgList.concat(retMap.pkgList);
pkgList = trimComponents(pkgList);
}
if (retMap.dependenciesList) {
if (moduleParent?.["bom-ref"]) {
Expand Down Expand Up @@ -5598,6 +5613,43 @@
existingComponent.properties = comp.properties;
}
}
// Retain all component.evidence.identity
if (comp?.evidence?.identity) {
if (!existingComponent.evidence) {
existingComponent.evidence = { identity: [] };
Dismissed Show dismissed Hide dismissed
} else if (
existingComponent?.evidence?.identity &&
!Array.isArray(existingComponent.evidence.identity)
) {
existingComponent.evidence.identity = [
existingComponent.evidence.identity,
];
}
// comp.evidence.identity can be an array or object
// Merge the evidence.identity based on methods or objects
const identities = Array.isArray(comp.evidence.identity)
? comp.evidence.identity
: [comp.evidence.identity];
for (const aident of identities) {
let methodBasedMerge = false;
if (aident?.methods?.length) {
for (const amethod of aident.methods) {
for (const existIdent of existingComponent.evidence.identity) {
if (existIdent.field === aident.field) {
if (!existIdent.methods) {
existIdent.methods = [];
}
existIdent.methods.push(amethod);
methodBasedMerge = true;
}
}
}
}
if (!methodBasedMerge && aident.field && aident.confidence) {
existingComponent.evidence.identity.push(aident);
}
}
}
// If the component is required in any of the child projects, then make it required
if (
existingComponent?.scope !== "required" &&
Expand Down
2 changes: 1 addition & 1 deletion types/lib/cli/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading