2022-09-23 03:33:32 +08:00
|
|
|
name: Security
|
2022-09-14 21:31:13 +08:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [main]
|
2022-09-30 03:46:48 +08:00
|
|
|
paths:
|
|
|
|
- "package.json"
|
2022-09-14 21:31:13 +08:00
|
|
|
pull_request:
|
2022-09-30 03:46:48 +08:00
|
|
|
paths:
|
|
|
|
- "package.json"
|
2022-09-14 21:31:13 +08:00
|
|
|
schedule:
|
|
|
|
# Runs every Monday morning PST
|
|
|
|
- cron: "17 15 * * 1"
|
|
|
|
|
2023-03-22 04:16:22 +08:00
|
|
|
# Cancel in-progress runs for pull requests when developers push additional
|
|
|
|
# changes, and serialize builds in branches.
|
2022-09-14 21:31:13 +08:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
|
|
|
|
|
|
jobs:
|
2024-07-11 05:15:15 +08:00
|
|
|
audit:
|
2022-09-23 03:33:32 +08:00
|
|
|
name: Audit node modules
|
2022-09-14 21:31:13 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 15
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2023-10-05 07:50:11 +08:00
|
|
|
uses: actions/checkout@v4
|
2022-09-14 21:31:13 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2023-11-15 05:45:56 +08:00
|
|
|
- name: Install Node.js
|
2023-11-15 02:23:05 +08:00
|
|
|
uses: actions/setup-node@v4
|
2022-09-14 21:31:13 +08:00
|
|
|
with:
|
2023-11-15 05:45:56 +08:00
|
|
|
node-version-file: .node-version
|
2022-09-14 21:31:13 +08:00
|
|
|
|
2023-09-22 08:13:34 +08:00
|
|
|
- name: Audit npm for vulnerabilities
|
2024-10-05 08:08:14 +08:00
|
|
|
run: npm audit
|
2022-09-14 21:31:13 +08:00
|
|
|
if: success()
|
|
|
|
|
|
|
|
trivy-scan-repo:
|
2022-09-23 03:33:32 +08:00
|
|
|
name: Scan repo with Trivy
|
2022-09-14 21:31:13 +08:00
|
|
|
permissions:
|
|
|
|
contents: read # for actions/checkout to fetch code
|
|
|
|
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2023-10-05 07:50:11 +08:00
|
|
|
uses: actions/checkout@v4
|
2022-09-14 21:31:13 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Run Trivy vulnerability scanner in repo mode
|
2024-07-11 05:10:01 +08:00
|
|
|
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8
|
2022-09-14 21:31:13 +08:00
|
|
|
with:
|
|
|
|
scan-type: "fs"
|
|
|
|
scan-ref: "."
|
|
|
|
ignore-unfixed: true
|
|
|
|
format: "template"
|
|
|
|
template: "@/contrib/sarif.tpl"
|
|
|
|
output: "trivy-repo-results.sarif"
|
|
|
|
severity: "HIGH,CRITICAL"
|
|
|
|
|
|
|
|
- name: Upload Trivy scan results to GitHub Security tab
|
2024-02-02 09:37:33 +08:00
|
|
|
uses: github/codeql-action/upload-sarif@v3
|
2022-09-14 21:31:13 +08:00
|
|
|
with:
|
|
|
|
sarif_file: "trivy-repo-results.sarif"
|
|
|
|
|
|
|
|
codeql-analyze:
|
|
|
|
permissions:
|
|
|
|
actions: read # for github/codeql-action/init to get workflow details
|
|
|
|
contents: read # for actions/checkout to fetch code
|
|
|
|
security-events: write # for github/codeql-action/autobuild to send a status report
|
2022-09-23 03:33:32 +08:00
|
|
|
name: Analyze with CodeQL
|
2022-09-14 21:31:13 +08:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2023-10-05 07:50:11 +08:00
|
|
|
uses: actions/checkout@v4
|
2022-09-14 21:31:13 +08:00
|
|
|
|
|
|
|
# Initializes the CodeQL tools for scanning.
|
|
|
|
- name: Initialize CodeQL
|
2024-02-02 09:37:33 +08:00
|
|
|
uses: github/codeql-action/init@v3
|
2022-09-14 21:31:13 +08:00
|
|
|
with:
|
|
|
|
config-file: ./.github/codeql-config.yml
|
|
|
|
languages: javascript
|
|
|
|
|
|
|
|
- name: Autobuild
|
2024-02-02 09:37:33 +08:00
|
|
|
uses: github/codeql-action/autobuild@v3
|
2022-09-14 21:31:13 +08:00
|
|
|
|
|
|
|
- name: Perform CodeQL Analysis
|
2024-02-02 09:37:33 +08:00
|
|
|
uses: github/codeql-action/analyze@v3
|