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

fix: eliminate test dependencies before creating stack analysis sbom #47

Merged
merged 2 commits into from
Sep 6, 2023
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
4 changes: 4 additions & 0 deletions src/cyclone_dx_sbom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {EOL} from "os";
import {PackageURL} from "packageurl-js";

/**
Expand Down Expand Up @@ -134,6 +135,9 @@ export default class CycloneDxSbom {
"components" : this.components,
"dependencies" : this.dependencies
}
if(process.env["EXHORT_DEBUG"] === "true") {
console.log("SBOM Generated for manifest, to be sent to exhort service:" + EOL + JSON.stringify(this.sbomObject, null, 4))
}
return JSON.stringify(this.sbomObject)
}

Expand Down
5 changes: 4 additions & 1 deletion src/providers/java_maven.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function createSbomStackAnalysis(manifest, opts = {}) {
let tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'exhort_'))
let tmpDepTree = path.join(tmpDir, 'mvn_deptree.txt')
// build initial command (dot outputType is not available for verbose mode)
let depTreeCmd = `${mvn} -q org.apache.maven.plugins:maven-dependency-plugin:3.6.0:tree -Dverbose -DoutputType=text -DoutputFile=${tmpDepTree} -f ${manifest}`
let depTreeCmd = `${mvn} -q org.apache.maven.plugins:maven-dependency-plugin:3.6.0:tree -Dverbose -DoutputType=text -Dscope=compile -Dscope=runtime -DoutputFile=${tmpDepTree} -f ${manifest}`
// exclude ignored dependencies, exclude format is groupId:artifactId:scope:version.
// version and scope are marked as '*' if not specified (we do not use scope yet)
let ignoredDeps = new Array()
Expand All @@ -192,6 +192,9 @@ function createSbomStackAnalysis(manifest, opts = {}) {
})
// read dependency tree from temp file
let content= fs.readFileSync(`${tmpDepTree}`)
if(process.env["EXHORT_DEBUG"] === "true") {
console.log("Dependency tree that will be used as input for creating the BOM =>" + EOL + EOL + content.toString())
}
let sbom = createSbomFileFromTextFormat(content.toString(),ignoredDeps);
// delete temp file and directory
fs.rmSync(tmpDir, {recursive: true, force: true})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@
"dependsOn": []
}
]
}
}
Loading