Repository navigation
Architecture validation for JDK file installs - #1324
Draft
v-mahabaleshwars wants to merge 2 commits into
Draft
v-mahabaleshwars wants to merge 2 commits into
v-mahabaleshwars wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The rejection test covers only heredoc input, leaving unsafe characters, path traversal, separators, whitespace, and invalid leading characters without regression coverage for tool-cache path validation.
1 open issue
What changed in this PR
Hardens setup-java’s architecture handling for local JDK installs, protecting environment-variable names and tool-cache paths while preserving supported aliases and safe custom tokens.
Changes:
- Validate architecture tokens and prevent inherited properties from being treated as aliases.
- Add contract tests and adjust Semeru tests for earlier validation.
- Document accepted syntax and update the bundled setup action.
| File | Description |
|---|---|
src/distributions/platform-types.ts |
Adds token validation and guards alias lookup. |
docs/advanced-usage.md |
Documents accepted architecture characters. |
dist/setup/index.js |
Includes the validation changes in the runtime bundle. |
__tests__/java-platform-contract.test.ts |
Tests custom tokens and unsafe-input rejection. |
__tests__/distributors/semeru-installer.test.ts |
Removes cases now rejected during construction. |
Review effort: Max
Comment on lines
+44
to
+55
| it('rejects an architecture that is not an identifier token', () => { | ||
| const architecture = 'x64<<end\nvalue\nend'; | ||
|
|
||
| expect(() => normalizeArchitecture(architecture)).toThrow( | ||
| `Unsupported architecture value: ${JSON.stringify(architecture)}` | ||
| ); | ||
| expect(() => | ||
| validateJavaPlatform('jdkfile', 'linux', architecture, '17') | ||
| ).toThrow( | ||
| `Unsupported architecture value: ${JSON.stringify(architecture)}` | ||
| ); | ||
| }); |
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.

Description:
Reject architecture values containing characters unsafe for environment-variable names and tool-cache paths, while preserving supported architecture aliases and safe custom tokens. This prevents command-file framing characters from being passed through for jdkfile installs
Related issue:
https://github.com/github/c2c-actions/issues/10581
Check list:
npm run checklocally (format, lint, build, test) and all checks pass.