Repository navigation
Conversation
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
exoego
force-pushed
the
harden-workflows
branch
from
October 28, 2026 01:26
e887744 to
f51c894
Compare
exoego
marked this pull request as ready for review
October 28, 2026 01:32
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
GH Workflow Linters such as jactionlint and zizmor report the below problems in the workflows that sbt-typelevel generates.
Fixing them today requires overriding
githubWorkflowJobSetup, or maintaining a copy by hand (see scala-steward-org/scala-steward#4040).actions/checkoutkeeps theGITHUB_TOKENin.git/config, where any later step or an artifact upload can read itartipackedactions/setup-javarestores the sbt cache in runs that publish, so a poisoned cache entry can end up in the published artifactscache-poisoninggithubWorkflowTargetTagsis set, whichsbt-typelevel-ci-releasedoes by defaultpermissions:, notimeout-minutes:shellcheck,missing-permissions,missing-timeoutclean.ymlHave you relied on LLM-based tools in this contribution?
Yes, I guided LLM on design, coding and verification.
I wrote this PR description per contribution guideline.
Changes
Adds options for findings 1 and 2.
Finding 3 will be addressed in #933 separately since no configuration
1.
githubWorkflowCheckoutPersistCredentials: Boolean(defaulttrue)For finding 1
When
false, every generatedactions/checkoutstep getspersist-credentials: false.This covers the
build,publish,dependency-submission,siteandvalidate-stewardjobs.I think
Booleanis enough.Explicit use of
GITHUB_TOKENwith appropriate permissions or OIDC should be preferred over the implicitly persisted credential.2.
githubWorkflowCacheOn: RunPredicate(defaultRunPredicate.Always)For finding 2
This let configure when to use sbt dependency cache, so users can harden workflow from cache poisoning.
RunPredicateis a new predicate on a workflow run.It has three 3 leaves, 2 constants and combinators.
And
RunPredicate.Ref.anyOflifts aSeq[RefPredicate], so the publish refs can be reused directly.RunPredicateis not specific to caching and may be used on other conditions later.The predicate compiles into the
cacheinput ofsetup-java, which disables both the restore and the save when the input is empty:WorkflowStep.SetupJavagets an overload withcacheCond: Option[String]for builds that assemble the steps themselves.The existing overload keeps its signature.
Example
Compatibility
ci.yml, so nothing changes for existing builds until they opt in.WorkflowStepkeep their signatures.Verification
Generated this repository's
ci.ymlwithgithubWorkflowCheckoutPersistCredentials := falseandgithubWorkflowCacheOn := !RunPredicate.Ref.anyOf(githubWorkflowPublishTargetBranches.value), then ran jactionlint 2.3.0 with the default profile.The
artipackedandcache-poisoningfindings disappear.