Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lirantal/0a14b8457b7854da6920d8eef4d12e6e to your computer and use it in GitHub Desktop.
Save lirantal/0a14b8457b7854da6920d8eef4d12e6e to your computer and use it in GitHub Desktop.
Transform Snyk's frontend vulns snapshot to WebPageTest DB
/* 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