| 1 | name: Security audit |
| 2 | |
| 3 | permissions: {} |
| 4 | |
| 5 | on: |
| 6 | workflow_dispatch: {} |
| 7 | workflow_call: {} |
| 8 | |
| 9 | env: |
| 10 | CARGO_TERM_COLOR: always |
| 11 | |
| 12 | jobs: |
| 13 | self-audit: |
| 14 | name: cargo-audit |
| 15 | runs-on: ubuntu-24.04 |
| 16 | timeout-minutes: 30 |
| 17 | permissions: |
| 18 | contents: read |
| 19 | steps: |
| 20 | - uses: actions/checkout@v7 |
| 21 | - uses: dtolnay/rust-toolchain@1.100.0 |
| 22 | - name: Install cargo-audit |
| 23 | run: cargo install cargo-audit@0.23.0 --locked |
| 24 | - name: Run cargo audit |
| 25 | run: cargo audit |
| 26 | |
| 27 | npm-audit: |
| 28 | name: npm-audit (${{ matrix.name }}) |
| 29 | runs-on: ubuntu-24.04 |
| 30 | timeout-minutes: 10 |
| 31 | permissions: |
| 32 | contents: read |
| 33 | strategy: |
| 34 | fail-fast: false |
| 35 | matrix: |
| 36 | # Every committed package-lock.json, including build-only tooling. |
| 37 | include: |
| 38 | - { name: root, directory: . } |
| 39 | - { name: web, directory: web } |
| 40 | - { name: telemetry-ingest, directory: telemetry-ingest } |
| 41 | - { name: telemetry-stats, directory: telemetry-stats } |
| 42 | - { name: extension-host, directory: crates/engine/extension-host } |
| 43 | - { name: vscode, directory: extensions/vscode } |
| 44 | - { name: dingtalk-bridge, directory: integrations/dingtalk-bridge } |
| 45 | - { name: feishu-bridge, directory: integrations/feishu-bridge } |
| 46 | - { name: telegram-bridge, directory: integrations/telegram-bridge } |
| 47 | - { name: wecom-bridge, directory: integrations/wecom-bridge } |
| 48 | - { name: pet, directory: pet } |
| 49 | - { name: whalenet-reuse, directory: docs/examples/whalenet-reuse } |
| 50 | defaults: |
| 51 | run: |
| 52 | working-directory: ${{ matrix.directory }} |
| 53 | steps: |
| 54 | - uses: actions/checkout@v7 |
| 55 | - uses: actions/setup-node@v7.1.0 |
| 56 | with: |
| 57 | node-version: '22' |
| 58 | # Audit the complete committed lock, including build dependencies, and |
| 59 | # keep the raw report. Runtime compatibility remains owned by surface CI. |
| 60 | - name: Audit locked dependencies |
| 61 | if: matrix.name != 'web' && matrix.name != 'vscode' |
| 62 | run: | |
| 63 | set +e |
| 64 | npm audit --json > "${{ runner.temp }}/npm-audit.json" |
| 65 | status=$? |
| 66 | set -e |
| 67 | node -e ' |
| 68 | const r = require(process.argv[1]); |
| 69 | if (r.error || !r.metadata?.vulnerabilities) throw new Error("Incomplete dependency audit"); |
| 70 | console.log(JSON.stringify(r.metadata.vulnerabilities)); |
| 71 | ' "${{ runner.temp }}/npm-audit.json" |
| 72 | exit "$status" |
| 73 | # The website also verifies its installed, reviewed build dependency |
| 74 | # mitigation (web/docs/DEPENDENCY_SECURITY.md); the raw report keeps every |
| 75 | # upstream finding. |
| 76 | - name: Install and verify website build dependency mitigation |
| 77 | if: matrix.name == 'web' |
| 78 | run: npm ci --no-audit |
| 79 | - name: Audit website with verified build dependency mitigation |
| 80 | if: matrix.name == 'web' |
| 81 | run: npm run audit:dependencies -- --report "${{ runner.temp }}/npm-audit.json" |
| 82 | # The VS Code extension's packager dependency override is recorded in |
| 83 | # docs/dependency-maintenance.md; any reported vulnerability fails the job. |
| 84 | - name: Audit extension with reviewed packager advisory acceptance |
| 85 | if: matrix.name == 'vscode' |
| 86 | run: npm run audit:dependencies -- --report "${{ runner.temp }}/npm-audit.json" |
| 87 | - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
| 88 | if: always() |
| 89 | with: |
| 90 | name: npm-audit-${{ matrix.name }} |
| 91 | path: ${{ runner.temp }}/npm-audit.json |
| 92 | if-no-files-found: error |
| 93 |