Repository navigation
Relax Develocity access key format validation - #1061
Merged
Merged
Conversation
The access key format is `server=key[;server=key]*`. Validation asserted `\w+` for the key, which rejects the `.`, `-`, `_` and `=` padding present in an OIDC token value. Parsing then split each entry on every `=`, so a key containing `=` would have been silently truncated rather than rejected. Replace the regex with structural validation in `parse`: split on `;`, then split each entry on its *first* `=` only. A hostname must be non-empty and free of whitespace (it cannot contain `=` or `;` by construction), and a key must be non-empty and free of whitespace. Nothing further is assumed about the shape of the key. The whole value is now trimmed, so a trailing newline on a secret no longer rejects the key. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Parsing previously returned `null` silently, so a mistyped access key surfaced only as the generic "Failed to fetch short-lived token" warning, with no indication that the value itself was the problem. Report the position of the offending entry and the reason (missing separator, empty server name or key, embedded whitespace) along with the expected format. The access key is a secret and is not yet registered for masking at parse time, so no part of the value is included in the message. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
bigdaz
enabled auto-merge (squash)
September 1, 2026 20:56
jprinet
added a commit
to gradle/develocity-actions
that referenced
this pull request
Sep 2, 2026
Develocity access keys have the format `server=key[;server=key]*`. The
short-lived-token code validated that format with:
/^([^;=\s]+=\w+)(;[^;=\s]+=\w+)*$/
This is too strict about `key`, and an OIDC token value fails it, making
Workload Identity unusable with these actions. There were two independent
problems:
1. `\w+` rejects the `.`, `-`, `_` and `=` padding a JWT contains.
2. Even had the regex passed, `parse` split each entry with
`hostKey.split('=')` and took `pair[1]`, so a key containing `=` would
have been silently truncated β a worse failure than rejection, since
the mangled key would then be sent to the server.
Drop `accessKeyRegexp` and the separate `isValid` gate; validate
structurally in `parse` instead, asserting only what is needed to split
the value: split on `;`, then split each entry on its first `=` only,
requiring a non-empty, whitespace-free hostname and key.
The fix is applied verbatim from gradle/actions#1061 so this copy of
`short-lived-token.ts` stays in sync with upstream. It lives in
`build-scan-shared`, so it covers setup-maven, setup-npm and
maven-publish-build-scan.
Two intentional behaviour deltas beyond the fix:
- The whole value is now trimmed, so a trailing newline on a secret no
longer rejects the key. Internal whitespace still rejects.
- Empty entries (`host=key;`, `;host=key`) still reject, as before.
Fixes gradle/dv#72981
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 of 2 tasks
cdsap
added a commit
to gradle/develocity-ci-injection
that referenced
this pull request
Oct 26, 2026
## Changes **OIDC pre-step.** In `gradle-build.yml` and `gradle-release.yml`, a step before `setup-gradle` mints a GitHub OIDC token with audience `https://ge.solutions-team.gradle.com` and passes it as `develocity-access-key` in `host=token` form. `setup-gradle` exchanges it for a short-lived Develocity token. **setup-gradle `v4` β `v6.4.0` (pinned SHA).** v4 predates gradle/actions#1061, so it rejects JWT-shaped access keys. v6.4.0 is the first release that accepts them, and is the same pin used in #567 and #2101. Its default cache provider (`enhanced`) is free for public repositories, so caching is left at the default. **Permissions.** - `gradle-build.yml` had no `permissions` block. It now declares `contents: read` and `id-token: write`. The job only checks out and builds. - `gradle-release.yml` gains `id-token: write` next to its existing `contents: write` / `pull-requests: write`. Its runs from `main` match the `GitHub Actions - gradle release` rule (`*release*.yml`). The tests use a mock Develocity server and don't depend on the access key, so test behavior is unchanged. PRs from forks get no OIDC token, just as they get no secrets today: the pre-step warns and `setup-gradle` runs unauthenticated. ## Verification - [x] `Gradle initScript test` on this branch ([run 39668728805](https://github.com/gradle/develocity-ci-injection/actions/runs/39668728805)): short-lived token exchanged, Build Scan [naj76njkorkmu](https://ge.solutions-team.gradle.com/s/naj76njkorkmu) published, build successful - Attempt 1 also authenticated and published [omw6nb2nrgvyq](https://ge.solutions-team.gradle.com/s/omw6nb2nrgvyq), but one TestKit test failed with a daemon `StreamCorruptedException` (Gradle 8.13), unrelated to this change. Attempt 2 passed. - [ ] `Gradle initScript release` was not run, since it publishes a release. Its first run will be the next release from `main`.
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.
Develocity access keys have the format
server=key[;server=key]*. The short-lived-token code validated that format with:This is too strict about
key, and an OIDC token value fails it. There were two independent problems:\w+rejects the.,-,_and=padding a JWT contains.parsesplit each entry withhostKey.split('=')and tookpair[1], so a key containing=would have been silently truncated β a worse failure than rejection, since the mangled key would then be sent to the server.Change
Drop
accessKeyRegexpand the separateisValidgate; validate structurally inparseinstead, asserting only what is needed to split the value:;, then split each entry on its first=only=or;by construction)Two small intentional behaviour deltas beyond the fix:
host=key;,;host=key) still reject, as before.Testing
Added cases to
short-lived-token.test.ts: a JWT-shaped key value, first-separator-only splitting (host1=a=b==β keya=b==), surrounding-whitespace tolerance, araw()round-trip preserving==padding, and a table of nine rejection cases. 32 tests pass; prettier, eslint and./buildare clean.π€ Generated with Claude Code