Socket
Socket
Sign inDemoInstall

snyk-to-html

Package Overview
Dependencies
21
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

template/iac/test-report.hbs

56

dist/lib/snyk-to-html.js

@@ -57,4 +57,17 @@ #!/usr/bin/env node

return promisedString
.then(promisedParseJSON)
.then(data => processData(data, remediation, template, summary));
.then(promisedParseJSON).then((data) => {
var _a;
if ((data === null || data === void 0 ? void 0 : data.infrastructureAsCodeIssues) || ((_a = data[0]) === null || _a === void 0 ? void 0 : _a.infrastructureAsCodeIssues)) {
// for IaC input we need to change the default template to an IaC specific template
// at the same time we also want to support the -t / --template flag
template =
template === path.join(__dirname, '../../template/test-report.hbs')
? path.join(__dirname, '../../template/iac/test-report.hbs')
: template;
return processIacData(data, template, summary);
}
else {
return processData(data, remediation, template, summary);
}
});
}

@@ -161,2 +174,12 @@ }

}
async function generateIacTemplate(data, template) {
await registerPeerPartial(template, 'inline-css');
await registerPeerPartial(template, 'header');
await registerPeerPartial(template, 'metatable-css');
await registerPeerPartial(template, 'metatable');
await registerPeerPartial(template, 'inline-js');
await registerPeerPartial(template, 'vuln-card');
const htmlTemplate = await compileTemplate(template);
return htmlTemplate(data);
}
function mergeData(dataArray) {

@@ -180,2 +203,28 @@ const vulnsArrays = dataArray.map(project => project.vulnerabilities || []);

}
async function processIacData(data, template, summary) {
if (data.error) {
return generateIacTemplate(data, template);
}
const dataArray = Array.isArray(data) ? data : [data];
dataArray.forEach(project => {
project.infrastructureAsCodeIssues.forEach(issue => {
issue.severityValue = vuln_1.severityMap[issue.severity];
});
});
const projectsArrays = dataArray.map((project) => {
return {
targetFile: project.targetFile,
targetFilePath: project.targetFilePath,
projectType: vuln_1.IacProjectType[project.projectType],
infrastructureAsCodeIssues: _.orderBy(project.infrastructureAsCodeIssues, ['severityValue', 'title'], ['desc', 'asc']),
};
});
const totalIssues = projectsArrays.reduce((acc, item) => acc + item.infrastructureAsCodeIssues.length || 0, 0);
const processedData = {
projects: projectsArrays,
showSummaryOnly: summary,
totalIssues,
};
return generateIacTemplate(processedData, template);
}
async function readInputFromStdin() {

@@ -245,4 +294,7 @@ return new Promise((resolve, reject) => {

},
startsWith: function (str, start, options) {
return str.startsWith(start) ? options.fn(this) : options.inverse(this);
},
};
Object.keys(hh).forEach(k => Handlebars.registerHelper(k, hh[k]));
//# sourceMappingURL=snyk-to-html.js.map

@@ -11,1 +11,9 @@ import { UpgradeRemediation, Vuln } from './types';

export declare function addIssueDataToPatch(remediation: any, vulnerabilities: any): any;
export declare const IacProjectType: {
k8config: string;
terraformconfig: string;
cloudformationconfig: string;
armconfig: string;
customconfig: string;
multiiacconfig: string;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addIssueDataToPatch = exports.getUpgrades = exports.getSeverityScore = exports.severityMap = void 0;
exports.IacProjectType = exports.addIssueDataToPatch = exports.getUpgrades = exports.getSeverityScore = exports.severityMap = void 0;
const _ = require("@snyk/lodash");

@@ -59,2 +59,10 @@ exports.severityMap = { low: 0, medium: 1, high: 2, critical: 3 };

exports.addIssueDataToPatch = addIssueDataToPatch;
exports.IacProjectType = {
k8config: 'Kubernetes',
terraformconfig: 'Terraform',
cloudformationconfig: 'CloudFormation',
armconfig: 'ARM',
customconfig: 'Custom',
multiiacconfig: 'Multi IaC',
};
//# sourceMappingURL=vuln.js.map

2

package.json

@@ -68,3 +68,3 @@ {

},
"version": "2.1.0"
"version": "2.2.0"
}

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