Skip to content

Commit

Permalink
dependency tree for dotnet packages.lock.json (#830)
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu authored Jan 26, 2024
1 parent 7605c7f commit b690d69
Show file tree
Hide file tree
Showing 8 changed files with 654 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ cdxgen can retain the dependency tree under the `dependencies` attribute for a s
- Gradle
- Scala SBT
- Python (requirements.txt, setup.py, pyproject.toml, poetry.lock)
- .NET (project.assets.json, paket.lock)
- .NET (packages.lock.json, project.assets.json, paket.lock)
- Go (go.mod)
- PHP (composer.lock)

Expand Down
27 changes: 26 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4357,16 +4357,41 @@ export const createCsharpBom = async (
}
} else if (pkgLockFiles.length) {
manifestFiles = manifestFiles.concat(pkgLockFiles);
let parentDependsOn = [];
// packages.lock.json from nuget
for (const af of pkgLockFiles) {
if (DEBUG_MODE) {
console.log(`Parsing ${af}`);
}
pkgData = readFileSync(af, { encoding: "utf-8" });
const dlist = await parseCsPkgLockData(pkgData);
let results = await parseCsPkgLockData(pkgData, af);
let deps = results["dependenciesList"];
let dlist = results["pkgList"];
let rootList = results["rootList"];
if (dlist && dlist.length) {
pkgList = pkgList.concat(dlist);
}
if (deps && deps.length) {
dependencies = dependencies.concat(deps);
}
if (!parentComponent) {
parentComponent = createDefaultParentComponent(
path,
options.type,
options
);
}
// Keep track of the direct dependencies so that we can construct one complete
// list after processing all lock files
if (rootList && rootList.length) {
parentDependsOn = parentDependsOn.concat(rootList);
}
}
if (parentDependsOn.length) {
dependencies.splice(0, 0, {
ref: parentComponent["bom-ref"],
dependsOn: parentDependsOn.map((p) => p["bom-ref"])
});
}
} else if (pkgConfigFiles.length) {
manifestFiles = manifestFiles.concat(pkgConfigFiles);
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cyclonedx/cdxgen",
"version": "9.11.2",
"version": "9.11.3",
"description": "Creates CycloneDX Software Bill of Materials (SBOM) from source or container image",
"homepage": "http://github.com/cyclonedx/cdxgen",
"author": "Prabhu Subramanian <[email protected]>",
Expand Down Expand Up @@ -55,9 +55,9 @@
"url": "https://github.com/cyclonedx/cdxgen/issues"
},
"dependencies": {
"@babel/parser": "^7.23.6",
"@babel/traverse": "^7.23.7",
"@npmcli/arborist": "7.2.2",
"@babel/parser": "^7.23.9",
"@babel/traverse": "^7.23.9",
"@npmcli/arborist": "7.3.1",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"cheerio": "^1.0.0-rc.12",
Expand Down
Loading

0 comments on commit b690d69

Please sign in to comment.