|
| 1 | +name: "Security Scanning" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + # The branches below must be a subset of the branches above |
| 8 | + branches: [main] |
| 9 | + schedule: |
| 10 | + # Runs every Monday morning PST |
| 11 | + - cron: "17 15 * * 1" |
| 12 | + |
| 13 | +# Cancel in-progress runs for pull requests when developers push |
| 14 | +# additional changes, and serialize builds in branches. |
| 15 | +# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 18 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 19 | + |
| 20 | +jobs: |
| 21 | + audit-ci: |
| 22 | + name: Run audit-ci |
| 23 | + runs-on: ubuntu-latest |
| 24 | + timeout-minutes: 15 |
| 25 | + steps: |
| 26 | + - name: Checkout repo |
| 27 | + uses: actions/checkout@v3 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Install Node.js v16 |
| 32 | + uses: actions/setup-node@v3 |
| 33 | + with: |
| 34 | + node-version: "16" |
| 35 | + |
| 36 | + - name: Fetch dependencies from cache |
| 37 | + id: cache-yarn |
| 38 | + uses: actions/cache@v3 |
| 39 | + with: |
| 40 | + path: "**/node_modules" |
| 41 | + key: yarn-build-${{ hashFiles('**/yarn.lock') }} |
| 42 | + restore-keys: | |
| 43 | + yarn-build- |
| 44 | +
|
| 45 | + - name: Install dependencies |
| 46 | + if: steps.cache-yarn.outputs.cache-hit != 'true' |
| 47 | + run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile |
| 48 | + |
| 49 | + - name: Audit for vulnerabilities |
| 50 | + run: yarn _audit |
| 51 | + if: success() |
| 52 | + |
| 53 | + trivy-scan-repo: |
| 54 | + permissions: |
| 55 | + contents: read # for actions/checkout to fetch code |
| 56 | + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results |
| 57 | + runs-on: ubuntu-20.04 |
| 58 | + steps: |
| 59 | + - name: Checkout repo |
| 60 | + uses: actions/checkout@v3 |
| 61 | + with: |
| 62 | + fetch-depth: 0 |
| 63 | + |
| 64 | + - name: Run Trivy vulnerability scanner in repo mode |
| 65 | + uses: aquasecurity/trivy-action@d63413b0a4a4482237085319f7f4a1ce99a8f2ac |
| 66 | + with: |
| 67 | + scan-type: "fs" |
| 68 | + scan-ref: "." |
| 69 | + ignore-unfixed: true |
| 70 | + format: "template" |
| 71 | + template: "@/contrib/sarif.tpl" |
| 72 | + output: "trivy-repo-results.sarif" |
| 73 | + severity: "HIGH,CRITICAL" |
| 74 | + |
| 75 | + - name: Upload Trivy scan results to GitHub Security tab |
| 76 | + uses: github/codeql-action/upload-sarif@v2 |
| 77 | + with: |
| 78 | + sarif_file: "trivy-repo-results.sarif" |
| 79 | + |
| 80 | + codeql-analyze: |
| 81 | + permissions: |
| 82 | + actions: read # for github/codeql-action/init to get workflow details |
| 83 | + contents: read # for actions/checkout to fetch code |
| 84 | + security-events: write # for github/codeql-action/autobuild to send a status report |
| 85 | + name: Analyze |
| 86 | + runs-on: ubuntu-20.04 |
| 87 | + |
| 88 | + steps: |
| 89 | + - name: Checkout repository |
| 90 | + uses: actions/checkout@v3 |
| 91 | + |
| 92 | + # Initializes the CodeQL tools for scanning. |
| 93 | + - name: Initialize CodeQL |
| 94 | + uses: github/codeql-action/init@v2 |
| 95 | + with: |
| 96 | + config-file: ./.github/codeql-config.yml |
| 97 | + languages: javascript |
| 98 | + |
| 99 | + - name: Autobuild |
| 100 | + uses: github/codeql-action/autobuild@v2 |
| 101 | + |
| 102 | + - name: Perform CodeQL Analysis |
| 103 | + uses: github/codeql-action/analyze@v2 |
0 commit comments