snyk-to-html
Advanced tools
Comparing version 1.7.4 to 1.8.0
@@ -5,2 +5,3 @@ #!/usr/bin/env node | ||
const program = require("commander"); | ||
const debugModule = require("debug"); | ||
const fs = require("fs"); | ||
@@ -14,2 +15,3 @@ const path = require("path"); | ||
.option('-s, --summary', 'Generates an HTML with only the summary, instead of the details report') | ||
.option('-d, --debug', 'Runs the CLI in debug mode') | ||
.parse(process.argv); | ||
@@ -40,2 +42,7 @@ let template; | ||
} | ||
if (program.debug) { | ||
const nameSpace = 'snyk-to-html'; | ||
process.env.DEBUG = nameSpace; | ||
debugModule.enable(nameSpace); | ||
} | ||
snyk_to_html_1.SnykToHtml.run(source, template, !!program.summary, onReportOutput); | ||
@@ -42,0 +49,0 @@ function onReportOutput(report) { |
@@ -13,2 +13,4 @@ #!/usr/bin/env node | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = require("chalk"); | ||
const debugModule = require("debug"); | ||
const fs = require("fs"); | ||
@@ -19,2 +21,3 @@ const Handlebars = require("handlebars"); | ||
const path = require("path"); | ||
const debug = debugModule('snyk-to-html'); | ||
const severityMap = { low: 0, medium: 1, high: 2 }; | ||
@@ -32,2 +35,23 @@ const defaultRemediationText = '## Remediation\nThere is no remediation at the moment'; | ||
} | ||
function handleInvalidJson(reason) { | ||
if (reason.isInvalidJson) { | ||
reason.message = reason.message + 'Error running `snyk-to-html`. Please check you are providing the correct parameters. ' + | ||
'Is the issue persists contact support@snyk.io'; | ||
} | ||
console.log(reason.message); | ||
} | ||
function promisedParseJSON(json) { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
resolve(JSON.parse(json)); | ||
} | ||
catch (error) { | ||
error.message = chalk_1.default.red.bold('The source provided is not a valid json! Please validate that the input provided to the CLI is an actual JSON\n\n' + | ||
'Tip: To find more information, try running `snyk-to-html` in debug mode by appending to the CLI the `-d` parameter\n\n'); | ||
debug(`Input provided to the CLI: \n${json}\n\n`); | ||
error.isInvalidJson = true; | ||
reject(error); | ||
} | ||
}); | ||
} | ||
class SnykToHtml { | ||
@@ -38,3 +62,3 @@ static run(dataSource, hbsTemplate, summary, reportCallback) { | ||
.then(reportCallback) | ||
.catch(console.log); | ||
.catch(handleInvalidJson); | ||
} | ||
@@ -45,3 +69,3 @@ static runAsync(source, template, summary) { | ||
return promisedString | ||
.then(JSON.parse) | ||
.then(promisedParseJSON) | ||
.then(data => processData(data, template, summary)); | ||
@@ -48,0 +72,0 @@ }); |
@@ -23,3 +23,5 @@ { | ||
"dependencies": { | ||
"chalk": "^2.4.2", | ||
"commander": "^4.1.1", | ||
"debug": "^4.1.1", | ||
"handlebars": "^4.7.3", | ||
@@ -35,2 +37,3 @@ "marked": "^0.7.0", | ||
"devDependencies": { | ||
"@types/chalk": "^2.2.0", | ||
"@types/marked": "^0.6.5", | ||
@@ -56,3 +59,3 @@ "@types/node": "^6.14.7", | ||
}, | ||
"version": "1.7.4" | ||
"version": "1.8.0" | ||
} |
@@ -24,2 +24,3 @@ [![Snyk logo](https://snyk.io/style/asset/logo/snyk-print.svg)](https://snyk.io) | ||
4. `-s` or `--summary` - Generates an HTML with only the summary, instead of the details report. Defaults to details vulnerability report | ||
5. `-d` or `--debug` - Runs the CLI in debug mode | ||
@@ -26,0 +27,0 @@ When in doubt, use `snyk-to-html --help` or `snyk-to-html -h`. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
40543
283
63
7
8
3
+ Addedchalk@^2.4.2
+ Addeddebug@^4.1.1
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addeddebug@4.3.5(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedms@2.1.2(transitive)
+ Addedsupports-color@5.5.0(transitive)