Skip to content

Commit

Permalink
refactor: audit_level → severity_level
Browse files Browse the repository at this point in the history
  • Loading branch information
basal-luke committed Apr 18, 2023
1 parent 55b254a commit 49b8282
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ If vulnerabilities are found by `yarn npm audit`, Action triggered by push, sche

|Parameter|Required|Default Value|Description|
|:--:|:--:|:--:|:--|
|severity|false|low|The value of `--severity` flag|
|severity_level|false|low|The value of `--severity` flag|
|create_issues|false|true|Flag to create issues when vulnerabilities are found|
|create_pr_comments|false|true|Flag to create pr comments when vulnerabilities are found|
|dedupe_issues|false|false|Flag to de-dupe against open issues|
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
run: yarn install
- uses: basaldev/yarn-npm-audit-action@v2
with:
audit_level: moderate
severity_level: moderate
github_token: ${{ secrets.MY_GITHUB_ACCESS_TOKEN }}
issue_assignees: basal-luke
issue_labels: vulnerability,test
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'yarn npm audit action'
description: 'run yarn npm audit'
author: 'basal-luke <luke@basal.dev>'
inputs:
audit_level:
severity_level:
description: 'The value of `--severity` flag'
default: low
required: false
Expand Down
4 changes: 2 additions & 2 deletions src/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export class Audit {
private status: number | null = null

public run(
auditLevel: string,
severityLevel: string,
productionFlag: string,
jsonFlag: string,
resursiveFlag: string
): void {
try {
const auditOptions: Array<string> = ['audit', '--severity', auditLevel]
const auditOptions: Array<string> = ['audit', '--severity', severityLevel]

const isWindowsEnvironment: boolean = process.platform == 'win32'
const cmd: string = isWindowsEnvironment ? 'yarn npm.cmd' : 'yarn npm'
Expand Down
10 changes: 5 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export async function run(): Promise<void> {
}
core.info(`Current working directory: ${process.cwd()}`)

// get audit-level
const auditLevel = core.getInput('severity', {required: true})
// get severity-level
const severityLevel = core.getInput('severity', {required: true})
if (
!['critical', 'high', 'moderate', 'low', 'info', 'none'].includes(
auditLevel
severityLevel
)
) {
throw new Error('Invalid input: severity')
throw new Error('Invalid input: severity_level')
}

const productionFlag = core.getInput('production_flag', {required: false})
Expand All @@ -46,7 +46,7 @@ export async function run(): Promise<void> {

// run `npm audit`
const audit = new Audit()
audit.run(auditLevel, productionFlag, jsonFlag, recursiveFlag)
audit.run(severityLevel, productionFlag, jsonFlag, recursiveFlag)
core.info(audit.stdout)
core.setOutput('npm_audit', audit.stdout)

Expand Down

0 comments on commit 49b8282

Please sign in to comment.