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 parent group and component across sub-projects. Fixes #474 again #481

Merged
merged 6 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 14 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,17 @@ function addMetadata(parentComponent = {}, format = "xml", options = {}) {
delete comp.evidence;
delete comp._integrity;
delete comp.license;
if (!comp["bom-ref"] && comp.name && comp.type) {
if (comp.name && comp.type) {
let fullName = componentToSimpleFullName(comp);
// Fixes #479
// Prevent the parent component from also appearing as a sub-component
// We cannot use purl or bom-ref here since they would not match
// purl - could have application on one side and a different type
// bom-ref could have qualifiers on one side
if (fullName !== parentFullName) {
comp["bom-ref"] = `pkg:${comp.type}/${fullName}`;
if (!comp["bom-ref"]) {
comp["bom-ref"] = `pkg:${comp.type}/${fullName}`;
}
subComponents.push(comp);
}
}
Expand Down Expand Up @@ -1355,9 +1357,13 @@ export const createJavaBom = async (path, options) => {
};
const rootSubProjectPurl = new PackageURL(
"maven",
rootSubProjectObj.group || parentComponent.group || "",
rootSubProjectObj.group && rootSubProjectObj.group.length
? rootSubProjectObj.group
: parentComponent.group,
rootSubProjectObj.name,
rootSubProjectObj.version,
retMap.metadata.version && retMap.metadata.version !== "latest"
? retMap.metadata.version
: parentComponent.version,
rootSubProjectObj.qualifiers,
null
).toString();
Expand Down Expand Up @@ -1433,9 +1439,11 @@ export const createJavaBom = async (path, options) => {
const cmdOutput = Buffer.from(sstdout).toString();
const parsedList = parseGradleDep(
cmdOutput,
sp.group,
sp.group || parentComponent.group,
sp.name,
sp.version
sp.version && sp.version.length && sp.version !== "latest"
? sp.version
: parentComponent.version
);
const dlist = parsedList.pkgList;
if (parsedList.dependenciesList && parsedList.dependenciesList) {
Expand Down
Loading
Loading