|
| 1 | +name: Dependency security |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - "**/pyproject.toml" |
| 7 | + - "**/uv.lock" |
| 8 | + - "**/package.json" |
| 9 | + - "**/pnpm-lock.yaml" |
| 10 | + - "renovate.json" |
| 11 | + - "scripts/audit_requirements.py" |
| 12 | + - "scripts/check_notebook_audit.py" |
| 13 | + - ".github/workflows/dependency-security.yml" |
| 14 | + push: |
| 15 | + branches: [main] |
| 16 | + schedule: |
| 17 | + - cron: "0 8 * * 1" |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +jobs: |
| 24 | + python: |
| 25 | + name: Python dependency audit (${{ matrix.python-version }}) |
| 26 | + runs-on: ubuntu-latest |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + python-version: ["3.10", "3.12", "3.14"] |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 33 | + |
| 34 | + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7 |
| 35 | + with: |
| 36 | + python-version: ${{ matrix.python-version }} |
| 37 | + |
| 38 | + - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 39 | + with: |
| 40 | + version: "0.12.24" |
| 41 | + |
| 42 | + - name: Export locked dependencies |
| 43 | + run: | |
| 44 | + uv export --locked --no-emit-workspace --no-hashes --output-file "$RUNNER_TEMP/dependencies.txt" > /dev/null |
| 45 | + uv export --project examples/local_video --locked --no-emit-local --no-hashes --output-file "$RUNNER_TEMP/example.txt" > /dev/null |
| 46 | +
|
| 47 | + - name: Audit workspace and example |
| 48 | + run: | |
| 49 | + uvx --from pip-audit==2.10.1 pip-audit --disable-pip --no-deps -r "$RUNNER_TEMP/dependencies.txt" --format json --output "$RUNNER_TEMP/python-audit.json" |
| 50 | + uvx --from pip-audit==2.10.1 pip-audit --disable-pip --no-deps -r "$RUNNER_TEMP/example.txt" --format json --output "$RUNNER_TEMP/example-audit.json" |
| 51 | +
|
| 52 | + - name: Report Python 3.9 findings |
| 53 | + if: matrix.python-version == '3.12' |
| 54 | + continue-on-error: true |
| 55 | + run: | |
| 56 | + uv run --no-project --with packaging==26.0 python scripts/audit_requirements.py "$RUNNER_TEMP/dependencies.txt" "$RUNNER_TEMP/python39.txt" --python-version 3.9 |
| 57 | + echo '::warning::Python 3.9 retains aiohttp/multidict advisories whose fixes require Python 3.10+. See the audit artifact.' |
| 58 | + uvx --from pip-audit==2.10.1 pip-audit --disable-pip --no-deps -r "$RUNNER_TEMP/python39.txt" --format json --output "$RUNNER_TEMP/python39-audit.json" |
| 59 | +
|
| 60 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
| 61 | + if: always() |
| 62 | + with: |
| 63 | + name: python-audit-${{ matrix.python-version }} |
| 64 | + path: ${{ runner.temp }}/*audit.json |
| 65 | + |
| 66 | + notebook: |
| 67 | + name: Notebook dependency audit |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 71 | + |
| 72 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 73 | + with: |
| 74 | + node-version: "22" |
| 75 | + |
| 76 | + - name: Audit notebook dependencies |
| 77 | + run: | |
| 78 | + npm install --global pnpm@10.28.2 |
| 79 | + # The checker handles the exact known unpatched finding and blocks all others. |
| 80 | + if pnpm --dir livekit-rtc/jupyter-html audit --json > "$RUNNER_TEMP/notebook-audit.json"; then |
| 81 | + echo "Notebook audit has no findings" |
| 82 | + fi |
| 83 | + python scripts/check_notebook_audit.py "$RUNNER_TEMP/notebook-audit.json" |
| 84 | +
|
| 85 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
| 86 | + if: always() |
| 87 | + with: |
| 88 | + name: notebook-audit |
| 89 | + path: ${{ runner.temp }}/notebook-audit.json |
0 commit comments