Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
Created March 27, 2020 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcmurphy/604b01b4b6c134a742c59da602241cea to your computer and use it in GitHub Desktop.
Save gcmurphy/604b01b4b6c134a742c59da602241cea to your computer and use it in GitHub Desktop.
lighthouse to extract librarie versions
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)
});
@gcmurphy
Copy link
Author

https://snyk.io/partners/api/v2/vulndb/clientside.json is a snapshot of client side vulnerabilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment