Skip to content

Add GitHub Actions OIDC authentication, lease renewal, and workflow annotations - #127

Open
vishalrajofficial wants to merge 1 commit into
prooflinedev:mainfrom
vishalrajofficial:feat/github-actions-oidc
Open

vishalrajofficial wants to merge 1 commit into
prooflinedev:mainfrom
vishalrajofficial:feat/github-actions-oidc

Conversation

@vishalrajofficial

Copy link
Copy Markdown

Who this helps

Teams running Python CI scripts (coverage uploads, wait_for_review checks, deploy verification, and MCP workflows) inside GitHub Actions can now authenticate without provisioning or rotating a long-lived PROOFLINE_TOKEN repository secret. Workflow jobs with id-token: write exchange their runner OIDC token for a short-lived Proofline lease, renew it automatically across multi-minute waits, read the reviewed commit accurately from GITHUB_EVENT_PATH, and emit inline PR workflow annotations from ReviewOutcome.

What changed

  • Added proofline/github_actions.py and re-exported GitHubActionsCredentials, AsyncGitHubActionsCredentials, GitHubActionsEvent, GitHubActionsLease, read_github_actions_event, and format_github_annotations from proofline.
  • Added ProoflineClient.from_github_actions() and AsyncProoflineClient.from_github_actions() factory constructors (plus .organization_id and .repository_id properties and support for passing dynamic TokenProvider / AsyncTokenProvider instances as token=), registering from_github_actions in scripts/contracts.py.
  • Updated proofline/_transport.py (BearerAuth, RetryTransport, AsyncRetryTransport, redacted, problem, and single-attempt checked transports SingleAttemptTransport / AsyncSingleAttemptTransport) so dynamic credentials supply fresh tokens on initial calls and GET 429/503 retries while redacting runner, OIDC, and current/retired session secrets from error messages.
  • Documented GitHub Actions OIDC usage in README.md and added sync/async HTTP and security tests in tests/test_github_actions.py.
  • Left openapi.public.json, proofline/_generated/, and workflows untouched.

Decisions made

  • Token renewal and single-flight locking: Short-lived leases schedule renewal at ttl - min(60s, ttl / 2) on a monotonic clock (60s lead on 1-hour leases, half-life on short test leases), guarded per client by threading.Lock (sync) or anyio.Lock (async). Renewals enforce a constant organization_id, raising urn:proofline:sdk:credential-mismatch and failing closed if a renewed lease changes organization or returns HTTP 4xx/5xx.
  • Transport and secret isolation: OIDC token fetches (GET ACTIONS_ID_TOKEN_REQUEST_URL) and exchanges (POST /api/v1/ci/github-actions/credentials) use single-attempt non-redirecting transports sharing the SDK's IO_DEADLINE, DEADLINE, Content-Encoding: identity, and 8 MiB response guards. Query parameters on ACTIONS_ID_TOKEN_REQUEST_URL (such as ?sig=...) are stripped from error text, and conflicting base_url values between a credential provider and client are rejected at construction time.
  • Event context and commit resolution: read_github_actions_event() reads GITHUB_EVENT_PATH under a 10 MiB bound and resolves commit_under_test to pull_request.head.sha or workflow_run.head_sha rather than synthetic GITHUB_SHA merge refs.
  • Injection-safe workflow annotations: format_github_annotations() reuses proofline.outcomes code-lane and withheld-value checks, excludes resolved/dismissed/accepted-risk items, sorts severe/unknown findings first, pins at most one validated repo-relative location per finding matching head_commit_sha (excluding companion repositories and path traversal), escapes %, CR, LF, :, and ,, strips control/bidi characters, and appends a ::warning annotation whenever an outcome is incomplete or has gaps.

How it was tested

Ran the full local verification suite on Windows (Python 3.11.1):

  • python scripts/generate.py --check: passed
  • python scripts/contracts.py: passed
  • ruff check . and ruff format --check .: passed (239 files formatted)
  • mypy proofline scripts tests/test_github_actions.py: passed (231 source files)
  • pytest -q: 230 passed (including all 12 new tests in tests/test_github_actions.py covering sync/async OIDC exchange against local tests.http_server.Server, single-flight concurrency, mid-poll wait_for_review renewal, retry-after header refresh, secret/query redaction, org-mismatch failure, redirect/expiry rejections, event parsing, and annotation escaping/gap warnings)
  • Built wheel (proofline_sdk-10.2.2-py3-none-any.whl) and sdist (proofline_sdk-10.2.2.tar.gz) via python -m build --no-isolation and verified both clean installations pass scripts/install_smoke.py

Adds secretless GitHub Actions OIDC credential exchange with automatic single-flight lease renewal, validated event commit context parsing, and injection-safe GitHub workflow annotations for review outcomes.

Signed-off-by: Vishal Raj <9031842908.vk@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant