Socket
Socket
Sign inDemoInstall

snyk-to-html

Package Overview
Dependencies
11
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.1 to 1.7.0

23

dist/index.js
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const program = require("commander");
const fs = require("fs");
const minimist = require("minimist");
const path = require("path");
const snyk_to_html_1 = require("./lib/snyk-to-html");
const argv = minimist(process.argv.slice(2));
program
.option('-t, --template <path>', 'Template location for generating the html. Defaults to template/test-report.hbs')
.option('-i, --input <path>', 'Input path from where to read the json. Defaults to stdin')
.option('-o, --output <path>', 'Output of the resulting HTML. Example: -o snyk.html. Defaults to stdout')
.option('-s, --summary', 'Generates an HTML with only the summary, instead of the details report')
.parse(process.argv);
let template;
let source;
let output;
if (argv.t) { // template
template = argv.t; // grab the next item
if (program.template) { // template
template = program.template; // grab the next item
if (typeof template === 'boolean') {

@@ -21,4 +26,4 @@ template = path.join(__dirname, '../template/test-report.hbs');

}
if (argv.i) { // input source
source = argv.i; // grab the next item
if (program.input) { // input source
source = program.input; // grab the next item
if (typeof source === 'boolean') {

@@ -28,4 +33,4 @@ source = undefined;

}
if (argv.o) { // output destination
output = argv.o; // grab the next item
if (program.output) { // output destination
output = program.output; // grab the next item
if (typeof output === 'boolean') {

@@ -35,3 +40,3 @@ output = undefined;

}
snyk_to_html_1.SnykToHtml.run(source, template, onReportOutput);
snyk_to_html_1.SnykToHtml.run(source, template, !!program.summary, onReportOutput);
function onReportOutput(report) {

@@ -38,0 +43,0 @@ if (output) {

#!/usr/bin/env node
declare class SnykToHtml {
static run(dataSource: string, hbsTemplate: string, reportCallback: (value: string) => void): void;
static runAsync(source: string, template: string): Promise<string>;
static run(dataSource: string, hbsTemplate: string, summary: boolean, reportCallback: (value: string) => void): void;
static runAsync(source: string, template: string, summary: boolean): Promise<string>;
}
export { SnykToHtml };

@@ -19,2 +19,3 @@ #!/usr/bin/env node

const severityMap = { low: 0, medium: 1, high: 2 };
const defaultRemediationText = '## Remediation\nThere is no remediation at the moment';
function readFile(filePath, encoding) {

@@ -31,15 +32,14 @@ return new Promise((resolve, reject) => {

class SnykToHtml {
static run(dataSource, hbsTemplate, reportCallback) {
static run(dataSource, hbsTemplate, summary, reportCallback) {
SnykToHtml
.runAsync(dataSource, hbsTemplate)
.runAsync(dataSource, hbsTemplate, summary)
.then(reportCallback)
.catch(console.log);
}
static runAsync(source, template) {
static runAsync(source, template, summary) {
return __awaiter(this, void 0, void 0, function* () {
const promisedString = source ? readFile(source, 'utf8') : readInputFromStdin();
const report = promisedString
return promisedString
.then(JSON.parse)
.then(data => processData(data, template));
return report;
.then(data => processData(data, template, summary));
});

@@ -58,2 +58,3 @@ }

description: vuln.description || 'No description available.',
fixedIn: vuln.fixedIn,
packageManager: vuln.packageManager,

@@ -98,3 +99,3 @@ };

}
function generateTemplate(data, template) {
function generateTemplate(data, template, summary) {
return __awaiter(this, void 0, void 0, function* () {

@@ -105,2 +106,3 @@ const vulnMetadata = groupVulns(data.vulnerabilities);

data.summary = vulnMetadata.vulnerabilitiesPathsCount + ' vulnerable dependency paths';
data.showSummaryOnly = summary;
yield registerPeerPartial(template, 'inline-css');

@@ -126,6 +128,6 @@ yield registerPeerPartial(template, 'vuln-card');

}
function processData(data, template) {
function processData(data, template, summary) {
return __awaiter(this, void 0, void 0, function* () {
const mergedData = Array.isArray(data) ? mergeData(data) : data;
return generateTemplate(mergedData, template);
return generateTemplate(mergedData, template, summary);
});

@@ -182,4 +184,18 @@ }

},
getRemediation: function (description, fixedIn) {
// check remediation in the description
const index = description.indexOf('## Remediation');
if (index > -1) {
return marked(description.substring(index));
}
// if no remediation in description, try to check in `fixedIn` attribute
if (Array.isArray(fixedIn) && fixedIn.length) {
const fixedInJoined = fixedIn.join(', ');
return marked(`## Remediation\n Fixed in: ${fixedInJoined}`);
}
// otherwise, fallback to default message, i.e. No remediation at the moment
return marked(defaultRemediationText);
},
};
Object.keys(hh).forEach(k => Handlebars.registerHelper(k, hh[k]));
//# sourceMappingURL=snyk-to-html.js.map

@@ -23,5 +23,5 @@ {

"dependencies": {
"commander": "^4.1.0",
"handlebars": "^4.5.3",
"marked": "^0.7.0",
"minimist": "^1.2.0",
"moment": "^2.24.0",

@@ -36,3 +36,2 @@ "source-map-support": "^0.5.16"

"@types/marked": "^0.6.5",
"@types/minimist": "^1.2.0",
"@types/node": "^6.14.7",

@@ -57,3 +56,3 @@ "snyk": "^1.235.0",

},
"version": "1.6.1"
"version": "1.7.0"
}

@@ -18,2 +18,11 @@ [![Snyk logo](https://snyk.io/style/asset/logo/snyk-print.svg)](https://snyk.io)

## Options of the CLI
1. `-t` or `--template`- Template location for generating the html. Defaults to template/test-report.hbs
2. `-i` or `--input` - Input path from where to read the json. Defaults to stdin
3. `-o` or `--output` - Output of the resulting HTML. Example: -o snyk.html. Defaults to stdout
4. `-s` or `--summary` - Generates an HTML with only the summary, instead of the details report. Defaults to details vulnerability report
When in doubt, use `snyk-to-html --help` or `snyk-to-html -h`.
## Generate the HTML report

@@ -39,2 +48,9 @@

3. By default, details about each vulnerability is shown.
If you want a simpler version of the report to be shown, you can pass `-s` or `--summary` to only
display the summary of the report.
`snyk-to-html -i results.json -o results.html -s`
## View the HTML report

@@ -41,0 +57,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

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