Created
March 27, 2020 02:03
-
-
Save gcmurphy/604b01b4b6c134a742c59da602241cea to your computer and use it in GitHub Desktop.
lighthouse to extract librarie versions
This file contains 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
const lighthouse = require('lighthouse'); | |
const chromeLauncher = require('chrome-launcher'); | |
function launchChromeAndRunLighthouse(url, opts, config = null) { | |
return chromeLauncher.launch({chromeFlags: opts.chromeFlags}).then(chrome => { | |
opts.port = chrome.port; | |
return lighthouse(url, opts, config).then(results => { | |
// use results.lhr for the JS-consumable output | |
// https://github.com/GoogleChrome/lighthouse/blob/master/types/lhr.d.ts | |
// use results.report for the HTML/JSON/CSV output as a string | |
// use results.artifacts for the trace/screenshots/other specific case you need (rarer) | |
return chrome.kill().then(() => results.lhr) | |
}); | |
}); | |
} | |
const opts = { | |
chromeFlags: ['--headless', '--disable-gpu'], | |
onlyAudits: ['no-vulnerable-libraries', 'js-libraries'] | |
}; | |
// Usage: | |
launchChromeAndRunLighthouse('https://cloud.elastic.co', opts).then(results => { | |
// Use results! | |
console.log(results.audits['no-vulnerable-libraries'].details) | |
console.log(results.audits['js-libraries'].details) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://snyk.io/partners/api/v2/vulndb/clientside.json is a snapshot of client side vulnerabilities.