filter vulnerabilities by audit_level (#55)

* filter vulnerabilities by audit_level

* update README.md

* fix test cases

* restrict audit_level value

* update dist/index.js
This commit is contained in:
Naoki Oketani
2020-03-21 07:08:53 +09:00
committed by GitHub
parent 4d8769971b
commit ad3449ef9c
8 changed files with 38 additions and 16 deletions

View File

@@ -8,9 +8,15 @@ import * as pr from './pr'
export async function run(): Promise<void> {
try {
// get audit-level
const auditLevel = core.getInput('audit_level', {required: true})
if (!['critical', 'high', 'moderate', 'low'].includes(auditLevel)) {
throw new Error('Invalid input: audit_level')
}
// run `npm audit`
const audit = new Audit()
audit.run()
audit.run(auditLevel)
core.info(audit.stdout)
if (audit.foundVulnerability()) {