|
| 1 | +name: dependabot-review |
| 2 | + |
| 3 | +# Dependency-update PR guardrails for Dependabot-authored PRs. |
| 4 | +# |
| 5 | +# Runs only on PRs opened by dependabot[bot]. Inspects which files |
| 6 | +# changed, then conditionally runs a Socket Firewall (sfw) install smoke |
| 7 | +# job for the Python dependency set. Because sfw uses the free, anonymous |
| 8 | +# Socket public-data path it needs NO API key, so we can run it from the |
| 9 | +# unprivileged `pull_request` context without pull_request_target or any |
| 10 | +# of its security tradeoffs. |
| 11 | +# |
| 12 | +# Pattern adapted from SocketDev/socket-python-cli. |
| 13 | + |
| 14 | +on: |
| 15 | + pull_request: |
| 16 | + types: [opened, synchronize, reopened, ready_for_review] |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: dependabot-review-${{ github.event.pull_request.number }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +jobs: |
| 26 | + inspect: |
| 27 | + if: github.event.pull_request.user.login == 'dependabot[bot]' |
| 28 | + runs-on: ubuntu-latest |
| 29 | + timeout-minutes: 5 |
| 30 | + outputs: |
| 31 | + python_deps_changed: ${{ steps.diff.outputs.python_deps_changed }} |
| 32 | + workflow_or_action_changed: ${{ steps.diff.outputs.workflow_or_action_changed }} |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 35 | + with: |
| 36 | + fetch-depth: 0 |
| 37 | + persist-credentials: false |
| 38 | + |
| 39 | + - name: Inspect changed files |
| 40 | + id: diff |
| 41 | + env: |
| 42 | + BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 43 | + HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 44 | + run: | |
| 45 | + CHANGED_FILES="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")" |
| 46 | +
|
| 47 | + { |
| 48 | + echo "## Changed files" |
| 49 | + echo '```' |
| 50 | + printf '%s\n' "$CHANGED_FILES" |
| 51 | + echo '```' |
| 52 | + } >> "$GITHUB_STEP_SUMMARY" |
| 53 | +
|
| 54 | + has_file() { |
| 55 | + local pattern="$1" |
| 56 | + if printf '%s\n' "$CHANGED_FILES" | grep -Eq "$pattern"; then |
| 57 | + echo "true" |
| 58 | + else |
| 59 | + echo "false" |
| 60 | + fi |
| 61 | + } |
| 62 | +
|
| 63 | + { |
| 64 | + echo "python_deps_changed=$(has_file '^(pyproject\.toml|uv\.lock)$')" |
| 65 | + echo "workflow_or_action_changed=$(has_file '^\.github/workflows/|^\.github/actions/|^\.github/dependabot\.yml$')" |
| 66 | + } >> "$GITHUB_OUTPUT" |
| 67 | +
|
| 68 | + - name: Summarize review expectations |
| 69 | + env: |
| 70 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 71 | + run: | |
| 72 | + { |
| 73 | + echo "## Dependabot Review Checklist" |
| 74 | + echo "- PR: $PR_URL" |
| 75 | + echo "- Confirm upstream release notes before merge" |
| 76 | + echo "- Do not treat a Dependabot PR as trusted solely because of the actor" |
| 77 | + echo "- This workflow runs in pull_request context only; no publish secrets are exposed" |
| 78 | + } >> "$GITHUB_STEP_SUMMARY" |
| 79 | +
|
| 80 | + python-sfw-smoke: |
| 81 | + needs: inspect |
| 82 | + if: needs.inspect.outputs.python_deps_changed == 'true' |
| 83 | + runs-on: ubuntu-latest |
| 84 | + timeout-minutes: 15 |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 87 | + with: |
| 88 | + fetch-depth: 1 |
| 89 | + persist-credentials: false |
| 90 | + |
| 91 | + - uses: ./.github/actions/setup-sfw |
| 92 | + with: |
| 93 | + uv: "true" |
| 94 | + |
| 95 | + - name: Sync project through Socket Firewall |
| 96 | + # `sfw uv sync` is the intended way to route uv through Socket Firewall |
| 97 | + # (per Socket's own uv wrapper guidance). --locked verifies the exact |
| 98 | + # uv.lock set and fails on lockfile drift rather than silently |
| 99 | + # re-resolving, so the firewall inspects precisely what would install. |
| 100 | + # Note: uv's sfw integration is quieter than npm/pip -- it does not |
| 101 | + # print the "N packages fetched" footer, but interception is active. |
| 102 | + run: sfw uv sync --locked --extra test --extra dev |
| 103 | + |
| 104 | + - name: Import smoke test |
| 105 | + run: | |
| 106 | + uv run python -c " |
| 107 | + import socketdev |
| 108 | + from socketdev import socketdev as SocketDevClient |
| 109 | + from socketdev.core.api import API |
| 110 | + from socketdev.version import __version__ |
| 111 | + print('import smoke OK', __version__) |
| 112 | + " |
| 113 | +
|
| 114 | + workflow-notice: |
| 115 | + needs: inspect |
| 116 | + if: needs.inspect.outputs.workflow_or_action_changed == 'true' |
| 117 | + runs-on: ubuntu-latest |
| 118 | + timeout-minutes: 2 |
| 119 | + steps: |
| 120 | + - name: Flag workflow-sensitive updates |
| 121 | + run: | |
| 122 | + { |
| 123 | + echo "## Sensitive File Notice" |
| 124 | + echo "This Dependabot PR changes workflow or dependabot config files." |
| 125 | + echo "Require explicit human review before merge." |
| 126 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments