2019-12-08 22:10:35 +09:00
|
|
|
# npm audit action
|
2019-12-08 19:17:13 +09:00
|
|
|
|
2021-10-02 21:51:01 +09:00
|
|
|
[](https://coveralls.io/github/oke-py/npm-audit-action?branch=main)
|
2019-12-09 16:00:28 +09:00
|
|
|
|
2019-12-08 22:10:35 +09:00
|
|
|
GitHub Action to run `npm audit`
|
2019-12-09 08:51:14 +09:00
|
|
|
|
2019-12-15 10:49:06 +09:00
|
|
|
## Feature
|
|
|
|
|
|
|
|
|
|
### Create a Pull Request comment
|
|
|
|
|
|
|
|
|
|
If vulnerabilities are found by `npm audit`, Action triggered by PR creates a comment.
|
|
|
|
|
|
|
|
|
|
### Create an Issue
|
|
|
|
|
|
|
|
|
|
If vulnerabilities are found by `npm audit`, Action triggered by push, schedule creates the following GitHub Issue.
|
2019-12-09 14:13:56 +09:00
|
|
|
|
2021-10-02 21:51:01 +09:00
|
|
|

|
2019-12-09 14:13:56 +09:00
|
|
|
|
2019-12-09 08:51:14 +09:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
### Inputs
|
|
|
|
|
|
|
|
|
|
|Parameter|Required|Default Value|Description|
|
|
|
|
|
|:--:|:--:|:--:|:--|
|
2020-03-21 07:08:53 +09:00
|
|
|
|audit_level|false|low|The value of `--audit-level` flag|
|
2023-01-02 10:32:48 +09:00
|
|
|
|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|
|
2023-01-02 10:25:02 +09:00
|
|
|
|github_context|false|`${{ toJson(github) }}`|The `github` context|
|
2023-01-02 10:23:32 +09:00
|
|
|
|github_token|true|N/A|GitHub Access Token.<br>${{ secrets.GITHUB_TOKEN }} is recommended.|
|
2019-12-09 12:43:13 +09:00
|
|
|
|issue_assignees|false|N/A|Issue assignees (separated by commma)|
|
|
|
|
|
|issue_labels|false|N/A|Issue labels (separated by commma)|
|
2019-12-09 08:51:14 +09:00
|
|
|
|issue_title|false|npm audit found vulnerabilities|Issue title|
|
2023-01-02 10:32:48 +09:00
|
|
|
|json_flag|false|false|Run `npm audit` with `--json`|
|
|
|
|
|
|production_flag|false|false|Run `npm audit` with `--omit=dev`|
|
|
|
|
|
|working_directory|false|N/A|The directory which contains package.json|
|
2019-12-09 09:41:29 +09:00
|
|
|
|
|
|
|
|
### Outputs
|
|
|
|
|
|
2020-12-12 13:56:05 +02:00
|
|
|
|Parameter name|Description|
|
|
|
|
|
|:--:|:--|
|
|
|
|
|
|npm_audit|The output of the npm audit report in a text format|
|
2019-12-09 09:41:29 +09:00
|
|
|
|
|
|
|
|
## Example Workflow
|
|
|
|
|
|
2019-12-09 14:13:56 +09:00
|
|
|
```yaml
|
|
|
|
|
name: npm audit
|
|
|
|
|
|
2019-12-15 10:49:06 +09:00
|
|
|
on:
|
|
|
|
|
pull_request:
|
|
|
|
|
push:
|
|
|
|
|
branches:
|
2021-10-02 21:51:01 +09:00
|
|
|
- main
|
2019-12-15 10:49:06 +09:00
|
|
|
- 'releases/*'
|
2019-12-09 14:13:56 +09:00
|
|
|
# on:
|
|
|
|
|
# schedule:
|
|
|
|
|
# - cron: '0 10 * * *'
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
scan:
|
|
|
|
|
name: npm audit
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
2022-12-10 22:22:40 +09:00
|
|
|
- uses: actions/checkout@v3
|
2019-12-09 14:13:56 +09:00
|
|
|
- name: install dependencies
|
|
|
|
|
run: npm ci
|
2022-03-26 15:31:24 +09:00
|
|
|
- uses: oke-py/npm-audit-action@v2
|
2019-12-09 14:13:56 +09:00
|
|
|
with:
|
2020-03-21 07:08:53 +09:00
|
|
|
audit_level: moderate
|
2019-12-13 12:18:28 +09:00
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
2019-12-09 14:13:56 +09:00
|
|
|
issue_assignees: oke-py
|
|
|
|
|
issue_labels: vulnerability,test
|
2020-05-28 07:24:52 +09:00
|
|
|
dedupe_issues: true
|
2019-12-09 14:13:56 +09:00
|
|
|
```
|
2019-12-09 19:59:47 +09:00
|
|
|
|
|
|
|
|
- - -
|
|
|
|
|
|
|
|
|
|
This action is inspired by [homoluctus/gitrivy](https://github.com/homoluctus/gitrivy).
|