Lighthouse Security
![npm lighthouse-security package](https://camo.githubusercontent.com/45600d0c9f1377cfefcd7b59a59d2f4b2f1d4913a8ca860986cf6ab3fa86377c/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f6c69676874686f7573652d73656375726974792e737667)
Runs the default Google Lighthouse tests with additional security tests.
npm install -g lighthouse-security
Run the command from CLI like displayed below. The options are the same as for the default Lighthouse CLI options.
lighthouse-security <url> [options]
To run security audits only, use the --security
flag:
lighthouse-security <url> --security [options]
The extension can also be used within your code. A short example is given below. To render reports etc. it is recommended to import functionality from Lighthouse.
const runLighthouse = require('lighthouse-security')
runLighthouse(url, flags)
.then(results => console.log(results))
Alternatively you can import just the lighthouse-security
configuration and use it in your own runner:
const lighthouse = require('lighthouse')
const chromeLauncher = require('lighthouse/chrome-launcher')
// import one or more lighthouse configs:
const securityConfig = require('lighthouse-security/config')
// combine configs into one:
const config = Object.assign({},
pageSecurityConfig,
{ extends: 'lighthouse:default' }
)
// run lighthouse as usual:
async function run(url, flags = {}) {
const chrome = await chromeLauncher.launch()
flags.port = chrome.port
const results = await lighthouse(url, flags, config)
const stopped = await chrome.kill()
return results
}
Contributions are always welcome. See CONTRIBUTING.md for guidelines and development scripts.