From 360418fd5be1245db190c5db821235d5379834f3 Mon Sep 17 00:00:00 2001 From: prabhu Date: Mon, 29 Jan 2024 10:54:32 +0000 Subject: [PATCH 1/2] dotnet dependency tree was getting lost without the type (#845) Signed-off-by: Prabhu Subramanian --- index.js | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 6dc6bfbb0..a9ae96f11 100644 --- a/index.js +++ b/index.js @@ -4280,14 +4280,11 @@ export const createRubyBom = async (path, options) => { * @param path to the project * @param options Parse options from the cli */ -export const createCsharpBom = async ( - path, - options, - parentComponent = undefined -) => { +export const createCsharpBom = async (path, options) => { let manifestFiles = []; let pkgData = undefined; let dependencies = []; + let parentComponent = createDefaultParentComponent(path, "nuget", options); let csProjFiles = getAllFiles( path, (options.multiProject ? "**/" : "") + "*.csproj", @@ -4352,7 +4349,7 @@ export const createCsharpBom = async ( pkgList = pkgList.concat(dlist); } if (deps && deps.length) { - dependencies = dependencies.concat(deps); + dependencies = mergeDependencies(dependencies, deps, parentComponent); } } } else if (pkgLockFiles.length) { @@ -4372,14 +4369,7 @@ export const createCsharpBom = async ( pkgList = pkgList.concat(dlist); } if (deps && deps.length) { - dependencies = dependencies.concat(deps); - } - if (!parentComponent) { - parentComponent = createDefaultParentComponent( - path, - options.type, - options - ); + dependencies = mergeDependencies(dependencies, deps, parentComponent); } // Keep track of the direct dependencies so that we can construct one complete // list after processing all lock files @@ -4443,15 +4433,11 @@ export const createCsharpBom = async ( pkgList = pkgList.concat(dlist); } if (deps && deps.length) { - dependencies = dependencies.concat(deps); + dependencies = mergeDependencies(dependencies, deps, parentComponent); } } } - if (!parentComponent) { - parentComponent = createDefaultParentComponent(path, options.type, options); - } if (pkgList.length) { - dependencies = mergeDependencies(dependencies, [], parentComponent); pkgList = trimComponents(pkgList, "json"); // Perform deep analysis using dosai if (options.deep) { @@ -4475,7 +4461,6 @@ export const createCsharpBom = async ( if (retMap.dependencies && retMap.dependencies.length) { dependencies = dependencies.concat(retMap.dependencies); } - dependencies = mergeDependencies(dependencies, [], parentComponent); pkgList = trimComponents(pkgList, "json"); } return buildBomNSData(options, pkgList, "nuget", { @@ -4833,7 +4818,7 @@ export const createMultiXBom = async (pathList, options) => { listComponents(options, {}, bomData.bomJson.components, "gem", "xml") ); } - bomData = await createCsharpBom(path, options, parentComponent); + bomData = await createCsharpBom(path, options); if ( bomData && bomData.bomJson && From 7d8e5be24113da9d45ea0cf68cab90f610644e9b Mon Sep 17 00:00:00 2001 From: prabhu Date: Mon, 29 Jan 2024 11:57:23 +0000 Subject: [PATCH 2/2] Fixes #848 (#849) Signed-off-by: Prabhu Subramanian --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a9ae96f11..021a04141 100644 --- a/index.js +++ b/index.js @@ -4459,7 +4459,11 @@ export const createCsharpBom = async (path, options) => { if (FETCH_LICENSE) { const retMap = await getNugetMetadata(pkgList, dependencies); if (retMap.dependencies && retMap.dependencies.length) { - dependencies = dependencies.concat(retMap.dependencies); + dependencies = mergeDependencies( + dependencies, + retMap.dependencies, + parentComponent + ); } pkgList = trimComponents(pkgList, "json"); }