snyk-to-html
Advanced tools
Comparing version 2.2.2 to 2.3.0
@@ -14,2 +14,3 @@ #!/usr/bin/env node | ||
const vuln_1 = require("./vuln"); | ||
const codeutil_1 = require("./codeutil"); | ||
const debug = debugModule('snyk-to-html'); | ||
@@ -69,2 +70,9 @@ const defaultRemediationText = '## Remediation\nThere is no remediation at the moment'; | ||
} | ||
else if ((data === null || data === void 0 ? void 0 : data.runs) && (data === null || data === void 0 ? void 0 : data.runs[0].tool.driver.name) === 'SnykCode') { | ||
template = | ||
template === path.join(__dirname, '../../template/test-report.hbs') | ||
? path.join(__dirname, '../../template/code/test-report.hbs') | ||
: template; | ||
return processCodeData(data, template, summary); | ||
} | ||
else { | ||
@@ -185,2 +193,12 @@ return processData(data, remediation, template, summary); | ||
} | ||
async function generateCodeTemplate(data, template) { | ||
await registerPeerPartial(template, 'inline-css'); | ||
await registerPeerPartial(template, 'inline-js'); | ||
await registerPeerPartial(template, 'header'); | ||
await registerPeerPartial(template, 'metatable-css'); | ||
await registerPeerPartial(template, 'metatable'); | ||
await registerPeerPartial(template, 'code-snip'); | ||
const htmlTemplate = await compileTemplate(template); | ||
return htmlTemplate(data); | ||
} | ||
function mergeData(dataArray) { | ||
@@ -230,2 +248,16 @@ const vulnsArrays = dataArray.map(project => project.vulnerabilities || []); | ||
} | ||
async function processCodeData(data, template, summary) { | ||
if (data.error) { | ||
return generateCodeTemplate(data, template); | ||
} | ||
const dataArray = Array.isArray(data) ? data : [data]; | ||
const OrderedIssuesArray = await codeutil_1.processSourceCode(dataArray); | ||
const totalIssues = dataArray[0].runs[0].results.length; | ||
const processedData = { | ||
projects: OrderedIssuesArray, | ||
showSummaryOnly: summary, | ||
totalIssues, | ||
}; | ||
return generateCodeTemplate(processedData, template); | ||
} | ||
async function readInputFromStdin() { | ||
@@ -232,0 +264,0 @@ return new Promise((resolve, reject) => { |
@@ -68,3 +68,3 @@ { | ||
}, | ||
"version": "2.2.2" | ||
"version": "2.3.0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
168135
43
635
4