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:
|
|
|
|
audit-ci:
|
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
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Install Node.js v16
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: "16"
|
|
|
|
|
|
|
|
- name: Fetch dependencies from cache
|
|
|
|
id: cache-yarn
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: "**/node_modules"
|
|
|
|
key: yarn-build-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
yarn-build-
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
if: steps.cache-yarn.outputs.cache-hit != 'true'
|
|
|
|
run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile
|
|
|
|
|
|
|
|
- name: Audit for vulnerabilities
|
|
|
|
run: yarn _audit
|
|
|
|
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
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Run Trivy vulnerability scanner in repo mode
|
2023-07-14 05:04:18 +08:00
|
|
|
uses: aquasecurity/trivy-action@41f05d9ecffa2ed3f1580af306000f734b733e54
|
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
|
|
|
|
uses: github/codeql-action/upload-sarif@v2
|
|
|
|
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
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
# Initializes the CodeQL tools for scanning.
|
|
|
|
- name: Initialize CodeQL
|
|
|
|
uses: github/codeql-action/init@v2
|
|
|
|
with:
|
|
|
|
config-file: ./.github/codeql-config.yml
|
|
|
|
languages: javascript
|
|
|
|
|
|
|
|
- name: Autobuild
|
|
|
|
uses: github/codeql-action/autobuild@v2
|
|
|
|
|
|
|
|
- name: Perform CodeQL Analysis
|
|
|
|
uses: github/codeql-action/analyze@v2
|