Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:
test:
runs-on: ubuntu-26.04
timeout-minutes: 10
# id-token: write lets the coverage upload prove to Codecov, through GitHub's
# OIDC, which repository it comes from. Job permissions replace the workflow's,
# so contents: read is repeated here.
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -60,7 +66,10 @@ jobs:
if: matrix.python-version == '3.12'
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
# OIDC, not a CODECOV_TOKEN secret: Codecov files an upload under the
# project its token belongs to, and this repository's secret held
# exeradar's, so the reports went there (tests/test_codecov_contract.py).
use_oidc: true
files: coverage.xml
# A failed upload loses a metric; it does not invalidate the tests that
# just passed. What it must not do is stay silent forever — ask Codecov
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ what has already shipped, and for nothing else. See `RELEASING.md`.
(`tests/test_scout_binary.py`). Sources:
[docker/scout-action#116](https://github.com/docker/scout-action/issues/116).

- **Coverage reaches this repository's Codecov project again.** The upload authenticated with a
`CODECOV_TOKEN` secret, and Codecov files an upload under the project its token belongs to: the
secret here held exeradar's token, so every report since at least 2026-10-17 went to exeradar's
project, and `codecov/patch` waited on #111 for one that never came. The upload now uses OIDC
(`use_oidc: true`, `id-token: write` on the test job): GitHub tells Codecov which repository the job
runs in, and there is no secret left to mix up. The test that required the token now requires OIDC
and forbids the secret (`tests/test_codecov_contract.py`). Same as maksimtech/mailradar#135 and
maksimtech/cookieradar#104.

### Security

- **CVE-2026-121482 (OpenSSL, CRL distribution points) is accepted until Debian ships a fix.** Docker
Expand Down
29 changes: 25 additions & 4 deletions tests/test_codecov_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,31 @@ def test_the_upload_runs_once_on_a_version_the_matrix_has(workflow):
)


def test_the_upload_is_given_a_token(workflow):
"""Codecov wants one even for a public repository; without it the upload is
rejected, and quietly."""
assert "CODECOV_TOKEN" in workflow
def test_the_upload_proves_which_repository_it_comes_from(workflow):
"""Codecov wants the upload authenticated even for a public repository; without
it the upload is rejected, and quietly.

It was a `CODECOV_TOKEN` secret until 2026-11-22, and Codecov files an upload
under the project the token belongs to, not under the repository that sends it:
this repository's secret held exeradar's token, so every report since at least
2026-10-17 went to exeradar's project, and `codecov/patch` here waited for one
that never came (#111). With OIDC, GitHub itself tells Codecov which repository
the job runs in, so the report cannot land anywhere else; there is no secret to
get wrong. The job needs `id-token: write` for that, and a token in the step
would only be ignored next to `use_oidc` and mislead whoever reads it."""
import yaml

jobs = yaml.safe_load(workflow)["jobs"]
uploads = [(name, job, step) for name, job in jobs.items() for step in job.get("steps", [])
if str(step.get("uses", "")).startswith("codecov/codecov-action@")]
assert uploads, "nothing uploads coverage"
for name, job, step in uploads:
options = step.get("with") or {}
assert options.get("use_oidc") is True, f"{name}: the upload does not use OIDC"
assert "token" not in options, f"{name}: a token next to use_oidc is ignored"
assert (job.get("permissions") or {}).get("id-token") == "write", (
f"{name}: without id-token: write the job cannot ask GitHub for the OIDC token")
assert "secrets.CODECOV_TOKEN" not in workflow, "the secret is still read somewhere"


def test_the_coverage_is_measured_on_this_package(workflow):
Expand Down