Skip to content

chore(ci): declare the workflow token scopes, pin the one floating action and stop persisting checkout credentials - #8463

Open
Totara-thib wants to merge 3 commits into
mikro-orm:masterfrom
Totara-thib:ci-hardening
Open

Totara-thib wants to merge 3 commits into
mikro-orm:masterfrom
Totara-thib:ci-hardening

Conversation

@Totara-thib

Copy link
Copy Markdown

Hi there, three commits on the workflows.

  • tests.yml and codeql-analysis.yml declare their token permissions: read-only for the build, lint, test, bench and docs jobs, actions: write on the release job that dispatches release.yml, security-events: write for CodeQL.
  • apify/actions/execute-workflow@v1.6.2 moves to its commit, the tag kept as a comment.
  • Eleven of the fourteen checkouts stop persisting the token. The three release checkouts that push version bumps with the GH_TOKEN they are given keep it.

Why: a job that only builds and tests should not hold a token that can write, and release.yml publishes every package to npm and pushes tags and docs with a personal token. The default token scopes are wider than any of them need.

Found and fixed by Plumber's analysis, reviewed and submitted by me.

Every action in the workflows is already referenced by commit except
apify/actions/execute-workflow@v1.6.2, which triggers the release
workflow from the tests job. A tag is a movable pointer, so it now
points at the commit the tag resolves to today, with the tag kept as
a comment.
…e token

tests.yml and codeql-analysis.yml had no permissions block, so their
ten jobs received the repository's default token scopes. The build,
lint, test, bench and docs jobs only read the repository, they get a
read-only token. The release job dispatches release.yml through the
job token, so it keeps actions: write. CodeQL uploads its results, so
it keeps security-events: write.
…th git

actions/checkout writes the job token into .git/config by default, so
every later step, including third-party actions and the packages yarn
installs, can read it. Eleven of the fourteen checkouts never push:
they build, lint, test, benchmark or deploy the docs through the Pages
action. Those eleven no longer keep the token. The three release.yml
checkouts that commit and push version bumps with the GH_TOKEN they
are given keep it.

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