Skip to content

Commit

Permalink
feat: add audit configuration info to json report
Browse files Browse the repository at this point in the history
  • Loading branch information
gabidobo committed May 3, 2023
1 parent eb5064c commit 9faf902
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions src/cli/cmds/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,25 +180,7 @@ exports.handler = async (argv) => {
}
}

// *****************
// Perform the audit
// *****************
const {
dependencyGraph,
svgs,
csv,
dependencyVulnerabilities,
rootVulnerabilities,
licenseUsage,
licenseIssues,
metaIssues,
resolvedIssues,
resolvedIssuesAlerts,
resolvedIssuesCount,
name,
version,
errors,
} = await getReport({
const configuration = {
appPath,
includeDev:
typeof fileConfig.includeDev !== 'undefined' ? fileConfig.includeDev : argv.includeDev,
Expand Down Expand Up @@ -233,7 +215,27 @@ exports.handler = async (argv) => {
'csv',
].filter((o) => o),
onProgress: onProgress({ora}),
});
};

// *****************
// Perform the audit
// *****************
const {
dependencyGraph,
svgs,
csv,
dependencyVulnerabilities,
rootVulnerabilities,
licenseUsage,
licenseIssues,
metaIssues,
resolvedIssues,
resolvedIssuesAlerts,
resolvedIssuesCount,
name,
version,
errors,
} = await getReport(configuration);

// ********************
// Write output to disk
Expand Down Expand Up @@ -263,22 +265,24 @@ exports.handler = async (argv) => {
!(typeof fileConfig.skipReport !== 'undefined' ? !!fileConfig.skipReport : argv.skipReport);
if (shouldWriteReport) {
const {version: sandwormVersion} = await loadManifest(path.join(__dirname, '../../..'));
delete configuration.appPath;
const report = {
name,
version,
createdAt: Date.now(),
system: {
sandwormVersion,
nodeVersion: process.versions.node,
...(dependencyGraph.root.meta || {}),
},
name,
version,
configuration,
rootVulnerabilities,
dependencyVulnerabilities,
licenseUsage,
licenseIssues,
metaIssues,
resolvedIssues,
errors,
errors: errors.map((e) => e.message || e),
};
const reportOutputPath = path.join(outputPath, filenames.json);
await fs.writeFile(reportOutputPath, JSON.stringify(report, null, 2));
Expand Down

0 comments on commit 9faf902

Please sign in to comment.