Socket
Socket
Sign inDemoInstall

snyk-to-html

Package Overview
Dependencies
20
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.7.4 to 1.8.0

7

dist/index.js

@@ -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) {

28

dist/lib/snyk-to-html.js

@@ -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 @@ });

5

package.json

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc