mirror of
https://github.com/actions/setup-java.git
synced 2026-07-31 16:12:59 +00:00
Verify JDK downloads with vendor checksums (#1167)
* Verify JDK downloads with vendor checksums Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a800a031-600e-4d28-b23e-be309555d38d * Handle missing vendor checksum values Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a800a031-600e-4d28-b23e-be309555d38d * Preserve checksum error during cleanup failure Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a800a031-600e-4d28-b23e-be309555d38d * Validate checksum metadata value types Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a800a031-600e-4d28-b23e-be309555d38d * Clarify checksum documentation Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a800a031-600e-4d28-b23e-be309555d38d * Expand vendor checksum verification Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a800a031-600e-4d28-b23e-be309555d38d * Accept SHA-256 or SHA-512 for JetBrains checksum sibling JetBrains publishes a single, generically-named ".checksum" sibling whose digest algorithm isn't disclosed by the filename. Older JBR 11 builds (e.g. jbrsdk_nomod-11_0_16-*-b2043.64.tar.gz) publish a SHA-256 digest there, while newer builds publish SHA-512. The JetBrains installer previously assumed SHA-512 unconditionally, so verification failed with "Malformed sha512 checksum metadata ... expected a 128-character hexadecimal digest" for those older builds, breaking the jetbrains 11 e2e job on macOS and Windows. fetchChecksum now accepts a list of candidate algorithms and infers the actual algorithm from the returned digest's length, preferring the strongest match. The JetBrains installer passes ['sha512', 'sha256']; all other callers are unaffected since they already pass a single, vendor-disclosed algorithm. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a800a031-600e-4d28-b23e-be309555d38d * Use SapMachine archive checksum files Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a800a031-600e-4d28-b23e-be309555d38d --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a800a031-600e-4d28-b23e-be309555d38d
This commit is contained in:
@@ -50,6 +50,14 @@ const archivePage = `
|
||||
<th>9.0.4 (build 9.0.4+11)</th>
|
||||
<a href="https://download.java.net/java/GA/jdk9/9.0.4/binaries/openjdk-9.0.4_linux-x64_bin.tar.gz">tar.gz</a>
|
||||
`;
|
||||
const GA_CHECKSUM = 'c'.repeat(64);
|
||||
const EA_CHECKSUM = 'd'.repeat(64);
|
||||
const checksumPages: Record<string, string> = {
|
||||
'https://download.java.net/java/GA/jdk26.0.2/hash/10/GPL/openjdk-26.0.2_linux-x64_bin.tar.gz.sha256':
|
||||
GA_CHECKSUM,
|
||||
'https://download.java.net/java/early_access/jdk27/32/GPL/openjdk-27-ea+32_linux-x64_bin.tar.gz.sha256':
|
||||
EA_CHECKSUM
|
||||
};
|
||||
|
||||
function createDistribution(
|
||||
version = '26',
|
||||
@@ -82,8 +90,16 @@ describe('OpenJdkDistribution', () => {
|
||||
'https://jdk.java.net/27/': earlyAccessPage,
|
||||
'https://jdk.java.net/archive/': archivePage
|
||||
};
|
||||
if (url in pages) {
|
||||
return {
|
||||
message: {statusCode: 200},
|
||||
readBody: async () => pages[url]
|
||||
} as Awaited<ReturnType<HttpClient['get']>>;
|
||||
}
|
||||
// Any other GET is a `${archiveUrl}.sha256` checksum sibling request.
|
||||
return {
|
||||
readBody: async () => pages[url] ?? ''
|
||||
message: {statusCode: 200},
|
||||
readBody: async () => checksumPages[url] ?? 'e'.repeat(64)
|
||||
} as Awaited<ReturnType<HttpClient['get']>>;
|
||||
});
|
||||
});
|
||||
@@ -97,8 +113,15 @@ describe('OpenJdkDistribution', () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
version: '26.0.2+10',
|
||||
url: 'https://download.java.net/java/GA/jdk26.0.2/hash/10/GPL/openjdk-26.0.2_linux-x64_bin.tar.gz'
|
||||
url: 'https://download.java.net/java/GA/jdk26.0.2/hash/10/GPL/openjdk-26.0.2_linux-x64_bin.tar.gz',
|
||||
checksum: {
|
||||
algorithm: 'sha256',
|
||||
value: GA_CHECKSUM,
|
||||
source:
|
||||
'https://download.java.net/java/GA/jdk26.0.2/hash/10/GPL/openjdk-26.0.2_linux-x64_bin.tar.gz.sha256'
|
||||
}
|
||||
});
|
||||
expect(getSpy).toHaveBeenCalledWith(`${result.url}.sha256`);
|
||||
});
|
||||
|
||||
it('resolves an archived GA release', async () => {
|
||||
@@ -144,9 +167,16 @@ describe('OpenJdkDistribution', () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
version: '27.0.0+32',
|
||||
url: 'https://download.java.net/java/early_access/jdk27/32/GPL/openjdk-27-ea+32_linux-x64_bin.tar.gz'
|
||||
url: 'https://download.java.net/java/early_access/jdk27/32/GPL/openjdk-27-ea+32_linux-x64_bin.tar.gz',
|
||||
checksum: {
|
||||
algorithm: 'sha256',
|
||||
value: EA_CHECKSUM,
|
||||
source:
|
||||
'https://download.java.net/java/early_access/jdk27/32/GPL/openjdk-27-ea+32_linux-x64_bin.tar.gz.sha256'
|
||||
}
|
||||
});
|
||||
expect(getSpy).not.toHaveBeenCalledWith('https://jdk.java.net/archive/');
|
||||
expect(getSpy).toHaveBeenCalledWith(`${result.url}.sha256`);
|
||||
});
|
||||
|
||||
it('reports available versions when no release matches', async () => {
|
||||
|
||||
Reference in New Issue
Block a user