Created
July 12, 2020 06:04
-
-
Save lirantal/0a14b8457b7854da6920d8eef4d12e6e to your computer and use it in GitHub Desktop.
Transform Snyk's frontend vulns snapshot to WebPageTest DB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable security/detect-non-literal-fs-filename */ | |
/* eslint-disable security/detect-object-injection */ | |
'use strict' | |
const fs = require('fs') | |
// const | |
const filePath = process.argv[2] | |
console.log('Input file is: ', filePath) | |
const outputFilePath = 'WPTFrontendVulns.json' | |
const SnykFrontendVulns = JSON.parse(fs.readFileSync(filePath)) | |
const WPTFrontendVulns = {} | |
for (const [libraryName, allVulns] of Object.entries(SnykFrontendVulns.npm)) { | |
const libraryVulns = [] | |
allVulns.forEach(function (vulnItem) { | |
libraryVulns.push({ | |
id: vulnItem.id, | |
severity: vulnItem.severity, | |
semver: vulnItem.semver | |
}) | |
}) | |
WPTFrontendVulns[libraryName] = libraryVulns | |
} | |
fs.writeFileSync(outputFilePath, JSON.stringify({npm: WPTFrontendVulns}, true, 2)) | |
console.log('Output file: ', outputFilePath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment