Skip to content

Architecture validation for JDK file installs - #1324

Draft
v-mahabaleshwars wants to merge 2 commits into
actions:mainfrom
v-mahabaleshwars:fix/jdk-file-arch-validation
Draft

v-mahabaleshwars wants to merge 2 commits into
actions:mainfrom
v-mahabaleshwars:fix/jdk-file-arch-validation

Conversation

@v-mahabaleshwars

@v-mahabaleshwars v-mahabaleshwars commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Ran npm run check locally (format, lint, build, test) and all checks pass.
  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

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.

2 participants