Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add audit and strict audit actions #39

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Repoistory to host all of Fuel's reusable workflows

| Group | Description |
| --------------------------------- | ---------------------------------------------------------------- |
| [audit](./audits/) | Reusable workflows for auditing npm packages |
| [changeset](./changeset/) | Reusable workflow for create changesets and release npm packages |
| [gh-projects](./gh-projects/) | Automating interactions between GH Projects and repositories |
| [setups/node](./setups/node/) | Setup node and pnpm requirements on CI |
Expand Down
27 changes: 27 additions & 0 deletions audits/lenient-audit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Audit

A github action that runs audit and does not fails if the reported vulnerabilities have not yet been fixed.

### How to use?

```yml
- uses: FuelLabs/github-actions/audits/lenient-audit
with:
node-version: 18.14.1
pnpm-version: latest
```

### Inputs

| Name | Description |
| ------------ | ------------ |
| node-version | Node version |
| pnpm-version | PNPM version |

### Outputs

No outputs defined

## License

The primary license for this repo is `Apache 2.0`, see [`LICENSE`](../../LICENSE.md).
41 changes: 41 additions & 0 deletions audits/lenient-audit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lenient Audit

on:
workflow_call:
inputs:
node-version:
required: true
type: string
pnpm-version:
required: true
type: string

jobs:
audit:
name: Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./setups/node
with:
node-version: ${{ inputs.node-version }}
pnpm-version: ${{ inputs.pnpm-version }}
- name: Install jq
run: sudo apt-get install jq
- run: |
pnpm audit --prod --json | jq '
def has_fix:
.advisories | to_entries | map(.value.patched_versions != "<0.0.0") | any;
if has_fix then
1
else
0
end
' > audit_result.txt
if [ "$(cat audit_result.txt)" -eq "1" ]; then
echo "Actionable vulnerabilities found"
exit 1
else
echo "No actionable vulnerabilities"
exit 0
fi
27 changes: 27 additions & 0 deletions audits/strict-audit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Strict Audit

A github action that runs audit without ignoring vulnerabilities that have not been fixed.

### How to use?

```yml
- uses: FuelLabs/github-actions/audits/strict-audit
with:
node-version: 18.14.1
pnpm-version: latest
```

### Inputs

| Name | Description |
| ------------ | ------------ |
| node-version | Node version |
| pnpm-version | PNPM version |

### Outputs

No outputs defined

## License

The primary license for this repo is `Apache 2.0`, see [`LICENSE`](../../LICENSE.md).
23 changes: 23 additions & 0 deletions audits/strict-audit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Strict Audit

on:
workflow_call:
inputs:
node-version:
required: true
type: string
pnpm-version:
required: true
type: string

jobs:
strict-audit:
name: Strict Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./setups/node
with:
node-version: ${{ inputs.node-version }}
pnpm-version: ${{ inputs.pnpm-version }}
- run: pnpm audit --prod
Loading