Skip to content

馃懛 ci: harden Scorecard-scored checks in CI - #3241

Merged
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:scorecard-hardening
Sep 16, 2026
Merged

gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:scorecard-hardening

Conversation

@gaborbernat

Copy link
Copy Markdown
Contributor

The OpenSSF Scorecard workflow from #3238 put the project at 7.0 this week. Two checks lose points for reasons that cost little to fix. Token-Permissions sits at 8 because check.yaml and pre-release.yaml lack a top-level permissions: block, something Scorecard flags even though every job in both files already scopes its own token. SAST sits at 3 for a different reason: this repo runs CodeQL through GitHub's default setup, but Scorecard's detection only looks for the github/codeql-action/analyze step that an advanced workflow uses, so it does not see the existing scanning.

Adding permissions: {} to the top of both workflows changes the effective token for zero jobs, since job-level permissions already override it. codeql.yaml runs an advanced CodeQL scan for python and actions on push, pull request, and a weekly schedule, pinned to the same github/codeql-action commit scorecard.yaml already uses. Turning this on means switching Code scanning from default setup to advanced in the repository settings, since GitHub only allows one at a time.

One finding stays as-is. Binary-Artifacts flags the four embedded pip and setuptools wheels, and virtualenv seeds every new environment from those wheels, so removing them is not an option. scorecard.yml annotates that finding as remediated: tasks/upgrade_wheels.py records and checks a sha256 for every bundled wheel, so the binaries carry verified integrity even though Scorecard cannot see it. The annotation documents that for anyone reading the report; it does not change the score.

The OpenSSF Scorecard added in pypa#3238 flagged missing top-level
permissions on two workflows and no SAST tool matching its detection
rules, since CodeQL default setup is invisible to it.

Added permissions: {} to check.yaml and pre-release.yaml (release.yaml
gets its own commit alongside the provenance work). Added an advanced
CodeQL workflow for python and actions, next to default setup which
gets disabled in repo settings. Annotated the embedded pip/setuptools
wheels in scorecard.yml as remediated, since they carry sha256
verification but Scorecard has no way to see that.
@gaborbernat
gaborbernat merged commit e13bb21 into pypa:main Sep 16, 2026
62 of 64 checks passed
@gaborbernat gaborbernat added the security Fixes a vulnerability or hardens the supply chain, CI or release label Sep 22, 2026
@gaborbernat
gaborbernat deleted the scorecard-hardening branch October 3, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement security Fixes a vulnerability or hardens the supply chain, CI or release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant