mirror of
https://github.com/actions/setup-java.git
synced 2026-10-02 09:06:05 +03:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0e6e4dbf7 | ||
|
|
b24925bc49 | ||
|
|
47b36480ae | ||
|
|
74920aab4a | ||
|
|
a78ec39f12 | ||
|
|
97c5a5e13a | ||
|
|
1aa87b638d | ||
|
|
de7274f081 | ||
|
|
134912a529 | ||
|
|
0781fc6af3 | ||
|
|
4889c4aff5 | ||
|
|
8fd3240085 | ||
|
|
2732291815 | ||
|
|
1a8f22b7f7 | ||
|
|
85030b78b5 |
+16
-13
@@ -1,22 +1,25 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
# Enable version updates for npm
|
||||
- package-ecosystem: 'npm'
|
||||
# Look for `package.json` and `lock` files in the `root` directory
|
||||
directory: '/'
|
||||
# Check the npm registry for updates every day (weekdays)
|
||||
schedule:
|
||||
interval: 'weekly'
|
||||
interval: 'monthly'
|
||||
cooldown:
|
||||
default-days: 7
|
||||
groups:
|
||||
monthly-npm-updates:
|
||||
applies-to: 'version-updates'
|
||||
patterns:
|
||||
- '*'
|
||||
|
||||
# Enable version updates for GitHub Actions
|
||||
- package-ecosystem: 'github-actions'
|
||||
# Workflow files stored in the default location of `.github/workflows`
|
||||
# You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'weekly'
|
||||
interval: 'monthly'
|
||||
cooldown:
|
||||
default-days: 7
|
||||
groups:
|
||||
monthly-actions-updates:
|
||||
applies-to: 'version-updates'
|
||||
patterns:
|
||||
- '*'
|
||||
|
||||
@@ -154,8 +154,8 @@ jobs:
|
||||
version: ['21', '17']
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Install bash
|
||||
run: apk add --no-cache bash
|
||||
- name: Install bash and GnuPG
|
||||
run: apk add --no-cache bash gnupg
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -340,6 +340,7 @@ jobs:
|
||||
with:
|
||||
java-version: ${{ matrix.version }}
|
||||
distribution: ${{ matrix.distribution }}
|
||||
verify-signature: ${{ matrix.distribution == 'temurin' && contains(matrix.version, '-ea') && 'false' || '' }}
|
||||
- name: Verify Java
|
||||
env:
|
||||
JAVA_VERSION: ${{ matrix.version }}
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: brace-expansion
|
||||
version: 5.0.9
|
||||
version: 5.0.12
|
||||
type: npm
|
||||
summary: Brace expansion as known from sh/bash
|
||||
homepage:
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: fast-xml-parser
|
||||
version: 5.11.0
|
||||
version: 5.11.1
|
||||
type: npm
|
||||
summary: Validate XML, Parse XML, Build XML without C/C++ based libraries
|
||||
homepage:
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: undici
|
||||
version: 6.28.0
|
||||
version: 6.29.0
|
||||
type: npm
|
||||
summary: An HTTP/1.1 client, written from scratch for Node.js
|
||||
homepage: https://undici.nodejs.org
|
||||
|
||||
@@ -48,13 +48,17 @@ steps:
|
||||
### V6
|
||||
|
||||
- Migrated the action implementation to ESM to support the latest `@actions/*` packages.
|
||||
- Added the `oracle-openjdk`, `redhat`, and `liberica-nik` distributions.
|
||||
- Added Oracle OpenJDK (`oracle-openjdk`), Red Hat Build of OpenJDK (`redhat`), and Liberica Native Image Kit (`liberica-nik`), and expanded Tencent Kona support through JDK 25.
|
||||
- Added `java-version: latest` to resolve the newest stable GA release from the distribution's remote metadata.
|
||||
- JDK downloads now automatically verify authoritative checksums, and package signature verification defaults to enabled for Temurin and Microsoft builds.
|
||||
- Expanded install compatibility with JEP 322 multi-field versions such as `18.0.1.1`, Temurin `jdk+jmods` packages, and native musl artifacts on Alpine for Dragonwell, Corretto, Zulu, and Liberica.
|
||||
- JDK downloads now automatically verify authoritative checksums. Package signature verification is supported for Temurin and Microsoft builds, with configurable strict enforcement.
|
||||
- Added `force-download: true` to bypass the tool cache and perform a reproducible fresh install.
|
||||
- Dependency caching now supports custom paths with `cache-path` and restore-only operation with `cache-read-only: true`.
|
||||
- Dependency cache keys now include `.mvn/extensions.xml` and `gradle.properties`, preventing stale restores when Maven extensions or Gradle dependency properties change.
|
||||
- Downloaded JDKs are now [cached](#caching-jdk-installations) automatically when `cache` is set; use `cache-jdk` to enable or disable it independently.
|
||||
- Warm JDK-cached jobs can reuse cached release metadata, avoiding vendor API calls while retaining a stale-metadata fallback for vendor outages and rate limits.
|
||||
- Maven configuration now supports multiple server credentials and custom dependency-resolution repositories.
|
||||
- Maven signing keys are imported into an isolated temporary GPG home instead of the runner's default keyring.
|
||||
- Set `problem-matcher: false` to disable Java compiler and uncaught-exception annotations.
|
||||
- GraalVM distributions now set `GRAALVM_HOME` in addition to `JAVA_HOME`.
|
||||
- Invalid boolean values, unsupported distribution/package/platform combinations, and mismatched Maven toolchain ID counts now fail with targeted errors.
|
||||
@@ -65,6 +69,7 @@ steps:
|
||||
- Deprecated aliases still work, but emit warnings.
|
||||
- Maven GPG passphrases are now passed through `gpg.passphraseEnvName` instead of a deprecated `gpg.passphrase` server entry in `settings.xml`. This requires `maven-gpg-plugin` 3.2.0 or newer. See [GPG](docs/advanced-usage.md#gpg).
|
||||
- Legacy AdoptOpenJDK distributions were removed. Use `temurin` instead of `adopt` or `adopt-hotspot`, and `semeru` instead of `adopt-openj9`.
|
||||
- See the [complete V6 release notes](https://github.com/actions/setup-java/releases/tag/v6.0.0) for all enhancements and fixes.
|
||||
|
||||
### V5
|
||||
|
||||
@@ -145,14 +150,14 @@ steps:
|
||||
| `java-version-file` | Path to `.java-version`, `.tool-versions`, or `.sdkmanrc`. Used when `java-version` is not set. | |
|
||||
| `distribution` | Java distribution keyword. Values are case-sensitive and must match one of the supported keywords below. Required unless `java-version-file` points to `.sdkmanrc` with a recognized distribution suffix. | |
|
||||
| `java-package` | Package variant such as `jdk`, `jre`, `jdk+fx`, `jre+fx`, `jdk+crac`, `jre+crac`, `jdk+jmods`, `jdk+jcef`, `jre+jcef`, `jdk+ft`, or `jre+ft`. Support varies by distribution. | `jdk` |
|
||||
| `architecture` | Package architecture. Canonical values are `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`, `ppc64`, and `s390x`. Aliases `ia32`, `amd64`, `arm`, and `arm64` are normalized. | Runner architecture |
|
||||
| `architecture` | Package architecture. Canonical values are `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`, `ppc64`, `riscv64`, and `s390x`. Aliases `ia32`, `amd64`, `arm`, and `arm64` are normalized. | Runner architecture |
|
||||
| `jdk-file` | Local compressed JDK archive. Requires `distribution: jdkfile`. | |
|
||||
| `check-latest` | Check remote metadata for the latest version satisfying the version spec before using the runner tool cache. | `false` |
|
||||
| `force-download` | Always download Java and replace any matching version in the tool cache. | `false` |
|
||||
| `set-default` | Add Java to `PATH` and set `JAVA_HOME`. When `false`, only version-specific `JAVA_HOME_<major>_<arch>` variables are set. | `true` |
|
||||
| `problem-matcher` | Register Java compiler and uncaught exception problem matchers. | `true` |
|
||||
| `verify-signature` | Verify downloaded Java package signatures when supported. Defaults to `true` for `temurin` and `microsoft`, and `false` for other distributions. | Automatically enabled for `temurin` and `microsoft` |
|
||||
| `verify-signature-public-key` | ASCII-armored GPG public key to use for signature verification. Overrides the bundled key. | |
|
||||
| `verify-signature` | Verify downloaded Java package signatures when supported. Explicitly setting this to `true` makes verification failures fatal. | Distribution-dependent; see [Download integrity and signatures](#download-integrity-and-signatures) |
|
||||
| `verify-signature-public-key` | One or more ASCII-armored GPG public keys used for signature verification. Concatenate multiple armored key blocks. Custom keys replace the bundled distribution keys. | |
|
||||
| `token` | Token for fetching GitHub.com-hosted version manifests, useful on GitHub Enterprise Server when unauthenticated requests are rate-limited. | `${{ github.token }}` on GitHub.com; empty string on GHES |
|
||||
| `cache` | Enable dependency caching for `maven`, `gradle`, or `sbt`. | |
|
||||
| `cache-jdk` | Cache downloaded JDK installations between jobs. When omitted, JDK caching is enabled only if `cache` is set. Set explicitly to `true` or `false` to override. | Enabled when `cache` is set |
|
||||
@@ -228,7 +233,7 @@ Additional distribution notes:
|
||||
| --- | --- |
|
||||
| Major version | `8`, `11`, `17`, `21`, `25` |
|
||||
| Specific feature or patch version | `11.0`, `11.0.4`, `17.0`, `8.0.282+8` |
|
||||
| JEP 322 multi-field versions | `11.0.9.1`, `18.0.1.1` |
|
||||
| JEP 322 multi-field versions | `11.0.9.1`, `18.0.1.1`, `26.0.2.1+1` |
|
||||
| Early access | `15-ea`, `15.0.0-ea`, `27-ea` |
|
||||
| Latest stable GA release | `latest` |
|
||||
|
||||
@@ -242,7 +247,34 @@ GitHub-hosted runners primarily pre-cache Eclipse Temurin JDKs. See the installe
|
||||
|
||||
Distributions or individual releases without an authoritative checksum continue to install normally, with the omission reported in debug logs. Installations resolved directly from the runner tool cache — including JDKs preinstalled on the runner image and JDKs installed by an earlier step of the same job — are not downloaded again and are not reverified, even when `verify-signature: true` is set. Use `force-download: true` to always download and verify the archive.
|
||||
|
||||
Use `verify-signature: true` to verify package signatures for distributions that support it. Currently supported distributions are `temurin` and `microsoft`; setting it for an unsupported distribution fails the workflow.
|
||||
Package signature verification is supported for `temurin` and `microsoft`. When `verify-signature` is omitted, the action checks the signature and warns if GPG is unavailable or verification fails, but does not enforce the result. Explicitly setting `verify-signature: true` enforces verification and makes these failures fatal. Setting `verify-signature: true` for an unsupported distribution also fails the workflow.
|
||||
|
||||
> [!WARNING]
|
||||
> Requesting explicit signature verification with verify-signature can fail a build after an unexpected but legitimate vendor signing-key rotation, because the action's bundled keys may not yet include the new key. Confirm a new key through the vendor's trusted documentation before using it.
|
||||
|
||||
After confirming a legitimate rotation, configure the updated key with `verify-signature-public-key`. The input accepts one or more ASCII-armored public keys; concatenate complete armored key blocks when both old and new vendor keys are needed during a transition. Custom keys replace, rather than extend, the keys bundled with the selected distribution.
|
||||
|
||||
```yaml
|
||||
- uses: actions/setup-java@v6
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '25'
|
||||
verify-signature: true
|
||||
verify-signature-public-key: |
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
...vendor key material...
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
```
|
||||
|
||||
As a temporary fallback while a legitimate rotation is being investigated, set `verify-signature: false`. This disables package signature verification, although authoritative checksum verification still applies when the vendor publishes a checksum.
|
||||
|
||||
```yaml
|
||||
- uses: actions/setup-java@v6
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '25'
|
||||
verify-signature: false
|
||||
```
|
||||
|
||||
## Caching
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ function createRegisteredJdk(version = '21.0.8+9') {
|
||||
architecture: 'x64',
|
||||
version,
|
||||
source: `sha256:${path.basename(root)}`,
|
||||
verification: 'unverified',
|
||||
verification: 'disabled',
|
||||
path: jdkPath
|
||||
};
|
||||
registerJdk(jdk);
|
||||
|
||||
@@ -71,8 +71,11 @@ jest.unstable_mockModule('@actions/tool-cache', () => ({
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('../../src/jdk-cache.js', () => ({
|
||||
getJdkVerificationIdentity: jest.fn((verified: boolean, key?: string) =>
|
||||
verified ? (key ? 'verified:custom' : 'verified:bundled') : 'unverified'
|
||||
getJdkVerificationIdentity: jest.fn(
|
||||
(verified: boolean, enforced: boolean, key?: string) =>
|
||||
verified
|
||||
? `${enforced ? 'enforced' : 'check-and-warn'}:${key ? 'custom' : 'bundled'}`
|
||||
: 'disabled'
|
||||
),
|
||||
registerJdk: jest.fn(),
|
||||
restoreJdk: jest.fn()
|
||||
@@ -395,8 +398,10 @@ describe('setupJava', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
(jdkCache.getJdkVerificationIdentity as jest.Mock).mockImplementation(
|
||||
(verified: boolean, key?: string) =>
|
||||
verified ? (key ? 'verified:custom' : 'verified:bundled') : 'unverified'
|
||||
(verified: boolean, enforced: boolean, key?: string) =>
|
||||
verified
|
||||
? `${enforced ? 'enforced' : 'check-and-warn'}:${key ? 'custom' : 'bundled'}`
|
||||
: 'disabled'
|
||||
);
|
||||
spyGetToolcachePath = util.getToolcachePath as jest.Mock;
|
||||
spyGetToolcachePath.mockImplementation(
|
||||
@@ -826,7 +831,7 @@ describe('setupJava', () => {
|
||||
expect(jdkCache.registerJdk).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
version: actualJavaVersion,
|
||||
verification: 'unverified'
|
||||
verification: 'disabled'
|
||||
})
|
||||
);
|
||||
});
|
||||
@@ -886,7 +891,7 @@ describe('setupJava', () => {
|
||||
architecture: 'x86',
|
||||
version: actualJavaVersion,
|
||||
source: `some/random_url/java/${actualJavaVersion}`,
|
||||
verification: 'unverified',
|
||||
verification: 'disabled',
|
||||
path: path.join(toolCachePath, 'Java_Empty_jdk', actualJavaVersion)
|
||||
});
|
||||
expect(downloadTool).not.toHaveBeenCalled();
|
||||
@@ -919,7 +924,7 @@ describe('setupJava', () => {
|
||||
architecture: 'x86',
|
||||
version: actualJavaVersion,
|
||||
source: `some/random_url/java/${actualJavaVersion}`,
|
||||
verification: 'unverified',
|
||||
verification: 'disabled',
|
||||
path: path.join(toolCachePath, 'Java_Empty_jdk', actualJavaVersion)
|
||||
};
|
||||
expect(jdkCache.restoreJdk).toHaveBeenCalledWith(expectedIdentity);
|
||||
@@ -1753,6 +1758,8 @@ describe('normalizeVersion', () => {
|
||||
['11.0.9.1', {version: '11.0.9+1', stable: true, latest: false}],
|
||||
['12.0.2.1.0', {version: '12.0.2+1.0', stable: true, latest: false}],
|
||||
['18.0.1.1-ea', {version: '18.0.1+1', stable: false, latest: false}],
|
||||
['26.0.2.1+1', {version: '26.0.2+1.1', stable: true, latest: false}],
|
||||
['25.0.4.1+1', {version: '25.0.4+1.1', stable: true, latest: false}],
|
||||
['latest', {version: 'x', stable: true, latest: true}],
|
||||
['LATEST', {version: 'x', stable: true, latest: true}],
|
||||
[' Latest ', {version: 'x', stable: true, latest: true}]
|
||||
|
||||
@@ -82,7 +82,7 @@ describe('getJavaDistribution', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.each(['8', '23.x', '23.0.1.1', '<24'])(
|
||||
it.each(['8', '23.x', '23.0.1.1', '23.0.1.1+1', '<24'])(
|
||||
"rejects Temurin java-package 'jdk+jmods' for version %s",
|
||||
async version => {
|
||||
await expect(
|
||||
@@ -96,7 +96,7 @@ describe('getJavaDistribution', () => {
|
||||
}
|
||||
);
|
||||
|
||||
it.each(['24', '24.0.1.1', '25-ea', '>=21', 'latest'])(
|
||||
it.each(['24', '24.0.1.1', '25.0.4.1+1', '25-ea', '>=21', 'latest'])(
|
||||
"accepts Temurin java-package 'jdk+jmods' for version %s",
|
||||
async version => {
|
||||
expect(
|
||||
|
||||
@@ -14,7 +14,6 @@ import type {IncomingMessage} from 'http';
|
||||
import {Readable} from 'stream';
|
||||
|
||||
import manifestData from '../data/jetbrains.json' with {type: 'json'};
|
||||
import os from 'os';
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
@@ -81,6 +80,7 @@ describe('getAvailableVersions', () => {
|
||||
jest.setTimeout(10_000);
|
||||
|
||||
let spyHttpClient: any;
|
||||
let spyHttpClientHead: any;
|
||||
let spyCoreError: any;
|
||||
const originalGitHubToken = process.env.GITHUB_TOKEN;
|
||||
|
||||
@@ -93,6 +93,10 @@ describe('getAvailableVersions', () => {
|
||||
headers: {},
|
||||
result: []
|
||||
});
|
||||
spyHttpClientHead = jest.spyOn(HttpClient.prototype, 'head');
|
||||
spyHttpClientHead.mockResolvedValue({
|
||||
message: {statusCode: 200}
|
||||
} as any);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
@@ -133,9 +137,7 @@ describe('getAvailableVersions', () => {
|
||||
const availableVersions = await distribution['getAvailableVersions']();
|
||||
expect(availableVersions).not.toBeNull();
|
||||
|
||||
const length =
|
||||
os.platform() === 'win32' ? manifestData.length : manifestData.length + 2;
|
||||
expect(availableVersions.length).toBe(length);
|
||||
expect(availableVersions.length).toBe(manifestData.length + 2);
|
||||
}, 10_000);
|
||||
|
||||
it('continues a stable request after an all-prerelease page', async () => {
|
||||
@@ -358,6 +360,7 @@ describe('getAvailableVersions', () => {
|
||||
|
||||
it('retries a GitHub rate limit using Retry-After', async () => {
|
||||
spyHttpClient.mockRestore();
|
||||
spyHttpClientHead.mockRestore();
|
||||
const sleep = jest.fn(async () => undefined);
|
||||
const requestRaw = jest
|
||||
.spyOn(HttpClient.prototype, 'requestRaw')
|
||||
|
||||
@@ -253,6 +253,39 @@ describe('findPackageForDownload', () => {
|
||||
expect(result.version).toBe(expected);
|
||||
});
|
||||
|
||||
describe('compound build versions', () => {
|
||||
beforeEach(() => {
|
||||
distribution['getAvailableVersions'] = async () =>
|
||||
['1', '1.1', '1.2', '1.10'].map(build => ({
|
||||
featureVersion: 25,
|
||||
interimVersion: 0,
|
||||
updateVersion: 4,
|
||||
buildVersion: 1,
|
||||
version: `25.0.4+${build}`,
|
||||
downloadUrl: `https://download.bell-sw.com/java/25.0.4+${build}/bellsoft-jdk25.0.4+${build}-macos-aarch64.tar.gz`
|
||||
}));
|
||||
});
|
||||
|
||||
it.each([
|
||||
['25.0.4+1.1', '25.0.4+1.1'],
|
||||
['25.0.4+1', '25.0.4+1'],
|
||||
['25.0.4', '25.0.4+1.10'],
|
||||
['25', '25.0.4+1.10']
|
||||
])('version is %s -> %s', async (input, expected) => {
|
||||
const result = await distribution['findPackageForDownload'](input);
|
||||
expect(result).toEqual({
|
||||
version: expected,
|
||||
url: `https://download.bell-sw.com/java/${expected}/bellsoft-jdk${expected}-macos-aarch64.tar.gz`
|
||||
});
|
||||
});
|
||||
|
||||
it('does not substitute a different compound build', async () => {
|
||||
await expect(
|
||||
distribution['findPackageForDownload']('25.0.4+1.3')
|
||||
).rejects.toThrow(/No matching version found for SemVer/);
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error', async () => {
|
||||
await expect(distribution['findPackageForDownload']('17')).rejects.toThrow(
|
||||
/No matching version found for SemVer/
|
||||
@@ -335,6 +368,36 @@ describe('convertVersionToSemver', () => {
|
||||
buildVersion: 13
|
||||
},
|
||||
'11.0.0+13'
|
||||
],
|
||||
[
|
||||
{
|
||||
version: '25.0.4+1.1',
|
||||
featureVersion: 25,
|
||||
interimVersion: 0,
|
||||
updateVersion: 4,
|
||||
buildVersion: 1
|
||||
},
|
||||
'25.0.4+1.1'
|
||||
],
|
||||
[
|
||||
{
|
||||
version: '25+36',
|
||||
featureVersion: 25,
|
||||
interimVersion: 0,
|
||||
updateVersion: 0,
|
||||
buildVersion: 36
|
||||
},
|
||||
'25.0.0+36'
|
||||
],
|
||||
[
|
||||
{
|
||||
version: '8u202',
|
||||
featureVersion: 8,
|
||||
interimVersion: 0,
|
||||
updateVersion: 202,
|
||||
buildVersion: 8
|
||||
},
|
||||
'8.0.202+8'
|
||||
]
|
||||
])('%s -> %s', (input, expected) => {
|
||||
const actual = distributions['convertVersionToSemver']({
|
||||
|
||||
@@ -58,7 +58,7 @@ jest.unstable_mockModule('@actions/tool-cache', () => ({
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('../../src/jdk-cache.js', () => ({
|
||||
getJdkVerificationIdentity: jest.fn(() => 'unverified'),
|
||||
getJdkVerificationIdentity: jest.fn(() => 'disabled'),
|
||||
registerJdk: jest.fn(),
|
||||
restoreJdk: jest.fn()
|
||||
}));
|
||||
@@ -106,7 +106,7 @@ describe('setupJava', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
(jdkCache.getJdkVerificationIdentity as jest.Mock).mockReturnValue(
|
||||
'unverified'
|
||||
'disabled'
|
||||
);
|
||||
spyGetToolcachePath = util.getToolcachePath as jest.Mock;
|
||||
spyGetToolcachePath.mockImplementation(
|
||||
@@ -283,7 +283,7 @@ describe('setupJava', () => {
|
||||
expect.objectContaining({
|
||||
distribution: 'jdkfile',
|
||||
version: actualJavaVersion,
|
||||
verification: 'unverified'
|
||||
verification: 'disabled'
|
||||
})
|
||||
);
|
||||
} finally {
|
||||
|
||||
@@ -444,6 +444,64 @@ describe('downloadTool', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('warns with key rotation recovery guidance when default verification fails', async () => {
|
||||
spyVerifySignature.mockRejectedValue(new Error('bad signature'));
|
||||
const signedDistribution = new MicrosoftDistributions({
|
||||
version: '17',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
await signedDistribution['downloadTool']({
|
||||
version: '17.0.14+7',
|
||||
url: 'https://example.com/jdk.tar.gz',
|
||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
||||
});
|
||||
|
||||
expect(core.warning).toHaveBeenCalledWith(
|
||||
expect.stringMatching(
|
||||
/bad signature.*https:\/\/github\.com\/actions\/setup-java#download-integrity-and-signatures/
|
||||
)
|
||||
);
|
||||
expect(spyExtractJdkFile).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('fails with recovery guidance when verification is explicitly enabled', async () => {
|
||||
spyVerifySignature.mockRejectedValue(new Error('bad signature'));
|
||||
const signedDistribution = new MicrosoftDistributions({
|
||||
version: '17',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false,
|
||||
verifySignature: true
|
||||
});
|
||||
|
||||
await expect(
|
||||
signedDistribution['downloadTool']({
|
||||
version: '17.0.14+7',
|
||||
url: 'https://example.com/jdk.tar.gz',
|
||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
||||
})
|
||||
).rejects.toThrow(
|
||||
/bad signature.*https:\/\/github\.com\/actions\/setup-java#download-integrity-and-signatures/
|
||||
);
|
||||
expect(spyExtractJdkFile).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('warns when the signature is missing during default verification', async () => {
|
||||
await distribution['downloadTool']({
|
||||
version: '17.0.14+7',
|
||||
url: 'https://example.com/jdk.tar.gz'
|
||||
});
|
||||
|
||||
expect(core.warning).toHaveBeenCalledWith(
|
||||
"Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version 17.0.14+7."
|
||||
);
|
||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
||||
expect(spyExtractJdkFile).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('fails when signature is missing and verification is enabled', async () => {
|
||||
const signedDistribution = new MicrosoftDistributions({
|
||||
version: '17',
|
||||
|
||||
@@ -73,6 +73,7 @@ jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
jest.unstable_mockModule('../../src/gpg.js', () => ({
|
||||
importKey: jest.fn(),
|
||||
removeGpgHome: jest.fn(),
|
||||
isGpgAvailable: jest.fn(),
|
||||
verifyPackageSignature: jest.fn()
|
||||
}));
|
||||
|
||||
@@ -292,7 +293,8 @@ describe('getAvailableVersions', () => {
|
||||
it.each([
|
||||
['amd64', 'x64'],
|
||||
['arm', 'arm'],
|
||||
['arm64', 'aarch64']
|
||||
['arm64', 'aarch64'],
|
||||
['riscv64', 'riscv64']
|
||||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
async (osArch: string, distroArch: string) => {
|
||||
@@ -376,6 +378,97 @@ describe('findPackageForDownload', () => {
|
||||
expect(resolvedVersion.version).toBe('16.0.2+7');
|
||||
});
|
||||
|
||||
describe('OpenJDK patch (respin) versions', () => {
|
||||
const makeRelease = (
|
||||
semverVersion: string,
|
||||
openjdkVersion: string,
|
||||
versionData: Record<string, number>
|
||||
) => ({
|
||||
binaries: [
|
||||
{
|
||||
package: {
|
||||
link: `https://example.com/${openjdkVersion}.tar.gz`,
|
||||
checksum: `checksum-${openjdkVersion}`,
|
||||
checksum_link: `https://example.com/${openjdkVersion}.sha256.txt`
|
||||
}
|
||||
}
|
||||
],
|
||||
version_data: {
|
||||
semver: semverVersion,
|
||||
openjdk_version: openjdkVersion,
|
||||
minor: 0,
|
||||
...versionData
|
||||
}
|
||||
});
|
||||
|
||||
const respinManifest = [
|
||||
makeRelease('26.0.2+101', '26.0.2.1+1', {
|
||||
major: 26,
|
||||
security: 2,
|
||||
patch: 1,
|
||||
build: 1
|
||||
}),
|
||||
makeRelease('26.0.2+10', '26.0.2+10', {
|
||||
major: 26,
|
||||
security: 2,
|
||||
build: 10
|
||||
}),
|
||||
makeRelease('25.0.4+101.0.LTS', '25.0.4.1+1-LTS', {
|
||||
major: 25,
|
||||
security: 4,
|
||||
patch: 1,
|
||||
build: 1
|
||||
}),
|
||||
makeRelease('25.0.4+7.0.LTS', '25.0.4+7-LTS', {
|
||||
major: 25,
|
||||
security: 4,
|
||||
build: 7
|
||||
})
|
||||
];
|
||||
|
||||
it.each([
|
||||
['26.0.2.1+1', '26.0.2+101'],
|
||||
['26.0.2+10', '26.0.2+10'],
|
||||
['26', '26.0.2+101'],
|
||||
['26.0.2', '26.0.2+101'],
|
||||
['25.0.4.1+1', '25.0.4+101.0.LTS'],
|
||||
['25.0.4+7', '25.0.4+7.0.LTS'],
|
||||
['25.0.4', '25.0.4+101.0.LTS']
|
||||
])('%s resolves to %s', async (input, expected) => {
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
version: input,
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
},
|
||||
TemurinImplementation.Hotspot
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => respinManifest as any;
|
||||
const resolvedVersion = await distribution['findPackageForDownload'](
|
||||
distribution['version']
|
||||
);
|
||||
expect(resolvedVersion.version).toBe(expected);
|
||||
expect(resolvedVersion).not.toHaveProperty('openjdkVersion');
|
||||
});
|
||||
|
||||
it('does not match a non-existent respin', async () => {
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
version: '26.0.2.2+1',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
},
|
||||
TemurinImplementation.Hotspot
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => respinManifest as any;
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](distribution['version'])
|
||||
).rejects.toThrow(/No matching version found for SemVer '26.0.2\+2.1'/);
|
||||
});
|
||||
});
|
||||
|
||||
it('version is found but binaries list is empty', async () => {
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
@@ -437,6 +530,7 @@ describe('downloadTool', () => {
|
||||
beforeEach(() => {
|
||||
spyDownloadTool = tc.downloadTool as jest.Mock;
|
||||
spyDownloadTool.mockResolvedValue('/tmp/jdk.tar.gz');
|
||||
(gpg.isGpgAvailable as jest.Mock).mockResolvedValue(true);
|
||||
spyVerifySignature = gpg.verifyPackageSignature as jest.Mock;
|
||||
spyVerifySignature.mockResolvedValue(undefined);
|
||||
spyExtractJdkFile = util.extractJdkFile as jest.Mock;
|
||||
@@ -502,6 +596,133 @@ describe('downloadTool', () => {
|
||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('skips implicit signature verification when gpg is unavailable', async () => {
|
||||
(gpg.isGpgAvailable as jest.Mock).mockResolvedValue(false);
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
version: '17',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
},
|
||||
TemurinImplementation.Hotspot
|
||||
);
|
||||
|
||||
await expect(
|
||||
distribution['downloadTool']({
|
||||
version: '17.0.14+7',
|
||||
url: 'https://example.com/jdk.tar.gz',
|
||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
||||
})
|
||||
).resolves.toEqual({version: '17.0.14+7', path: '/tmp/toolcache'});
|
||||
|
||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
||||
expect(core.warning).toHaveBeenCalledWith(
|
||||
"Input 'verify-signature' is enabled, but gpg is not available."
|
||||
);
|
||||
});
|
||||
|
||||
it('fails when signature verification is explicitly enabled without gpg', async () => {
|
||||
(gpg.isGpgAvailable as jest.Mock).mockResolvedValue(false);
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
version: '17',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false,
|
||||
verifySignature: true
|
||||
},
|
||||
TemurinImplementation.Hotspot
|
||||
);
|
||||
|
||||
await expect(
|
||||
distribution['downloadTool']({
|
||||
version: '17.0.14+7',
|
||||
url: 'https://example.com/jdk.tar.gz',
|
||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
||||
})
|
||||
).rejects.toThrow(
|
||||
"Input 'verify-signature' is enabled, but gpg is not available."
|
||||
);
|
||||
|
||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('warns when implicit signature verification fails', async () => {
|
||||
spyVerifySignature.mockRejectedValue(new Error('bad signature'));
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
version: '17',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
},
|
||||
TemurinImplementation.Hotspot
|
||||
);
|
||||
|
||||
await expect(
|
||||
distribution['downloadTool']({
|
||||
version: '17.0.14+7',
|
||||
url: 'https://example.com/jdk.tar.gz',
|
||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
||||
})
|
||||
).resolves.toEqual({version: '17.0.14+7', path: '/tmp/toolcache'});
|
||||
|
||||
expect(core.warning).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
'https://github.com/actions/setup-java#download-integrity-and-signatures'
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it('fails when explicitly requested signature verification fails', async () => {
|
||||
spyVerifySignature.mockRejectedValue(new Error('bad signature'));
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
version: '17',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false,
|
||||
verifySignature: true
|
||||
},
|
||||
TemurinImplementation.Hotspot
|
||||
);
|
||||
|
||||
await expect(
|
||||
distribution['downloadTool']({
|
||||
version: '17.0.14+7',
|
||||
url: 'https://example.com/jdk.tar.gz',
|
||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
||||
})
|
||||
).rejects.toThrow(
|
||||
/Failed to verify signature for Temurin version 17\.0\.14\+7.*bad signature.*https:\/\/github\.com\/actions\/setup-java#download-integrity-and-signatures/
|
||||
);
|
||||
});
|
||||
|
||||
it('warns when a signature is missing and verification is implicit', async () => {
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
version: '17',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
},
|
||||
TemurinImplementation.Hotspot
|
||||
);
|
||||
|
||||
await expect(
|
||||
distribution['downloadTool']({
|
||||
version: '17.0.14+7',
|
||||
url: 'https://example.com/jdk.tar.gz'
|
||||
})
|
||||
).resolves.toEqual({version: '17.0.14+7', path: '/tmp/toolcache'});
|
||||
|
||||
expect(core.warning).toHaveBeenCalledWith(
|
||||
"Input 'verify-signature' is enabled, but no signature URL was found for Temurin version 17.0.14+7."
|
||||
);
|
||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('downloads and adds matching JMODs to the JDK', async () => {
|
||||
spyDownloadTool
|
||||
.mockResolvedValueOnce('/tmp/jdk.tar.gz')
|
||||
|
||||
@@ -334,6 +334,69 @@ describe('findPackageForDownload', () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe('hotfix builds with a 4-segment java_version', () => {
|
||||
// Mirrors the Azul Metadata API: 25.0.4.1 hotfix is reported as
|
||||
// java_version=[25,0,4,1], openjdk_build_number=1 (SDKMAN '25.0.4+1.1').
|
||||
const hotfixManifest = [
|
||||
{
|
||||
package_uuid: 'uuid-25.0.4+7',
|
||||
name: 'zulu25.36.15-ca-jdk25.0.4-linux_x64.tar.gz',
|
||||
download_url:
|
||||
'https://cdn.azul.com/zulu/bin/zulu25.36.15-ca-jdk25.0.4-linux_x64.tar.gz',
|
||||
java_version: [25, 0, 4],
|
||||
openjdk_build_number: 7,
|
||||
distro_version: [25, 36, 15, 0],
|
||||
latest: false,
|
||||
availability_type: 'ca'
|
||||
},
|
||||
{
|
||||
package_uuid: 'uuid-25.0.4+1.1',
|
||||
name: 'zulu25.36.205-ca-jdk25.0.4.1-linux_x64.tar.gz',
|
||||
download_url:
|
||||
'https://cdn.azul.com/zulu/bin/zulu25.36.205-ca-jdk25.0.4.1-linux_x64.tar.gz',
|
||||
java_version: [25, 0, 4, 1],
|
||||
openjdk_build_number: 1,
|
||||
distro_version: [25, 36, 205, 0],
|
||||
latest: true,
|
||||
availability_type: 'ca'
|
||||
},
|
||||
{
|
||||
package_uuid: 'uuid-25.0.3+9',
|
||||
name: 'zulu25.34.17-ca-jdk25.0.3-linux_x64.tar.gz',
|
||||
download_url:
|
||||
'https://cdn.azul.com/zulu/bin/zulu25.34.17-ca-jdk25.0.3-linux_x64.tar.gz',
|
||||
java_version: [25, 0, 3],
|
||||
openjdk_build_number: 9,
|
||||
distro_version: [25, 34, 17, 0],
|
||||
latest: false,
|
||||
availability_type: 'ca'
|
||||
}
|
||||
] as IZuluVersions[];
|
||||
|
||||
it.each([
|
||||
['25.0.4+1.1', '25.0.4+1.1', 'uuid-25.0.4+1.1'],
|
||||
['25', '25.0.4+1.1', 'uuid-25.0.4+1.1'],
|
||||
['25.0.4', '25.0.4+1.1', 'uuid-25.0.4+1.1'],
|
||||
['25.0.4+7', '25.0.4+7', 'uuid-25.0.4+7'],
|
||||
['25.0.3', '25.0.3+9', 'uuid-25.0.3+9']
|
||||
])('version is %s -> %s', async (input, expected, uuid) => {
|
||||
const distribution = new ZuluDistribution({
|
||||
version: input,
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
distribution['getAvailableVersions'] = async () => hotfixManifest;
|
||||
const result = await distribution['findPackageForDownload'](
|
||||
distribution['version']
|
||||
);
|
||||
expect(result.version).toBe(expected);
|
||||
expect(result.url).toBe(
|
||||
hotfixManifest.find(item => item.package_uuid === uuid)!.download_url
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error', async () => {
|
||||
const distribution = new ZuluDistribution({
|
||||
version: '18',
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import {afterAll, beforeAll, describe, expect, it} from '@jest/globals';
|
||||
import {spawnSync} from 'child_process';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import {fileURLToPath, pathToFileURL} from 'url';
|
||||
|
||||
const dist = fileURLToPath(new URL('../dist/', import.meta.url));
|
||||
let tempDir: string;
|
||||
let linkedDist: string;
|
||||
|
||||
beforeAll(() => {
|
||||
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-java-entrypoints-'));
|
||||
linkedDist = path.join(tempDir, 'linked # dist');
|
||||
fs.symlinkSync(dist, linkedDist, 'junction');
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
fs.rmSync(tempDir, {recursive: true, force: true});
|
||||
});
|
||||
|
||||
function execute(args: string[], input?: string) {
|
||||
return spawnSync(process.execPath, args, {
|
||||
encoding: 'utf8',
|
||||
input,
|
||||
timeout: 10000,
|
||||
env: {
|
||||
PATH: process.env.PATH,
|
||||
SystemRoot: process.env.SystemRoot
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe.each([
|
||||
['setup', 1, 'java-version or java-version-file input expected'],
|
||||
['cleanup', 0, '']
|
||||
] as const)('%s entrypoint', (name, exitCode, output) => {
|
||||
it.each(['direct', 'symlink', 'preserved symlink'])(
|
||||
'executes through a %s path',
|
||||
mode => {
|
||||
const entry = path.join(
|
||||
mode === 'direct' ? dist : linkedDist,
|
||||
name,
|
||||
'index.js'
|
||||
);
|
||||
const args =
|
||||
mode === 'preserved symlink'
|
||||
? ['--preserve-symlinks-main', entry]
|
||||
: [entry];
|
||||
const result = execute(args);
|
||||
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.status).toBe(exitCode);
|
||||
expect(result.stderr).toBe('');
|
||||
expect(result.stdout).not.toContain('skipping the execution');
|
||||
if (output) {
|
||||
expect(result.stdout).toContain(output);
|
||||
} else {
|
||||
expect(result.stdout).toBe('');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
it.each(['eval', 'stdin', 'file'])(
|
||||
'does not execute when imported from %s',
|
||||
mode => {
|
||||
const moduleUrl = pathToFileURL(path.join(dist, name, 'index.js')).href;
|
||||
const source = `const {run} = await import(${JSON.stringify(moduleUrl)}); console.log(typeof run);`;
|
||||
const importer = path.join(tempDir, `${name}-importer.mjs`);
|
||||
fs.writeFileSync(importer, source);
|
||||
const args =
|
||||
mode === 'file'
|
||||
? [importer]
|
||||
: mode === 'eval'
|
||||
? ['--input-type=module', '-e', source]
|
||||
: ['--input-type=module', '-'];
|
||||
const result = execute(args, mode === 'stdin' ? source : undefined);
|
||||
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stderr).toBe('');
|
||||
expect(result.stdout).toContain('skipping the execution');
|
||||
expect(result.stdout).toContain('function');
|
||||
expect(result.stdout).not.toContain('::error::');
|
||||
}
|
||||
);
|
||||
});
|
||||
+125
-1
@@ -9,10 +9,18 @@ import {
|
||||
} from '@jest/globals';
|
||||
import {fileURLToPath} from 'url';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as io from '@actions/io';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const mockTmpDir = jest.fn(os.tmpdir);
|
||||
|
||||
jest.unstable_mockModule('os', () => ({
|
||||
...os,
|
||||
default: {...os, tmpdir: mockTmpDir},
|
||||
tmpdir: mockTmpDir
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('@actions/exec', () => ({
|
||||
exec: jest.fn()
|
||||
@@ -34,6 +42,7 @@ describe('gpg tests', () => {
|
||||
await io.rmRF(tempDir);
|
||||
await io.mkdirP(tempDir);
|
||||
jest.clearAllMocks();
|
||||
mockTmpDir.mockImplementation(os.tmpdir);
|
||||
(exec.exec as jest.Mock<any>).mockResolvedValue(0);
|
||||
});
|
||||
|
||||
@@ -222,6 +231,94 @@ describe('gpg tests', () => {
|
||||
});
|
||||
|
||||
describe('verifyPackageSignature', () => {
|
||||
describe.each(['long', 'canonical macOS'])('%s TMPDIR', tempDirKind => {
|
||||
afterEach(() => {
|
||||
process.env['RUNNER_TEMP'] = tempDir;
|
||||
});
|
||||
|
||||
it.each([
|
||||
'success',
|
||||
'import failure',
|
||||
'verification failure',
|
||||
'gpgconf unavailable'
|
||||
])(
|
||||
'uses a short macOS home or RUNNER_TEMP elsewhere and cleans up after %s',
|
||||
async outcome => {
|
||||
const longRunnerTemp = path.join(
|
||||
tempDir,
|
||||
'long-runner-path-'.repeat(8)
|
||||
);
|
||||
const signaturePath = path.join(tempDir, 'jdk.tar.gz.sig');
|
||||
const expectedParent =
|
||||
process.platform === 'darwin' ? '/tmp' : longRunnerTemp;
|
||||
let gpgHome = '';
|
||||
process.env['RUNNER_TEMP'] = longRunnerTemp;
|
||||
mockTmpDir.mockReturnValue(
|
||||
tempDirKind === 'long'
|
||||
? longRunnerTemp
|
||||
: `/private/var/folders/ab/${'c'.repeat(31)}/T`
|
||||
);
|
||||
fs.mkdirSync(longRunnerTemp, {recursive: true});
|
||||
fs.writeFileSync(signaturePath, 'signature');
|
||||
(tc.downloadTool as jest.Mock<any>).mockResolvedValue(signaturePath);
|
||||
(exec.exec as jest.Mock<any>).mockImplementation(
|
||||
async (command: string, args: string[]) => {
|
||||
gpgHome = path.join(expectedParent, path.posix.basename(args[1]));
|
||||
expect(args[1]).toBe(gpg.toGpgPath(gpgHome));
|
||||
if (command === 'gpgconf') {
|
||||
expect(fs.existsSync(gpgHome)).toBe(true);
|
||||
if (outcome === 'gpgconf unavailable') {
|
||||
throw new Error('gpgconf unavailable');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (process.platform === 'darwin') {
|
||||
expect(
|
||||
Buffer.byteLength(path.join(gpgHome, 'S.gpg-agent.browser'))
|
||||
).toBeLessThan(104);
|
||||
}
|
||||
expect(
|
||||
fs.readFileSync(path.join(gpgHome, 'public-key-0.asc'), 'utf8')
|
||||
).toBe('public key');
|
||||
if (process.platform !== 'win32') {
|
||||
expect(fs.statSync(gpgHome).mode & 0o777).toBe(0o700);
|
||||
}
|
||||
if (
|
||||
(outcome === 'import failure' && args.includes('--import')) ||
|
||||
(outcome === 'verification failure' &&
|
||||
args.includes('--verify'))
|
||||
) {
|
||||
throw new Error(outcome);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
|
||||
const verification = gpg.verifyPackageSignature(
|
||||
path.join(tempDir, 'jdk.tar.gz'),
|
||||
'https://example.com/jdk.tar.gz.sig',
|
||||
'public key'
|
||||
);
|
||||
if (outcome === 'success' || outcome === 'gpgconf unavailable') {
|
||||
await verification;
|
||||
} else {
|
||||
await expect(verification).rejects.toThrow(outcome);
|
||||
}
|
||||
expect(exec.exec).toHaveBeenCalledTimes(
|
||||
outcome === 'import failure' ? 2 : 3
|
||||
);
|
||||
expect(exec.exec).toHaveBeenLastCalledWith(
|
||||
'gpgconf',
|
||||
['--homedir', gpg.toGpgPath(gpgHome), '--kill', 'gpg-agent'],
|
||||
{silent: true, ignoreReturnCode: true}
|
||||
);
|
||||
expect(fs.existsSync(gpgHome)).toBe(false);
|
||||
expect(fs.existsSync(signaturePath)).toBe(false);
|
||||
expect(fs.readdirSync(longRunnerTemp)).toEqual([]);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('imports bundled key and verifies package', async () => {
|
||||
const publicKeyContent =
|
||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----\ntest\n-----END PGP PUBLIC KEY BLOCK-----';
|
||||
@@ -245,7 +342,7 @@ describe('gpg tests', () => {
|
||||
expect.any(String),
|
||||
'--batch',
|
||||
'--import',
|
||||
expect.stringContaining('public-key.asc')
|
||||
expect.stringContaining('public-key-0.asc')
|
||||
],
|
||||
expect.objectContaining({silent: true})
|
||||
);
|
||||
@@ -263,5 +360,32 @@ describe('gpg tests', () => {
|
||||
expect.objectContaining({silent: true})
|
||||
);
|
||||
});
|
||||
|
||||
it('imports multiple bundled keys before verifying the package', async () => {
|
||||
(tc.downloadTool as jest.Mock<any>).mockResolvedValue(
|
||||
'/tmp/jdk.tar.gz.sig'
|
||||
);
|
||||
|
||||
await gpg.verifyPackageSignature(
|
||||
'/tmp/jdk.tar.gz',
|
||||
'https://example.com/jdk.tar.gz.sig',
|
||||
['public-key-a', 'public-key-b']
|
||||
);
|
||||
|
||||
expect(exec.exec).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'gpg',
|
||||
[
|
||||
'--homedir',
|
||||
expect.any(String),
|
||||
'--batch',
|
||||
'--import',
|
||||
expect.stringContaining('public-key-0.asc'),
|
||||
expect.stringContaining('public-key-1.asc')
|
||||
],
|
||||
expect.objectContaining({silent: true})
|
||||
);
|
||||
expect(exec.exec).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals';
|
||||
import fs from 'fs';
|
||||
import {isMainModule} from '../src/is-main-module.js';
|
||||
|
||||
describe('main module detection', () => {
|
||||
const originalArgv = process.argv;
|
||||
|
||||
beforeEach(() => {
|
||||
process.argv = [process.execPath, 'entrypoint.js'];
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.argv = originalArgv;
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it.each([undefined, '-'])(
|
||||
'skips filesystem access when argv[1] is %s',
|
||||
entrypoint => {
|
||||
process.argv =
|
||||
entrypoint === undefined
|
||||
? [process.execPath]
|
||||
: [process.execPath, entrypoint];
|
||||
const realpath = jest.spyOn(fs, 'realpathSync');
|
||||
|
||||
expect(isMainModule(import.meta.url)).toBe(false);
|
||||
expect(realpath).not.toHaveBeenCalled();
|
||||
}
|
||||
);
|
||||
|
||||
it.each(['ENOENT', 'ENOTDIR'])(
|
||||
'treats a non-file entrypoint returning %s as an import',
|
||||
code => {
|
||||
jest.spyOn(fs, 'realpathSync').mockImplementation(() => {
|
||||
throw Object.assign(new Error('No file-based entrypoint'), {code});
|
||||
});
|
||||
|
||||
expect(isMainModule(import.meta.url)).toBe(false);
|
||||
}
|
||||
);
|
||||
|
||||
it('propagates unexpected filesystem errors', () => {
|
||||
const error = Object.assign(new Error('Permission denied'), {
|
||||
code: 'EACCES'
|
||||
});
|
||||
jest.spyOn(fs, 'realpathSync').mockImplementation(() => {
|
||||
throw error;
|
||||
});
|
||||
|
||||
expect(() => isMainModule(import.meta.url)).toThrow(error);
|
||||
});
|
||||
});
|
||||
@@ -25,6 +25,7 @@ describe('Java platform capabilities', () => {
|
||||
['aarch64', 'aarch64'],
|
||||
['arm64', 'aarch64'],
|
||||
['ppc64le', 'ppc64le'],
|
||||
['RiScV64', 'riscv64'],
|
||||
['s390x', 's390x']
|
||||
])('normalizes architecture %s to %s', (input, expected) => {
|
||||
expect(normalizeArchitecture(input)).toBe(expected);
|
||||
@@ -68,6 +69,12 @@ describe('Java platform capabilities', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('allows Temurin on Linux riscv64', () => {
|
||||
expect(validateJavaPlatform('temurin', 'linux', 'riscv64', '25')).toBe(
|
||||
'riscv64'
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects OS-specific restrictions with a consistent diagnostic', () => {
|
||||
expect(() =>
|
||||
validateJavaPlatform('oracle', 'win32', 'arm64', '21')
|
||||
@@ -115,6 +122,7 @@ describe('Java platform capabilities', () => {
|
||||
'aarch64',
|
||||
'ppc64le',
|
||||
'ppc64',
|
||||
'riscv64',
|
||||
's390x'
|
||||
]) {
|
||||
expect(content).toContain(architecture);
|
||||
|
||||
+45
-18
@@ -43,7 +43,7 @@ const jdk = {
|
||||
architecture: 'x64',
|
||||
version: '21.0.8+9',
|
||||
source: 'sha256:abc123',
|
||||
verification: 'unverified',
|
||||
verification: 'disabled',
|
||||
path: '/toolcache/Java_temurin_jdk/21.0.8-9'
|
||||
};
|
||||
|
||||
@@ -117,32 +117,59 @@ describe('JDK cache', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('separates unverified, bundled-key, and custom-key caches', () => {
|
||||
const unverified = getJdkVerificationIdentity(false);
|
||||
const bundled = getJdkVerificationIdentity(true);
|
||||
it('separates verification policies and keys', () => {
|
||||
const disabled = getJdkVerificationIdentity(false, false);
|
||||
const checkAndWarnBundled = getJdkVerificationIdentity(true, false);
|
||||
const enforcedBundled = getJdkVerificationIdentity(true, true);
|
||||
const customA = getJdkVerificationIdentity(
|
||||
true,
|
||||
true,
|
||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nkey-a\r\n-----END PGP PUBLIC KEY BLOCK-----\r\n'
|
||||
);
|
||||
const customANormalized = getJdkVerificationIdentity(
|
||||
true,
|
||||
true,
|
||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----\nkey-a\n-----END PGP PUBLIC KEY BLOCK-----'
|
||||
);
|
||||
const customB = getJdkVerificationIdentity(true, 'different-key');
|
||||
|
||||
expect(new Set([unverified, bundled, customA, customB])).toHaveProperty(
|
||||
'size',
|
||||
4
|
||||
const customB = getJdkVerificationIdentity(true, true, 'different-key');
|
||||
const checkAndWarnCustomA = getJdkVerificationIdentity(
|
||||
true,
|
||||
false,
|
||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----\nkey-a\n-----END PGP PUBLIC KEY BLOCK-----'
|
||||
);
|
||||
const customList = getJdkVerificationIdentity(true, true, [
|
||||
'key-a',
|
||||
'key-b'
|
||||
]);
|
||||
const customListWithDifferentBoundary = getJdkVerificationIdentity(
|
||||
true,
|
||||
true,
|
||||
['key-ak', 'ey-b']
|
||||
);
|
||||
|
||||
expect(
|
||||
new Set([
|
||||
disabled,
|
||||
checkAndWarnBundled,
|
||||
enforcedBundled,
|
||||
customA,
|
||||
customB
|
||||
])
|
||||
).toHaveProperty('size', 5);
|
||||
expect(disabled).toBe('disabled');
|
||||
expect(checkAndWarnBundled).toBe('check-and-warn:bundled');
|
||||
expect(enforcedBundled).toBe('enforced:bundled');
|
||||
expect(checkAndWarnCustomA).not.toBe(customA);
|
||||
expect(customA).toBe(customANormalized);
|
||||
expect(customA).not.toContain('key-a');
|
||||
expect(customList).not.toBe(customListWithDifferentBoundary);
|
||||
expect(
|
||||
new Set(
|
||||
[unverified, bundled, customA, customB].map(verification =>
|
||||
buildJdkCacheKey({...jdk, verification})
|
||||
[disabled, checkAndWarnBundled, enforcedBundled, customA, customB].map(
|
||||
verification => buildJdkCacheKey({...jdk, verification})
|
||||
)
|
||||
)
|
||||
).toHaveProperty('size', 4);
|
||||
).toHaveProperty('size', 5);
|
||||
});
|
||||
|
||||
it('restores and records an exact JDK cache hit', async () => {
|
||||
@@ -210,12 +237,12 @@ describe('JDK cache', () => {
|
||||
|
||||
it('saves only the key matching the installation that occupies the path', async () => {
|
||||
const jdkPath = createInstallation();
|
||||
const verified = {...jdk, path: jdkPath, verification: 'verified:bundled'};
|
||||
const unverified = {...jdk, path: jdkPath};
|
||||
const enforced = {...jdk, path: jdkPath, verification: 'enforced:bundled'};
|
||||
const disabled = {...jdk, path: jdkPath};
|
||||
|
||||
registerJdk(verified);
|
||||
registerJdk(enforced);
|
||||
writeInstallation(jdkPath, 'force-downloaded-without-verification');
|
||||
registerJdk(unverified);
|
||||
registerJdk(disabled);
|
||||
(core.getState as jest.Mock).mockReturnValue(lastState());
|
||||
(cache.saveCache as jest.Mock).mockResolvedValue(1);
|
||||
|
||||
@@ -223,11 +250,11 @@ describe('JDK cache', () => {
|
||||
|
||||
expect(cache.saveCache).not.toHaveBeenCalledWith(
|
||||
[jdkPath],
|
||||
buildJdkCacheKey(verified)
|
||||
buildJdkCacheKey(enforced)
|
||||
);
|
||||
expect(cache.saveCache).toHaveBeenCalledWith(
|
||||
[jdkPath],
|
||||
buildJdkCacheKey(unverified)
|
||||
buildJdkCacheKey(disabled)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ jest.unstable_mockModule('@actions/core', () => ({
|
||||
|
||||
jest.unstable_mockModule('fs', () => ({
|
||||
default: {
|
||||
...jest.requireActual<typeof import('fs')>('fs'),
|
||||
readFileSync: jest.fn()
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -27,6 +27,7 @@ jest.unstable_mockModule('@actions/core', () => ({
|
||||
|
||||
jest.unstable_mockModule('fs', () => ({
|
||||
default: {
|
||||
...jest.requireActual<typeof import('fs')>('fs'),
|
||||
readFileSync: jest.fn()
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -43,6 +43,7 @@ const core = await import('@actions/core');
|
||||
|
||||
const {
|
||||
convertVersionToSemver,
|
||||
normalizeJavaVersionToSemver,
|
||||
getNextPageUrlFromLinkHeader,
|
||||
getVersionFromFileContent,
|
||||
isVersionSatisfies,
|
||||
@@ -188,6 +189,22 @@ describe('convertVersionToSemver', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('normalizeJavaVersionToSemver', () => {
|
||||
it.each([
|
||||
['17', '17'],
|
||||
['17.0.8', '17.0.8'],
|
||||
['17.0.8+7', '17.0.8+7'],
|
||||
['11.0.9.1', '11.0.9+1'],
|
||||
['12.0.2.1.0', '12.0.2+1.0'],
|
||||
['26.0.2.1+1', '26.0.2+1.1'],
|
||||
['17.0.8.1+1080.1', '17.0.8+1.1080.1'],
|
||||
['>=11.0.9.1', '>=11.0.9.1'],
|
||||
['17.x', '17.x']
|
||||
])('%s -> %s', (input: string, expected: string) => {
|
||||
expect(normalizeJavaVersionToSemver(input)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getNextPageUrlFromLinkHeader', () => {
|
||||
it.each([
|
||||
[
|
||||
@@ -276,6 +293,8 @@ describe('getVersionFromFileContent', () => {
|
||||
['java=21.0.5-graal', '21.0.5', 'graalvm'],
|
||||
['java=17.0.9-graalce', '17.0.9', 'graalvm'],
|
||||
['java=11.0.25-librca', '11.0.25', 'liberica'],
|
||||
['java=25.0.4+1.1-librca', '25.0.4+1.1', 'liberica'],
|
||||
['java=25.0.4+1.1-zulu', '25.0.4+1.1', 'zulu'],
|
||||
['java=11.0.25-ms', '11.0.25', 'microsoft'],
|
||||
['java=21.0.5-oracle', '21.0.5', 'oracle'],
|
||||
['java=11.0.25-sapmchn', '11.0.25', 'sapmachine'],
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@ inputs:
|
||||
required: false
|
||||
default: 'jdk'
|
||||
architecture:
|
||||
description: "The architecture of the package (`x86`, `x64`, `armv7`, `aarch64`, `ppc64le`, `ppc64`, or `s390x`). Aliases `ia32`, `amd64`, `arm`, and `arm64` are normalized to `x86`, `x64`, `armv7`, and `aarch64`. Supported values vary by distribution and operating system. Defaults to the action runner's architecture."
|
||||
description: "The architecture of the package (`x86`, `x64`, `armv7`, `aarch64`, `ppc64le`, `ppc64`, `riscv64`, or `s390x`). Aliases `ia32`, `amd64`, `arm`, and `arm64` are normalized to `x86`, `x64`, `armv7`, and `aarch64`. Supported values vary by distribution and operating system. Defaults to the action runner's architecture."
|
||||
required: false
|
||||
jdk-file:
|
||||
description: 'Path to where the compressed JDK is located'
|
||||
@@ -39,10 +39,10 @@ inputs:
|
||||
required: false
|
||||
default: true
|
||||
verify-signature:
|
||||
description: 'Verify downloaded Java package signatures when supported by the selected distribution'
|
||||
description: 'Check downloaded Java package signatures when supported by the selected distribution. When omitted, failures produce warnings. Explicitly setting this to true enforces verification and makes failures fatal, including failures caused by an unexpected vendor signing-key rotation.'
|
||||
required: false
|
||||
verify-signature-public-key:
|
||||
description: 'ASCII-armored GPG public key used to verify the downloaded package signature. Overrides the default bundled key for the selected distribution.'
|
||||
description: 'One or more ASCII-armored GPG public keys used to verify downloaded package signatures. Concatenate multiple armored key blocks. Custom keys replace the bundled keys for the selected distribution.'
|
||||
required: false
|
||||
server-id:
|
||||
description: 'ID of the distributionManagement repository in the pom.xml
|
||||
|
||||
Vendored
+15
-6
@@ -122,16 +122,25 @@ function getInstallationIdentity(jdkPath, architecture) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function getJdkVerificationIdentity(verifySignature, publicKey) {
|
||||
function getJdkVerificationIdentity(verifySignature, enforceSignatureVerification, publicKey) {
|
||||
if (!verifySignature) {
|
||||
return 'unverified';
|
||||
return 'disabled';
|
||||
}
|
||||
const verificationPolicy = enforceSignatureVerification
|
||||
? 'enforced'
|
||||
: 'check-and-warn';
|
||||
if (!publicKey) {
|
||||
return 'verified:bundled';
|
||||
return `${verificationPolicy}:bundled`;
|
||||
}
|
||||
const normalizedKey = publicKey.replace(/\r\n?/g, '\n').trim();
|
||||
const fingerprint = createHash('sha256').update(normalizedKey).digest('hex');
|
||||
return `verified:custom:sha256:${fingerprint}`;
|
||||
const publicKeys = Array.isArray(publicKey) ? publicKey : [publicKey];
|
||||
const normalizedKeys = publicKeys.map(key => key.replace(/\r\n?/g, '\n').trim());
|
||||
const fingerprintSource = Array.isArray(publicKey)
|
||||
? normalizedKeys.map(key => `${Buffer.byteLength(key)}:${key}`).join('')
|
||||
: normalizedKeys[0];
|
||||
const fingerprint = createHash('sha256')
|
||||
.update(fingerprintSource)
|
||||
.digest('hex');
|
||||
return `${verificationPolicy}:custom:sha256:${fingerprint}`;
|
||||
}
|
||||
async function saveJdkCaches() {
|
||||
const state = lib_core/* getState */.Gu(STATE_JDK_CACHES);
|
||||
|
||||
Vendored
+164
-28
@@ -18360,9 +18360,102 @@ function readAttributeStr(xmlData, i) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all the attributes whether valid or invalid.
|
||||
* Walk `attrStr` once, left to right, splitting it into attribute tokens.
|
||||
*
|
||||
* This replaces a regex that used to do the same job
|
||||
* (`(\s*)([^\s=]+)(\s*=)?(\s*(['"])(([\s\S])*?)\5)?`). That regex led with an
|
||||
* optional whitespace group followed by a required "non-whitespace" group.
|
||||
* On a long run of whitespace that never resolves into an attribute name
|
||||
* (e.g. a tag with thousands of trailing spaces before `>`), the engine
|
||||
* backtracks the whitespace group one character at a time before giving up
|
||||
* and moving to the next starting position — one full backtrack per
|
||||
* position, which is quadratic in the length of the run.
|
||||
*
|
||||
* A single forward-only scan can never backtrack, so it can't be made slow
|
||||
* this way no matter how much whitespace the input contains — it's always
|
||||
* proportional to the length of the string, once.
|
||||
*
|
||||
* Each returned token mirrors the shape the old regex match array had, so
|
||||
* the validation logic below (which reads token[1]..token[6]) didn't need
|
||||
* to change:
|
||||
* token.startIndex - where this token begins in attrStr
|
||||
* token[1] - leading whitespace before the name
|
||||
* token[2] - the attribute name
|
||||
* token[3] - whitespace + '=' if present, else undefined
|
||||
* token[4] - marker (any defined value) if a quoted value was found
|
||||
* token[5] - the quote character used ('"' or "'")
|
||||
* token[6] - the value's text, without the surrounding quotes
|
||||
*
|
||||
* A malformed leading character (e.g. a stray '=' with no name before it)
|
||||
* is simply skipped over, one character at a time — the same outcome the
|
||||
* old regex produced by failing to match at that position and retrying at
|
||||
* the next one.
|
||||
*/
|
||||
const validAttrStrRegxp = new RegExp('(\\s*)([^\\s=]+)(\\s*=)?(\\s*([\'"])(([\\s\\S])*?)\\5)?', 'g');
|
||||
function scanAttributeTokens(attrStr) {
|
||||
const tokens = [];
|
||||
const len = attrStr.length;
|
||||
let i = 0;
|
||||
|
||||
while (i < len) {
|
||||
const tokenStart = i;
|
||||
|
||||
// Leading whitespace before the name.
|
||||
while (i < len && isWhiteSpace(attrStr[i])) i++;
|
||||
if (i >= len) break; // trailing whitespace only — nothing left to read
|
||||
|
||||
if (attrStr[i] === '=') {
|
||||
// No name before this '=' — not a valid attribute start. Move past
|
||||
// just this one character and try again from the next position.
|
||||
i = tokenStart + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const leadingWs = attrStr.slice(tokenStart, i);
|
||||
|
||||
// Attribute name — everything up to the next whitespace or '='.
|
||||
const nameStart = i;
|
||||
while (i < len && !isWhiteSpace(attrStr[i]) && attrStr[i] !== '=') i++;
|
||||
const name = attrStr.slice(nameStart, i);
|
||||
|
||||
// Optional whitespace + '='.
|
||||
let equalsGroup; // whitespace + '=' text, or undefined if absent
|
||||
let j = i;
|
||||
while (j < len && isWhiteSpace(attrStr[j])) j++;
|
||||
if (j < len && attrStr[j] === '=') {
|
||||
equalsGroup = attrStr.slice(i, j + 1);
|
||||
i = j + 1;
|
||||
}
|
||||
|
||||
// Optional whitespace + quoted value.
|
||||
let quoteChar;
|
||||
let value;
|
||||
let k = i;
|
||||
while (k < len && isWhiteSpace(attrStr[k])) k++;
|
||||
if (k < len && (attrStr[k] === '"' || attrStr[k] === "'")) {
|
||||
const valueStart = k + 1;
|
||||
const closeIdx = attrStr.indexOf(attrStr[k], valueStart);
|
||||
if (closeIdx !== -1) {
|
||||
quoteChar = attrStr[k];
|
||||
value = attrStr.slice(valueStart, closeIdx);
|
||||
i = closeIdx + 1;
|
||||
}
|
||||
// No closing quote found anywhere in the rest of the string — leave
|
||||
// quoteChar/value undefined, same as the old regex's group failing
|
||||
// to match a backreference-less run.
|
||||
}
|
||||
|
||||
const token = { startIndex: tokenStart };
|
||||
token[1] = leadingWs;
|
||||
token[2] = name;
|
||||
token[3] = equalsGroup;
|
||||
token[4] = quoteChar !== undefined ? true : undefined;
|
||||
token[5] = quoteChar;
|
||||
token[6] = value;
|
||||
tokens.push(token);
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
//attr, ="sd", a="amit's", a="sd"b="saf", ab cd=""
|
||||
|
||||
@@ -18371,7 +18464,7 @@ function validateAttributeString(attrStr, options) {
|
||||
|
||||
//if(attrStr.trim().length === 0) return true; //empty string
|
||||
|
||||
const matches = getAllMatches(attrStr, validAttrStrRegxp);
|
||||
const matches = scanAttributeTokens(attrStr);
|
||||
const attrNames = {};
|
||||
|
||||
for (let i = 0; i < matches.length; i++) {
|
||||
@@ -18473,7 +18566,6 @@ function getLineNumberForPosition(xmlData, index) {
|
||||
function getPositionFromMatch(match) {
|
||||
return match.startIndex + match[1].length;
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/fast-xml-parser/src/fxp.js
|
||||
|
||||
|
||||
@@ -59498,6 +59590,24 @@ const EXPANSION_MAX = 100_000;
|
||||
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
||||
// characters) so legitimate input is unaffected.
|
||||
const EXPANSION_MAX_LENGTH = 4_000_000;
|
||||
// `expand_` recurses once per level of brace *nesting* - both when expanding a
|
||||
// set's comma members and when re-wrapping a set whose body is a single part.
|
||||
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
||||
// level per chained group), which left nesting depth unbounded: about 3,100
|
||||
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
||||
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
||||
// will follow nesting. It sits far above any realistic pattern and well below
|
||||
// the depth at which the stack runs out.
|
||||
const EXPANSION_MAX_DEPTH = 1_000;
|
||||
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
||||
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
||||
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
||||
// full passes over a string that itself grows by one `escClose` sentinel each
|
||||
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
||||
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
||||
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
||||
// times the scan may restart. Real `{a},b}` input needs a handful.
|
||||
const EXPANSION_MAX_REWRITES = 1_000;
|
||||
function numeric(str) {
|
||||
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
||||
}
|
||||
@@ -59517,37 +59627,52 @@ function unescapeBraces(str) {
|
||||
.replace(escCommaPattern, ',')
|
||||
.replace(escPeriodPattern, '.');
|
||||
}
|
||||
// Like `target.push(...items)` but doesn't overflow the stack
|
||||
function pushAll(target, items) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
target.push(items[i]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Basically just str.split(","), but handling cases
|
||||
* where we have nested braced sections, which should be
|
||||
* treated as individual members, like {a,{b,c},d}
|
||||
*/
|
||||
function parseCommaParts(str) {
|
||||
if (!str) {
|
||||
return [''];
|
||||
}
|
||||
const parts = [];
|
||||
const m = balanced('{', '}', str);
|
||||
if (!m) {
|
||||
return str.split(',');
|
||||
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
||||
// chain of them exhaust the stack - the parsing-side counterpart to
|
||||
// the `expand_` overflow fixed for CVE-2026-14257, and not something `max` or
|
||||
// `maxLength` can bound, since it happens before expansion.
|
||||
//
|
||||
// The part the next chunk continues
|
||||
let carry = '';
|
||||
for (;;) {
|
||||
const m = balanced('{', '}', str);
|
||||
if (!m) {
|
||||
const tail = str.split(',');
|
||||
tail[0] = carry + tail[0];
|
||||
pushAll(parts, tail);
|
||||
return parts;
|
||||
}
|
||||
const { pre, body, post } = m;
|
||||
const p = pre.split(',');
|
||||
p[0] = carry + p[0];
|
||||
p[p.length - 1] += '{' + body + '}';
|
||||
if (!post.length) {
|
||||
pushAll(parts, p);
|
||||
return parts;
|
||||
}
|
||||
carry = p.pop();
|
||||
pushAll(parts, p);
|
||||
str = post;
|
||||
}
|
||||
const { pre, body, post } = m;
|
||||
const p = pre.split(',');
|
||||
p[p.length - 1] += '{' + body + '}';
|
||||
const postParts = parseCommaParts(post);
|
||||
if (post.length) {
|
||||
;
|
||||
p[p.length - 1] += postParts.shift();
|
||||
p.push.apply(p, postParts);
|
||||
}
|
||||
parts.push.apply(parts, p);
|
||||
return parts;
|
||||
}
|
||||
function expand(str, options = {}) {
|
||||
if (!str) {
|
||||
return [];
|
||||
}
|
||||
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
||||
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES, } = options;
|
||||
// I don't know why Bash 4.3 does this, but it does.
|
||||
// Anything starting with {} will have the first two bytes preserved
|
||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||
@@ -59557,7 +59682,7 @@ function expand(str, options = {}) {
|
||||
if (str.slice(0, 2) === '{}') {
|
||||
str = '\\{\\}' + str.slice(2);
|
||||
}
|
||||
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
||||
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
||||
}
|
||||
function embrace(str) {
|
||||
return '{' + str + '}';
|
||||
@@ -59652,7 +59777,13 @@ function expandSequence(body, isAlphaSequence, max, maxLength) {
|
||||
}
|
||||
return N;
|
||||
}
|
||||
function expand_(str, max, maxLength, isTop) {
|
||||
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
||||
// Too deeply nested to keep following: treat the rest as literal, the same
|
||||
// way a group that cannot expand is already handled. Truncating rather than
|
||||
// throwing keeps `expand` total, matching `max` and `maxLength`.
|
||||
if (depth > maxDepth) {
|
||||
return [str];
|
||||
}
|
||||
// Consume the string's top-level brace groups left to right, threading a
|
||||
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
||||
// rather than recursing on `m.post` once per group - keeps the native stack
|
||||
@@ -59664,6 +59795,9 @@ function expand_(str, max, maxLength, isTop) {
|
||||
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
||||
// is on the final strings, so it is applied to whichever `combine` produces
|
||||
// them (the one with no brace set left in the tail).
|
||||
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
||||
// re-reads the whole string, so leaving this unbounded is quadratic.
|
||||
let rewrites = 0;
|
||||
let dropEmpties = false;
|
||||
let firstGroup = true;
|
||||
for (;;) {
|
||||
@@ -59688,7 +59822,8 @@ function expand_(str, max, maxLength, isTop) {
|
||||
const isOptions = m.body.indexOf(',') >= 0;
|
||||
if (!isSequence && !isOptions) {
|
||||
// {a},b}
|
||||
if (m.post.match(/,(?!,).*\}/)) {
|
||||
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
||||
rewrites++;
|
||||
str = m.pre + '{' + m.body + escClose + m.post;
|
||||
isTop = true;
|
||||
continue;
|
||||
@@ -59708,7 +59843,7 @@ function expand_(str, max, maxLength, isTop) {
|
||||
let n = parseCommaParts(m.body);
|
||||
if (n.length === 1 && n[0] !== undefined) {
|
||||
// x{{a,b}}y ==> x{a}y x{b}y
|
||||
n = expand_(n[0], max, maxLength, false).map(embrace);
|
||||
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
||||
//XXX is this necessary? Can't seem to hit it in tests.
|
||||
/* c8 ignore start */
|
||||
if (n.length === 1) {
|
||||
@@ -59734,12 +59869,13 @@ function expand_(str, max, maxLength, isTop) {
|
||||
values = [];
|
||||
let valuesLength = 0;
|
||||
outer: for (let j = 0; j < n.length; j++) {
|
||||
const expanded = expand_(n[j], max, maxLength, false);
|
||||
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
||||
for (let k = 0; k < expanded.length; k++) {
|
||||
const v = expanded[k];
|
||||
if (dropsEmpties && !v)
|
||||
continue;
|
||||
if (values.length >= max || valuesLength + v.length > maxLength) {
|
||||
if (values.length >= max ||
|
||||
valuesLength + v.length > maxLength) {
|
||||
break outer;
|
||||
}
|
||||
values.push(v);
|
||||
|
||||
Vendored
+520
-198
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -65,7 +65,7 @@ class LocalDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__/
|
||||
architecture: this.architecture,
|
||||
version: this.version,
|
||||
source,
|
||||
verification: getJdkVerificationIdentity(false),
|
||||
verification: getJdkVerificationIdentity(false, false),
|
||||
path: this.getJdkCachePath(this.version)
|
||||
};
|
||||
}
|
||||
|
||||
Vendored
+42
-15
@@ -42,6 +42,8 @@ Fa133tP85xzJEq1XeXm8WeLFo2wV
|
||||
=rHCS
|
||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
||||
|
||||
// EXTERNAL MODULE: ./src/constants.ts
|
||||
var constants = __webpack_require__(7242);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js + 7 modules
|
||||
var core = __webpack_require__(3838);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/tool-cache/lib/tool-cache.js + 2 modules
|
||||
@@ -62,6 +64,7 @@ var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_);
|
||||
|
||||
|
||||
|
||||
|
||||
class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
||||
constructor(installerOptions) {
|
||||
super('Microsoft', installerOptions);
|
||||
@@ -70,15 +73,23 @@ class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
||||
core/* info */.pq(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
||||
if (this.verifySignature) {
|
||||
if (!javaRelease.signatureUrl) {
|
||||
throw new Error(`Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version ${javaRelease.version}.`);
|
||||
}
|
||||
core/* info */.pq(`Verifying Java package signature...`);
|
||||
try {
|
||||
await gpg/* verifyPackageSignature */.Yi(javaArchivePath, javaRelease.signatureUrl, this.verifySignaturePublicKey ?? MICROSOFT_PUBLIC_KEY);
|
||||
if (!javaRelease.signatureUrl) {
|
||||
throw new Error(`Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version ${javaRelease.version}.`);
|
||||
}
|
||||
core/* info */.pq(`Verifying Java package signature...`);
|
||||
try {
|
||||
await gpg/* verifyPackageSignature */.Yi(javaArchivePath, javaRelease.signatureUrl, this.verifySignaturePublicKey ?? MICROSOFT_PUBLIC_KEY);
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Failed to verify signature for Microsoft Build of OpenJDK version ${javaRelease.version}. Signature URL: ${javaRelease.signatureUrl}. Error: ${error.message} ${constants/* SIGNATURE_VERIFICATION_FAILURE_HELP */.kQ}`, { cause: error });
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Failed to verify signature for Microsoft Build of OpenJDK version ${javaRelease.version}. Signature URL: ${javaRelease.signatureUrl}. Error: ${error.message}`, { cause: error });
|
||||
if (this.verifySignatureExplicitlyRequested) {
|
||||
throw error;
|
||||
}
|
||||
core/* warning */.$e(error instanceof Error ? error.message : `Unknown error: ${error}`);
|
||||
}
|
||||
}
|
||||
core/* info */.pq(`Extracting Java archive...`);
|
||||
@@ -167,7 +178,8 @@ class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
||||
/* harmony export */ Fh: () => (/* binding */ importKey),
|
||||
/* harmony export */ Yi: () => (/* binding */ verifyPackageSignature),
|
||||
/* harmony export */ mS: () => (/* binding */ removeGpgHome),
|
||||
/* harmony export */ nY: () => (/* binding */ toGpgPath)
|
||||
/* harmony export */ nY: () => (/* binding */ toGpgPath),
|
||||
/* harmony export */ o6: () => (/* binding */ isGpgAvailable)
|
||||
/* harmony export */ });
|
||||
/* unused harmony export GPG_HOME_PREFIX */
|
||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9896);
|
||||
@@ -189,6 +201,9 @@ class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
||||
|
||||
const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
||||
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
||||
async function isGpgAvailable() {
|
||||
return Boolean(await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .which */ .K7('gpg', false));
|
||||
}
|
||||
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
||||
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
||||
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
||||
@@ -200,8 +215,8 @@ function toGpgPath(p) {
|
||||
.replace(/\\/g, '/')
|
||||
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
||||
}
|
||||
function createGpgHome(prefix) {
|
||||
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4(), prefix));
|
||||
function createGpgHome(prefix, tempDir = _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4()) {
|
||||
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(tempDir, prefix));
|
||||
if (process.platform !== 'win32') {
|
||||
fs__WEBPACK_IMPORTED_MODULE_0__.chmodSync(gpgHome, 0o700);
|
||||
}
|
||||
@@ -248,19 +263,24 @@ async function removeGpgHome(gpgHome) {
|
||||
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
|
||||
return;
|
||||
}
|
||||
await stopGpgAgent(resolvedGpgHome);
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
||||
}
|
||||
async function stopGpgAgent(gpgHome) {
|
||||
try {
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
||||
}
|
||||
catch {
|
||||
// gpgconf may be unavailable, but directory removal must still be attempted.
|
||||
}
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
||||
}
|
||||
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
|
||||
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
|
||||
let gpgHome;
|
||||
try {
|
||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX);
|
||||
// Both RUNNER_TEMP and TMPDIR can exceed macOS's 104-byte agent socket limit.
|
||||
const tempDir = process.platform === 'darwin' ? '/tmp' : _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4();
|
||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX, tempDir);
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
@@ -272,15 +292,21 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
||||
throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`, { cause: error });
|
||||
}
|
||||
try {
|
||||
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, 'public-key.asc');
|
||||
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKeyContent, { encoding: 'utf-8' });
|
||||
const publicKeys = Array.isArray(publicKeyContent)
|
||||
? publicKeyContent
|
||||
: [publicKeyContent];
|
||||
const publicKeyFiles = publicKeys.map((publicKey, index) => {
|
||||
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, `public-key-${index}.asc`);
|
||||
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKey, { encoding: 'utf-8' });
|
||||
return toGpgPath(publicKeyFile);
|
||||
});
|
||||
const options = { silent: true };
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||
'--homedir',
|
||||
toGpgPath(gpgHome),
|
||||
'--batch',
|
||||
'--import',
|
||||
toGpgPath(publicKeyFile)
|
||||
...publicKeyFiles
|
||||
], options);
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||
'--homedir',
|
||||
@@ -292,6 +318,7 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
||||
], options);
|
||||
}
|
||||
finally {
|
||||
await stopGpgAgent(gpgHome);
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
|
||||
}
|
||||
|
||||
Vendored
+7
-7
@@ -226,6 +226,7 @@ class JavaBase {
|
||||
floatingVersionVerified = false;
|
||||
setDefault;
|
||||
verifySignature;
|
||||
verifySignatureExplicitlyRequested;
|
||||
verifySignaturePublicKey;
|
||||
constructor(distribution, installerOptions) {
|
||||
this.distribution = distribution;
|
||||
@@ -246,6 +247,8 @@ class JavaBase {
|
||||
: true;
|
||||
this.verifySignature =
|
||||
installerOptions.verifySignature ?? this.supportsSignatureVerification();
|
||||
this.verifySignatureExplicitlyRequested =
|
||||
installerOptions.verifySignature === true;
|
||||
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
||||
}
|
||||
async downloadAndVerify(javaRelease) {
|
||||
@@ -481,7 +484,7 @@ class JavaBase {
|
||||
architecture: this.architecture,
|
||||
version: javaRelease.version,
|
||||
source: this.getJdkReleaseIdentity(javaRelease),
|
||||
verification: getJdkVerificationIdentity(this.verifySignature, this.verifySignaturePublicKey),
|
||||
verification: getJdkVerificationIdentity(this.verifySignature, this.verifySignatureExplicitlyRequested, this.verifySignaturePublicKey),
|
||||
path: this.getJdkCachePath(javaRelease.version)
|
||||
};
|
||||
}
|
||||
@@ -727,12 +730,9 @@ class JavaBase {
|
||||
}
|
||||
// Java uses a versioning scheme (JEP 322) that can contain more numeric
|
||||
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
|
||||
// exact versions to SemVer build notation ('18.0.1+1') so they are
|
||||
// accepted. Ranges and versions that already carry build metadata are
|
||||
// left untouched.
|
||||
if (/^\d+(\.\d+){3,}$/.test(version)) {
|
||||
version = (0,util/* convertVersionToSemver */.ZY)(version);
|
||||
}
|
||||
// exact versions to SemVer build notation ('18.0.1+1', or '26.0.2+1.1'
|
||||
// for '26.0.2.1+1') so they are accepted. Ranges are left untouched.
|
||||
version = (0,util/* normalizeJavaVersionToSemver */.zZ)(version);
|
||||
if (!semver_default().validRange(version)) {
|
||||
throw new Error(`The string '${version}' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information`);
|
||||
}
|
||||
|
||||
Vendored
+79
-18
@@ -109,7 +109,7 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
||||
const formattedVersion = this.stable
|
||||
? item.version_data.semver
|
||||
: item.version_data.semver.replace('-beta+', '+');
|
||||
return {
|
||||
const release = {
|
||||
version: formattedVersion,
|
||||
url: item.binaries[0].package.link,
|
||||
signatureUrl: item.binaries[0].package.signature_link,
|
||||
@@ -119,15 +119,29 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
||||
source: item.binaries[0].package.checksum_link
|
||||
}
|
||||
};
|
||||
return {
|
||||
release,
|
||||
openjdkVersion: getOpenJdkSemverVersion(item.version_data)
|
||||
};
|
||||
});
|
||||
// The Adoptium API `semver` folds the JEP 322 patch field into the build
|
||||
// number ('26.0.2.1+1' -> '26.0.2+101') and appends extra metadata for LTS
|
||||
// releases ('25.0.4+7' -> '25.0.4+7.0.LTS'). Exact versions requested by
|
||||
// users follow the OpenJDK notation instead, so also match them against a
|
||||
// key derived from the OpenJDK version fields ('26.0.2+1.1', '25.0.4+7').
|
||||
const isExactBuildRequest = (semver_default().parse(version)?.build.length ?? 0) > 0;
|
||||
const satisfiedVersions = availableVersionsWithBinaries
|
||||
.filter(item => (0,util/* isVersionSatisfies */.y)(version, item.version))
|
||||
.filter(({ release, openjdkVersion }) => (0,util/* isVersionSatisfies */.y)(version, release.version) ||
|
||||
(isExactBuildRequest &&
|
||||
openjdkVersion !== null &&
|
||||
semver_default().compareBuild(version, openjdkVersion) === 0))
|
||||
.map(({ release }) => release)
|
||||
.sort((a, b) => {
|
||||
return -semver_default().compareBuild(a.version, b.version);
|
||||
});
|
||||
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableVersionStrings = availableVersionsWithBinaries.map(item => item.version);
|
||||
const availableVersionStrings = availableVersionsWithBinaries.map(({ release }) => release.version);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
return resolvedFullVersion;
|
||||
@@ -159,15 +173,32 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
||||
async downloadPackage(release) {
|
||||
const archivePath = await this.downloadAndVerify(release);
|
||||
if (this.verifySignature) {
|
||||
if (!release.signatureUrl) {
|
||||
throw new Error(`Input 'verify-signature' is enabled, but no signature URL was found for Temurin version ${release.version}.`);
|
||||
}
|
||||
core/* info */.pq(`Verifying Java package signature...`);
|
||||
try {
|
||||
await gpg/* verifyPackageSignature */.Yi(archivePath, release.signatureUrl, this.verifySignaturePublicKey ?? ADOPTIUM_PUBLIC_KEY);
|
||||
if (!(await gpg/* isGpgAvailable */.o6())) {
|
||||
throw new Error("Input 'verify-signature' is enabled, but gpg is not available.");
|
||||
}
|
||||
if (!release.signatureUrl) {
|
||||
throw new Error(`Input 'verify-signature' is enabled, but no signature URL was found for Temurin version ${release.version}.`);
|
||||
}
|
||||
core/* info */.pq(`Verifying Java package signature...`);
|
||||
try {
|
||||
await gpg/* verifyPackageSignature */.Yi(archivePath, release.signatureUrl, this.verifySignaturePublicKey ?? ADOPTIUM_PUBLIC_KEY);
|
||||
}
|
||||
catch (error) {
|
||||
const verificationError = new Error(`Failed to verify signature for Temurin version ${release.version} from ${release.signatureUrl}: ${error.message} ${constants/* SIGNATURE_VERIFICATION_FAILURE_HELP */.kQ}`, { cause: error });
|
||||
if (this.verifySignatureExplicitlyRequested) {
|
||||
throw verificationError;
|
||||
}
|
||||
else {
|
||||
core/* warning */.$e(verificationError.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(`Failed to verify signature for Temurin version ${release.version} from ${release.signatureUrl}: ${error.message}`, { cause: error });
|
||||
if (this.verifySignatureExplicitlyRequested) {
|
||||
throw error;
|
||||
}
|
||||
core/* warning */.$e(error instanceof Error ? error.message : `Unknown error: ${error}`);
|
||||
}
|
||||
}
|
||||
return archivePath;
|
||||
@@ -262,6 +293,20 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
||||
return architecture === 'armv7' ? 'arm' : architecture;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Builds a SemVer version from the OpenJDK version fields reported by the
|
||||
* Adoptium API, e.g. '26.0.2.1+1' -> '26.0.2+1.1' and '25.0.4+7-LTS' ->
|
||||
* '25.0.4+7'. Returns null if the fields cannot form a valid SemVer version.
|
||||
*/
|
||||
function getOpenJdkSemverVersion(versionData) {
|
||||
const { major, minor, security, patch, build } = versionData;
|
||||
if (build === undefined || build === null) {
|
||||
return null;
|
||||
}
|
||||
const buildMetadata = patch ? `${patch}.${build}` : `${build}`;
|
||||
const version = `${major}.${minor}.${security}+${buildMetadata}`;
|
||||
return semver_default().valid(version) ? version : null;
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -273,7 +318,8 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
||||
/* harmony export */ Fh: () => (/* binding */ importKey),
|
||||
/* harmony export */ Yi: () => (/* binding */ verifyPackageSignature),
|
||||
/* harmony export */ mS: () => (/* binding */ removeGpgHome),
|
||||
/* harmony export */ nY: () => (/* binding */ toGpgPath)
|
||||
/* harmony export */ nY: () => (/* binding */ toGpgPath),
|
||||
/* harmony export */ o6: () => (/* binding */ isGpgAvailable)
|
||||
/* harmony export */ });
|
||||
/* unused harmony export GPG_HOME_PREFIX */
|
||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9896);
|
||||
@@ -295,6 +341,9 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
||||
|
||||
const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
||||
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
||||
async function isGpgAvailable() {
|
||||
return Boolean(await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .which */ .K7('gpg', false));
|
||||
}
|
||||
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
||||
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
||||
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
||||
@@ -306,8 +355,8 @@ function toGpgPath(p) {
|
||||
.replace(/\\/g, '/')
|
||||
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
||||
}
|
||||
function createGpgHome(prefix) {
|
||||
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4(), prefix));
|
||||
function createGpgHome(prefix, tempDir = _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4()) {
|
||||
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(tempDir, prefix));
|
||||
if (process.platform !== 'win32') {
|
||||
fs__WEBPACK_IMPORTED_MODULE_0__.chmodSync(gpgHome, 0o700);
|
||||
}
|
||||
@@ -354,19 +403,24 @@ async function removeGpgHome(gpgHome) {
|
||||
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
|
||||
return;
|
||||
}
|
||||
await stopGpgAgent(resolvedGpgHome);
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
||||
}
|
||||
async function stopGpgAgent(gpgHome) {
|
||||
try {
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
||||
}
|
||||
catch {
|
||||
// gpgconf may be unavailable, but directory removal must still be attempted.
|
||||
}
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
||||
}
|
||||
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
|
||||
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
|
||||
let gpgHome;
|
||||
try {
|
||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX);
|
||||
// Both RUNNER_TEMP and TMPDIR can exceed macOS's 104-byte agent socket limit.
|
||||
const tempDir = process.platform === 'darwin' ? '/tmp' : _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4();
|
||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX, tempDir);
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
@@ -378,15 +432,21 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
||||
throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`, { cause: error });
|
||||
}
|
||||
try {
|
||||
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, 'public-key.asc');
|
||||
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKeyContent, { encoding: 'utf-8' });
|
||||
const publicKeys = Array.isArray(publicKeyContent)
|
||||
? publicKeyContent
|
||||
: [publicKeyContent];
|
||||
const publicKeyFiles = publicKeys.map((publicKey, index) => {
|
||||
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, `public-key-${index}.asc`);
|
||||
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKey, { encoding: 'utf-8' });
|
||||
return toGpgPath(publicKeyFile);
|
||||
});
|
||||
const options = { silent: true };
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||
'--homedir',
|
||||
toGpgPath(gpgHome),
|
||||
'--batch',
|
||||
'--import',
|
||||
toGpgPath(publicKeyFile)
|
||||
...publicKeyFiles
|
||||
], options);
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||
'--homedir',
|
||||
@@ -398,6 +458,7 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
||||
], options);
|
||||
}
|
||||
finally {
|
||||
await stopGpgAgent(gpgHome);
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
|
||||
}
|
||||
|
||||
Vendored
+2
-1
@@ -128,7 +128,8 @@ class LibericaDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODULE_
|
||||
}
|
||||
}
|
||||
convertVersionToSemver(version) {
|
||||
const { buildVersion, featureVersion, interimVersion, updateVersion } = version;
|
||||
const { featureVersion, interimVersion, updateVersion } = version;
|
||||
const buildVersion = version.version.split('+')[1] || version.buildVersion;
|
||||
const mainVersion = [featureVersion, interimVersion, updateVersion].join('.');
|
||||
if (buildVersion != 0) {
|
||||
return `${mainVersion}+${buildVersion}`;
|
||||
|
||||
Vendored
+15
-6
@@ -127,16 +127,25 @@ function getInstallationIdentity(jdkPath, architecture) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function getJdkVerificationIdentity(verifySignature, publicKey) {
|
||||
function getJdkVerificationIdentity(verifySignature, enforceSignatureVerification, publicKey) {
|
||||
if (!verifySignature) {
|
||||
return 'unverified';
|
||||
return 'disabled';
|
||||
}
|
||||
const verificationPolicy = enforceSignatureVerification
|
||||
? 'enforced'
|
||||
: 'check-and-warn';
|
||||
if (!publicKey) {
|
||||
return 'verified:bundled';
|
||||
return `${verificationPolicy}:bundled`;
|
||||
}
|
||||
const normalizedKey = publicKey.replace(/\r\n?/g, '\n').trim();
|
||||
const fingerprint = (0,crypto__WEBPACK_IMPORTED_MODULE_0__.createHash)('sha256').update(normalizedKey).digest('hex');
|
||||
return `verified:custom:sha256:${fingerprint}`;
|
||||
const publicKeys = Array.isArray(publicKey) ? publicKey : [publicKey];
|
||||
const normalizedKeys = publicKeys.map(key => key.replace(/\r\n?/g, '\n').trim());
|
||||
const fingerprintSource = Array.isArray(publicKey)
|
||||
? normalizedKeys.map(key => `${Buffer.byteLength(key)}:${key}`).join('')
|
||||
: normalizedKeys[0];
|
||||
const fingerprint = (0,crypto__WEBPACK_IMPORTED_MODULE_0__.createHash)('sha256')
|
||||
.update(fingerprintSource)
|
||||
.digest('hex');
|
||||
return `${verificationPolicy}:custom:sha256:${fingerprint}`;
|
||||
}
|
||||
async function saveJdkCaches() {
|
||||
const state = _actions_core__WEBPACK_IMPORTED_MODULE_4__/* .getState */ .Gu(STATE_JDK_CACHES);
|
||||
|
||||
Vendored
+25
-9
@@ -265,7 +265,8 @@ async function write(directory, settings, overwriteSettings) {
|
||||
/* harmony export */ Fh: () => (/* binding */ importKey),
|
||||
/* harmony export */ Yi: () => (/* binding */ verifyPackageSignature),
|
||||
/* harmony export */ mS: () => (/* binding */ removeGpgHome),
|
||||
/* harmony export */ nY: () => (/* binding */ toGpgPath)
|
||||
/* harmony export */ nY: () => (/* binding */ toGpgPath),
|
||||
/* harmony export */ o6: () => (/* binding */ isGpgAvailable)
|
||||
/* harmony export */ });
|
||||
/* unused harmony export GPG_HOME_PREFIX */
|
||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9896);
|
||||
@@ -287,6 +288,9 @@ async function write(directory, settings, overwriteSettings) {
|
||||
|
||||
const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
||||
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
||||
async function isGpgAvailable() {
|
||||
return Boolean(await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .which */ .K7('gpg', false));
|
||||
}
|
||||
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
||||
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
||||
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
||||
@@ -298,8 +302,8 @@ function toGpgPath(p) {
|
||||
.replace(/\\/g, '/')
|
||||
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
||||
}
|
||||
function createGpgHome(prefix) {
|
||||
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4(), prefix));
|
||||
function createGpgHome(prefix, tempDir = _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4()) {
|
||||
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(tempDir, prefix));
|
||||
if (process.platform !== 'win32') {
|
||||
fs__WEBPACK_IMPORTED_MODULE_0__.chmodSync(gpgHome, 0o700);
|
||||
}
|
||||
@@ -346,19 +350,24 @@ async function removeGpgHome(gpgHome) {
|
||||
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
|
||||
return;
|
||||
}
|
||||
await stopGpgAgent(resolvedGpgHome);
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
||||
}
|
||||
async function stopGpgAgent(gpgHome) {
|
||||
try {
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
||||
}
|
||||
catch {
|
||||
// gpgconf may be unavailable, but directory removal must still be attempted.
|
||||
}
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
||||
}
|
||||
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
|
||||
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
|
||||
let gpgHome;
|
||||
try {
|
||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX);
|
||||
// Both RUNNER_TEMP and TMPDIR can exceed macOS's 104-byte agent socket limit.
|
||||
const tempDir = process.platform === 'darwin' ? '/tmp' : _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4();
|
||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX, tempDir);
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
@@ -370,15 +379,21 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
||||
throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`, { cause: error });
|
||||
}
|
||||
try {
|
||||
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, 'public-key.asc');
|
||||
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKeyContent, { encoding: 'utf-8' });
|
||||
const publicKeys = Array.isArray(publicKeyContent)
|
||||
? publicKeyContent
|
||||
: [publicKeyContent];
|
||||
const publicKeyFiles = publicKeys.map((publicKey, index) => {
|
||||
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, `public-key-${index}.asc`);
|
||||
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKey, { encoding: 'utf-8' });
|
||||
return toGpgPath(publicKeyFile);
|
||||
});
|
||||
const options = { silent: true };
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||
'--homedir',
|
||||
toGpgPath(gpgHome),
|
||||
'--batch',
|
||||
'--import',
|
||||
toGpgPath(publicKeyFile)
|
||||
...publicKeyFiles
|
||||
], options);
|
||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||
'--homedir',
|
||||
@@ -390,6 +405,7 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
||||
], options);
|
||||
}
|
||||
finally {
|
||||
await stopGpgAgent(gpgHome);
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
|
||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
|
||||
}
|
||||
|
||||
Vendored
+96
-4
@@ -418,9 +418,102 @@ function readAttributeStr(xmlData, i) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all the attributes whether valid or invalid.
|
||||
* Walk `attrStr` once, left to right, splitting it into attribute tokens.
|
||||
*
|
||||
* This replaces a regex that used to do the same job
|
||||
* (`(\s*)([^\s=]+)(\s*=)?(\s*(['"])(([\s\S])*?)\5)?`). That regex led with an
|
||||
* optional whitespace group followed by a required "non-whitespace" group.
|
||||
* On a long run of whitespace that never resolves into an attribute name
|
||||
* (e.g. a tag with thousands of trailing spaces before `>`), the engine
|
||||
* backtracks the whitespace group one character at a time before giving up
|
||||
* and moving to the next starting position — one full backtrack per
|
||||
* position, which is quadratic in the length of the run.
|
||||
*
|
||||
* A single forward-only scan can never backtrack, so it can't be made slow
|
||||
* this way no matter how much whitespace the input contains — it's always
|
||||
* proportional to the length of the string, once.
|
||||
*
|
||||
* Each returned token mirrors the shape the old regex match array had, so
|
||||
* the validation logic below (which reads token[1]..token[6]) didn't need
|
||||
* to change:
|
||||
* token.startIndex - where this token begins in attrStr
|
||||
* token[1] - leading whitespace before the name
|
||||
* token[2] - the attribute name
|
||||
* token[3] - whitespace + '=' if present, else undefined
|
||||
* token[4] - marker (any defined value) if a quoted value was found
|
||||
* token[5] - the quote character used ('"' or "'")
|
||||
* token[6] - the value's text, without the surrounding quotes
|
||||
*
|
||||
* A malformed leading character (e.g. a stray '=' with no name before it)
|
||||
* is simply skipped over, one character at a time — the same outcome the
|
||||
* old regex produced by failing to match at that position and retrying at
|
||||
* the next one.
|
||||
*/
|
||||
const validAttrStrRegxp = new RegExp('(\\s*)([^\\s=]+)(\\s*=)?(\\s*([\'"])(([\\s\\S])*?)\\5)?', 'g');
|
||||
function scanAttributeTokens(attrStr) {
|
||||
const tokens = [];
|
||||
const len = attrStr.length;
|
||||
let i = 0;
|
||||
|
||||
while (i < len) {
|
||||
const tokenStart = i;
|
||||
|
||||
// Leading whitespace before the name.
|
||||
while (i < len && isWhiteSpace(attrStr[i])) i++;
|
||||
if (i >= len) break; // trailing whitespace only — nothing left to read
|
||||
|
||||
if (attrStr[i] === '=') {
|
||||
// No name before this '=' — not a valid attribute start. Move past
|
||||
// just this one character and try again from the next position.
|
||||
i = tokenStart + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const leadingWs = attrStr.slice(tokenStart, i);
|
||||
|
||||
// Attribute name — everything up to the next whitespace or '='.
|
||||
const nameStart = i;
|
||||
while (i < len && !isWhiteSpace(attrStr[i]) && attrStr[i] !== '=') i++;
|
||||
const name = attrStr.slice(nameStart, i);
|
||||
|
||||
// Optional whitespace + '='.
|
||||
let equalsGroup; // whitespace + '=' text, or undefined if absent
|
||||
let j = i;
|
||||
while (j < len && isWhiteSpace(attrStr[j])) j++;
|
||||
if (j < len && attrStr[j] === '=') {
|
||||
equalsGroup = attrStr.slice(i, j + 1);
|
||||
i = j + 1;
|
||||
}
|
||||
|
||||
// Optional whitespace + quoted value.
|
||||
let quoteChar;
|
||||
let value;
|
||||
let k = i;
|
||||
while (k < len && isWhiteSpace(attrStr[k])) k++;
|
||||
if (k < len && (attrStr[k] === '"' || attrStr[k] === "'")) {
|
||||
const valueStart = k + 1;
|
||||
const closeIdx = attrStr.indexOf(attrStr[k], valueStart);
|
||||
if (closeIdx !== -1) {
|
||||
quoteChar = attrStr[k];
|
||||
value = attrStr.slice(valueStart, closeIdx);
|
||||
i = closeIdx + 1;
|
||||
}
|
||||
// No closing quote found anywhere in the rest of the string — leave
|
||||
// quoteChar/value undefined, same as the old regex's group failing
|
||||
// to match a backreference-less run.
|
||||
}
|
||||
|
||||
const token = { startIndex: tokenStart };
|
||||
token[1] = leadingWs;
|
||||
token[2] = name;
|
||||
token[3] = equalsGroup;
|
||||
token[4] = quoteChar !== undefined ? true : undefined;
|
||||
token[5] = quoteChar;
|
||||
token[6] = value;
|
||||
tokens.push(token);
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
//attr, ="sd", a="amit's", a="sd"b="saf", ab cd=""
|
||||
|
||||
@@ -429,7 +522,7 @@ function validateAttributeString(attrStr, options) {
|
||||
|
||||
//if(attrStr.trim().length === 0) return true; //empty string
|
||||
|
||||
const matches = (0,_util_js__WEBPACK_IMPORTED_MODULE_0__/* .getAllMatches */ .Xe)(attrStr, validAttrStrRegxp);
|
||||
const matches = scanAttributeTokens(attrStr);
|
||||
const attrNames = {};
|
||||
|
||||
for (let i = 0; i < matches.length; i++) {
|
||||
@@ -532,7 +625,6 @@ function getPositionFromMatch(match) {
|
||||
return match.startIndex + match[1].length;
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 6009:
|
||||
|
||||
Vendored
+68
-24
@@ -52431,6 +52431,24 @@ const EXPANSION_MAX = 100_000;
|
||||
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
||||
// characters) so legitimate input is unaffected.
|
||||
const EXPANSION_MAX_LENGTH = 4_000_000;
|
||||
// `expand_` recurses once per level of brace *nesting* - both when expanding a
|
||||
// set's comma members and when re-wrapping a set whose body is a single part.
|
||||
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
||||
// level per chained group), which left nesting depth unbounded: about 3,100
|
||||
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
||||
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
||||
// will follow nesting. It sits far above any realistic pattern and well below
|
||||
// the depth at which the stack runs out.
|
||||
const EXPANSION_MAX_DEPTH = 1_000;
|
||||
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
||||
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
||||
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
||||
// full passes over a string that itself grows by one `escClose` sentinel each
|
||||
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
||||
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
||||
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
||||
// times the scan may restart. Real `{a},b}` input needs a handful.
|
||||
const EXPANSION_MAX_REWRITES = 1_000;
|
||||
function numeric(str) {
|
||||
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
||||
}
|
||||
@@ -52450,37 +52468,52 @@ function unescapeBraces(str) {
|
||||
.replace(escCommaPattern, ',')
|
||||
.replace(escPeriodPattern, '.');
|
||||
}
|
||||
// Like `target.push(...items)` but doesn't overflow the stack
|
||||
function pushAll(target, items) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
target.push(items[i]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Basically just str.split(","), but handling cases
|
||||
* where we have nested braced sections, which should be
|
||||
* treated as individual members, like {a,{b,c},d}
|
||||
*/
|
||||
function parseCommaParts(str) {
|
||||
if (!str) {
|
||||
return [''];
|
||||
}
|
||||
const parts = [];
|
||||
const m = balanced('{', '}', str);
|
||||
if (!m) {
|
||||
return str.split(',');
|
||||
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
||||
// chain of them exhaust the stack - the parsing-side counterpart to
|
||||
// the `expand_` overflow fixed for CVE-2026-14257, and not something `max` or
|
||||
// `maxLength` can bound, since it happens before expansion.
|
||||
//
|
||||
// The part the next chunk continues
|
||||
let carry = '';
|
||||
for (;;) {
|
||||
const m = balanced('{', '}', str);
|
||||
if (!m) {
|
||||
const tail = str.split(',');
|
||||
tail[0] = carry + tail[0];
|
||||
pushAll(parts, tail);
|
||||
return parts;
|
||||
}
|
||||
const { pre, body, post } = m;
|
||||
const p = pre.split(',');
|
||||
p[0] = carry + p[0];
|
||||
p[p.length - 1] += '{' + body + '}';
|
||||
if (!post.length) {
|
||||
pushAll(parts, p);
|
||||
return parts;
|
||||
}
|
||||
carry = p.pop();
|
||||
pushAll(parts, p);
|
||||
str = post;
|
||||
}
|
||||
const { pre, body, post } = m;
|
||||
const p = pre.split(',');
|
||||
p[p.length - 1] += '{' + body + '}';
|
||||
const postParts = parseCommaParts(post);
|
||||
if (post.length) {
|
||||
;
|
||||
p[p.length - 1] += postParts.shift();
|
||||
p.push.apply(p, postParts);
|
||||
}
|
||||
parts.push.apply(parts, p);
|
||||
return parts;
|
||||
}
|
||||
function expand(str, options = {}) {
|
||||
if (!str) {
|
||||
return [];
|
||||
}
|
||||
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
||||
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES, } = options;
|
||||
// I don't know why Bash 4.3 does this, but it does.
|
||||
// Anything starting with {} will have the first two bytes preserved
|
||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||
@@ -52490,7 +52523,7 @@ function expand(str, options = {}) {
|
||||
if (str.slice(0, 2) === '{}') {
|
||||
str = '\\{\\}' + str.slice(2);
|
||||
}
|
||||
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
||||
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
||||
}
|
||||
function embrace(str) {
|
||||
return '{' + str + '}';
|
||||
@@ -52585,7 +52618,13 @@ function expandSequence(body, isAlphaSequence, max, maxLength) {
|
||||
}
|
||||
return N;
|
||||
}
|
||||
function expand_(str, max, maxLength, isTop) {
|
||||
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
||||
// Too deeply nested to keep following: treat the rest as literal, the same
|
||||
// way a group that cannot expand is already handled. Truncating rather than
|
||||
// throwing keeps `expand` total, matching `max` and `maxLength`.
|
||||
if (depth > maxDepth) {
|
||||
return [str];
|
||||
}
|
||||
// Consume the string's top-level brace groups left to right, threading a
|
||||
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
||||
// rather than recursing on `m.post` once per group - keeps the native stack
|
||||
@@ -52597,6 +52636,9 @@ function expand_(str, max, maxLength, isTop) {
|
||||
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
||||
// is on the final strings, so it is applied to whichever `combine` produces
|
||||
// them (the one with no brace set left in the tail).
|
||||
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
||||
// re-reads the whole string, so leaving this unbounded is quadratic.
|
||||
let rewrites = 0;
|
||||
let dropEmpties = false;
|
||||
let firstGroup = true;
|
||||
for (;;) {
|
||||
@@ -52621,7 +52663,8 @@ function expand_(str, max, maxLength, isTop) {
|
||||
const isOptions = m.body.indexOf(',') >= 0;
|
||||
if (!isSequence && !isOptions) {
|
||||
// {a},b}
|
||||
if (m.post.match(/,(?!,).*\}/)) {
|
||||
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
||||
rewrites++;
|
||||
str = m.pre + '{' + m.body + escClose + m.post;
|
||||
isTop = true;
|
||||
continue;
|
||||
@@ -52641,7 +52684,7 @@ function expand_(str, max, maxLength, isTop) {
|
||||
let n = parseCommaParts(m.body);
|
||||
if (n.length === 1 && n[0] !== undefined) {
|
||||
// x{{a,b}}y ==> x{a}y x{b}y
|
||||
n = expand_(n[0], max, maxLength, false).map(embrace);
|
||||
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
||||
//XXX is this necessary? Can't seem to hit it in tests.
|
||||
/* c8 ignore start */
|
||||
if (n.length === 1) {
|
||||
@@ -52667,12 +52710,13 @@ function expand_(str, max, maxLength, isTop) {
|
||||
values = [];
|
||||
let valuesLength = 0;
|
||||
outer: for (let j = 0; j < n.length; j++) {
|
||||
const expanded = expand_(n[j], max, maxLength, false);
|
||||
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
||||
for (let k = 0; k < expanded.length; k++) {
|
||||
const v = expanded[k];
|
||||
if (dropsEmpties && !v)
|
||||
continue;
|
||||
if (values.length >= max || valuesLength + v.length > maxLength) {
|
||||
if (values.length >= max ||
|
||||
valuesLength + v.length > maxLength) {
|
||||
break outer;
|
||||
}
|
||||
values.push(v);
|
||||
|
||||
Vendored
+32
-20
@@ -13,19 +13,26 @@ export const modules = {
|
||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9896);
|
||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2088);
|
||||
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(semver__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6242);
|
||||
/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7444);
|
||||
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4527);
|
||||
/* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6242);
|
||||
/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7444);
|
||||
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4527);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4__/* .JavaBase */ .O {
|
||||
function compareNumberArrays(a, b) {
|
||||
const length = Math.max(a.length, b.length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
const diff = (a[i] ?? 0) - (b[i] ?? 0);
|
||||
if (diff !== 0) {
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__/* .JavaBase */ .O {
|
||||
constructor(installerOptions) {
|
||||
super('Zulu', installerOptions);
|
||||
}
|
||||
@@ -39,19 +46,24 @@ class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4__/*
|
||||
? [...item.java_version, item.openjdk_build_number]
|
||||
: item.java_version;
|
||||
return {
|
||||
version: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .convertVersionToSemver */ .ZY)(javaVersion),
|
||||
version: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .convertVersionToSemver */ .ZY)(javaVersion),
|
||||
url: item.download_url,
|
||||
zuluVersion: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .convertVersionToSemver */ .ZY)(item.distro_version),
|
||||
javaVersion: item.java_version,
|
||||
buildNumber: item.openjdk_build_number ?? 0,
|
||||
distroVersion: item.distro_version,
|
||||
packageUuid: item.package_uuid
|
||||
};
|
||||
});
|
||||
const satisfiedVersions = availableVersions
|
||||
.filter(item => (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .isVersionSatisfies */ .y)(version, item.version))
|
||||
.filter(item => (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .isVersionSatisfies */ .y)(version, item.version))
|
||||
.sort((a, b) => {
|
||||
// Azul provides two versions: java_version and distro_version
|
||||
// we should sort by both fields by descending
|
||||
return (-semver__WEBPACK_IMPORTED_MODULE_3___default().compareBuild(a.version, b.version) ||
|
||||
-semver__WEBPACK_IMPORTED_MODULE_3___default().compareBuild(a.zuluVersion, b.zuluVersion));
|
||||
// Compare numerically rather than via semver build metadata: Azul
|
||||
// hotfix releases carry a 4th java_version segment (e.g. 25.0.4.1+1,
|
||||
// rendered as '25.0.4+1.1') that must rank above 25.0.4+7, whereas
|
||||
// semver.compareBuild would order the build identifiers '7' > '1'.
|
||||
return (-compareNumberArrays(a.javaVersion, b.javaVersion) ||
|
||||
b.buildNumber - a.buildNumber ||
|
||||
-compareNumberArrays(a.distroVersion, b.distroVersion));
|
||||
})
|
||||
.map((item) => ({
|
||||
version: item.version,
|
||||
@@ -85,21 +97,21 @@ class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4__/*
|
||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Extracting Java archive...`);
|
||||
const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getDownloadArchiveExtension */ .ag)();
|
||||
const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .getDownloadArchiveExtension */ .ag)();
|
||||
if (process.platform === 'win32') {
|
||||
javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .renameWinArchive */ .n2)(javaArchivePath);
|
||||
javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .renameWinArchive */ .n2)(javaArchivePath);
|
||||
}
|
||||
const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .extractJdkFile */ .PE)(javaArchivePath, extension);
|
||||
const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .extractJdkFile */ .PE)(javaArchivePath, extension);
|
||||
const archiveName = fs__WEBPACK_IMPORTED_MODULE_2___default().readdirSync(extractedJavaPath)[0];
|
||||
const archivePath = path__WEBPACK_IMPORTED_MODULE_1___default().join(extractedJavaPath, archiveName);
|
||||
const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
|
||||
const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
|
||||
return { version: javaRelease.version, path: javaPath };
|
||||
}
|
||||
async getAvailableVersions() {
|
||||
const arch = this.getArchitectureOptions();
|
||||
const [bundleType, features] = this.packageType.split('+');
|
||||
const platform = this.getPlatformOption();
|
||||
const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getDownloadArchiveExtension */ .ag)();
|
||||
const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .getDownloadArchiveExtension */ .ag)();
|
||||
const javafx = features?.includes('fx') ?? false;
|
||||
const crac = features?.includes('crac') ?? false;
|
||||
const releaseStatus = this.stable ? 'ga' : 'ea';
|
||||
@@ -185,7 +197,7 @@ class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4__/*
|
||||
// The new Metadata API's "linux" value returns both glibc and musl
|
||||
// packages, so target the libc the runner actually has. A glibc JDK
|
||||
// cannot run on Alpine.
|
||||
return (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_5__/* .isAlpineLinux */ .G6)() ? 'linux_musl' : 'linux_glibc';
|
||||
return (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_4__/* .isAlpineLinux */ .G6)() ? 'linux_musl' : 'linux_glibc';
|
||||
default:
|
||||
return process.platform;
|
||||
}
|
||||
|
||||
Vendored
+509
-197
File diff suppressed because it is too large
Load Diff
+20
-11
@@ -539,18 +539,27 @@ tool-cache installation short-circuits setup, so a changed `jdk-file` is not
|
||||
re-extracted for a version that is already installed. Use
|
||||
`force-download: true` when the archive contents change but the version does not.
|
||||
|
||||
The verification identity separates unverified downloads from packages verified
|
||||
with the distribution's bundled signing key and from packages verified with each
|
||||
custom key. Custom public keys are represented by a SHA-256 fingerprint of
|
||||
normalized key material; the key itself is not placed in the cache key, the logs,
|
||||
or action state. A verified exact-key hit reuses content that was
|
||||
signature-verified when it was downloaded by the run that saved the entry,
|
||||
instead of downloading and verifying it again.
|
||||
The verification identity separates requests that disable signature verification,
|
||||
check and warn without enforcement, or explicitly enforce verification. Disabled
|
||||
and check-and-warn requests have the same non-enforcement guarantee, but they are
|
||||
kept separate so an entry downloaded with verification disabled cannot prevent a
|
||||
later check-and-warn request from attempting verification. The identity also
|
||||
separates the distribution's bundled signing keys from custom keys. Custom
|
||||
public-key sets are represented by a SHA-256 fingerprint of normalized,
|
||||
boundary-delimited key material; the keys themselves are not placed in the cache
|
||||
key, the logs, or action state. Enforced requests only restore entries created by
|
||||
an enforced request whose signature verification succeeded. Check-and-warn entries
|
||||
may have been saved after verification succeeded or after a verification failure
|
||||
was reported as a warning.
|
||||
|
||||
For signature-verification defaults, enforced failure behavior, and recovery from
|
||||
a legitimate vendor signing-key rotation, see
|
||||
[Download integrity and signatures](../README.md#download-integrity-and-signatures).
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The JDK cache **key** is what isolates verification modes and release
|
||||
> identity: a JDK cache entry created by an unverified download can never be
|
||||
> restored for a request that sets `verify-signature: true`, and vice versa.
|
||||
> The JDK cache **key** isolates disabled, check-and-warn, and enforced verification
|
||||
> modes as well as release identity. A check-and-warn entry can never be restored
|
||||
> for a request that sets `verify-signature: true`, and vice versa.
|
||||
> `cache-jdk` does not change how the runner tool cache is used. setup-java
|
||||
> first looks for an installation in the runner tool cache — a preinstalled
|
||||
> JDK, or one installed by an earlier step of the same job — and uses it as-is. Such an installation is not downloaded again, and its checksum
|
||||
@@ -640,7 +649,7 @@ absent from a vendor catalog.
|
||||
|
||||
| Distribution | Linux | macOS | Windows | Other / version restrictions |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `temurin` | `x64`, `x86`, `armv7`, `aarch64`, `ppc64le`, `s390x` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | Linux `armv7` is available through Java 17. |
|
||||
| `temurin` | `x64`, `x86`, `armv7`, `aarch64`, `ppc64le`, `riscv64`, `s390x` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | Linux `armv7` is available through Java 17. |
|
||||
| `zulu` | `x64`, `x86`, `armv7`, `aarch64` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | |
|
||||
| `liberica` | `x64`, `x86`, `armv7`, `aarch64`, `ppc64le` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | Solaris: `x64`. |
|
||||
| `liberica-nik` | `x64`, `aarch64` | `x64`, `aarch64` | `x64`, `aarch64` | |
|
||||
|
||||
Generated
+1241
-671
File diff suppressed because it is too large
Load Diff
+11
-11
@@ -49,27 +49,27 @@
|
||||
"@actions/http-client": "^4.0.1",
|
||||
"@actions/io": "^3.0.2",
|
||||
"@actions/tool-cache": "^4.0.0",
|
||||
"fast-xml-parser": "^5.11.0",
|
||||
"fast-xml-parser": "^5.11.1",
|
||||
"semver": "^7.8.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@jest/globals": "^30.4.1",
|
||||
"@types/node": "^26.2.0",
|
||||
"@jest/globals": "^30.5.2",
|
||||
"@types/node": "^26.6.2",
|
||||
"@types/semver": "^7.8.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.67.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.70.1",
|
||||
"@typescript-eslint/parser": "^8.65.0",
|
||||
"@vercel/ncc": "^0.45.0",
|
||||
"eslint": "^10.7.0",
|
||||
"eslint": "^10.11.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-jest": "^29.16.1",
|
||||
"eslint-plugin-jest": "^29.16.6",
|
||||
"eslint-plugin-n": "^18.3.0",
|
||||
"globals": "^17.9.0",
|
||||
"globals": "^17.12.0",
|
||||
"husky": "^9.1.7",
|
||||
"jest": "^30.4.2",
|
||||
"lint-staged": "^17.3.0",
|
||||
"prettier": "^3.9.5",
|
||||
"ts-jest": "^29.4.11",
|
||||
"jest": "^30.5.2",
|
||||
"lint-staged": "^17.5.1",
|
||||
"prettier": "^3.9.9",
|
||||
"ts-jest": "^29.4.13",
|
||||
"typescript": "^6.0.3"
|
||||
},
|
||||
"bugs": {
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import {
|
||||
isJdkCacheEnabled,
|
||||
isJobStatusSuccess
|
||||
} from './util.js';
|
||||
import {fileURLToPath} from 'url';
|
||||
import {isMainModule} from './is-main-module.js';
|
||||
|
||||
async function removeGpgHome() {
|
||||
const gpgHome = core.getState(constants.STATE_GPG_HOME);
|
||||
@@ -77,7 +77,7 @@ export async function run() {
|
||||
await ignoreError(saveCaches());
|
||||
}
|
||||
|
||||
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||
if (isMainModule(import.meta.url)) {
|
||||
run();
|
||||
} else {
|
||||
// https://nodejs.org/api/modules.html#modules_accessing_the_main_module
|
||||
|
||||
@@ -12,6 +12,9 @@ export const INPUT_SET_DEFAULT = 'set-default';
|
||||
export const INPUT_PROBLEM_MATCHER = 'problem-matcher';
|
||||
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||
export const INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
||||
export const SIGNATURE_VERIFICATION_DOCUMENTATION_URL =
|
||||
'https://github.com/actions/setup-java#download-integrity-and-signatures';
|
||||
export const SIGNATURE_VERIFICATION_FAILURE_HELP = `If this is a legitimate vendor signing-key rotation, see ${SIGNATURE_VERIFICATION_DOCUMENTATION_URL} for instructions to configure the updated public key or temporarily disable signature verification.`;
|
||||
export const INPUT_MVN_SERVER_CREDENTIALS = 'mvn-server-credentials';
|
||||
export const INPUT_MVN_REPOSITORIES = 'mvn-repositories';
|
||||
export const INPUT_MVN_REPOSITORIES_INCLUDE_CENTRAL =
|
||||
|
||||
@@ -5,16 +5,17 @@ import semver from 'semver';
|
||||
import path from 'path';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import {
|
||||
convertVersionToSemver,
|
||||
getToolcachePath,
|
||||
isVersionSatisfies
|
||||
isVersionSatisfies,
|
||||
normalizeJavaVersionToSemver
|
||||
} from '../util.js';
|
||||
import {
|
||||
import type {
|
||||
ChecksumAlgorithm,
|
||||
ChecksumMetadata,
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
JavaInstallerResults,
|
||||
SignatureVerificationKey
|
||||
} from './base-models.js';
|
||||
import {MACOS_JAVA_CONTENT_POSTFIX} from '../constants.js';
|
||||
import {RetryingHttpClient} from '../retrying-http-client.js';
|
||||
@@ -44,7 +45,8 @@ export abstract class JavaBase {
|
||||
private floatingVersionVerified = false;
|
||||
protected setDefault: boolean;
|
||||
protected verifySignature: boolean;
|
||||
protected verifySignaturePublicKey: string | undefined;
|
||||
protected verifySignatureExplicitlyRequested: boolean;
|
||||
protected verifySignaturePublicKey: SignatureVerificationKey | undefined;
|
||||
|
||||
constructor(
|
||||
protected distribution: string,
|
||||
@@ -70,6 +72,8 @@ export abstract class JavaBase {
|
||||
: true;
|
||||
this.verifySignature =
|
||||
installerOptions.verifySignature ?? this.supportsSignatureVerification();
|
||||
this.verifySignatureExplicitlyRequested =
|
||||
installerOptions.verifySignature === true;
|
||||
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
||||
}
|
||||
|
||||
@@ -369,6 +373,7 @@ export abstract class JavaBase {
|
||||
source: this.getJdkReleaseIdentity(javaRelease),
|
||||
verification: getJdkVerificationIdentity(
|
||||
this.verifySignature,
|
||||
this.verifySignatureExplicitlyRequested,
|
||||
this.verifySignaturePublicKey
|
||||
),
|
||||
path: this.getJdkCachePath(javaRelease.version)
|
||||
@@ -670,12 +675,9 @@ export abstract class JavaBase {
|
||||
|
||||
// Java uses a versioning scheme (JEP 322) that can contain more numeric
|
||||
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
|
||||
// exact versions to SemVer build notation ('18.0.1+1') so they are
|
||||
// accepted. Ranges and versions that already carry build metadata are
|
||||
// left untouched.
|
||||
if (/^\d+(\.\d+){3,}$/.test(version)) {
|
||||
version = convertVersionToSemver(version);
|
||||
}
|
||||
// exact versions to SemVer build notation ('18.0.1+1', or '26.0.2+1.1'
|
||||
// for '26.0.2.1+1') so they are accepted. Ranges are left untouched.
|
||||
version = normalizeJavaVersionToSemver(version);
|
||||
|
||||
if (!semver.validRange(version)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export type SignatureVerificationKey = string | readonly string[];
|
||||
|
||||
export interface JavaInstallerOptions {
|
||||
version: string;
|
||||
architecture: string;
|
||||
@@ -7,7 +9,7 @@ export interface JavaInstallerOptions {
|
||||
cacheJdk?: boolean;
|
||||
setDefault?: boolean;
|
||||
verifySignature?: boolean;
|
||||
verifySignaturePublicKey?: string;
|
||||
verifySignaturePublicKey?: SignatureVerificationKey;
|
||||
}
|
||||
|
||||
export interface JavaInstallerResults {
|
||||
|
||||
@@ -166,8 +166,8 @@ export class LibericaDistributions extends JavaBase {
|
||||
}
|
||||
|
||||
private convertVersionToSemver(version: LibericaVersion): string {
|
||||
const {buildVersion, featureVersion, interimVersion, updateVersion} =
|
||||
version;
|
||||
const {featureVersion, interimVersion, updateVersion} = version;
|
||||
const buildVersion = version.version.split('+')[1] || version.buildVersion;
|
||||
const mainVersion = [featureVersion, interimVersion, updateVersion].join(
|
||||
'.'
|
||||
);
|
||||
|
||||
@@ -65,7 +65,7 @@ export class LocalDistribution extends JavaBase {
|
||||
architecture: this.architecture,
|
||||
version: this.version,
|
||||
source,
|
||||
verification: getJdkVerificationIdentity(false),
|
||||
verification: getJdkVerificationIdentity(false, false),
|
||||
path: this.getJdkCachePath(this.version)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from '../../util.js';
|
||||
import * as gpg from '../../gpg.js';
|
||||
import {MICROSOFT_PUBLIC_KEY} from './microsoft-key.js';
|
||||
import {SIGNATURE_VERIFICATION_FAILURE_HELP} from '../../constants.js';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import fs from 'fs';
|
||||
@@ -34,22 +35,31 @@ export class MicrosoftDistributions extends JavaBase {
|
||||
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
||||
|
||||
if (this.verifySignature) {
|
||||
if (!javaRelease.signatureUrl) {
|
||||
throw new Error(
|
||||
`Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version ${javaRelease.version}.`
|
||||
);
|
||||
}
|
||||
core.info(`Verifying Java package signature...`);
|
||||
try {
|
||||
await gpg.verifyPackageSignature(
|
||||
javaArchivePath,
|
||||
javaRelease.signatureUrl,
|
||||
this.verifySignaturePublicKey ?? MICROSOFT_PUBLIC_KEY
|
||||
);
|
||||
if (!javaRelease.signatureUrl) {
|
||||
throw new Error(
|
||||
`Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version ${javaRelease.version}.`
|
||||
);
|
||||
}
|
||||
core.info(`Verifying Java package signature...`);
|
||||
try {
|
||||
await gpg.verifyPackageSignature(
|
||||
javaArchivePath,
|
||||
javaRelease.signatureUrl,
|
||||
this.verifySignaturePublicKey ?? MICROSOFT_PUBLIC_KEY
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Failed to verify signature for Microsoft Build of OpenJDK version ${javaRelease.version}. Signature URL: ${javaRelease.signatureUrl}. Error: ${(error as Error).message} ${SIGNATURE_VERIFICATION_FAILURE_HELP}`,
|
||||
{cause: error}
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Failed to verify signature for Microsoft Build of OpenJDK version ${javaRelease.version}. Signature URL: ${javaRelease.signatureUrl}. Error: ${(error as Error).message}`,
|
||||
{cause: error}
|
||||
if (this.verifySignatureExplicitlyRequested) {
|
||||
throw error;
|
||||
}
|
||||
core.warning(
|
||||
error instanceof Error ? error.message : `Unknown error: ${error}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import semver from 'semver';
|
||||
import {convertVersionToSemver} from '../util.js';
|
||||
import {normalizeJavaVersionToSemver} from '../util.js';
|
||||
|
||||
export enum JavaDistribution {
|
||||
Temurin = 'temurin',
|
||||
@@ -98,12 +98,9 @@ function canResolveTemurinJmods(version: string): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
let normalizedRange = normalizedVersion
|
||||
.replace(/-ea$/, '')
|
||||
.replace('-ea.', '+');
|
||||
if (/^\d+(\.\d+){3,}$/.test(normalizedRange)) {
|
||||
normalizedRange = convertVersionToSemver(normalizedRange);
|
||||
}
|
||||
const normalizedRange = normalizeJavaVersionToSemver(
|
||||
normalizedVersion.replace(/-ea$/, '').replace('-ea.', '+')
|
||||
);
|
||||
if (!semver.validRange(normalizedRange)) {
|
||||
// JavaBase owns general version validation and its targeted error messages.
|
||||
return true;
|
||||
|
||||
@@ -5,7 +5,14 @@ import {JavaDistribution} from './package-types.js';
|
||||
export type JavaPlatform = 'linux' | 'macos' | 'windows' | 'solaris';
|
||||
|
||||
export type JavaArchitecture =
|
||||
'x86' | 'x64' | 'armv7' | 'aarch64' | 'ppc64le' | 'ppc64' | 's390x';
|
||||
| 'x86'
|
||||
| 'x64'
|
||||
| 'armv7'
|
||||
| 'aarch64'
|
||||
| 'ppc64le'
|
||||
| 'ppc64'
|
||||
| 'riscv64'
|
||||
| 's390x';
|
||||
|
||||
interface VersionedArchitecture {
|
||||
architecture: JavaArchitecture;
|
||||
@@ -27,7 +34,14 @@ export type JavaPlatformCapability =
|
||||
RestrictedPlatformCapability | UnrestrictedPlatformCapability;
|
||||
|
||||
const X64_ARM64 = ['x64', 'aarch64'] as const;
|
||||
const STANDARD_LINUX = ['x64', 'x86', 'aarch64', 'ppc64le', 's390x'] as const;
|
||||
const STANDARD_LINUX = [
|
||||
'x64',
|
||||
'x86',
|
||||
'aarch64',
|
||||
'ppc64le',
|
||||
'riscv64',
|
||||
's390x'
|
||||
] as const;
|
||||
|
||||
export const JAVA_PLATFORM_CAPABILITIES: Record<
|
||||
JavaDistribution,
|
||||
@@ -174,6 +188,7 @@ const CANONICAL_ARCHITECTURES: readonly JavaArchitecture[] = [
|
||||
'aarch64',
|
||||
'ppc64le',
|
||||
'ppc64',
|
||||
'riscv64',
|
||||
's390x'
|
||||
];
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ import * as gpg from '../../gpg.js';
|
||||
import {ADOPTIUM_PUBLIC_KEY} from './adoptium-key.js';
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {ITemurinAvailableVersions} from './models.js';
|
||||
import {MACOS_JAVA_CONTENT_POSTFIX} from '../../constants.js';
|
||||
import {
|
||||
MACOS_JAVA_CONTENT_POSTFIX,
|
||||
SIGNATURE_VERIFICATION_FAILURE_HELP
|
||||
} from '../../constants.js';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
@@ -67,7 +70,7 @@ export class TemurinDistribution extends JavaBase {
|
||||
const formattedVersion = this.stable
|
||||
? item.version_data.semver
|
||||
: item.version_data.semver.replace('-beta+', '+');
|
||||
return {
|
||||
const release: JavaDownloadRelease = {
|
||||
version: formattedVersion,
|
||||
url: item.binaries[0].package.link,
|
||||
signatureUrl: item.binaries[0].package.signature_link,
|
||||
@@ -76,11 +79,29 @@ export class TemurinDistribution extends JavaBase {
|
||||
value: item.binaries[0].package.checksum,
|
||||
source: item.binaries[0].package.checksum_link
|
||||
}
|
||||
} as JavaDownloadRelease;
|
||||
};
|
||||
return {
|
||||
release,
|
||||
openjdkVersion: getOpenJdkSemverVersion(item.version_data)
|
||||
};
|
||||
});
|
||||
|
||||
// The Adoptium API `semver` folds the JEP 322 patch field into the build
|
||||
// number ('26.0.2.1+1' -> '26.0.2+101') and appends extra metadata for LTS
|
||||
// releases ('25.0.4+7' -> '25.0.4+7.0.LTS'). Exact versions requested by
|
||||
// users follow the OpenJDK notation instead, so also match them against a
|
||||
// key derived from the OpenJDK version fields ('26.0.2+1.1', '25.0.4+7').
|
||||
const isExactBuildRequest = (semver.parse(version)?.build.length ?? 0) > 0;
|
||||
|
||||
const satisfiedVersions = availableVersionsWithBinaries
|
||||
.filter(item => isVersionSatisfies(version, item.version))
|
||||
.filter(
|
||||
({release, openjdkVersion}) =>
|
||||
isVersionSatisfies(version, release.version) ||
|
||||
(isExactBuildRequest &&
|
||||
openjdkVersion !== null &&
|
||||
semver.compareBuild(version, openjdkVersion) === 0)
|
||||
)
|
||||
.map(({release}) => release)
|
||||
.sort((a, b) => {
|
||||
return -semver.compareBuild(a.version, b.version);
|
||||
});
|
||||
@@ -89,7 +110,7 @@ export class TemurinDistribution extends JavaBase {
|
||||
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableVersionStrings = availableVersionsWithBinaries.map(
|
||||
item => item.version
|
||||
({release}) => release.version
|
||||
);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
@@ -141,24 +162,41 @@ export class TemurinDistribution extends JavaBase {
|
||||
const archivePath = await this.downloadAndVerify(release);
|
||||
|
||||
if (this.verifySignature) {
|
||||
if (!release.signatureUrl) {
|
||||
throw new Error(
|
||||
`Input 'verify-signature' is enabled, but no signature URL was found for Temurin version ${release.version}.`
|
||||
);
|
||||
}
|
||||
core.info(`Verifying Java package signature...`);
|
||||
try {
|
||||
await gpg.verifyPackageSignature(
|
||||
archivePath,
|
||||
release.signatureUrl,
|
||||
this.verifySignaturePublicKey ?? ADOPTIUM_PUBLIC_KEY
|
||||
);
|
||||
if (!(await gpg.isGpgAvailable())) {
|
||||
throw new Error(
|
||||
"Input 'verify-signature' is enabled, but gpg is not available."
|
||||
);
|
||||
}
|
||||
if (!release.signatureUrl) {
|
||||
throw new Error(
|
||||
`Input 'verify-signature' is enabled, but no signature URL was found for Temurin version ${release.version}.`
|
||||
);
|
||||
}
|
||||
core.info(`Verifying Java package signature...`);
|
||||
try {
|
||||
await gpg.verifyPackageSignature(
|
||||
archivePath,
|
||||
release.signatureUrl,
|
||||
this.verifySignaturePublicKey ?? ADOPTIUM_PUBLIC_KEY
|
||||
);
|
||||
} catch (error) {
|
||||
const verificationError = new Error(
|
||||
`Failed to verify signature for Temurin version ${release.version} from ${release.signatureUrl}: ${(error as Error).message} ${SIGNATURE_VERIFICATION_FAILURE_HELP}`,
|
||||
{cause: error}
|
||||
);
|
||||
if (this.verifySignatureExplicitlyRequested) {
|
||||
throw verificationError;
|
||||
} else {
|
||||
core.warning(verificationError.message);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Failed to verify signature for Temurin version ${release.version} from ${release.signatureUrl}: ${
|
||||
(error as Error).message
|
||||
}`,
|
||||
{cause: error}
|
||||
if (this.verifySignatureExplicitlyRequested) {
|
||||
throw error;
|
||||
}
|
||||
core.warning(
|
||||
error instanceof Error ? error.message : `Unknown error: ${error}`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -289,3 +327,20 @@ export class TemurinDistribution extends JavaBase {
|
||||
return architecture === 'armv7' ? 'arm' : architecture;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a SemVer version from the OpenJDK version fields reported by the
|
||||
* Adoptium API, e.g. '26.0.2.1+1' -> '26.0.2+1.1' and '25.0.4+7-LTS' ->
|
||||
* '25.0.4+7'. Returns null if the fields cannot form a valid SemVer version.
|
||||
*/
|
||||
function getOpenJdkSemverVersion(
|
||||
versionData: ITemurinAvailableVersions['version_data']
|
||||
): string | null {
|
||||
const {major, minor, security, patch, build} = versionData;
|
||||
if (build === undefined || build === null) {
|
||||
return null;
|
||||
}
|
||||
const buildMetadata = patch ? `${patch}.${build}` : `${build}`;
|
||||
const version = `${major}.${minor}.${security}+${buildMetadata}`;
|
||||
return semver.valid(version) ? version : null;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ export interface ITemurinAvailableVersions {
|
||||
minor: number;
|
||||
openjdk_version: string;
|
||||
security: string;
|
||||
patch?: number;
|
||||
semver: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as core from '@actions/core';
|
||||
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import semver from 'semver';
|
||||
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {IZuluPackageDetails, IZuluVersions} from './models.js';
|
||||
@@ -30,6 +29,17 @@ interface ZuluResolvedRelease {
|
||||
packageUuid: string;
|
||||
}
|
||||
|
||||
function compareNumberArrays(a: number[], b: number[]): number {
|
||||
const length = Math.max(a.length, b.length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
const diff = (a[i] ?? 0) - (b[i] ?? 0);
|
||||
if (diff !== 0) {
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export class ZuluDistribution extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
super('Zulu', installerOptions);
|
||||
@@ -50,7 +60,9 @@ export class ZuluDistribution extends JavaBase {
|
||||
return {
|
||||
version: convertVersionToSemver(javaVersion),
|
||||
url: item.download_url,
|
||||
zuluVersion: convertVersionToSemver(item.distro_version),
|
||||
javaVersion: item.java_version,
|
||||
buildNumber: item.openjdk_build_number ?? 0,
|
||||
distroVersion: item.distro_version,
|
||||
packageUuid: item.package_uuid
|
||||
};
|
||||
});
|
||||
@@ -58,11 +70,14 @@ export class ZuluDistribution extends JavaBase {
|
||||
const satisfiedVersions = availableVersions
|
||||
.filter(item => isVersionSatisfies(version, item.version))
|
||||
.sort((a, b) => {
|
||||
// Azul provides two versions: java_version and distro_version
|
||||
// we should sort by both fields by descending
|
||||
// Compare numerically rather than via semver build metadata: Azul
|
||||
// hotfix releases carry a 4th java_version segment (e.g. 25.0.4.1+1,
|
||||
// rendered as '25.0.4+1.1') that must rank above 25.0.4+7, whereas
|
||||
// semver.compareBuild would order the build identifiers '7' > '1'.
|
||||
return (
|
||||
-semver.compareBuild(a.version, b.version) ||
|
||||
-semver.compareBuild(a.zuluVersion, b.zuluVersion)
|
||||
-compareNumberArrays(a.javaVersion, b.javaVersion) ||
|
||||
b.buildNumber - a.buildNumber ||
|
||||
-compareNumberArrays(a.distroVersion, b.distroVersion)
|
||||
);
|
||||
})
|
||||
.map((item): ZuluResolvedRelease => ({
|
||||
|
||||
+31
-11
@@ -5,11 +5,16 @@ import * as io from '@actions/io';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as util from './util.js';
|
||||
import {ExecOptions} from '@actions/exec';
|
||||
import type {ExecOptions} from '@actions/exec';
|
||||
import type {SignatureVerificationKey} from './distributions/base-models.js';
|
||||
|
||||
export const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
||||
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
||||
|
||||
export async function isGpgAvailable(): Promise<boolean> {
|
||||
return Boolean(await io.which('gpg', false));
|
||||
}
|
||||
|
||||
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
||||
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
||||
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
||||
@@ -21,8 +26,11 @@ export function toGpgPath(p: string): string {
|
||||
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
||||
}
|
||||
|
||||
function createGpgHome(prefix: string): string {
|
||||
const gpgHome = fs.mkdtempSync(path.join(util.getTempDir(), prefix));
|
||||
function createGpgHome(
|
||||
prefix: string,
|
||||
tempDir: string = util.getTempDir()
|
||||
): string {
|
||||
const gpgHome = fs.mkdtempSync(path.join(tempDir, prefix));
|
||||
if (process.platform !== 'win32') {
|
||||
fs.chmodSync(gpgHome, 0o700);
|
||||
}
|
||||
@@ -81,28 +89,33 @@ export async function removeGpgHome(gpgHome: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
await stopGpgAgent(resolvedGpgHome);
|
||||
await io.rmRF(resolvedGpgHome);
|
||||
}
|
||||
|
||||
async function stopGpgAgent(gpgHome: string): Promise<void> {
|
||||
try {
|
||||
await exec.exec(
|
||||
'gpgconf',
|
||||
['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'],
|
||||
['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'],
|
||||
{silent: true, ignoreReturnCode: true}
|
||||
);
|
||||
} catch {
|
||||
// gpgconf may be unavailable, but directory removal must still be attempted.
|
||||
}
|
||||
|
||||
await io.rmRF(resolvedGpgHome);
|
||||
}
|
||||
|
||||
export async function verifyPackageSignature(
|
||||
archivePath: string,
|
||||
signatureUrl: string,
|
||||
publicKeyContent: string
|
||||
publicKeyContent: SignatureVerificationKey
|
||||
) {
|
||||
const signaturePath = await tc.downloadTool(signatureUrl);
|
||||
let gpgHome: string;
|
||||
try {
|
||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX);
|
||||
// Both RUNNER_TEMP and TMPDIR can exceed macOS's 104-byte agent socket limit.
|
||||
const tempDir = process.platform === 'darwin' ? '/tmp' : util.getTempDir();
|
||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX, tempDir);
|
||||
} catch (error) {
|
||||
try {
|
||||
await io.rmRF(signaturePath);
|
||||
@@ -117,8 +130,14 @@ export async function verifyPackageSignature(
|
||||
);
|
||||
}
|
||||
try {
|
||||
const publicKeyFile = path.join(gpgHome, 'public-key.asc');
|
||||
fs.writeFileSync(publicKeyFile, publicKeyContent, {encoding: 'utf-8'});
|
||||
const publicKeys = Array.isArray(publicKeyContent)
|
||||
? publicKeyContent
|
||||
: [publicKeyContent];
|
||||
const publicKeyFiles = publicKeys.map((publicKey, index) => {
|
||||
const publicKeyFile = path.join(gpgHome, `public-key-${index}.asc`);
|
||||
fs.writeFileSync(publicKeyFile, publicKey, {encoding: 'utf-8'});
|
||||
return toGpgPath(publicKeyFile);
|
||||
});
|
||||
const options: ExecOptions = {silent: true};
|
||||
await exec.exec(
|
||||
'gpg',
|
||||
@@ -127,7 +146,7 @@ export async function verifyPackageSignature(
|
||||
toGpgPath(gpgHome),
|
||||
'--batch',
|
||||
'--import',
|
||||
toGpgPath(publicKeyFile)
|
||||
...publicKeyFiles
|
||||
],
|
||||
options
|
||||
);
|
||||
@@ -144,6 +163,7 @@ export async function verifyPackageSignature(
|
||||
options
|
||||
);
|
||||
} finally {
|
||||
await stopGpgAgent(gpgHome);
|
||||
await io.rmRF(signaturePath);
|
||||
await io.rmRF(gpgHome);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import fs from 'fs';
|
||||
import {fileURLToPath} from 'url';
|
||||
|
||||
export function isMainModule(moduleUrl: string): boolean {
|
||||
const entrypoint = process.argv[1];
|
||||
if (!entrypoint || entrypoint === '-') {
|
||||
return false;
|
||||
}
|
||||
|
||||
let entrypointPath: string;
|
||||
try {
|
||||
entrypointPath = fs.realpathSync(entrypoint);
|
||||
} catch (error) {
|
||||
if (
|
||||
error instanceof Error &&
|
||||
'code' in error &&
|
||||
(error.code === 'ENOENT' || error.code === 'ENOTDIR')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Resolve both paths for runtimes using --preserve-symlinks-main.
|
||||
return entrypointPath === fs.realpathSync(fileURLToPath(moduleUrl));
|
||||
}
|
||||
+19
-6
@@ -4,6 +4,7 @@ import path from 'path';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import {isCacheFeatureAvailable} from './cache-feature.js';
|
||||
import type {SignatureVerificationKey} from './distributions/base-models.js';
|
||||
|
||||
const STATE_JDK_CACHES = 'jdk-caches';
|
||||
const JDK_CACHE_KEY_VERSION = 1;
|
||||
@@ -117,18 +118,30 @@ function getInstallationIdentity(
|
||||
|
||||
export function getJdkVerificationIdentity(
|
||||
verifySignature: boolean,
|
||||
publicKey?: string
|
||||
enforceSignatureVerification: boolean,
|
||||
publicKey?: SignatureVerificationKey
|
||||
): string {
|
||||
if (!verifySignature) {
|
||||
return 'unverified';
|
||||
return 'disabled';
|
||||
}
|
||||
const verificationPolicy = enforceSignatureVerification
|
||||
? 'enforced'
|
||||
: 'check-and-warn';
|
||||
if (!publicKey) {
|
||||
return 'verified:bundled';
|
||||
return `${verificationPolicy}:bundled`;
|
||||
}
|
||||
|
||||
const normalizedKey = publicKey.replace(/\r\n?/g, '\n').trim();
|
||||
const fingerprint = createHash('sha256').update(normalizedKey).digest('hex');
|
||||
return `verified:custom:sha256:${fingerprint}`;
|
||||
const publicKeys = Array.isArray(publicKey) ? publicKey : [publicKey];
|
||||
const normalizedKeys = publicKeys.map(key =>
|
||||
key.replace(/\r\n?/g, '\n').trim()
|
||||
);
|
||||
const fingerprintSource = Array.isArray(publicKey)
|
||||
? normalizedKeys.map(key => `${Buffer.byteLength(key)}:${key}`).join('')
|
||||
: normalizedKeys[0];
|
||||
const fingerprint = createHash('sha256')
|
||||
.update(fingerprintSource)
|
||||
.digest('hex');
|
||||
return `${verificationPolicy}:custom:sha256:${fingerprint}`;
|
||||
}
|
||||
|
||||
export async function saveJdkCaches(): Promise<void> {
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@ import {getJavaDistribution} from './distributions/distribution-factory.js';
|
||||
import {JavaInstallerOptions} from './distributions/base-models.js';
|
||||
import {configureProblemMatcher} from './problem-matcher.js';
|
||||
import {validateToolchainIds} from './toolchain-ids.js';
|
||||
import {isMainModule} from './is-main-module.js';
|
||||
|
||||
export async function run() {
|
||||
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
|
||||
@@ -172,7 +173,7 @@ function settle<T>(promise: Promise<T>): Promise<PromiseSettledResult<T>> {
|
||||
);
|
||||
}
|
||||
|
||||
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||
if (isMainModule(import.meta.url)) {
|
||||
run();
|
||||
} else {
|
||||
// https://nodejs.org/api/modules.html#modules_accessing_the_main_module
|
||||
|
||||
+15
@@ -510,6 +510,21 @@ export function convertVersionToSemver(version: number[] | string) {
|
||||
return mainVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Java versions (JEP 322) can contain more numeric fields than SemVer allows,
|
||||
* e.g. '11.0.9.1' or Temurin respins such as '26.0.2.1+1'. Move the extra
|
||||
* fields into SemVer build metadata ('11.0.9+1', '26.0.2+1.1'). Any other
|
||||
* input (ranges, regular SemVer versions) is returned unchanged.
|
||||
*/
|
||||
export function normalizeJavaVersionToSemver(version: string): string {
|
||||
const match = /^(\d+(?:\.\d+){3,})(?:\+([0-9A-Za-z.-]+))?$/.exec(version);
|
||||
if (!match) {
|
||||
return version;
|
||||
}
|
||||
const converted = convertVersionToSemver(match[1]);
|
||||
return match[2] ? `${converted}.${match[2]}` : converted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a validator for the bytes currently served by a URL from the response
|
||||
* headers of a HEAD request. A vendor's `/latest/` URL never changes, so this
|
||||
|
||||
Reference in New Issue
Block a user