-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(workflows): add standalone SBOM diffing script for local testing
related to camunda/camunda-bpm-platform#2781
- Loading branch information
1 parent
0bc9a6d
commit 583276c
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbom-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const diffSBOMs = require('./src/sbom-diff/differ.js'); | ||
const formatTemplate = require('./src/sbom-diff/format-handlebars-template.js'); | ||
const fs = require('fs'); | ||
|
||
const readFile = function(path) { | ||
return fs.readFileSync(path, 'utf8') | ||
} | ||
|
||
const writeFile = function(path, content) { | ||
fs.writeFileSync(path, content); // default encoding is utf8 | ||
} | ||
|
||
var args = process.argv.slice(2); // first two arguments are the executable and the JS file | ||
|
||
if (args.length != 3) { | ||
throw new Error('Requires three arguments: <path to base SBOM> <path to comparing SBOM> <path to output file>'); | ||
} | ||
|
||
const baseSbomPath = args[0]; | ||
const headSbomPath = args[1]; | ||
const outPath = args[2]; | ||
|
||
const baseSbom = readFile(baseSbomPath); | ||
const headSbom = readFile(headSbomPath); | ||
|
||
const licenseList = readFile('../java-dependency-check/licenses.json'); | ||
|
||
const commentTemplate = readFile('../java-dependency-check/diff.hbs'); | ||
|
||
const partialPaths = [ | ||
'componentDetails:../java-dependency-check/component-details.hbs', | ||
'componentDiff:../java-dependency-check/component-diff.hbs', | ||
'componentTree:../java-dependency-check/component-tree.hbs', | ||
'componentVersion:../java-dependency-check/component-version.hbs' | ||
]; | ||
|
||
const partials = partialPaths.reduce( | ||
(result, input) => { | ||
[ partialId, partialPath ] = input.split(':'); | ||
result[partialId.trim()] = readFile(partialPath.trim()); | ||
return result; | ||
}, | ||
{} | ||
); | ||
|
||
diffSBOMs(baseSbom, headSbom, '^org\\.camunda', licenseList) | ||
.then(rootComponentDiff => formatTemplate(rootComponentDiff, commentTemplate, partials) | ||
.then(diff => writeFile(outPath, diff.fullDiff))); | ||
|
||
|