diff --git a/.github/workflows/__analysis-kinds.yml b/.github/workflows/__analysis-kinds.yml index 5d0576e2f..5353c1095 100644 --- a/.github/workflows/__analysis-kinds.yml +++ b/.github/workflows/__analysis-kinds.yml @@ -87,7 +87,7 @@ jobs: post-processed-sarif-path: '${{ runner.temp }}/post-processed' - name: Upload SARIF files - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: | analysis-kinds-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }} @@ -95,7 +95,7 @@ jobs: retention-days: 7 - name: Upload post-processed SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: | post-processed-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }} diff --git a/.github/workflows/__config-export.yml b/.github/workflows/__config-export.yml index 0c7a2cc15..f8d0ecf0c 100644 --- a/.github/workflows/__config-export.yml +++ b/.github/workflows/__config-export.yml @@ -65,7 +65,7 @@ jobs: output: '${{ runner.temp }}/results' upload-database: false - name: Upload SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: config-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json path: '${{ runner.temp }}/results/javascript.sarif' diff --git a/.github/workflows/__config-input.yml b/.github/workflows/__config-input.yml index f3f248cda..c015526c6 100644 --- a/.github/workflows/__config-input.yml +++ b/.github/workflows/__config-input.yml @@ -47,7 +47,7 @@ jobs: - name: Check out repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 20.x cache: npm diff --git a/.github/workflows/__diagnostics-export.yml b/.github/workflows/__diagnostics-export.yml index c55f3de9b..32361c922 100644 --- a/.github/workflows/__diagnostics-export.yml +++ b/.github/workflows/__diagnostics-export.yml @@ -76,7 +76,7 @@ jobs: output: '${{ runner.temp }}/results' upload-database: false - name: Upload SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: diagnostics-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json path: '${{ runner.temp }}/results/javascript.sarif' diff --git a/.github/workflows/__export-file-baseline-information.yml b/.github/workflows/__export-file-baseline-information.yml index acdb09908..597c7ce9b 100644 --- a/.github/workflows/__export-file-baseline-information.yml +++ b/.github/workflows/__export-file-baseline-information.yml @@ -97,7 +97,7 @@ jobs: with: output: '${{ runner.temp }}/results' - name: Upload SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: with-baseline-information-${{ matrix.os }}-${{ matrix.version }}.sarif.json path: '${{ runner.temp }}/results/javascript.sarif' diff --git a/.github/workflows/__job-run-uuid-sarif.yml b/.github/workflows/__job-run-uuid-sarif.yml index 429a69494..b24ab3900 100644 --- a/.github/workflows/__job-run-uuid-sarif.yml +++ b/.github/workflows/__job-run-uuid-sarif.yml @@ -62,7 +62,7 @@ jobs: with: output: '${{ runner.temp }}/results' - name: Upload SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: ${{ matrix.os }}-${{ matrix.version }}.sarif.json path: '${{ runner.temp }}/results/javascript.sarif' diff --git a/.github/workflows/__packaging-codescanning-config-inputs-js.yml b/.github/workflows/__packaging-codescanning-config-inputs-js.yml index 4cb0499d6..27139c831 100644 --- a/.github/workflows/__packaging-codescanning-config-inputs-js.yml +++ b/.github/workflows/__packaging-codescanning-config-inputs-js.yml @@ -80,7 +80,7 @@ jobs: go-version: ${{ inputs.go-version || '>=1.21.0' }} cache: false - name: Install Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 20.x cache: npm diff --git a/.github/workflows/__packaging-config-inputs-js.yml b/.github/workflows/__packaging-config-inputs-js.yml index ed049214e..9844c4348 100644 --- a/.github/workflows/__packaging-config-inputs-js.yml +++ b/.github/workflows/__packaging-config-inputs-js.yml @@ -80,7 +80,7 @@ jobs: go-version: ${{ inputs.go-version || '>=1.21.0' }} cache: false - name: Install Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 20.x cache: npm diff --git a/.github/workflows/__packaging-config-js.yml b/.github/workflows/__packaging-config-js.yml index 7cf99882b..916e89276 100644 --- a/.github/workflows/__packaging-config-js.yml +++ b/.github/workflows/__packaging-config-js.yml @@ -80,7 +80,7 @@ jobs: go-version: ${{ inputs.go-version || '>=1.21.0' }} cache: false - name: Install Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 20.x cache: npm diff --git a/.github/workflows/__packaging-inputs-js.yml b/.github/workflows/__packaging-inputs-js.yml index 6b488a7cf..01ddb5dc3 100644 --- a/.github/workflows/__packaging-inputs-js.yml +++ b/.github/workflows/__packaging-inputs-js.yml @@ -80,7 +80,7 @@ jobs: go-version: ${{ inputs.go-version || '>=1.21.0' }} cache: false - name: Install Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 20.x cache: npm diff --git a/.github/workflows/codescanning-config-cli.yml b/.github/workflows/codescanning-config-cli.yml index 54474d58f..782031948 100644 --- a/.github/workflows/codescanning-config-cli.yml +++ b/.github/workflows/codescanning-config-cli.yml @@ -57,7 +57,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 cache: 'npm' diff --git a/.github/workflows/debug-artifacts-failure-safe.yml b/.github/workflows/debug-artifacts-failure-safe.yml index 936fe6e95..c61bd6b17 100644 --- a/.github/workflows/debug-artifacts-failure-safe.yml +++ b/.github/workflows/debug-artifacts-failure-safe.yml @@ -89,7 +89,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Download all artifacts - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - name: Check expected artifacts exist run: | LANGUAGES="cpp csharp go java javascript python" diff --git a/.github/workflows/debug-artifacts-safe.yml b/.github/workflows/debug-artifacts-safe.yml index 8792aea32..6d162d9c0 100644 --- a/.github/workflows/debug-artifacts-safe.yml +++ b/.github/workflows/debug-artifacts-safe.yml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Download all artifacts - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - name: Check expected artifacts exist run: | VERSIONS="stable-v2.20.7 default linked nightly-latest" diff --git a/.github/workflows/post-release-mergeback.yml b/.github/workflows/post-release-mergeback.yml index c493c2a38..354da0afd 100644 --- a/.github/workflows/post-release-mergeback.yml +++ b/.github/workflows/post-release-mergeback.yml @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 # ensure we have all tags and can push commits - - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 cache: 'npm' diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 2ae059440..ccbe4a6d2 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -42,7 +42,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: ${{ matrix.node-version }} cache: "npm" @@ -110,7 +110,7 @@ jobs: fi - name: Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 cache: "npm" @@ -175,7 +175,7 @@ jobs: - name: Upload repo size comment if: steps.fetch-base.outcome == 'success' - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: repo-size-comment path: ${{ runner.temp }}/repo-size/ @@ -223,7 +223,7 @@ jobs: steps: - name: Download repo size comment - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: repo-size-comment path: repo-size-comment diff --git a/.github/workflows/query-filters.yml b/.github/workflows/query-filters.yml index 87b934eb6..1891f4195 100644 --- a/.github/workflows/query-filters.yml +++ b/.github/workflows/query-filters.yml @@ -33,7 +33,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Install Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 cache: npm diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index c9522bf9a..1c174ac7a 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -30,7 +30,7 @@ jobs: ref: ${{ env.HEAD_REF }} - name: Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 cache: 'npm' diff --git a/.github/workflows/update-bundle.yml b/.github/workflows/update-bundle.yml index d3ee924e5..43708f573 100644 --- a/.github/workflows/update-bundle.yml +++ b/.github/workflows/update-bundle.yml @@ -41,7 +41,7 @@ jobs: git config --global user.name "github-actions[bot]" - name: Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 cache: 'npm' diff --git a/.github/workflows/update-supported-enterprise-server-versions.yml b/.github/workflows/update-supported-enterprise-server-versions.yml index ee2649ad0..6510f11e2 100644 --- a/.github/workflows/update-supported-enterprise-server-versions.yml +++ b/.github/workflows/update-supported-enterprise-server-versions.yml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 cache: 'npm' diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ce2edd61..b63b79671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,14 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th ## [UNRELEASED] +No user facing changes. + +## 4.39.0 - 15 Oct 2026 + - _Breaking change_: Bump the minimum required CodeQL bundle version to 2.20.7. [#4205](https://github.com/github/codeql-action/pull/4205) +- The `codeql-action/analyze` step now validates that a correct argument for the `checkout_path` input has been provided. The `checkout_path` input must be set to the path where the repository that is being analyzed is checked out at on the runner, if that path is something other than the workspace root. If the path does not point to a repository checkout or is different from the path that was used by `codeql-action/init`, then the CodeQL Action now produces a warning. [#4148](https://github.com/github/codeql-action/pull/4148) +- Resolved an issue with third-party caching implementations that prevented caches from being restored correctly. [#4206](https://github.com/github/codeql-action/pull/4206) +- The `codeql-action/start-proxy` step that is used in Code Scanning Default Setup now finds CodeQL releases using the same logic as `codeql-action/init`. This primarily benefits customers who are using GitHub instances other than `github.com` where the `codeql-action/start-proxy` step may previously have been unable to locate recent releases and ended up using outdated versions of the private registry authentication proxy as a result. [#4198](https://github.com/github/codeql-action/pull/4198) ## 4.38.3 - 08 Oct 2026 diff --git a/lib/entry-points.js b/lib/entry-points.js index e66570e14..1ca7b7229 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -2384,9 +2384,9 @@ var require_dispatcher_base = __commonJS({ } close(callback) { if (callback === void 0) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { this.close((err, data) => { - return err ? reject(err) : resolve14(data); + return err ? reject(err) : resolve15(data); }); }); } @@ -2424,12 +2424,12 @@ var require_dispatcher_base = __commonJS({ err = null; } if (callback === void 0) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { this.destroy(err, (err2, data) => { return err2 ? ( /* istanbul ignore next: should never error */ reject(err2) - ) : resolve14(data); + ) : resolve15(data); }); }); } @@ -4696,8 +4696,8 @@ var require_util2 = __commonJS({ function createDeferredPromise() { let res; let rej; - const promise = new Promise((resolve14, reject) => { - res = resolve14; + const promise = new Promise((resolve15, reject) => { + res = resolve15; rej = reject; }); return { promise, resolve: res, reject: rej }; @@ -6943,12 +6943,12 @@ upgrade: ${upgrade}\r cb(); } } - const waitForDrain = () => new Promise((resolve14, reject) => { + const waitForDrain = () => new Promise((resolve15, reject) => { assert(callback === null); if (socket[kError]) { reject(socket[kError]); } else { - callback = resolve14; + callback = resolve15; } }); socket.on("close", onDrain).on("drain", onDrain); @@ -7585,12 +7585,12 @@ var require_client_h2 = __commonJS({ cb(); } } - const waitForDrain = () => new Promise((resolve14, reject) => { + const waitForDrain = () => new Promise((resolve15, reject) => { assert(callback === null); if (socket[kError]) { reject(socket[kError]); } else { - callback = resolve14; + callback = resolve15; } }); h2stream.on("close", onDrain).on("drain", onDrain); @@ -8068,16 +8068,16 @@ var require_client = __commonJS({ return this[kNeedDrain] < 2; } async [kClose]() { - return new Promise((resolve14) => { + return new Promise((resolve15) => { if (this[kSize]) { - this[kClosedResolve] = resolve14; + this[kClosedResolve] = resolve15; } else { - resolve14(null); + resolve15(null); } }); } async [kDestroy](err) { - return new Promise((resolve14) => { + return new Promise((resolve15) => { const requests = this[kQueue].splice(this[kPendingIdx]); for (let i = 0; i < requests.length; i++) { const request3 = requests[i]; @@ -8088,7 +8088,7 @@ var require_client = __commonJS({ this[kClosedResolve](); this[kClosedResolve] = null; } - resolve14(null); + resolve15(null); }; if (this[kHTTPContext]) { this[kHTTPContext].destroy(err, callback); @@ -8139,7 +8139,7 @@ var require_client = __commonJS({ }); } try { - const socket = await new Promise((resolve14, reject) => { + const socket = await new Promise((resolve15, reject) => { client[kConnector]({ host, hostname, @@ -8151,7 +8151,7 @@ var require_client = __commonJS({ if (err) { reject(err); } else { - resolve14(socket2); + resolve15(socket2); } }); }); @@ -8487,8 +8487,8 @@ var require_pool_base = __commonJS({ if (this[kQueue].isEmpty()) { await Promise.all(this[kClients].map((c) => c.close())); } else { - await new Promise((resolve14) => { - this[kClosedResolve] = resolve14; + await new Promise((resolve15) => { + this[kClosedResolve] = resolve15; }); } } @@ -9731,7 +9731,7 @@ var require_readable = __commonJS({ if (this._readableState.closeEmitted) { return null; } - return await new Promise((resolve14, reject) => { + return await new Promise((resolve15, reject) => { if (this[kContentLength] > limit) { this.destroy(new AbortError2()); } @@ -9744,7 +9744,7 @@ var require_readable = __commonJS({ if (signal?.aborted) { reject(signal.reason ?? new AbortError2()); } else { - resolve14(null); + resolve15(null); } }).on("error", noop3).on("data", function(chunk) { limit -= chunk.length; @@ -9763,7 +9763,7 @@ var require_readable = __commonJS({ } async function consume(stream2, type) { assert(!stream2[kConsume]); - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { if (isUnusable(stream2)) { const rState = stream2._readableState; if (rState.destroyed && rState.closeEmitted === false) { @@ -9780,7 +9780,7 @@ var require_readable = __commonJS({ stream2[kConsume] = { type, stream: stream2, - resolve: resolve14, + resolve: resolve15, reject, length: 0, body: [] @@ -9850,18 +9850,18 @@ var require_readable = __commonJS({ return buffer; } function consumeEnd(consume2) { - const { type, body, resolve: resolve14, stream: stream2, length } = consume2; + const { type, body, resolve: resolve15, stream: stream2, length } = consume2; try { if (type === "text") { - resolve14(chunksDecode(body, length)); + resolve15(chunksDecode(body, length)); } else if (type === "json") { - resolve14(JSON.parse(chunksDecode(body, length))); + resolve15(JSON.parse(chunksDecode(body, length))); } else if (type === "arrayBuffer") { - resolve14(chunksConcat(body, length).buffer); + resolve15(chunksConcat(body, length).buffer); } else if (type === "blob") { - resolve14(new Blob(body, { type: stream2[kContentType] })); + resolve15(new Blob(body, { type: stream2[kContentType] })); } else if (type === "bytes") { - resolve14(chunksConcat(body, length)); + resolve15(chunksConcat(body, length)); } consumeFinish(consume2); } catch (err) { @@ -10118,9 +10118,9 @@ var require_api_request = __commonJS({ }; function request3(opts, callback) { if (callback === void 0) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { request3.call(this, opts, (err, data) => { - return err ? reject(err) : resolve14(data); + return err ? reject(err) : resolve15(data); }); }); } @@ -10343,9 +10343,9 @@ var require_api_stream = __commonJS({ }; function stream2(opts, factory, callback) { if (callback === void 0) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { stream2.call(this, opts, factory, (err, data) => { - return err ? reject(err) : resolve14(data); + return err ? reject(err) : resolve15(data); }); }); } @@ -10630,9 +10630,9 @@ var require_api_upgrade = __commonJS({ }; function upgrade(opts, callback) { if (callback === void 0) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { upgrade.call(this, opts, (err, data) => { - return err ? reject(err) : resolve14(data); + return err ? reject(err) : resolve15(data); }); }); } @@ -10724,9 +10724,9 @@ var require_api_connect = __commonJS({ }; function connect(opts, callback) { if (callback === void 0) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { connect.call(this, opts, (err, data) => { - return err ? reject(err) : resolve14(data); + return err ? reject(err) : resolve15(data); }); }); } @@ -14588,7 +14588,7 @@ var require_fetch = __commonJS({ function dispatch({ body }) { const url2 = requestCurrentURL(request3); const agent = fetchParams.controller.dispatcher; - return new Promise((resolve14, reject) => agent.dispatch( + return new Promise((resolve15, reject) => agent.dispatch( { path: url2.pathname + url2.search, origin: url2.origin, @@ -14664,7 +14664,7 @@ var require_fetch = __commonJS({ } } const onError = this.onError.bind(this); - resolve14({ + resolve15({ status, statusText, headersList, @@ -14710,7 +14710,7 @@ var require_fetch = __commonJS({ for (let i = 0; i < rawHeaders.length; i += 2) { headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i]), rawHeaders[i + 1].toString("latin1"), true); } - resolve14({ + resolve15({ status, statusText: STATUS_CODES[status], headersList, @@ -18440,8 +18440,8 @@ var require_util8 = __commonJS({ return true; } function delay2(ms) { - return new Promise((resolve14) => { - setTimeout(resolve14, ms).unref(); + return new Promise((resolve15) => { + setTimeout(resolve15, ms).unref(); }); } module2.exports = { @@ -19164,11 +19164,11 @@ var require_lib = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -19184,7 +19184,7 @@ var require_lib = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -19271,26 +19271,26 @@ var require_lib = __commonJS({ } readBody() { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15) => __awaiter2(this, void 0, void 0, function* () { let output = Buffer.alloc(0); this.message.on("data", (chunk) => { output = Buffer.concat([output, chunk]); }); this.message.on("end", () => { - resolve14(output.toString()); + resolve15(output.toString()); }); })); }); } readBodyBuffer() { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15) => __awaiter2(this, void 0, void 0, function* () { const chunks = []; this.message.on("data", (chunk) => { chunks.push(chunk); }); this.message.on("end", () => { - resolve14(Buffer.concat(chunks)); + resolve15(Buffer.concat(chunks)); }); })); }); @@ -19498,14 +19498,14 @@ var require_lib = __commonJS({ */ requestRaw(info8, data) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { function callbackForResult(err, res) { if (err) { reject(err); } else if (!res) { reject(new Error("Unknown error")); } else { - resolve14(res); + resolve15(res); } } this.requestRawWithCallback(info8, data, callbackForResult); @@ -19749,12 +19749,12 @@ var require_lib = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise((resolve14) => setTimeout(() => resolve14(), ms)); + return new Promise((resolve15) => setTimeout(() => resolve15(), ms)); }); } _processResponse(res, options) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14, reject) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15, reject) => __awaiter2(this, void 0, void 0, function* () { const statusCode = res.message.statusCode || 0; const response = { statusCode, @@ -19762,7 +19762,7 @@ var require_lib = __commonJS({ headers: {} }; if (statusCode === HttpCodes.NotFound) { - resolve14(response); + resolve15(response); } function dateTimeDeserializer(key, value) { if (typeof value === "string") { @@ -19801,7 +19801,7 @@ var require_lib = __commonJS({ err.result = response.result; reject(err); } else { - resolve14(response); + resolve15(response); } })); }); @@ -19818,11 +19818,11 @@ var require_auth = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -19838,7 +19838,7 @@ var require_auth = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -19922,11 +19922,11 @@ var require_oidc_utils = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -19942,7 +19942,7 @@ var require_oidc_utils = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -20020,11 +20020,11 @@ var require_summary = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -20040,7 +20040,7 @@ var require_summary = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -20409,11 +20409,11 @@ var require_io_util = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -20429,7 +20429,7 @@ var require_io_util = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -20606,11 +20606,11 @@ var require_io = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -20626,7 +20626,7 @@ var require_io = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -20867,11 +20867,11 @@ var require_toolrunner = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -20887,7 +20887,7 @@ var require_toolrunner = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -21116,7 +21116,7 @@ var require_toolrunner = __commonJS({ this.toolPath = path30.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); } this.toolPath = yield io9.which(this.toolPath, true); - return new Promise((resolve14, reject) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15, reject) => __awaiter2(this, void 0, void 0, function* () { this._debug(`exec tool: ${this.toolPath}`); this._debug("arguments:"); for (const arg of this.args) { @@ -21199,7 +21199,7 @@ var require_toolrunner = __commonJS({ if (error3) { reject(error3); } else { - resolve14(exitCode); + resolve15(exitCode); } }); if (this.options.input) { @@ -21365,11 +21365,11 @@ var require_exec = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -21385,7 +21385,7 @@ var require_exec = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -21485,11 +21485,11 @@ var require_platform = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -21505,7 +21505,7 @@ var require_platform = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -21614,11 +21614,11 @@ var require_core = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -21634,7 +21634,7 @@ var require_core = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -21912,11 +21912,11 @@ var require_utils3 = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -21932,7 +21932,7 @@ var require_utils3 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -28929,8 +28929,8 @@ var require_light = __commonJS({ return this.Promise.resolve(); } yieldLoop(t = 0) { - return new this.Promise(function(resolve14, reject) { - return setTimeout(resolve14, t); + return new this.Promise(function(resolve15, reject) { + return setTimeout(resolve15, t); }); } computePenalty() { @@ -29141,15 +29141,15 @@ var require_light = __commonJS({ return this._queue.length === 0; } async _tryToRun() { - var args, cb, error3, reject, resolve14, returned, task; + var args, cb, error3, reject, resolve15, returned, task; if (this._running < 1 && this._queue.length > 0) { this._running++; - ({ task, args, resolve: resolve14, reject } = this._queue.shift()); + ({ task, args, resolve: resolve15, reject } = this._queue.shift()); cb = await (async function() { try { returned = await task(...args); return function() { - return resolve14(returned); + return resolve15(returned); }; } catch (error1) { error3 = error1; @@ -29164,13 +29164,13 @@ var require_light = __commonJS({ } } schedule(task, ...args) { - var promise, reject, resolve14; - resolve14 = reject = null; + var promise, reject, resolve15; + resolve15 = reject = null; promise = new this.Promise(function(_resolve, _reject) { - resolve14 = _resolve; + resolve15 = _resolve; return reject = _reject; }); - this._queue.push({ task, args, resolve: resolve14, reject }); + this._queue.push({ task, args, resolve: resolve15, reject }); this._tryToRun(); return promise; } @@ -29571,14 +29571,14 @@ var require_light = __commonJS({ counts = this._states.counts; return counts[0] + counts[1] + counts[2] + counts[3] === at; }; - return new this.Promise((resolve14, reject) => { + return new this.Promise((resolve15, reject) => { if (finished()) { - return resolve14(); + return resolve15(); } else { return this.on("done", () => { if (finished()) { this.removeAllListeners("done"); - return resolve14(); + return resolve15(); } }); } @@ -29671,9 +29671,9 @@ var require_light = __commonJS({ options = parser$5.load(options, this.jobDefaults); } task = (...args2) => { - return new this.Promise(function(resolve14, reject) { + return new this.Promise(function(resolve15, reject) { return fn(...args2, function(...args3) { - return (args3[0] != null ? reject : resolve14)(args3); + return (args3[0] != null ? reject : resolve15)(args3); }); }); }; @@ -29913,7 +29913,7 @@ var require_helpers = __commonJS({ this.base = base; this.schemas = schemas; }; - SchemaContext.prototype.resolve = function resolve14(target) { + SchemaContext.prototype.resolve = function resolve15(target) { return (() => resolveUrl(this.base, target))(); }; SchemaContext.prototype.makeChild = function makeChild(schema, propertyName) { @@ -31018,7 +31018,7 @@ var require_validator = __commonJS({ } return schema; }; - Validator3.prototype.resolve = function resolve14(schema, switchSchema, ctx) { + Validator3.prototype.resolve = function resolve15(schema, switchSchema, ctx) { switchSchema = ctx.resolve(switchSchema); if (ctx.schemas[switchSchema]) { return { subschema: ctx.schemas[switchSchema], switchSchema }; @@ -32974,11 +32974,11 @@ var require_internal_globber = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -32994,7 +32994,7 @@ var require_internal_globber = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -33007,14 +33007,14 @@ var require_internal_globber = __commonJS({ }, i); function verb(n) { i[n] = o[n] && function(v) { - return new Promise(function(resolve14, reject) { - v = o[n](v), settle(resolve14, reject, v.done, v.value); + return new Promise(function(resolve15, reject) { + v = o[n](v), settle(resolve15, reject, v.done, v.value); }); }; } - function settle(resolve14, reject, d, v) { + function settle(resolve15, reject, d, v) { Promise.resolve(v).then(function(v2) { - resolve14({ value: v2, done: d }); + resolve15({ value: v2, done: d }); }, reject); } }; @@ -33264,11 +33264,11 @@ var require_internal_hash_files = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -33284,7 +33284,7 @@ var require_internal_hash_files = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -33297,14 +33297,14 @@ var require_internal_hash_files = __commonJS({ }, i); function verb(n) { i[n] = o[n] && function(v) { - return new Promise(function(resolve14, reject) { - v = o[n](v), settle(resolve14, reject, v.done, v.value); + return new Promise(function(resolve15, reject) { + v = o[n](v), settle(resolve15, reject, v.done, v.value); }); }; } - function settle(resolve14, reject, d, v) { + function settle(resolve15, reject, d, v) { Promise.resolve(v).then(function(v2) { - resolve14({ value: v2, done: d }); + resolve15({ value: v2, done: d }); }, reject); } }; @@ -33376,11 +33376,11 @@ var require_glob = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -33396,7 +33396,7 @@ var require_glob = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -34657,11 +34657,11 @@ var require_cacheUtils = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -34677,7 +34677,7 @@ var require_cacheUtils = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -34690,14 +34690,14 @@ var require_cacheUtils = __commonJS({ }, i); function verb(n) { i[n] = o[n] && function(v) { - return new Promise(function(resolve14, reject) { - v = o[n](v), settle(resolve14, reject, v.done, v.value); + return new Promise(function(resolve15, reject) { + v = o[n](v), settle(resolve15, reject, v.done, v.value); }); }; } - function settle(resolve14, reject, d, v) { + function settle(resolve15, reject, d, v) { Promise.resolve(v).then(function(v2) { - resolve14({ value: v2, done: d }); + resolve15({ value: v2, done: d }); }, reject); } }; @@ -36241,9 +36241,9 @@ var require_nodeHttpClient = __commonJS({ if (stream2.readable === false) { return Promise.resolve(); } - return new Promise((resolve14) => { + return new Promise((resolve15) => { const handler2 = () => { - resolve14(); + resolve15(); stream2.removeListener("close", handler2); stream2.removeListener("end", handler2); stream2.removeListener("error", handler2); @@ -36398,8 +36398,8 @@ var require_nodeHttpClient = __commonJS({ headers: request3.headers.toJSON({ preserveCase: true }), ...request3.requestOverrides }; - return new Promise((resolve14, reject) => { - const req = isInsecure ? import_node_http.default.request(options, resolve14) : import_node_https.default.request(options, resolve14); + return new Promise((resolve15, reject) => { + const req = isInsecure ? import_node_http.default.request(options, resolve15) : import_node_https.default.request(options, resolve15); req.once("error", (err) => { reject( new import_restError.RestError(err.message, { code: err.code ?? import_restError.RestError.REQUEST_SEND_ERROR, request: request3 }) @@ -36489,7 +36489,7 @@ var require_nodeHttpClient = __commonJS({ return stream2; } function streamToText(stream2) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const buffer = []; stream2.on("data", (chunk) => { if (Buffer.isBuffer(chunk)) { @@ -36499,7 +36499,7 @@ var require_nodeHttpClient = __commonJS({ } }); stream2.on("end", () => { - resolve14(Buffer.concat(buffer).toString("utf8")); + resolve15(Buffer.concat(buffer).toString("utf8")); }); stream2.on("error", (e) => { if (e && e?.name === "AbortError") { @@ -36899,7 +36899,7 @@ var require_helpers2 = __commonJS({ var import_AbortError = require_AbortError(); var StandardAbortMessage = "The operation was aborted."; function delay2(delayInMs, value, options) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { let timer = void 0; let onAborted = void 0; const rejectOnAbort = () => { @@ -36924,7 +36924,7 @@ var require_helpers2 = __commonJS({ } timer = setTimeout(() => { removeListeners(); - resolve14(value); + resolve15(value); }, delayInMs); if (options?.abortSignal) { options.abortSignal.addEventListener("abort", onAborted); @@ -38300,8 +38300,8 @@ var require_helpers3 = __commonJS({ function req(url2, opts = {}) { const href = typeof url2 === "string" ? url2 : url2.href; const req2 = (href.startsWith("https:") ? https3 : http).request(url2, opts); - const promise = new Promise((resolve14, reject) => { - req2.once("response", resolve14).once("error", reject).end(); + const promise = new Promise((resolve15, reject) => { + req2.once("response", resolve15).once("error", reject).end(); }); req2.then = promise.then.bind(promise); return req2; @@ -38478,7 +38478,7 @@ var require_parse_proxy_response = __commonJS({ var debug_1 = __importDefault2(require_src()); var debug6 = (0, debug_1.default)("https-proxy-agent:parse-proxy-response"); function parseProxyResponse(socket) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { let buffersLength = 0; const buffers = []; function read() { @@ -38544,7 +38544,7 @@ var require_parse_proxy_response = __commonJS({ } debug6("got proxy server response: %o %o", firstLine, headers); cleanup(); - resolve14({ + resolve15({ connect: { statusCode, statusText, @@ -41806,11 +41806,11 @@ function __metadata(metadataKey, metadataValue) { } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -41826,7 +41826,7 @@ function __awaiter(thisArg, _arguments, P, generator) { } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -42017,14 +42017,14 @@ function __asyncValues(o) { }, i); function verb(n) { i[n] = o[n] && function(v) { - return new Promise(function(resolve14, reject) { - v = o[n](v), settle(resolve14, reject, v.done, v.value); + return new Promise(function(resolve15, reject) { + v = o[n](v), settle(resolve15, reject, v.done, v.value); }); }; } - function settle(resolve14, reject, d, v) { + function settle(resolve15, reject, d, v) { Promise.resolve(v).then(function(v2) { - resolve14({ value: v2, done: d }); + resolve15({ value: v2, done: d }); }, reject); } } @@ -42362,7 +42362,7 @@ var require_createAbortablePromise = __commonJS({ var abort_controller_1 = require_commonjs3(); function createAbortablePromise(buildPromise, options) { const { cleanupBeforeAbort, abortSignal, abortErrorMsg } = options ?? {}; - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { function rejectOnAbort() { reject(new abort_controller_1.AbortError(abortErrorMsg ?? "The operation was aborted.")); } @@ -42380,7 +42380,7 @@ var require_createAbortablePromise = __commonJS({ try { buildPromise((x) => { removeListeners(); - resolve14(x); + resolve15(x); }, (x) => { removeListeners(); reject(x); @@ -42407,8 +42407,8 @@ var require_delay2 = __commonJS({ function delay2(timeInMs, options) { let token; const { abortSignal, abortErrorMsg } = options ?? {}; - return (0, createAbortablePromise_js_1.createAbortablePromise)((resolve14) => { - token = setTimeout(resolve14, timeInMs); + return (0, createAbortablePromise_js_1.createAbortablePromise)((resolve15) => { + token = setTimeout(resolve15, timeInMs); }, { cleanupBeforeAbort: () => clearTimeout(token), abortSignal, @@ -42967,11 +42967,11 @@ var require_tracingPolicy = __commonJS({ var import_log = require_log3(); var import_core_util = require_commonjs4(); var import_restError = require_restError3(); - var import_util58 = require_internal3(); + var import_util59 = require_internal3(); var tracingPolicyName2 = "tracingPolicy"; function tracingPolicy2(options = {}) { const userAgentPromise = (0, import_userAgent.getUserAgentValue)(options.userAgentPrefix); - const sanitizer = new import_util58.Sanitizer({ + const sanitizer = new import_util59.Sanitizer({ additionalAllowedQueryParameters: options.additionalAllowedQueryParameters }); const tracingClient = tryCreateTracingClient(); @@ -46597,11 +46597,11 @@ var require_response2 = __commonJS({ }); module2.exports = __toCommonJS2(response_exports); var import_core_rest_pipeline = require_commonjs6(); - var import_util58 = require_util9(); + var import_util59 = require_util9(); var originalResponse = /* @__PURE__ */ Symbol("Original FullOperationResponse"); function toCompatResponse2(response, options) { - let request3 = (0, import_util58.toWebResourceLike)(response.request); - let headers = (0, import_util58.toHttpHeadersLike)(response.headers); + let request3 = (0, import_util59.toWebResourceLike)(response.request); + let headers = (0, import_util59.toHttpHeadersLike)(response.headers); if (options?.createProxy) { return new Proxy(response, { get(target, prop, receiver) { @@ -46642,7 +46642,7 @@ var require_response2 = __commonJS({ return { ...compatResponse, headers, - request: (0, import_util58.toPipelineRequest)(compatResponse.request) + request: (0, import_util59.toPipelineRequest)(compatResponse.request) }; } } @@ -46749,7 +46749,7 @@ var require_requestPolicyFactoryPolicy = __commonJS({ requestPolicyFactoryPolicyName: () => requestPolicyFactoryPolicyName2 }); module2.exports = __toCommonJS2(requestPolicyFactoryPolicy_exports); - var import_util58 = require_util9(); + var import_util59 = require_util9(); var import_response = require_response2(); var HttpPipelineLogLevel2 = /* @__PURE__ */ ((HttpPipelineLogLevel22) => { HttpPipelineLogLevel22[HttpPipelineLogLevel22["ERROR"] = 1] = "ERROR"; @@ -46773,14 +46773,14 @@ var require_requestPolicyFactoryPolicy = __commonJS({ async sendRequest(request3, next) { let httpPipeline = { async sendRequest(httpRequest) { - const response2 = await next((0, import_util58.toPipelineRequest)(httpRequest)); + const response2 = await next((0, import_util59.toPipelineRequest)(httpRequest)); return (0, import_response.toCompatResponse)(response2, { createProxy: true }); } }; for (const factory of orderedFactories) { httpPipeline = factory.create(httpPipeline, mockRequestPolicyOptions); } - const webResourceLike = (0, import_util58.toWebResourceLike)(request3, { createProxy: true }); + const webResourceLike = (0, import_util59.toWebResourceLike)(request3, { createProxy: true }); const response = await httpPipeline.sendRequest(webResourceLike); return (0, import_response.toPipelineResponse)(response); } @@ -46815,12 +46815,12 @@ var require_httpClientAdapter = __commonJS({ }); module2.exports = __toCommonJS2(httpClientAdapter_exports); var import_response = require_response2(); - var import_util58 = require_util9(); + var import_util59 = require_util9(); function convertHttpClient2(requestPolicyClient) { return { sendRequest: async (request3) => { const response = await requestPolicyClient.sendRequest( - (0, import_util58.toWebResourceLike)(request3, { createProxy: true }) + (0, import_util59.toWebResourceLike)(request3, { createProxy: true }) ); return (0, import_response.toPipelineResponse)(response); } @@ -46858,7 +46858,7 @@ var require_commonjs9 = __commonJS({ disableKeepAlivePolicyName: () => import_disableKeepAlivePolicy.disableKeepAlivePolicyName, requestPolicyFactoryPolicyName: () => import_requestPolicyFactoryPolicy.requestPolicyFactoryPolicyName, toCompatResponse: () => import_response.toCompatResponse, - toHttpHeadersLike: () => import_util58.toHttpHeadersLike + toHttpHeadersLike: () => import_util59.toHttpHeadersLike }); module2.exports = __toCommonJS2(src_exports); var import_extendedClient = require_extendedClient(); @@ -46866,7 +46866,7 @@ var require_commonjs9 = __commonJS({ var import_requestPolicyFactoryPolicy = require_requestPolicyFactoryPolicy(); var import_disableKeepAlivePolicy = require_disableKeepAlivePolicy(); var import_httpClientAdapter = require_httpClientAdapter(); - var import_util58 = require_util9(); + var import_util59 = require_util9(); } }); @@ -48872,7 +48872,7 @@ var require_BufferScheduler = __commonJS({ * */ async do() { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { this.readable.on("data", (data) => { data = typeof data === "string" ? Buffer.from(data, this.encoding) : data; this.appendUnresolvedData(data); @@ -48900,11 +48900,11 @@ var require_BufferScheduler = __commonJS({ if (this.isStreamEnd && this.executingOutgoingHandlers === 0) { if (this.unresolvedLength > 0 && this.unresolvedLength < this.bufferSize) { const buffer = this.shiftBufferFromUnresolvedDataArray(); - this.outgoingHandler(() => buffer.getReadableStream(), buffer.size, this.offset).then(resolve14).catch(reject); + this.outgoingHandler(() => buffer.getReadableStream(), buffer.size, this.offset).then(resolve15).catch(reject); } else if (this.unresolvedLength >= this.bufferSize) { return; } else { - resolve14(); + resolve15(); } } }); @@ -49170,8 +49170,8 @@ var require_crc64 = __commonJS({ NativeCRC642 = NativeCRC642 || {}; var Module = typeof NativeCRC642 != "undefined" ? NativeCRC642 : {}; var readyPromiseResolve, readyPromiseReject; - Module["ready"] = new Promise(function(resolve14, reject) { - readyPromiseResolve = resolve14; + Module["ready"] = new Promise(function(resolve15, reject) { + readyPromiseResolve = resolve15; readyPromiseReject = reject; }); ["_malloc", "_free", "_emscripten_bind_VoidPtr___destroy___0", "_emscripten_bind_Crc64Hash_Crc64Hash_0", "_emscripten_bind_Crc64Hash_OnAppend_2", "_emscripten_bind_Crc64Hash_OnFinal_3", "_emscripten_bind_Crc64Hash___destroy___0", "_fflush", "onRuntimeInitialized"].forEach((prop) => { @@ -52883,7 +52883,7 @@ var require_utils_common = __commonJS({ return (0, import_core_util.uint8ArrayToString)((0, import_core_util.stringToUint8Array)(res, "utf-8"), "base64"); } async function delay2(timeInMs, aborter, abortError) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { let timeout; const abortHandler = () => { if (timeout !== void 0) { @@ -52895,7 +52895,7 @@ var require_utils_common = __commonJS({ if (aborter !== void 0) { aborter.removeEventListener("abort", abortHandler); } - resolve14(); + resolve15(); }; timeout = setTimeout(resolveHandler, timeInMs); if (aborter !== void 0) { @@ -70310,7 +70310,7 @@ var require_utils_common2 = __commonJS({ return base64encode(res); } async function delay2(timeInMs, aborter, abortError) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { let timeout; const abortHandler = () => { if (timeout !== void 0) { @@ -70322,7 +70322,7 @@ var require_utils_common2 = __commonJS({ if (aborter !== void 0) { aborter.removeEventListener("abort", abortHandler); } - resolve14(); + resolve15(); }; timeout = setTimeout(resolveHandler, timeInMs); if (aborter !== void 0) { @@ -70626,7 +70626,7 @@ var require_utils_common2 = __commonJS({ throw new RangeError("List Blobs response body is empty or unavailable."); } function readNodeStreamToBytes(stream2) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const chunks = []; let totalLength = 0; stream2.on("data", (chunk) => { @@ -70641,7 +70641,7 @@ var require_utils_common2 = __commonJS({ result.set(chunk, offset); offset += chunk.byteLength; } - resolve14(result); + resolve15(result); }); stream2.on("error", reject); }); @@ -71236,7 +71236,7 @@ function fromNodeStream(stream2) { return yield __await(null); function cleanup(events2, err2) { buffer = buffers = null; - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { for (const [evt, fn] of events2) { stream2["off"](evt, fn); } @@ -71247,7 +71247,7 @@ function fromNodeStream(stream2) { } catch (e) { err2 = e || err2; } finally { - err2 != null ? reject(err2) : resolve14(); + err2 != null ? reject(err2) : resolve15(); } }); } @@ -71322,9 +71322,9 @@ var init_adapters = __esm({ } }; onEvent = (stream2, event) => { - const handler2 = (_2) => resolve14([event, _2]); - let resolve14; - return [event, handler2, new Promise((r) => (resolve14 = r) && stream2["once"](event, handler2))]; + const handler2 = (_2) => resolve15([event, _2]); + let resolve15; + return [event, handler2, new Promise((r) => (resolve15 = r) && stream2["once"](event, handler2))]; }; } }); @@ -79953,8 +79953,8 @@ var init_interfaces = __esm({ } else if (!this._closedPromiseResolve) { return Promise.resolve(ITERATOR_DONE); } else { - return new Promise((resolve14, reject) => { - this.resolvers.push({ resolve: resolve14, reject }); + return new Promise((resolve15, reject) => { + this.resolvers.push({ resolve: resolve15, reject }); }); } } @@ -89626,7 +89626,7 @@ var require_AvroReadableFromStream = __commonJS({ this._position += chunk.length; return this.toUint8Array(chunk); } else { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const cleanUp = () => { this._readable.removeListener("readable", readableCallback); this._readable.removeListener("error", rejectCallback); @@ -89641,7 +89641,7 @@ var require_AvroReadableFromStream = __commonJS({ if (callbackChunk) { this._position += callbackChunk.length; cleanUp(); - resolve14(this.toUint8Array(callbackChunk)); + resolve15(this.toUint8Array(callbackChunk)); } }; const rejectCallback = () => { @@ -91211,8 +91211,8 @@ var require_poller3 = __commonJS({ this.stopped = true; this.pollProgressCallbacks = []; this.operation = operation; - this.promise = new Promise((resolve14, reject) => { - this.resolve = resolve14; + this.promise = new Promise((resolve15, reject) => { + this.resolve = resolve15; this.reject = reject; }); this.promise.catch(() => { @@ -91465,7 +91465,7 @@ var require_lroEngine = __commonJS({ * The method used by the poller to wait before attempting to update its operation. */ delay() { - return new Promise((resolve14) => setTimeout(() => resolve14(), this.config.intervalInMs)); + return new Promise((resolve15) => setTimeout(() => resolve15(), this.config.intervalInMs)); } }; exports2.LroEngine = LroEngine; @@ -91773,8 +91773,8 @@ var require_Batch = __commonJS({ return Promise.resolve(); } this.parallelExecute(); - return new Promise((resolve14, reject) => { - this.emitter.on("finish", resolve14); + return new Promise((resolve15, reject) => { + this.emitter.on("finish", resolve15); this.emitter.on("error", (error3) => { this.state = 1; reject(error3); @@ -91863,7 +91863,7 @@ var require_utils7 = __commonJS({ async function streamToBuffer(stream2, buffer, offset, end, encoding) { let pos = 0; const count = end - offset; - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const timeout = setTimeout( () => reject(new Error(`The operation cannot be completed in timeout.`)), import_constants5.REQUEST_TIMEOUT @@ -91871,7 +91871,7 @@ var require_utils7 = __commonJS({ stream2.on("readable", () => { if (pos >= count) { clearTimeout(timeout); - resolve14(); + resolve15(); return; } let chunk; @@ -91884,7 +91884,7 @@ var require_utils7 = __commonJS({ pos += chunkLength2; if (pos >= count) { clearTimeout(timeout); - resolve14(); + resolve15(); return; } } @@ -91898,7 +91898,7 @@ var require_utils7 = __commonJS({ ) ); } - resolve14(); + resolve15(); }); stream2.on("error", (msg) => { clearTimeout(timeout); @@ -91909,7 +91909,7 @@ var require_utils7 = __commonJS({ async function streamToBuffer2(stream2, buffer, encoding) { let pos = 0; const bufferSize = buffer.length; - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { stream2.on("readable", () => { let chunk; while ((chunk = stream2.read()) !== null) { @@ -91925,25 +91925,25 @@ var require_utils7 = __commonJS({ } }); stream2.on("end", () => { - resolve14(pos); + resolve15(pos); }); stream2.on("error", reject); }); } async function streamToBuffer3(readableStream, encoding) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const chunks = []; readableStream.on("data", (data) => { chunks.push(typeof data === "string" ? Buffer.from(data, encoding) : data); }); readableStream.on("end", () => { - resolve14(Buffer.concat(chunks)); + resolve15(Buffer.concat(chunks)); }); readableStream.on("error", reject); }); } async function readStreamToLocalFile(rs, file) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const ws = import_node_fs.default.createWriteStream(file); rs.on("error", (err) => { reject(err); @@ -91951,7 +91951,7 @@ var require_utils7 = __commonJS({ ws.on("error", (err) => { reject(err); }); - ws.on("close", resolve14); + ws.on("close", resolve15); rs.pipe(ws); }); } @@ -93011,7 +93011,7 @@ var require_Clients = __commonJS({ * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateSasUrl(options) { - return new Promise((resolve14) => { + return new Promise((resolve15) => { if (!(this.credential instanceof import_storage_common.StorageSharedKeyCredential)) { throw new RangeError( "Can only generate the SAS when the client is initialized with a shared key credential" @@ -93027,7 +93027,7 @@ var require_Clients = __commonJS({ }, this.credential ).toString(); - resolve14((0, import_utils_common.appendToURLQuery)(this.url, sas)); + resolve15((0, import_utils_common.appendToURLQuery)(this.url, sas)); }); } /** @@ -93071,7 +93071,7 @@ var require_Clients = __commonJS({ * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateUserDelegationSasUrl(options, userDelegationKey) { - return new Promise((resolve14) => { + return new Promise((resolve15) => { const sas = (0, import_BlobSASSignatureValues.generateBlobSASQueryParameters)( { containerName: this._containerName, @@ -93083,7 +93083,7 @@ var require_Clients = __commonJS({ userDelegationKey, this.accountName ).toString(); - resolve14((0, import_utils_common.appendToURLQuery)(this.url, sas)); + resolve15((0, import_utils_common.appendToURLQuery)(this.url, sas)); }); } /** @@ -95320,14 +95320,14 @@ var require_Mutex = __commonJS({ * @param key - lock key */ static async lock(key) { - return new Promise((resolve14) => { + return new Promise((resolve15) => { if (this.keys[key] === void 0 || this.keys[key] === 1) { this.keys[key] = 0; - resolve14(); + resolve15(); } else { this.onUnlockEvent(key, () => { this.keys[key] = 0; - resolve14(); + resolve15(); }); } }); @@ -95338,12 +95338,12 @@ var require_Mutex = __commonJS({ * @param key - */ static async unlock(key) { - return new Promise((resolve14) => { + return new Promise((resolve15) => { if (this.keys[key] === 0) { this.emitUnlockEvent(key); } delete this.keys[key]; - resolve14(); + resolve15(); }); } static keys = {}; @@ -97325,7 +97325,7 @@ var require_ContainerClient = __commonJS({ * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateSasUrl(options) { - return new Promise((resolve14) => { + return new Promise((resolve15) => { if (!(this.credential instanceof import_storage_common.StorageSharedKeyCredential)) { throw new RangeError( "Can only generate the SAS when the client is initialized with a shared key credential" @@ -97338,7 +97338,7 @@ var require_ContainerClient = __commonJS({ }, this.credential ).toString(); - resolve14((0, import_utils_common.appendToURLQuery)(this.url, sas)); + resolve15((0, import_utils_common.appendToURLQuery)(this.url, sas)); }); } /** @@ -97378,7 +97378,7 @@ var require_ContainerClient = __commonJS({ * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token. */ generateUserDelegationSasUrl(options, userDelegationKey) { - return new Promise((resolve14) => { + return new Promise((resolve15) => { const sas = (0, import_BlobSASSignatureValues.generateBlobSASQueryParameters)( { containerName: this._containerName, @@ -97387,7 +97387,7 @@ var require_ContainerClient = __commonJS({ userDelegationKey, this.accountName ).toString(); - resolve14((0, import_utils_common.appendToURLQuery)(this.url, sas)); + resolve15((0, import_utils_common.appendToURLQuery)(this.url, sas)); }); } /** @@ -99008,11 +99008,11 @@ var require_uploadUtils = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -99028,7 +99028,7 @@ var require_uploadUtils = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -99195,11 +99195,11 @@ var require_requestUtils = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -99215,7 +99215,7 @@ var require_requestUtils = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -99255,7 +99255,7 @@ var require_requestUtils = __commonJS({ } function sleep(milliseconds) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => setTimeout(resolve14, milliseconds)); + return new Promise((resolve15) => setTimeout(resolve15, milliseconds)); }); } function retry2(name_1, method_1, getStatusCode_1) { @@ -99516,11 +99516,11 @@ var require_downloadUtils = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -99536,7 +99536,7 @@ var require_downloadUtils = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -99832,8 +99832,8 @@ var require_downloadUtils = __commonJS({ } var promiseWithTimeout = (timeoutMs, promise) => __awaiter2(void 0, void 0, void 0, function* () { let timeoutHandle; - const timeoutPromise = new Promise((resolve14) => { - timeoutHandle = setTimeout(() => resolve14("timeout"), timeoutMs); + const timeoutPromise = new Promise((resolve15) => { + timeoutHandle = setTimeout(() => resolve15("timeout"), timeoutMs); }); return Promise.race([promise, timeoutPromise]).then((result) => { clearTimeout(timeoutHandle); @@ -100013,7 +100013,7 @@ var require_package = __commonJS({ "node_modules/@actions/cache/package.json"(exports2, module2) { module2.exports = { name: "@actions/cache", - version: "5.2.0", + version: "5.3.0", preview: true, description: "Actions cache lib", keywords: [ @@ -100050,22 +100050,22 @@ var require_package = __commonJS({ url: "https://github.com/actions/toolkit/issues" }, dependencies: { - "@actions/core": "^2.0.0", + "@actions/core": "^2.0.3", "@actions/exec": "^2.0.0", "@actions/glob": "^0.5.1", - "@protobuf-ts/runtime-rpc": "^2.11.1", "@actions/http-client": "^3.0.2", "@actions/io": "^2.0.0", "@azure/abort-controller": "^1.1.0", - "@azure/core-rest-pipeline": "^1.22.0", - "@azure/storage-blob": "^12.29.1", + "@azure/core-rest-pipeline": "^1.25.0", + "@azure/storage-blob": "^12.34.0", + "@protobuf-ts/runtime-rpc": "^2.11.1", semver: "^6.3.1" }, devDependencies: { - "@types/node": "^24.1.0", - "@types/semver": "^6.0.0", - "@protobuf-ts/plugin": "^2.9.4", - typescript: "^5.2.2" + "@protobuf-ts/plugin": "^2.11.1", + "@types/node": "^24.13.6", + "@types/semver": "^6.2.7", + typescript: "^5.9.3" }, overrides: { "uri-js": "npm:uri-js-replace@^1.0.1", @@ -100131,11 +100131,11 @@ var require_cacheHttpClient = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -100151,7 +100151,7 @@ var require_cacheHttpClient = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -103627,8 +103627,8 @@ var require_deferred = __commonJS({ */ constructor(preventUnhandledRejectionWarning = true) { this._state = DeferredState.PENDING; - this._promise = new Promise((resolve14, reject) => { - this._resolve = resolve14; + this._promise = new Promise((resolve15, reject) => { + this._resolve = resolve15; this._reject = reject; }); if (preventUnhandledRejectionWarning) { @@ -103843,11 +103843,11 @@ var require_unary_call = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -103863,7 +103863,7 @@ var require_unary_call = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -103912,11 +103912,11 @@ var require_server_streaming_call = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -103932,7 +103932,7 @@ var require_server_streaming_call = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -103982,11 +103982,11 @@ var require_client_streaming_call = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -104002,7 +104002,7 @@ var require_client_streaming_call = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -104051,11 +104051,11 @@ var require_duplex_streaming_call = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -104071,7 +104071,7 @@ var require_duplex_streaming_call = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -104119,11 +104119,11 @@ var require_test_transport = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -104139,7 +104139,7 @@ var require_test_transport = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -104336,11 +104336,11 @@ var require_test_transport = __commonJS({ responseTrailer: "test" }; function delay2(ms, abort) { - return (v) => new Promise((resolve14, reject) => { + return (v) => new Promise((resolve15, reject) => { if (abort === null || abort === void 0 ? void 0 : abort.aborted) { reject(new rpc_error_1.RpcError("user cancel", "CANCELLED")); } else { - const id = setTimeout(() => resolve14(v), ms); + const id = setTimeout(() => resolve15(v), ms); if (abort) { abort.addEventListener("abort", (ev) => { clearTimeout(id); @@ -105338,11 +105338,11 @@ var require_cacheTwirpClient = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -105358,7 +105358,7 @@ var require_cacheTwirpClient = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -105498,7 +105498,7 @@ var require_cacheTwirpClient = __commonJS({ } sleep(milliseconds) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => setTimeout(resolve14, milliseconds)); + return new Promise((resolve15) => setTimeout(resolve15, milliseconds)); }); } getExponentialRetryTimeMilliseconds(attempt) { @@ -105563,11 +105563,11 @@ var require_tar = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -105583,7 +105583,7 @@ var require_tar = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -105592,6 +105592,7 @@ var require_tar = __commonJS({ exports2.listTar = listTar; exports2.extractTar = extractTar3; exports2.createTar = createTar; + var core29 = __importStar2(require_core()); var exec_1 = require_exec(); var io9 = __importStar2(require_io()); var fs_1 = require("fs"); @@ -105644,7 +105645,7 @@ var require_tar = __commonJS({ args.push("--posix", "-cf", BSD_TAR_ZSTD ? tarFile : cacheFileName.replace(new RegExp(`\\${path30.sep}`, "g"), "/"), "--exclude", BSD_TAR_ZSTD ? tarFile : cacheFileName.replace(new RegExp(`\\${path30.sep}`, "g"), "/"), "-P", "-C", workingDirectory.replace(new RegExp(`\\${path30.sep}`, "g"), "/"), "--files-from", constants_1.ManifestFilename); break; case "extract": - args.push("-xf", BSD_TAR_ZSTD ? tarFile : archivePath.replace(new RegExp(`\\${path30.sep}`, "g"), "/"), "-P", "-C", workingDirectory.replace(new RegExp(`\\${path30.sep}`, "g"), "/")); + args.push("-xf", BSD_TAR_ZSTD ? tarFile : archivePath.replace(new RegExp(`\\${path30.sep}`, "g"), "/"), "-P", "-C", BSD_TAR_ZSTD ? quoteAbsolutePath(workingDirectory) : workingDirectory.replace(new RegExp(`\\${path30.sep}`, "g"), "/")); break; case "list": args.push("-tf", BSD_TAR_ZSTD ? tarFile : archivePath.replace(new RegExp(`\\${path30.sep}`, "g"), "/"), "-P"); @@ -105675,16 +105676,19 @@ var require_tar = __commonJS({ } else { args = [[...tarArgs].join(" "), [...compressionArgs].join(" ")]; } - if (BSD_TAR_ZSTD) { - return args; - } - return [args.join(" ")]; + return { + commands: BSD_TAR_ZSTD ? args : [args.join(" ")], + requiresTempDirectory: BSD_TAR_ZSTD && type !== "create" + }; }); } function getWorkingDirectory() { var _a6; return (_a6 = process.env["GITHUB_WORKSPACE"]) !== null && _a6 !== void 0 ? _a6 : process.cwd(); } + function quoteAbsolutePath(filePath) { + return `"${path30.resolve(filePath).replace(new RegExp(`\\${path30.sep}`, "g"), "/")}"`; + } function getDecompressionProgram(tarPath, compressionMethod, archivePath) { return __awaiter2(this, void 0, void 0, function* () { const BSD_TAR_ZSTD = tarPath.type === constants_1.ArchiveToolType.BSD && compressionMethod !== constants_1.CompressionMethod.Gzip && IS_WINDOWS; @@ -105693,17 +105697,13 @@ var require_tar = __commonJS({ return BSD_TAR_ZSTD ? [ "zstd -d --long=30 --force -o", constants_1.TarFilename, - archivePath.replace(new RegExp(`\\${path30.sep}`, "g"), "/") + quoteAbsolutePath(archivePath) ] : [ "--use-compress-program", IS_WINDOWS ? '"zstd -d --long=30"' : "unzstd --long=30" ]; case constants_1.CompressionMethod.ZstdWithoutLong: - return BSD_TAR_ZSTD ? [ - "zstd -d --force -o", - constants_1.TarFilename, - archivePath.replace(new RegExp(`\\${path30.sep}`, "g"), "/") - ] : ["--use-compress-program", IS_WINDOWS ? '"zstd -d"' : "unzstd"]; + return BSD_TAR_ZSTD ? ["zstd -d --force -o", constants_1.TarFilename, quoteAbsolutePath(archivePath)] : ["--use-compress-program", IS_WINDOWS ? '"zstd -d"' : "unzstd"]; default: return ["-z"]; } @@ -105748,24 +105748,39 @@ var require_tar = __commonJS({ } }); } + function execReadCommands(archivePath, compressionMethod, type) { + return __awaiter2(this, void 0, void 0, function* () { + const { commands, requiresTempDirectory } = yield getCommands(compressionMethod, type, archivePath); + const tempDirectory = requiresTempDirectory ? yield utils.createTempDirectory() : void 0; + try { + yield execCommands(commands, tempDirectory); + } finally { + if (tempDirectory) { + try { + yield io9.rmRF(tempDirectory); + } catch (error3) { + core29.debug(`Failed to delete temporary tar directory: ${error3}`); + } + } + } + }); + } function listTar(archivePath, compressionMethod) { return __awaiter2(this, void 0, void 0, function* () { - const commands = yield getCommands(compressionMethod, "list", archivePath); - yield execCommands(commands); + yield execReadCommands(archivePath, compressionMethod, "list"); }); } function extractTar3(archivePath, compressionMethod) { return __awaiter2(this, void 0, void 0, function* () { const workingDirectory = getWorkingDirectory(); yield io9.mkdirP(workingDirectory); - const commands = yield getCommands(compressionMethod, "extract", archivePath); - yield execCommands(commands); + yield execReadCommands(archivePath, compressionMethod, "extract"); }); } function createTar(archiveFolder, sourceDirectories, compressionMethod) { return __awaiter2(this, void 0, void 0, function* () { (0, fs_1.writeFileSync)(path30.join(archiveFolder, constants_1.ManifestFilename), sourceDirectories.join("\n")); - const commands = yield getCommands(compressionMethod, "create"); + const { commands } = yield getCommands(compressionMethod, "create"); yield execCommands(commands, archiveFolder); }); } @@ -105815,11 +105830,11 @@ var require_cache4 = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -105835,7 +105850,7 @@ var require_cache4 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -106317,11 +106332,11 @@ var require_manifest = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -106337,7 +106352,7 @@ var require_manifest = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -106465,11 +106480,11 @@ var require_retry_helper = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -106485,7 +106500,7 @@ var require_retry_helper = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -106530,7 +106545,7 @@ var require_retry_helper = __commonJS({ } sleep(seconds) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => setTimeout(resolve14, seconds * 1e3)); + return new Promise((resolve15) => setTimeout(resolve15, seconds * 1e3)); }); } }; @@ -106581,11 +106596,11 @@ var require_tool_cache = __commonJS({ })(); var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -106601,7 +106616,7 @@ var require_tool_cache = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -107096,41 +107111,6 @@ var require_tool_cache = __commonJS({ } }); -// node_modules/fast-deep-equal/index.js -var require_fast_deep_equal = __commonJS({ - "node_modules/fast-deep-equal/index.js"(exports2, module2) { - "use strict"; - module2.exports = function equal(a, b) { - if (a === b) return true; - if (a && b && typeof a == "object" && typeof b == "object") { - if (a.constructor !== b.constructor) return false; - var length, i, keys; - if (Array.isArray(a)) { - length = a.length; - if (length != b.length) return false; - for (i = length; i-- !== 0; ) - if (!equal(a[i], b[i])) return false; - return true; - } - if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; - if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); - if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); - keys = Object.keys(a); - length = keys.length; - if (length !== Object.keys(b).length) return false; - for (i = length; i-- !== 0; ) - if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; - for (i = length; i-- !== 0; ) { - var key = keys[i]; - if (!equal(a[key], b[key])) return false; - } - return true; - } - return a !== a && b !== b; - }; - } -}); - // node_modules/follow-redirects/debug.js var require_debug3 = __commonJS({ "node_modules/follow-redirects/debug.js"(exports2, module2) { @@ -107381,6 +107361,12 @@ var require_follow_redirects = __commonJS({ RedirectableRequest.prototype._sanitizeOptions = function(options) { if (!options.headers) { options.headers = {}; + } else if (Array.isArray(options.headers)) { + var headerList = options.headers; + options.headers = {}; + for (var i = 0; i < headerList.length; i += 2) { + options.headers[headerList[i]] = headerList[i + 1]; + } } if (!isArray2(options.sensitiveHeaders)) { options.sensitiveHeaders = []; @@ -107655,7 +107641,7 @@ var require_follow_redirects = __commonJS({ return URL2 && value instanceof URL2; } function escapeRegex(regex) { - return regex.replace(/[\]\\/()*+?.$]/g, "\\$&"); + return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&"); } module2.exports = wrap({ http, https: https3 }); module2.exports.wrap = wrap; @@ -113081,11 +113067,11 @@ var require_artifact_twirp_client2 = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -113101,7 +113087,7 @@ var require_artifact_twirp_client2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -113228,7 +113214,7 @@ var require_artifact_twirp_client2 = __commonJS({ } sleep(milliseconds) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => setTimeout(resolve14, milliseconds)); + return new Promise((resolve15) => setTimeout(resolve15, milliseconds)); }); } getExponentialRetryTimeMilliseconds(attempt) { @@ -113369,11 +113355,11 @@ var require_blob_upload = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -113389,7 +113375,7 @@ var require_blob_upload = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -113408,7 +113394,7 @@ var require_blob_upload = __commonJS({ let lastProgressTime = Date.now(); const abortController = new AbortController(); const chunkTimer = (interval) => __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const timer = setInterval(() => { if (Date.now() - lastProgressTime > interval) { reject(new Error("Upload progress stalled.")); @@ -113416,7 +113402,7 @@ var require_blob_upload = __commonJS({ }, interval); abortController.signal.addEventListener("abort", () => { clearInterval(timer); - resolve14(); + resolve15(); }); }); }); @@ -114381,9 +114367,9 @@ var require_readdir_glob = __commonJS({ var fs33 = require("fs"); var { EventEmitter: EventEmitter2 } = require("events"); var { Minimatch: Minimatch2 } = require_minimatch2(); - var { resolve: resolve14 } = require("path"); + var { resolve: resolve15 } = require("path"); function readdir3(dir, strict) { - return new Promise((resolve15, reject) => { + return new Promise((resolve16, reject) => { fs33.readdir(dir, { withFileTypes: true }, (err, files) => { if (err) { switch (err.code) { @@ -114391,7 +114377,7 @@ var require_readdir_glob = __commonJS({ if (strict) { reject(err); } else { - resolve15([]); + resolve16([]); } break; case "ENOTSUP": @@ -114401,7 +114387,7 @@ var require_readdir_glob = __commonJS({ case "ENAMETOOLONG": // Filename too long case "UNKNOWN": - resolve15([]); + resolve16([]); break; case "ELOOP": // Too many levels of symbolic links @@ -114410,30 +114396,30 @@ var require_readdir_glob = __commonJS({ break; } } else { - resolve15(files); + resolve16(files); } }); }); } function stat2(file, followSymlinks) { - return new Promise((resolve15, reject) => { + return new Promise((resolve16, reject) => { const statFunc = followSymlinks ? fs33.stat : fs33.lstat; statFunc(file, (err, stats) => { if (err) { switch (err.code) { case "ENOENT": if (followSymlinks) { - resolve15(stat2(file, false)); + resolve16(stat2(file, false)); } else { - resolve15(null); + resolve16(null); } break; default: - resolve15(null); + resolve16(null); break; } } else { - resolve15(stats); + resolve16(stats); } }); }); @@ -114523,7 +114509,7 @@ var require_readdir_glob = __commonJS({ (skip) => new Minimatch2(skip, { dot: true }) ); } - this.iterator = explore2(resolve14(cwd || "."), this.options.follow, this.options.stat, this._shouldSkipDirectory.bind(this)); + this.iterator = explore2(resolve15(cwd || "."), this.options.follow, this.options.stat, this._shouldSkipDirectory.bind(this)); this.paused = false; this.inactive = false; this.aborted = false; @@ -114690,10 +114676,10 @@ var require_async = __commonJS({ if (typeof args[arity - 1] === "function") { return asyncFn.apply(this, args); } - return new Promise((resolve14, reject2) => { + return new Promise((resolve15, reject2) => { args[arity - 1] = (err, ...cbArgs) => { if (err) return reject2(err); - resolve14(cbArgs.length > 1 ? cbArgs : cbArgs[0]); + resolve15(cbArgs.length > 1 ? cbArgs : cbArgs[0]); }; asyncFn.apply(this, args); }); @@ -114939,13 +114925,13 @@ var require_async = __commonJS({ var applyEachSeries = applyEach$1(mapSeries$1); const PROMISE_SYMBOL = /* @__PURE__ */ Symbol("promiseCallback"); function promiseCallback() { - let resolve14, reject2; + let resolve15, reject2; function callback(err, ...args) { if (err) return reject2(err); - resolve14(args.length > 1 ? args : args[0]); + resolve15(args.length > 1 ? args : args[0]); } callback[PROMISE_SYMBOL] = new Promise((res, rej) => { - resolve14 = res, reject2 = rej; + resolve15 = res, reject2 = rej; }); return callback; } @@ -115292,8 +115278,8 @@ var require_async = __commonJS({ }); } if (rejectOnError || !callback) { - return new Promise((resolve14, reject2) => { - res = resolve14; + return new Promise((resolve15, reject2) => { + res = resolve15; rej = reject2; }); } @@ -115332,10 +115318,10 @@ var require_async = __commonJS({ } const eventMethod = (name) => (handler2) => { if (!handler2) { - return new Promise((resolve14, reject2) => { + return new Promise((resolve15, reject2) => { once2(name, (err, data) => { if (err) return reject2(err); - resolve14(data); + resolve15(data); }); }); } @@ -121234,25 +121220,25 @@ var require_util13 = __commonJS({ }; }, createDeferredPromise: function() { - let resolve14; + let resolve15; let reject; const promise = new Promise((res, rej) => { - resolve14 = res; + resolve15 = res; reject = rej; }); return { promise, - resolve: resolve14, + resolve: resolve15, reject }; }, promisify(fn) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { fn((err, ...args) => { if (err) { return reject(err); } - return resolve14(...args); + return resolve15(...args); }); }); }, @@ -122043,7 +122029,7 @@ var require_end_of_stream = __commonJS({ validateBoolean(opts.cleanup, "cleanup"); autoCleanup = opts.cleanup; } - return new Promise2((resolve14, reject) => { + return new Promise2((resolve15, reject) => { const cleanup = eos(stream2, opts, (err) => { if (autoCleanup) { cleanup(); @@ -122051,7 +122037,7 @@ var require_end_of_stream = __commonJS({ if (err) { reject(err); } else { - resolve14(); + resolve15(); } }); }); @@ -123217,7 +123203,7 @@ var require_readable3 = __commonJS({ error3 = this.readableEnded ? null : new AbortError2(); this.destroy(error3); } - return new Promise2((resolve14, reject) => eos(this, (err) => err && err !== error3 ? reject(err) : resolve14(null))); + return new Promise2((resolve15, reject) => eos(this, (err) => err && err !== error3 ? reject(err) : resolve15(null))); }; Readable4.prototype.push = function(chunk, encoding) { return readableAddChunk(this, chunk, encoding, false); @@ -123761,12 +123747,12 @@ var require_readable3 = __commonJS({ } async function* createAsyncIterator(stream2, options) { let callback = nop; - function next(resolve14) { + function next(resolve15) { if (this === stream2) { callback(); callback = nop; } else { - callback = resolve14; + callback = resolve15; } } stream2.on("readable", next); @@ -124818,7 +124804,7 @@ var require_duplexify = __commonJS({ ); }; function fromAsyncGen(fn) { - let { promise, resolve: resolve14 } = createDeferredPromise(); + let { promise, resolve: resolve15 } = createDeferredPromise(); const ac = new AbortController2(); const signal = ac.signal; const value = fn( @@ -124833,7 +124819,7 @@ var require_duplexify = __commonJS({ throw new AbortError2(void 0, { cause: signal.reason }); - ({ promise, resolve: resolve14 } = createDeferredPromise()); + ({ promise, resolve: resolve15 } = createDeferredPromise()); yield chunk; } })(), @@ -124844,8 +124830,8 @@ var require_duplexify = __commonJS({ return { value, write(chunk, encoding, cb) { - const _resolve = resolve14; - resolve14 = null; + const _resolve = resolve15; + resolve15 = null; _resolve({ chunk, done: false, @@ -124853,8 +124839,8 @@ var require_duplexify = __commonJS({ }); }, final(cb) { - const _resolve = resolve14; - resolve14 = null; + const _resolve = resolve15; + resolve15 = null; _resolve({ done: true, cb @@ -125305,7 +125291,7 @@ var require_pipeline4 = __commonJS({ callback(); } }; - const wait = () => new Promise2((resolve14, reject) => { + const wait = () => new Promise2((resolve15, reject) => { if (error3) { reject(error3); } else { @@ -125313,7 +125299,7 @@ var require_pipeline4 = __commonJS({ if (error3) { reject(error3); } else { - resolve14(); + resolve15(); } }; } @@ -125957,8 +125943,8 @@ var require_operators = __commonJS({ next = null; } if (!done && (queue2.length >= highWaterMark || cnt >= concurrency)) { - await new Promise2((resolve14) => { - resume = resolve14; + await new Promise2((resolve15) => { + resume = resolve15; }); } } @@ -125992,8 +125978,8 @@ var require_operators = __commonJS({ queue2.shift(); maybeResume(); } - await new Promise2((resolve14) => { - next = resolve14; + await new Promise2((resolve15) => { + next = resolve15; }); } } finally { @@ -126251,7 +126237,7 @@ var require_promises = __commonJS({ var { finished } = require_end_of_stream(); require_stream2(); function pipeline2(...streams) { - return new Promise2((resolve14, reject) => { + return new Promise2((resolve15, reject) => { let signal; let end; const lastArg = streams[streams.length - 1]; @@ -126266,7 +126252,7 @@ var require_promises = __commonJS({ if (err) { reject(err); } else { - resolve14(value); + resolve15(value); } }, { @@ -131053,11 +131039,11 @@ var require_core2 = __commonJS({ this._finalize(); } var self2 = this; - return new Promise(function(resolve14, reject) { + return new Promise(function(resolve15, reject) { var errored; self2._module.on("end", function() { if (!errored) { - resolve14(); + resolve15(); } }); self2._module.on("error", function(err) { @@ -133416,8 +133402,8 @@ var require_streamx = __commonJS({ return this; }, next() { - return new Promise(function(resolve14, reject) { - promiseResolve = resolve14; + return new Promise(function(resolve15, reject) { + promiseResolve = resolve15; promiseReject = reject; const data = stream2.read(); if (data !== null) ondata(data); @@ -133446,11 +133432,11 @@ var require_streamx = __commonJS({ } function destroy(err) { stream2.destroy(err); - return new Promise((resolve14, reject) => { - if (stream2._duplexState & DESTROYED) return resolve14({ value: void 0, done: true }); + return new Promise((resolve15, reject) => { + if (stream2._duplexState & DESTROYED) return resolve15({ value: void 0, done: true }); stream2.once("close", function() { if (err) reject(err); - else resolve14({ value: void 0, done: true }); + else resolve15({ value: void 0, done: true }); }); }); } @@ -133494,8 +133480,8 @@ var require_streamx = __commonJS({ const writes = pending + (ws._duplexState & WRITE_WRITING ? 1 : 0); if (writes === 0) return Promise.resolve(true); if (state.drains === null) state.drains = []; - return new Promise((resolve14) => { - state.drains.push({ writes, resolve: resolve14 }); + return new Promise((resolve15) => { + state.drains.push({ writes, resolve: resolve15 }); }); } write(data) { @@ -133600,10 +133586,10 @@ var require_streamx = __commonJS({ cb(null); } function pipelinePromise(...streams) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { return pipeline2(...streams, (err) => { if (err) return reject(err); - resolve14(); + resolve15(); }); }); } @@ -134246,16 +134232,16 @@ var require_extract = __commonJS({ entryCallback = null; cb(err); } - function onnext(resolve14, reject) { + function onnext(resolve15, reject) { if (error3) { return reject(error3); } if (entryStream) { - resolve14({ value: entryStream, done: false }); + resolve15({ value: entryStream, done: false }); entryStream = null; return; } - promiseResolve = resolve14; + promiseResolve = resolve15; promiseReject = reject; consumeCallback(null); if (extract2._finished && promiseResolve) { @@ -134283,11 +134269,11 @@ var require_extract = __commonJS({ function destroy(err) { extract2.destroy(err); consumeCallback(err); - return new Promise((resolve14, reject) => { - if (extract2.destroyed) return resolve14({ value: void 0, done: true }); + return new Promise((resolve15, reject) => { + if (extract2.destroyed) return resolve15({ value: void 0, done: true }); extract2.once("close", function() { if (err) reject(err); - else resolve14({ value: void 0, done: true }); + else resolve15({ value: void 0, done: true }); }); }); } @@ -135083,11 +135069,11 @@ var require_zip2 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -135103,7 +135089,7 @@ var require_zip2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -135218,11 +135204,11 @@ var require_upload_artifact = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -135238,7 +135224,7 @@ var require_upload_artifact = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -135484,11 +135470,11 @@ var require_lib4 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -135504,7 +135490,7 @@ var require_lib4 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -135590,26 +135576,26 @@ var require_lib4 = __commonJS({ } readBody() { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15) => __awaiter2(this, void 0, void 0, function* () { let output = Buffer.alloc(0); this.message.on("data", (chunk) => { output = Buffer.concat([output, chunk]); }); this.message.on("end", () => { - resolve14(output.toString()); + resolve15(output.toString()); }); })); }); } readBodyBuffer() { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15) => __awaiter2(this, void 0, void 0, function* () { const chunks = []; this.message.on("data", (chunk) => { chunks.push(chunk); }); this.message.on("end", () => { - resolve14(Buffer.concat(chunks)); + resolve15(Buffer.concat(chunks)); }); })); }); @@ -135818,14 +135804,14 @@ var require_lib4 = __commonJS({ */ requestRaw(info8, data) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { function callbackForResult(err, res) { if (err) { reject(err); } else if (!res) { reject(new Error("Unknown error")); } else { - resolve14(res); + resolve15(res); } } this.requestRawWithCallback(info8, data, callbackForResult); @@ -136007,12 +135993,12 @@ var require_lib4 = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise((resolve14) => setTimeout(() => resolve14(), ms)); + return new Promise((resolve15) => setTimeout(() => resolve15(), ms)); }); } _processResponse(res, options) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14, reject) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15, reject) => __awaiter2(this, void 0, void 0, function* () { const statusCode = res.message.statusCode || 0; const response = { statusCode, @@ -136020,7 +136006,7 @@ var require_lib4 = __commonJS({ headers: {} }; if (statusCode === HttpCodes.NotFound) { - resolve14(response); + resolve15(response); } function dateTimeDeserializer(key, value) { if (typeof value === "string") { @@ -136059,7 +136045,7 @@ var require_lib4 = __commonJS({ err.result = response.result; reject(err); } else { - resolve14(response); + resolve15(response); } })); }); @@ -136103,11 +136089,11 @@ var require_utils9 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -136123,7 +136109,7 @@ var require_utils9 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -141988,11 +141974,11 @@ var require_download_artifact = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -142008,7 +141994,7 @@ var require_download_artifact = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -142059,7 +142045,7 @@ var require_download_artifact = __commonJS({ } catch (error3) { retryCount++; core29.debug(`Failed to download artifact after ${retryCount} retries due to ${error3.message}. Retrying in 5 seconds...`); - yield new Promise((resolve14) => setTimeout(resolve14, 5e3)); + yield new Promise((resolve15) => setTimeout(resolve15, 5e3)); } } throw new Error(`Artifact download failed after ${retryCount} retries.`); @@ -142073,7 +142059,7 @@ var require_download_artifact = __commonJS({ throw new Error(`Unexpected HTTP response from blob storage: ${response.message.statusCode} ${response.message.statusMessage}`); } let sha256Digest = void 0; - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const timerFn = () => { const timeoutError = new Error(`Blob storage chunk did not respond in ${opts.timeout}ms`); response.message.destroy(timeoutError); @@ -142098,7 +142084,7 @@ var require_download_artifact = __commonJS({ sha256Digest = hashStream.read(); core29.info(`SHA256 digest of downloaded artifact is ${sha256Digest}`); } - resolve14({ sha256Digest: `sha256:${sha256Digest}` }); + resolve15({ sha256Digest: `sha256:${sha256Digest}` }); }).on("error", (error3) => { reject(error3); }); @@ -142381,11 +142367,11 @@ var require_get_artifact = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -142401,7 +142387,7 @@ var require_get_artifact = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -142504,11 +142490,11 @@ var require_delete_artifact = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -142524,7 +142510,7 @@ var require_delete_artifact = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -142610,11 +142596,11 @@ var require_list_artifacts = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -142630,7 +142616,7 @@ var require_list_artifacts = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -142767,11 +142753,11 @@ var require_client2 = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -142787,7 +142773,7 @@ var require_client2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -143256,11 +143242,11 @@ var require_lib5 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -143276,7 +143262,7 @@ var require_lib5 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -143362,26 +143348,26 @@ var require_lib5 = __commonJS({ } readBody() { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15) => __awaiter2(this, void 0, void 0, function* () { let output = Buffer.alloc(0); this.message.on("data", (chunk) => { output = Buffer.concat([output, chunk]); }); this.message.on("end", () => { - resolve14(output.toString()); + resolve15(output.toString()); }); })); }); } readBodyBuffer() { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15) => __awaiter2(this, void 0, void 0, function* () { const chunks = []; this.message.on("data", (chunk) => { chunks.push(chunk); }); this.message.on("end", () => { - resolve14(Buffer.concat(chunks)); + resolve15(Buffer.concat(chunks)); }); })); }); @@ -143590,14 +143576,14 @@ var require_lib5 = __commonJS({ */ requestRaw(info8, data) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { function callbackForResult(err, res) { if (err) { reject(err); } else if (!res) { reject(new Error("Unknown error")); } else { - resolve14(res); + resolve15(res); } } this.requestRawWithCallback(info8, data, callbackForResult); @@ -143779,12 +143765,12 @@ var require_lib5 = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise((resolve14) => setTimeout(() => resolve14(), ms)); + return new Promise((resolve15) => setTimeout(() => resolve15(), ms)); }); } _processResponse(res, options) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14, reject) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15, reject) => __awaiter2(this, void 0, void 0, function* () { const statusCode = res.message.statusCode || 0; const response = { statusCode, @@ -143792,7 +143778,7 @@ var require_lib5 = __commonJS({ headers: {} }; if (statusCode === HttpCodes.NotFound) { - resolve14(response); + resolve15(response); } function dateTimeDeserializer(key, value) { if (typeof value === "string") { @@ -143831,7 +143817,7 @@ var require_lib5 = __commonJS({ err.result = response.result; reject(err); } else { - resolve14(response); + resolve15(response); } })); }); @@ -143848,11 +143834,11 @@ var require_auth2 = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -143868,7 +143854,7 @@ var require_auth2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -143952,11 +143938,11 @@ var require_oidc_utils2 = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -143972,7 +143958,7 @@ var require_oidc_utils2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -144050,11 +144036,11 @@ var require_summary2 = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -144070,7 +144056,7 @@ var require_summary2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -144416,11 +144402,11 @@ var require_io_util2 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -144436,7 +144422,7 @@ var require_io_util2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -144589,11 +144575,11 @@ var require_io2 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -144609,7 +144595,7 @@ var require_io2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -144837,11 +144823,11 @@ var require_toolrunner2 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -144857,7 +144843,7 @@ var require_toolrunner2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -145085,7 +145071,7 @@ var require_toolrunner2 = __commonJS({ this.toolPath = path30.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); } this.toolPath = yield io9.which(this.toolPath, true); - return new Promise((resolve14, reject) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15, reject) => __awaiter2(this, void 0, void 0, function* () { this._debug(`exec tool: ${this.toolPath}`); this._debug("arguments:"); for (const arg of this.args) { @@ -145168,7 +145154,7 @@ var require_toolrunner2 = __commonJS({ if (error3) { reject(error3); } else { - resolve14(exitCode); + resolve15(exitCode); } }); if (this.options.input) { @@ -145321,11 +145307,11 @@ var require_exec2 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -145341,7 +145327,7 @@ var require_exec2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -145432,11 +145418,11 @@ var require_platform2 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -145452,7 +145438,7 @@ var require_platform2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -145551,11 +145537,11 @@ var require_core3 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -145571,7 +145557,7 @@ var require_core3 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -146674,11 +146660,11 @@ var require_utils12 = __commonJS({ "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -146694,7 +146680,7 @@ var require_utils12 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -146904,19 +146890,19 @@ Header Information: ${JSON.stringify(response.message.headers, void 0, 2)} exports2.getProperRetention = getProperRetention; function sleep(milliseconds) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => setTimeout(resolve14, milliseconds)); + return new Promise((resolve15) => setTimeout(resolve15, milliseconds)); }); } exports2.sleep = sleep; function digestForStream(stream2) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const crc64 = new crc64_1.default(); const md5 = crypto_1.default.createHash("md5"); stream2.on("data", (data) => { crc64.update(data); md5.update(data); - }).on("end", () => resolve14({ + }).on("end", () => resolve15({ crc64: crc64.digest("base64"), md5: md5.digest("base64") })).on("error", reject); @@ -147040,11 +147026,11 @@ var require_upload_gzip = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -147060,7 +147046,7 @@ var require_upload_gzip = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -147073,14 +147059,14 @@ var require_upload_gzip = __commonJS({ }, i); function verb(n) { i[n] = o[n] && function(v) { - return new Promise(function(resolve14, reject) { - v = o[n](v), settle(resolve14, reject, v.done, v.value); + return new Promise(function(resolve15, reject) { + v = o[n](v), settle(resolve15, reject, v.done, v.value); }); }; } - function settle(resolve14, reject, d, v) { + function settle(resolve15, reject, d, v) { Promise.resolve(v).then(function(v2) { - resolve14({ value: v2, done: d }); + resolve15({ value: v2, done: d }); }, reject); } }; @@ -147121,14 +147107,14 @@ var require_upload_gzip = __commonJS({ return Number.MAX_SAFE_INTEGER; } } - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const inputStream = fs33.createReadStream(originalFilePath); const gzip = zlib3.createGzip(); const outputStream = fs33.createWriteStream(tempFilePath); inputStream.pipe(gzip).pipe(outputStream); outputStream.on("finish", () => __awaiter2(this, void 0, void 0, function* () { const size = (yield stat2(tempFilePath)).size; - resolve14(size); + resolve15(size); })); outputStream.on("error", (error3) => { console.log(error3); @@ -147140,7 +147126,7 @@ var require_upload_gzip = __commonJS({ exports2.createGZipFileOnDisk = createGZipFileOnDisk; function createGZipFileInBuffer(originalFilePath) { return __awaiter2(this, void 0, void 0, function* () { - return new Promise((resolve14) => __awaiter2(this, void 0, void 0, function* () { + return new Promise((resolve15) => __awaiter2(this, void 0, void 0, function* () { var _a6, e_1, _b2, _c2; const inputStream = fs33.createReadStream(originalFilePath); const gzip = zlib3.createGzip(); @@ -147166,7 +147152,7 @@ var require_upload_gzip = __commonJS({ if (e_1) throw e_1.error; } } - resolve14(Buffer.concat(chunks)); + resolve15(Buffer.concat(chunks)); })); }); } @@ -147207,11 +147193,11 @@ var require_requestUtils2 = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -147227,7 +147213,7 @@ var require_requestUtils2 = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -147324,11 +147310,11 @@ var require_upload_http_client = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -147344,7 +147330,7 @@ var require_upload_http_client = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -147716,11 +147702,11 @@ var require_download_http_client = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -147736,7 +147722,7 @@ var require_download_http_client = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -147869,10 +147855,10 @@ var require_download_http_client = __commonJS({ }; const resetDestinationStream = (fileDownloadPath) => __awaiter2(this, void 0, void 0, function* () { destinationStream.close(); - yield new Promise((resolve14) => { - destinationStream.on("close", resolve14); + yield new Promise((resolve15) => { + destinationStream.on("close", resolve15); if (destinationStream.writableFinished) { - resolve14(); + resolve15(); } }); yield (0, utils_1.rmFile)(fileDownloadPath); @@ -147921,7 +147907,7 @@ var require_download_http_client = __commonJS({ */ pipeResponseToFile(response, destinationStream, isGzip) { return __awaiter2(this, void 0, void 0, function* () { - yield new Promise((resolve14, reject) => { + yield new Promise((resolve15, reject) => { if (isGzip) { const gunzip = zlib3.createGunzip(); response.message.on("error", (error3) => { @@ -147934,7 +147920,7 @@ var require_download_http_client = __commonJS({ destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { - resolve14(); + resolve15(); }).on("error", (error3) => { core29.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); @@ -147945,7 +147931,7 @@ var require_download_http_client = __commonJS({ destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { - resolve14(); + resolve15(); }).on("error", (error3) => { core29.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); @@ -148059,11 +148045,11 @@ var require_artifact_client = __commonJS({ }; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { - return value instanceof P ? value : new P(function(resolve14) { - resolve14(value); + return value instanceof P ? value : new P(function(resolve15) { + resolve15(value); }); } - return new (P || (P = Promise))(function(resolve14, reject) { + return new (P || (P = Promise))(function(resolve15, reject) { function fulfilled(value) { try { step(generator.next(value)); @@ -148079,7 +148065,7 @@ var require_artifact_client = __commonJS({ } } function step(result) { - result.done ? resolve14(result.value) : adopt(result.value).then(fulfilled, rejected); + result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); @@ -166176,6 +166162,12 @@ var Env = class extends ReadOnlyEnv { this.vars[name] = value; this.changed = true; } + /** Sets all environment variables given by `vars`. */ + setAll(vars) { + for (const [key, val] of Object.entries(vars)) { + this.set(key, val); + } + } /** * Wrapper around `core.exportVariable` which does not call `core.exportVariable` * when running unit tests. This is important, because otherwise `core.exportVariable` @@ -168147,7 +168139,7 @@ function readBlockScalar(state, parentIndent, props) { state.position = linePosition + column; throwError(state, "tab characters must not be used in indentation"); } - if (column < maxLeadingIndent) { + if (column >= parentIndent && column < maxLeadingIndent) { state.position = linePosition + column; throwError(state, "bad indentation of a mapping entry"); } @@ -168357,13 +168349,16 @@ function readBlockMapping(state, nodeIndent, flowIndent, props) { ch = state.input.charCodeAt(++state.position); if (!isWsOrEolOrEnd(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping"); if (!mappingOpened) { - restoreState(state, beforeKey); - addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK); + state.events.splice(beforeKey.eventsLength, 0, { + type: EVENT_ID.MAPPING, + start: beforeKey.position, + anchorStart: props.anchorStart, + anchorEnd: props.anchorEnd, + tagStart: props.tagStart, + tagEnd: props.tagEnd, + style: COLLECTION_STYLE.BLOCK + }); mappingOpened = true; - parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true); - ch = state.input.charCodeAt(state.position); - while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position); - state.position++; } detected = true; atExplicitKey = false; @@ -169850,12 +169845,12 @@ var ExhaustivityCheckingError = class extends Error { function assertNever(value) { throw new ExhaustivityCheckingError(value); } -function initializeEnvironment(version) { - exportEnvVar("CODEQL_ACTION_FEATURE_MULTI_LANGUAGE" /* FEATURE_MULTI_LANGUAGE */, "false"); - exportEnvVar("CODEQL_ACTION_FEATURE_SANDWICH" /* FEATURE_SANDWICH */, "false"); - exportEnvVar("CODEQL_ACTION_FEATURE_SARIF_COMBINE" /* FEATURE_SARIF_COMBINE */, "true"); - exportEnvVar("CODEQL_ACTION_FEATURE_WILL_UPLOAD" /* FEATURE_WILL_UPLOAD */, "true"); - exportEnvVar("CODEQL_ACTION_VERSION" /* VERSION */, version); +function initializeEnvironment(version, env = getEnv()) { + env.export("CODEQL_ACTION_FEATURE_MULTI_LANGUAGE" /* FEATURE_MULTI_LANGUAGE */, "false"); + env.export("CODEQL_ACTION_FEATURE_SANDWICH" /* FEATURE_SANDWICH */, "false"); + env.export("CODEQL_ACTION_FEATURE_SARIF_COMBINE" /* FEATURE_SARIF_COMBINE */, "true"); + env.export("CODEQL_ACTION_FEATURE_WILL_UPLOAD" /* FEATURE_WILL_UPLOAD */, "true"); + env.export("CODEQL_ACTION_VERSION" /* VERSION */, version); } var HTTPError = class extends Error { status; @@ -169913,8 +169908,8 @@ function durationMsSince(startTime) { } async function delay(milliseconds, opts) { const { allowProcessExit } = opts || {}; - return new Promise((resolve14) => { - const timer = setTimeout(resolve14, milliseconds); + return new Promise((resolve15) => { + const timer = setTimeout(resolve15, milliseconds); if (allowProcessExit) { timer.unref(); } @@ -170191,7 +170186,7 @@ function getDiffRangesJsonFilePath(env = getEnv()) { return path2.join(getTemporaryDirectory(env), PR_DIFF_RANGE_JSON_FILENAME); } function getActionVersion() { - return "4.39.0"; + return "4.39.1"; } function getWorkflowEventName(env = getEnv()) { return env.getRequired("GITHUB_EVENT_NAME" /* GITHUB_EVENT_NAME */); @@ -170668,6 +170663,9 @@ retry.VERSION = VERSION7; var import_undici = __toESM(require_undici()); // src/repository.ts +function isRepositoryNwoStr(val) { + return val.includes("/"); +} function getRepositoryNwo() { return getRepositoryNwoFromEnv("GITHUB_REPOSITORY"); } @@ -171062,7 +171060,7 @@ var runGitCommand = async function(workingDirectory, args, customErrorMessage, o throw error3; } }; -var getCommitOid = async function(checkoutPath, ref = "HEAD") { +var getCommitOid = async function(env, checkoutPath, ref = "HEAD") { try { const stdout = await runGitCommand( checkoutPath, @@ -171071,7 +171069,7 @@ var getCommitOid = async function(checkoutPath, ref = "HEAD") { ); return stdout.trim(); } catch { - return getOptionalInput("sha") || getRequiredEnvParam("GITHUB_SHA"); + return getOptionalInput("sha") || env.getRequired("GITHUB_SHA" /* GITHUB_SHA */); } }; var determineBaseBranchHeadCommitOid = async function(checkoutPathOverride) { @@ -171148,7 +171146,7 @@ var getGitRoot = async function(sourceRoot) { ["rev-parse", "--show-toplevel"], `Cannot find Git repository root from the source root ${sourceRoot}.` ); - return stdout.trim(); + return path4.resolve(stdout.trim()); } catch { return void 0; } @@ -171181,12 +171179,12 @@ var getFileOidsUnderPath = async function(basePath) { } return fileOidMap; }; -function getRefFromEnv() { +function getRefFromEnv(env) { let refEnv; try { - refEnv = getRequiredEnvParam("GITHUB_REF"); + refEnv = env.getRequired("GITHUB_REF" /* GITHUB_REF */); } catch (e) { - const maybeRef = process.env["CODE_SCANNING_REF"]; + const maybeRef = env.getOptional("CODE_SCANNING_REF" /* CODE_SCANNING_REF */); if (maybeRef === void 0 || maybeRef.length === 0) { throw e; } @@ -171194,10 +171192,10 @@ function getRefFromEnv() { } return refEnv; } -async function getRef() { +async function getRef(env, checkoutPath) { const refInput = getOptionalInput("ref"); const shaInput = getOptionalInput("sha"); - const checkoutPath = getOptionalInput("checkout_path") || getOptionalInput("source-root") || getRequiredEnvParam("GITHUB_WORKSPACE"); + checkoutPath = checkoutPath ?? env.getRequired("GITHUB_WORKSPACE" /* GITHUB_WORKSPACE */); const hasRefInput = !!refInput; const hasShaInput = !!shaInput; if ((hasRefInput || hasShaInput) && !(hasRefInput && hasShaInput)) { @@ -171205,8 +171203,8 @@ async function getRef() { "Both 'ref' and 'sha' are required if one of them is provided." ); } - const ref = refInput || getRefFromEnv(); - const sha = shaInput || getRequiredEnvParam("GITHUB_SHA"); + const ref = refInput || getRefFromEnv(env); + const sha = shaInput || env.getRequired("GITHUB_SHA" /* GITHUB_SHA */); if (refInput) { return refInput; } @@ -171214,8 +171212,9 @@ async function getRef() { if (!pull_ref_regex.test(ref)) { return ref; } - const head = await getCommitOid(checkoutPath, "HEAD"); + const head = await getCommitOid(env, checkoutPath, "HEAD"); const hasChangedRef = sha !== head && await getCommitOid( + env, checkoutPath, ref.replace(/^refs\/pull\//, "refs/remotes/pull/") ) !== head; @@ -171232,16 +171231,16 @@ async function getRef() { function removeRefsHeadsPrefix(ref) { return ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref; } -async function isAnalyzingDefaultBranch() { - if (process.env.CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH === "true") { +async function isAnalyzingDefaultBranch(env, checkoutPath) { + if (env.getOptional("CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH") === "true") { return true; } - let currentRef = await getRef(); + let currentRef = await getRef(env, checkoutPath); currentRef = removeRefsHeadsPrefix(currentRef); - const event = getWorkflowEvent(); + const event = getWorkflowEvent(env); let defaultBranch = event?.repository?.default_branch; - if (getWorkflowEventName() === "schedule") { - defaultBranch = removeRefsHeadsPrefix(getRefFromEnv()); + if (getWorkflowEventName(env) === "schedule") { + defaultBranch = removeRefsHeadsPrefix(getRefFromEnv(env)); } return currentRef === defaultBranch; } @@ -171518,7 +171517,7 @@ function getRegistryTypesFromEnv(logger2, env = getEnv()) { async function createStatusReportBase(actionName, status, actionStartedAt, config, diskInfo, logger2, cause, exception) { try { const commitOid = getOptionalInput("sha") || process.env["GITHUB_SHA"] || ""; - const ref = await getRef(); + const ref = await getRef(getEnv(), config?.repositoryRoot); const jobRunUUID = process.env["CODEQL_ACTION_JOB_RUN_UUID" /* JOB_RUN_UUID */] || ""; const workflowRunID = getWorkflowRunID(); const workflowRunAttempt = getWorkflowRunAttempt(); @@ -174133,7 +174132,7 @@ async function getOverlayStatus(codeql, languages, diskUsage, logger2) { await fs9.promises.mkdir(path9.dirname(statusFile), { recursive: true }); const foundKey = await waitForResultWithTimeLimit( MAX_CACHE_OPERATION_MS, - actionsCache.restoreCache([statusFile], cacheKey3), + actionsCache.restoreCache([statusFile], cacheKey3, [cacheKey3]), () => { logger2.warning("Timed out restoring overlay status from cache."); } @@ -174202,7 +174201,7 @@ var CACHE_VERSION = 1; var CODEQL_TRAP_CACHE_PREFIX = "codeql-trap"; var MINIMUM_CACHE_MB_TO_UPLOAD = 10; var MAX_CACHE_OPERATION_MS2 = 12e4; -async function downloadTrapCaches(codeql, languages, logger2) { +async function downloadTrapCaches(codeql, languages, logger2, repositoryRoot) { const result = {}; const languagesSupportingCaching = await getLanguagesSupportingCaching( codeql, @@ -174222,7 +174221,7 @@ async function downloadTrapCaches(codeql, languages, logger2) { fs10.mkdirSync(cacheDir2, { recursive: true }); result[language] = cacheDir2; } - if (await isAnalyzingDefaultBranch()) { + if (await isAnalyzingDefaultBranch(getEnv(), repositoryRoot)) { logger2.info( "Analyzing default branch. Skipping downloading of TRAP caches." ); @@ -174244,6 +174243,7 @@ async function downloadTrapCaches(codeql, languages, logger2) { const found = await waitForResultWithTimeLimit( MAX_CACHE_OPERATION_MS2, actionsCache2.restoreCache([cacheDir2], preferredKey, [ + preferredKey, // Fall back to any cache with the right key prefix await cachePrefix(codeql, language) ]), @@ -174261,7 +174261,9 @@ async function downloadTrapCaches(codeql, languages, logger2) { return result; } async function uploadTrapCaches(codeql, config, logger2) { - if (!await isAnalyzingDefaultBranch()) return false; + if (!await isAnalyzingDefaultBranch(getEnv(), config.repositoryRoot)) { + return false; + } for (const language of config.languages) { const cacheDir2 = config.trapCaches[language]; if (cacheDir2 === void 0) continue; @@ -174297,6 +174299,7 @@ async function uploadTrapCaches(codeql, config, logger2) { return true; } async function cleanupTrapCaches(config, features, logger2) { + const env = getEnv(); if (!await features.getValue("cleanup_trap_caches" /* CleanupTrapCaches */)) { return { trap_cache_cleanup_skipped_because: "feature disabled" @@ -174305,7 +174308,7 @@ async function cleanupTrapCaches(config, features, logger2) { logger2.warning( "TRAP cache cleanup is deprecated and will be removed in May 2026. We recommend instead disabling TRAP caching by passing the `trap-caching: false` input to the `init` Action." ); - if (!await isAnalyzingDefaultBranch()) { + if (!await isAnalyzingDefaultBranch(env, config.repositoryRoot)) { return { trap_cache_cleanup_skipped_because: "not analyzing default branch" }; @@ -174314,7 +174317,7 @@ async function cleanupTrapCaches(config, features, logger2) { let totalBytesCleanedUp = 0; const allCaches = await listActionsCaches( CODEQL_TRAP_CACHE_PREFIX, - await getRef() + await getRef(env, config.repositoryRoot) ); for (const language of config.languages) { if (config.trapCaches[language]) { @@ -174545,7 +174548,7 @@ async function initActionState({ analysisKinds, logger: logger2, enableFileCoverageInformation -}, userConfig) { +}, userConfig, repositoryRoot) { const languages = await getLanguages( codeql, languagesInput, @@ -174581,6 +174584,7 @@ async function initActionState({ ); return { version: getActionVersion(), + repositoryRoot, analysisKinds, languages, buildMode, @@ -174605,9 +174609,14 @@ async function initActionState({ enableFileCoverageInformation }; } -async function downloadCacheWithTime(codeQL, languages, logger2) { +async function downloadCacheWithTime(codeQL, languages, logger2, repositoryRoot) { const start = import_perf_hooks2.performance.now(); - const trapCaches = await downloadTrapCaches(codeQL, languages, logger2); + const trapCaches = await downloadTrapCaches( + codeQL, + languages, + logger2, + repositoryRoot + ); const trapCacheDownloadTime = import_perf_hooks2.performance.now() - start; return { trapCaches, trapCacheDownloadTime }; } @@ -174731,7 +174740,7 @@ async function checkRunnerResources(codeql, features, diskUsage, ramInput, logge } return new Success(void 0); } -async function checkOverlayEnablement(codeql, features, languages, sourceRoot, buildMode, ramInput, codeScanningConfig, repositoryProperties, gitVersion, logger2) { +async function checkOverlayEnablement(codeql, features, languages, repositoryRoot, sourceRoot, buildMode, ramInput, codeScanningConfig, repositoryProperties, gitVersion, logger2) { const modeEnv = process.env.CODEQL_OVERLAY_DATABASE_MODE; if (modeEnv === "overlay" /* Overlay */ || modeEnv === "overlay-base" /* OverlayBase */ || modeEnv === "none" /* None */) { logger2.info( @@ -174746,6 +174755,7 @@ async function checkOverlayEnablement(codeql, features, languages, sourceRoot, b true, codeql, languages, + repositoryRoot, sourceRoot, buildMode, gitVersion, @@ -174804,7 +174814,7 @@ async function checkOverlayEnablement(codeql, features, languages, sourceRoot, b logger2.info( `Setting overlay database mode to ${overlayDatabaseMode} with caching because we are analyzing a pull request.` ); - } else if (await isAnalyzingDefaultBranch()) { + } else if (await isAnalyzingDefaultBranch(getEnv(), repositoryRoot)) { overlayDatabaseMode = "overlay-base" /* OverlayBase */; logger2.info( `Setting overlay database mode to ${overlayDatabaseMode} with caching because we are analyzing the default branch.` @@ -174818,13 +174828,14 @@ async function checkOverlayEnablement(codeql, features, languages, sourceRoot, b false, codeql, languages, + repositoryRoot, sourceRoot, buildMode, gitVersion, logger2 ); } -async function validateOverlayDatabaseMode(overlayDatabaseMode, useOverlayDatabaseCaching, overlayModeSetExplicitly, codeql, languages, sourceRoot, buildMode, gitVersion, logger2) { +async function validateOverlayDatabaseMode(overlayDatabaseMode, useOverlayDatabaseCaching, overlayModeSetExplicitly, codeql, languages, repositoryRoot, sourceRoot, buildMode, gitVersion, logger2) { if (buildMode !== "none" /* None */ && (await Promise.all( languages.map( async (l) => l !== "go" /* go */ && // Workaround to allow overlay analysis for Go with any build @@ -174845,14 +174856,13 @@ async function validateOverlayDatabaseMode(overlayDatabaseMode, useOverlayDataba ); return new Failure("incompatible-codeql" /* IncompatibleCodeQl */); } - const gitRoot = await getGitRoot(sourceRoot); - if (gitRoot === void 0) { + if (repositoryRoot === void 0) { logger2.warning( `Cannot build an ${overlayDatabaseMode} database because the source root "${sourceRoot}" is not inside a git repository. Falling back to creating a normal full database instead.` ); return new Failure("no-git-root" /* NoGitRoot */); } - if (hasSubmodules(gitRoot)) { + if (hasSubmodules(repositoryRoot)) { if (gitVersion === void 0) { logger2.warning( `Cannot build an ${overlayDatabaseMode} database because the repository has submodules and the Git version could not be determined. Falling back to creating a normal full database instead.` @@ -174979,8 +174989,9 @@ async function determineUserConfig(action, tempDir, inputs) { async function initConfig(actionState, inputs) { const { logger: logger2, features } = actionState; const { tempDir } = inputs; + const repositoryRoot = await getGitRoot(inputs.sourceRoot); const userConfig = await determineUserConfig(actionState, tempDir, inputs); - const config = await initActionState(inputs, userConfig); + const config = await initActionState(inputs, userConfig, repositoryRoot); if (config.analysisKinds.length === 1 && isCodeQualityEnabled(config)) { if (hasQueryCustomisation(config.computedConfig)) { throw new ConfigurationError( @@ -175033,6 +175044,7 @@ async function initConfig(actionState, inputs) { inputs.codeql, inputs.features, config.languages, + repositoryRoot, inputs.sourceRoot, config.buildMode, inputs.ramInput, @@ -175081,7 +175093,8 @@ async function initConfig(actionState, inputs) { const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime( inputs.codeql, config.languages, - logger2 + logger2, + repositoryRoot ); config.trapCaches = trapCaches; config.trapCacheDownloadTime = trapCacheDownloadTime; @@ -175337,7 +175350,6 @@ var fs15 = __toESM(require("fs")); var path13 = __toESM(require("path")); var import_perf_hooks4 = require("perf_hooks"); var toolcache3 = __toESM(require_tool_cache()); -var import_fast_deep_equal = __toESM(require_fast_deep_equal()); var semver9 = __toESM(require_semver2()); // src/codeql-bundle.ts @@ -175537,7 +175549,7 @@ async function downloadOverlayBaseDatabaseFromCache(codeql, config, logger2) { actionsCache3.restoreCache( [dbLocation], cacheRestoreKeyPrefix, - void 0, + [cacheRestoreKeyPrefix], { // Azure SDK download (which is the default) uses 128MB segments; see // https://github.com/actions/toolkit/blob/main/packages/cache/README.md. @@ -175601,7 +175613,7 @@ async function getCacheSaveKey(config, codeQlVersion, checkoutPath, logger2) { `Failed to get workflow run ID or attempt ID. Reason: ${getErrorMessage(e)}` ); } - const sha = await getCommitOid(checkoutPath); + const sha = await getCommitOid(getEnv(), checkoutPath); const restoreKeyPrefix = await getCacheRestoreKeyPrefix( config, codeQlVersion @@ -175793,6 +175805,78 @@ function logPerLanguageBundleFallback({ logger: logger2 }, language, location) { ); } +// src/setup/repository.ts +var CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action"; +function getCodeQLActionRepository(action) { + if (isRunningLocalAction(action.env)) { + action.logger.info( + "The CodeQL Action is checked out locally. Using the default CodeQL Action repository." + ); + return CODEQL_DEFAULT_ACTION_REPOSITORY; + } + const actionRepository = action.env.getRequired( + "GITHUB_ACTION_REPOSITORY" /* GITHUB_ACTION_REPOSITORY */ + ); + if (isRepositoryNwoStr(actionRepository)) { + return actionRepository; + } + throw new Error( + `The value of '${"GITHUB_ACTION_REPOSITORY" /* GITHUB_ACTION_REPOSITORY */}' is '${actionRepository}', which does not match the expected 'owner/repo' format.` + ); +} +var DEFAULT_DOWNLOAD_SOURCE = [ + GITHUB_DOTCOM_URL, + CODEQL_DEFAULT_ACTION_REPOSITORY +]; +var isSameDownloadSource = ([srcUrl, srcRepo], [otherUrl, otherRepo]) => { + return srcUrl === otherUrl && srcRepo === otherRepo; +}; +function getDefaultDotcomDownloadURL(tagName, assetName) { + return `${GITHUB_DOTCOM_URL}/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${assetName}`; +} +async function getCodeQLAssetDownloadURL(action, apiDetails, tagName, assetName, assetKind = "CodeQL bundle") { + const codeQLActionRepository = getCodeQLActionRepository(action); + const potentialDownloadSources = [ + // This GitHub instance, and this Action. + [apiDetails.url, codeQLActionRepository], + // This GitHub instance, and the canonical Action. + [apiDetails.url, CODEQL_DEFAULT_ACTION_REPOSITORY], + // GitHub.com, and the canonical Action. + DEFAULT_DOWNLOAD_SOURCE + ]; + const uniqueDownloadSources = potentialDownloadSources.filter( + (source, index2, self2) => { + return !self2.slice(0, index2).some((other) => isSameDownloadSource(source, other)); + } + ); + for (const [instanceURL, repository] of uniqueDownloadSources) { + if (isSameDownloadSource(DEFAULT_DOWNLOAD_SOURCE, [instanceURL, repository])) { + break; + } + const { owner: repositoryOwner, repo: repositoryName } = parseRepositoryNwo(repository); + try { + const release2 = await getApiClient().rest.repos.getReleaseByTag({ + owner: repositoryOwner, + repo: repositoryName, + tag: tagName + }); + for (const asset of release2.data.assets) { + if (asset.name === assetName) { + action.logger.info( + `Found ${assetKind} ${assetName} in ${repository} on ${instanceURL} with URL ${asset.url}.` + ); + return asset.url; + } + } + } catch (e) { + action.logger.info( + `Looked for ${assetKind} ${assetName} in ${repository} on ${instanceURL} but got error ${e}.` + ); + } + } + return getDefaultDotcomDownloadURL(tagName, assetName); +} + // src/tar.ts var import_child_process = require("child_process"); var fs13 = __toESM(require("fs")); @@ -175896,7 +175980,7 @@ async function extractTarZst(tar, dest, tarVersion, logger2) { args.push("-f", tar instanceof stream.Readable ? "-" : tar, "-C", dest); process.stdout.write(`[command]tar ${args.join(" ")} `); - await new Promise((resolve14, reject) => { + await new Promise((resolve15, reject) => { const tarProcess = (0, import_child_process.spawn)("tar", args, { stdio: "pipe" }); let stdout = ""; tarProcess.stdout?.on("data", (data) => { @@ -175932,7 +176016,7 @@ async function extractTarZst(tar, dest, tarVersion, logger2) { ) ); } - resolve14(); + resolve15(); }); }); } catch (e) { @@ -176047,7 +176131,7 @@ async function downloadAndExtractZstdWithStreaming(codeqlURL, dest, authorizatio authorization ? { authorization } : {}, headers ); - const response = await new Promise((resolve14, reject) => { + const response = await new Promise((resolve15, reject) => { const request3 = import_follow_redirects.https.get( codeqlURL, { @@ -176057,7 +176141,7 @@ async function downloadAndExtractZstdWithStreaming(codeqlURL, dest, authorizatio // Use the agent to respect proxy settings. agent }, - (r) => resolve14(r) + (r) => resolve15(r) ); request3.on("error", reject); request3.setTimeout(STREAMING_STALL_TIMEOUT_MS, () => { @@ -176184,64 +176268,11 @@ function writeToolcacheMarkerFile(extractedPath, logger2) { } // src/setup-codeql.ts -var CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action"; var CODEQL_NIGHTLIES_REPOSITORY_OWNER = "dsp-testing"; var CODEQL_NIGHTLIES_REPOSITORY_NAME = "codeql-cli-nightlies"; var CODEQL_BUNDLE_VERSION_ALIAS = ["linked", "latest"]; var CODEQL_NIGHTLY_TOOLS_INPUTS = ["nightly", "nightly-latest"]; var CODEQL_TOOLCACHE_INPUT = "toolcache"; -function getCodeQLActionRepository(logger2) { - if (isRunningLocalAction()) { - logger2.info( - "The CodeQL Action is checked out locally. Using the default CodeQL Action repository." - ); - return CODEQL_DEFAULT_ACTION_REPOSITORY; - } - return getRequiredEnvParam("GITHUB_ACTION_REPOSITORY"); -} -async function getCodeQLBundleDownloadURL(tagName, apiDetails, codeQLBundleName, logger2) { - const codeQLActionRepository = getCodeQLActionRepository(logger2); - const potentialDownloadSources = [ - // This GitHub instance, and this Action. - [apiDetails.url, codeQLActionRepository], - // This GitHub instance, and the canonical Action. - [apiDetails.url, CODEQL_DEFAULT_ACTION_REPOSITORY], - // GitHub.com, and the canonical Action. - [GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY] - ]; - const uniqueDownloadSources = potentialDownloadSources.filter( - (source, index2, self2) => { - return !self2.slice(0, index2).some((other) => (0, import_fast_deep_equal.default)(source, other)); - } - ); - for (const downloadSource of uniqueDownloadSources) { - const [apiURL, repository] = downloadSource; - if (apiURL === GITHUB_DOTCOM_URL && repository === CODEQL_DEFAULT_ACTION_REPOSITORY) { - break; - } - const [repositoryOwner, repositoryName] = repository.split("/"); - try { - const release2 = await getApiClient().rest.repos.getReleaseByTag({ - owner: repositoryOwner, - repo: repositoryName, - tag: tagName - }); - for (const asset of release2.data.assets) { - if (asset.name === codeQLBundleName) { - logger2.info( - `Found CodeQL bundle ${codeQLBundleName} in ${repository} on ${apiURL} with URL ${asset.url}.` - ); - return asset.url; - } - } - } catch (e) { - logger2.info( - `Looked for CodeQL bundle ${codeQLBundleName} in ${repository} on ${apiURL} but got error ${e}.` - ); - } - } - return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${codeQLBundleName}`; -} function tryGetBundleVersionFromTagName(tagName, logger2) { const match2 = tagName.match(/^codeql-bundle-(.+)$/); if (match2 === null || match2.length < 2) { @@ -176599,9 +176630,10 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, rawLanguages, othe ); } compressionMethod = cliVersion2 !== void 0 && await useZstdBundle(cliVersion2, tarSupportsZstd) ? "zstd" : "gzip"; + const action = { env: getEnv(), logger: logger2 }; const platform2 = getBundlePlatform(); const perLanguageBundleLanguage = await getPerLanguageBundleLanguage( - { env: getEnv(), features, logger: logger2 }, + { ...action, features }, { rawLanguages, otherLanguagePacksReason, @@ -176611,11 +176643,11 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, rawLanguages, othe variant } ); - const resolveBundleURL = (language) => getCodeQLBundleDownloadURL( - bundleTagName, + const resolveBundleURL = (language) => getCodeQLAssetDownloadURL( + action, apiDetails, - getCodeQLBundleName(compressionMethod, platform2, language), - logger2 + bundleTagName, + getCodeQLBundleName(compressionMethod, platform2, language) ); const combinedBundleURL = await resolveBundleURL(); if (perLanguageBundleLanguage !== void 0) { @@ -177590,7 +177622,7 @@ async function getTrapCachingExtractorConfigArgs(config) { async function getTrapCachingExtractorConfigArgsForLang(config, language) { const cacheDir2 = config.trapCaches[language]; if (cacheDir2 === void 0) return []; - const write = await isAnalyzingDefaultBranch(); + const write = await isAnalyzingDefaultBranch(getEnv(), config.repositoryRoot); return [ `-O=${language}.trap.cache.dir=${cacheDir2}`, `-O=${language}.trap.cache.bound=${TRAP_CACHE_SIZE_MB}`, @@ -177823,6 +177855,7 @@ async function downloadDependencyCaches(codeql, features, languages, logger2) { } const primaryKey = await cacheKey2(codeql, features, language, patterns); const restoreKeys = [ + primaryKey, await cachePrefix2(codeql, features, language) ]; logger2.info( @@ -177987,6 +178020,38 @@ var CodeQLAnalysisError = class extends Error { message; error; }; +async function determineCheckoutPath(action, config) { + const checkoutPathInput = action.actions.getRequiredInput("checkout_path"); + const absCheckoutPathInput = path16.resolve(checkoutPathInput); + const repositoryRoot = await getGitRoot(absCheckoutPathInput); + if (repositoryRoot === void 0) { + action.logger.warning( + [ + `The directory at '${absCheckoutPathInput}' is not in the work tree of a git repository.`, + "If the repository being analyzed is checked out elsewhere,", + "you must explicitly set the 'checkout_path' input for the 'codeql-action/analyze' step to", + "the checkout path." + ].join(" ") + ); + } else if (repositoryRoot !== absCheckoutPathInput) { + action.logger.warning( + [ + `The directory at '${absCheckoutPathInput}' is not the root of the repository ('${repositoryRoot}').`, + "Set the 'checkout_path' input for the 'codeql-action/analyze' step to the root path of the checkout." + ].join(" ") + ); + } else if (config.repositoryRoot !== void 0 && repositoryRoot !== config.repositoryRoot) { + action.logger.warning( + [ + `The repository path at '${repositoryRoot}' does not match that found by the 'codeql-action/init' step: '${config.repositoryRoot}'.`, + "Ensure that the 'checkout_path' input for the 'codeql-action/analyze' step is set to the path of the same repository that", + "the 'codeql-action/init' step determined. This is either the GitHub Actions workspace or the repository root corresponding to", + "the 'source-root' input if that was provided." + ].join(" ") + ); + } + return absCheckoutPathInput; +} async function setupPythonExtractor(logger2) { const codeqlPython = process.env["CODEQL_PYTHON"]; if (codeqlPython === void 0 || codeqlPython.length === 0) { @@ -178371,7 +178436,7 @@ async function cleanupAndUploadDatabases(action, repositoryNwo, codeql, config, logger2.debug("Not running against github.com or GHEC-DR. Skipping upload."); return []; } - if (!await isAnalyzingDefaultBranch()) { + if (!await isAnalyzingDefaultBranch(action.env, checkoutPath)) { logger2.debug("Not analyzing default branch. Skipping upload."); return []; } @@ -178388,7 +178453,7 @@ async function cleanupAndUploadDatabases(action, repositoryNwo, codeql, config, includeDiagnostics: false }); bundledDbSize = fs19.statSync(bundledDb).size; - const commitOid = await getCommitOid(checkoutPath); + const commitOid = await getCommitOid(action.env, checkoutPath); const maxAttempts = 4; let uploadDurationMs; for (let attempt = 1; attempt <= maxAttempts; attempt++) { @@ -178417,7 +178482,7 @@ async function cleanupAndUploadDatabases(action, repositoryNwo, codeql, config, logger2.debug( `Database upload attempt ${attempt} of ${maxAttempts} failed for ${language}: ${getErrorMessage(e)}. Retrying in ${backoffMs / 1e3}s...` ); - await new Promise((resolve14) => setTimeout(resolve14, backoffMs)); + await new Promise((resolve15) => setTimeout(resolve15, backoffMs)); } } reports.push({ @@ -180398,12 +180463,13 @@ async function uploadPostProcessedFiles(logger2, checkoutPath, uploadTarget, pos logger2.debug(`Compressing serialized SARIF`); const zippedSarif = import_zlib.default.gzipSync(sarifPayload).toString("base64"); const checkoutURI = url.pathToFileURL(checkoutPath).href; + const env = getEnv(); const payload = uploadTarget.transformPayload( buildPayload( - await getCommitOid(checkoutPath), - await getRef(), + await getCommitOid(env, checkoutPath), + await getRef(env, checkoutPath), postProcessingResults.analysisKey, - getRequiredEnvParam("GITHUB_WORKFLOW"), + env.getRequired("GITHUB_WORKFLOW" /* GITHUB_WORKFLOW */), zippedSarif, getWorkflowRunID(), getWorkflowRunAttempt(), @@ -180735,12 +180801,9 @@ async function runAutobuildIfLegacyGoWorkflow(config, logger2) { ); await runAutobuild(config, "go" /* go */, logger2); } -async function run({ - startedAt, - env, - logger: logger2, - actions -}) { +async function run(action) { + const startedAt = action.startedAt; + const logger2 = action.logger; let uploadResults = void 0; let runStats = void 0; let config = void 0; @@ -180783,7 +180846,7 @@ async function run({ } const apiDetails = getApiDetails(); const outputDir = getRequiredInput("output"); - env.export("CODEQL_ACTION_SARIF_RESULTS_OUTPUT_DIR" /* SARIF_RESULTS_OUTPUT_DIR */, outputDir); + action.env.export("CODEQL_ACTION_SARIF_RESULTS_OUTPUT_DIR" /* SARIF_RESULTS_OUTPUT_DIR */, outputDir); const threads = getThreadsFlag( getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger2 @@ -180801,7 +180864,7 @@ async function run({ getOptionalInput("ram") || process.env["CODEQL_RAM"], logger2 ); - const checkoutPath = actions.getRequiredInput("checkout_path"); + const checkoutPath = await determineCheckoutPath(action, config); const diffRangePackDir = await setupDiffInformedQueryRun( logger2, checkoutPath @@ -180876,8 +180939,9 @@ async function run({ logger2, checkoutPath ); + const actionWithFeatures = extendActionState(action, { features }); databaseUploadResults = await cleanupAndUploadDatabases( - { logger: logger2, features }, + actionWithFeatures, repositoryNwo, codeql, config, @@ -180914,7 +180978,7 @@ async function run({ `expect-error input was set to true but no error was thrown.` ); } - env.export("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */, "true"); + action.env.export("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */, "true"); } catch (unwrappedError) { const error3 = wrapError(unwrappedError); if (getOptionalInput("expect-error") !== "true" || hasBadExpectErrorInput()) { @@ -183081,7 +183145,7 @@ var import_async = __toESM(require_async(), 1); var import_path7 = require("path"); // node_modules/archiver/lib/error.js -var import_util36 = __toESM(require("util"), 1); +var import_util37 = __toESM(require("util"), 1); var ERROR_CODES = { ABORTED: "archive was aborted", DIRECTORYDIRPATHREQUIRED: "diretory dirpath argument must be a non-empty string value", @@ -183106,7 +183170,7 @@ function ArchiverError(code, data) { this.code = code; this.data = data; } -import_util36.default.inherits(ArchiverError, Error); +import_util37.default.inherits(ArchiverError, Error); // node_modules/archiver/lib/core.js var import_readable_stream2 = __toESM(require_ours(), 1); @@ -183797,11 +183861,11 @@ var Archiver = class extends import_readable_stream2.Transform { this._finalize(); } var self2 = this; - return new Promise(function(resolve14, reject) { + return new Promise(function(resolve15, reject) { var errored; self2._module.on("end", function() { if (!errored) { - resolve14(); + resolve15(); } }); self2._module.on("error", function(err) { @@ -186326,14 +186390,20 @@ function getUploadInputOrThrow(workflow, jobName, matrixVars) { matrixVars ); } -function getCheckoutPathInputOrThrow(workflow, jobName, matrixVars) { - return getInputOrThrow( - workflow, - jobName, - getAnalyzeActionName(), - "checkout_path", - matrixVars - ) || getRequiredEnvParam("GITHUB_WORKSPACE"); +function getRepositoryRootOrThrow(workflow, jobName, matrixVars, config, env = getEnv()) { + return ( + // If the CodeQL Action already has a persisted repository root, then we can just use that. + config.repositoryRoot ?? // Otherwise, try to retrieve it from a `checkout_path` input in the workflow specification. + getInputOrThrow( + workflow, + jobName, + getAnalyzeActionName(), + "checkout_path", + matrixVars + ) ?? // Finally, if all of the above fail, just use the value of `GITHUB_WORKSPACE` since that + // is what is used by default. + env.getRequired("GITHUB_WORKSPACE" /* GITHUB_WORKSPACE */) + ); } async function checkWorkflow(logger2, codeql) { if (!isDynamicWorkflow() && process.env["CODEQL_ACTION_SKIP_WORKFLOW_VALIDATION" /* SKIP_WORKFLOW_VALIDATION */] !== "true") { @@ -186924,7 +186994,12 @@ async function prepareFailedSarif(logger2, features, config) { }); } const category = getCategoryInputOrThrow(workflow, jobName, matrix); - const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix); + const checkoutPath = getRepositoryRootOrThrow( + workflow, + jobName, + matrix, + config + ); const result = await generateFailedSarif( logger2, features, @@ -187262,7 +187337,10 @@ async function run4(action) { action.env, logger2 ); - if (await isAnalyzingDefaultBranch() && hasConfigKey(config, "dependencyCachingEnabled") && config.dependencyCachingEnabled !== "none" /* None */) { + if (await isAnalyzingDefaultBranch( + action.env, + config.repositoryRoot + ) && hasConfigKey(config, "dependencyCachingEnabled") && config.dependencyCachingEnabled !== "none" /* None */) { dependencyCachingUsage = await getDependencyCacheUsage(logger2); } } @@ -187604,11 +187682,73 @@ var core25 = __toESM(require_core()); // src/start-proxy.ts var path27 = __toESM(require("path")); -var core24 = __toESM(require_core()); var toolcache4 = __toESM(require_tool_cache()); -// src/start-proxy/validation.ts +// src/start-proxy/status-report.ts var core23 = __toESM(require_core()); +async function sendSuccessStatusReport(startedAt, config, registry_types, status, logger2) { + const statusReportBase = await createStatusReportBase( + "start-proxy" /* StartProxy */, + "success", + startedAt, + config, + await checkDiskUsage(logger2), + logger2 + ); + if (statusReportBase !== void 0) { + const statusReport = { + ...statusReportBase, + registry_types: registry_types.sort().join(","), + start_proxy: status + }; + await sendStatusReport(statusReport); + } +} +function getStartProxyErrorMessage(errorType) { + switch (errorType) { + case 0 /* DownloadFailed */: + return "Failed to download proxy archive."; + case 1 /* ExtractionFailed */: + return "Failed to extract proxy archive."; + case 2 /* CacheFailed */: + return "Failed to add proxy to toolcache"; + } +} +var StartProxyError = class extends Error { + errorType; + constructor(errorType) { + super(); + this.errorType = errorType; + } +}; +function getSafeErrorMessage(error3) { + if (error3 instanceof StartProxyError) { + return getStartProxyErrorMessage(error3.errorType); + } + return `Error from start-proxy Action omitted (${error3.constructor.name}).`; +} +async function sendFailedStatusReport(logger2, startedAt, language, unwrappedError) { + const error3 = wrapError(unwrappedError); + core23.setFailed(`start-proxy action failed: ${error3.message}`); + const statusReportMessage = getSafeErrorMessage(error3); + const errorStatusReportBase = await createStatusReportBase( + "start-proxy" /* StartProxy */, + getActionsStatus(error3), + startedAt, + { + languages: language === void 0 ? void 0 : [language] + }, + await checkDiskUsage(logger2), + logger2, + statusReportMessage + ); + if (errorStatusReportBase !== void 0) { + await sendStatusReport(errorStatusReportBase); + } +} + +// src/start-proxy/validation.ts +var core24 = __toESM(require_core()); function cloneCredential(schema, obj) { const result = {}; for (const key of Object.keys(schema)) { @@ -187627,14 +187767,14 @@ function getAuthConfig(config) { } if (isToken(config)) { if (isDefined2(config.token)) { - core23.setSecret(config.token); + core24.setSecret(config.token); } return cloneCredential(tokenSchema, config); } else { let username = void 0; let password = void 0; if ("password" in config && isString(config.password)) { - core23.setSecret(config.password); + core24.setSecret(config.password); password = config.password; } if ("username" in config && isString(config.username)) { @@ -187648,68 +187788,7 @@ function getAuthConfig(config) { } // src/start-proxy.ts -function getStartProxyErrorMessage(errorType) { - switch (errorType) { - case 0 /* DownloadFailed */: - return "Failed to download proxy archive."; - case 1 /* ExtractionFailed */: - return "Failed to extract proxy archive."; - case 2 /* CacheFailed */: - return "Failed to add proxy to toolcache"; - } -} -var StartProxyError = class extends Error { - errorType; - constructor(errorType) { - super(); - this.errorType = errorType; - } -}; -async function sendSuccessStatusReport(startedAt, config, registry_types, logger2) { - const statusReportBase = await createStatusReportBase( - "start-proxy" /* StartProxy */, - "success", - startedAt, - config, - await checkDiskUsage(logger2), - logger2 - ); - if (statusReportBase !== void 0) { - const statusReport = { - ...statusReportBase, - registry_types: registry_types.join(",") - }; - await sendStatusReport(statusReport); - } -} -function getSafeErrorMessage(error3) { - if (error3 instanceof StartProxyError) { - return getStartProxyErrorMessage(error3.errorType); - } - return `Error from start-proxy Action omitted (${error3.constructor.name}).`; -} -async function sendFailedStatusReport(logger2, startedAt, language, unwrappedError) { - const error3 = wrapError(unwrappedError); - core24.setFailed(`start-proxy action failed: ${error3.message}`); - const statusReportMessage = getSafeErrorMessage(error3); - const errorStatusReportBase = await createStatusReportBase( - "start-proxy" /* StartProxy */, - getActionsStatus(error3), - startedAt, - { - languages: language === void 0 ? void 0 : [language] - }, - await checkDiskUsage(logger2), - logger2, - statusReportMessage - ); - if (errorStatusReportBase !== void 0) { - await sendStatusReport(errorStatusReportBase); - } -} var UPDATEJOB_PROXY = "update-job-proxy"; -var UPDATEJOB_PROXY_VERSION = "v2.0.20250624110901"; -var UPDATEJOB_PROXY_URL_PREFIX = "https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.22.0/"; function isPAT(value) { return isAuthToken(value, [ GITHUB_PAT_CLASSIC_PATTERN, @@ -187827,21 +187906,11 @@ function getCredentials(logger2, registrySecrets, registriesCredentials, languag function getProxyPackage(platform2) { return `${UPDATEJOB_PROXY}-${platform2}.tar.gz`; } -function getFallbackUrl(proxyPackage) { - return `${UPDATEJOB_PROXY_URL_PREFIX}${proxyPackage}`; -} -async function getReleaseByVersion(version) { - return getApiClient().rest.repos.getReleaseByTag({ - owner: "github", - repo: "codeql-action", - tag: version - }); -} async function getCliVersionFromFeatures(features) { const gitHubVersion = await getGitHubVersion(); return await features.getEnabledDefaultCliVersions(gitHubVersion.type); } -async function getDownloadUrl(action) { +async function getDownloadUrl(action, apiDetails) { let platform2 = getBundlePlatform(action.platform, action.arch); if (platform2 === void 0) { action.logger.warning( @@ -187858,37 +187927,29 @@ async function getDownloadUrl(action) { cliVersion, tagName: bundleVersion }; - const cliRelease = await getReleaseByVersion(versionInfo.tagName); - for (const asset of cliRelease.data.assets) { - if (asset.name === proxyPackage) { - action.logger.info( - `Found '${proxyPackage}' in release '${versionInfo.tagName}' at '${asset.url}'` - ); - return { - url: asset.url, - // The `update-job-proxy` doesn't have a version as such. Since we now bundle it - // with CodeQL CLI bundle releases, we use the corresponding CLI version to - // differentiate between (potentially) different versions of `update-job-proxy`. - version: versionInfo.cliVersion - }; - } - } + const proxyAssetUrl = await getCodeQLAssetDownloadURL( + action, + apiDetails, + versionInfo.tagName, + proxyPackage, + "private registry proxy" + ); + return { + url: proxyAssetUrl, + // The `update-job-proxy` doesn't have a version as such. Since we now bundle it + // with CodeQL CLI bundle releases, we use the corresponding CLI version to + // differentiate between (potentially) different versions of `update-job-proxy`. + version: versionInfo.cliVersion + }; } catch (ex) { - action.logger.warning( + throw new Error( `Failed to retrieve information about the linked release: ${getErrorMessage(ex)}` ); } - action.logger.info( - `Did not find '${proxyPackage}' in the linked release, falling back to hard-coded version.` - ); - return { - url: getFallbackUrl(proxyPackage), - version: UPDATEJOB_PROXY_VERSION - }; } async function downloadProxy(logger2, url2, authorization) { try { - return toolcache4.downloadTool( + return await toolcache4.downloadTool( url2, /* dest: */ void 0, @@ -187927,28 +187988,43 @@ async function cacheProxy(logger2, source, filename, version) { function getProxyFilename() { return process.platform === "win32" ? `${UPDATEJOB_PROXY}.exe` : UPDATEJOB_PROXY; } -async function getProxyBinaryPath(action) { +async function getProxyBinaryPath(action, apiDetails) { const logger2 = action.logger; - const proxyFileName = getProxyFilename(); - const proxyInfo = await getDownloadUrl(action); - let proxyBin = toolcache4.find(proxyFileName, proxyInfo.version); - if (!proxyBin) { - const apiDetails = getApiDetails(); - const authorization = getAuthorizationHeaderFor( - logger2, - apiDetails, - proxyInfo.url - ); - const temp = await downloadProxy(logger2, proxyInfo.url, authorization); - const extracted = await extractProxy(logger2, temp); - proxyBin = await cacheProxy( - logger2, - extracted, - proxyFileName, - proxyInfo.version + logger2.startGroup("Setting up authentication proxy"); + try { + const proxyFileName = getProxyFilename(); + const proxyInfo = await getDownloadUrl(action, apiDetails); + logger2.info( + `Using authentication proxy from CodeQL release ${proxyInfo.version}.` ); + let proxyDir = toolcache4.find(proxyFileName, proxyInfo.version); + if (!proxyDir) { + logger2.info( + `Authentication proxy is not in the toolcache. Will try to download it from '${proxyInfo.url}'.` + ); + const authorization = getAuthorizationHeaderFor( + logger2, + apiDetails, + proxyInfo.url + ); + const temp = await downloadProxy(logger2, proxyInfo.url, authorization); + logger2.info(`Downloaded the authentication proxy asset to '${temp}'.`); + const extracted = await extractProxy(logger2, temp); + proxyDir = await cacheProxy( + logger2, + extracted, + proxyFileName, + proxyInfo.version + ); + logger2.info(`Extracted the authentication proxy to '${proxyDir}'.`); + } + return { + path: path27.join(proxyDir, proxyFileName), + version: proxyInfo.version + }; + } finally { + logger2.endGroup(); } - return path27.join(proxyBin, proxyFileName); } // src/start-proxy/ca.ts @@ -188184,7 +188260,7 @@ var NetworkReachabilityBackend = class { proxy; agent; async checkConnection(url2) { - return new Promise((resolve14, reject) => { + return new Promise((resolve15, reject) => { const req = https2.request( url2, { @@ -188197,7 +188273,7 @@ var NetworkReachabilityBackend = class { (res) => { res.destroy(); if (res.statusCode !== void 0 && res.statusCode < 400) { - resolve14(res.statusCode); + resolve15(res.statusCode); } else { reject(new ReachabilityError(res.statusCode)); } @@ -188311,9 +188387,12 @@ async function run7(action) { ca }; const actionWithFeatures = extendActionState(action, { features }); - const proxyBin = await getProxyBinaryPath(actionWithFeatures); + const proxyBin = await getProxyBinaryPath( + actionWithFeatures, + getApiDetails(action.env) + ); const proxyInfo = await startProxy( - proxyBin, + proxyBin.path, proxyConfig, proxyLogFilePath, logger2 @@ -188325,6 +188404,7 @@ async function run7(action) { languages: language === void 0 ? void 0 : [language] }, proxyConfig.all_credentials.map((c) => c.type), + { proxy_version: proxyBin.version }, logger2 ); } catch (unwrappedError) { @@ -188717,7 +188797,7 @@ tmp/lib/tmp.js: *) js-yaml/dist/js-yaml.mjs: - (*! js-yaml 5.4.2 https://github.com/nodeca/js-yaml @license MIT *) + (*! js-yaml 5.4.3 https://github.com/nodeca/js-yaml @license MIT *) long/index.js: (** diff --git a/package-lock.json b/package-lock.json index 050ff1e48..d702b0f6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codeql", - "version": "4.39.0", + "version": "4.39.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "codeql", - "version": "4.39.0", + "version": "4.39.1", "license": "MIT", "workspaces": [ "pr-checks" @@ -14,7 +14,7 @@ "dependencies": { "@actions/artifact": "^5.0.3", "@actions/artifact-legacy": "npm:@actions/artifact@^1.1.2", - "@actions/cache": "^5.2.0", + "@actions/cache": "^5.3.0", "@actions/core": "^2.0.3", "@actions/exec": "^2.0.0", "@actions/github": "^8.0.1", @@ -23,15 +23,14 @@ "@actions/io": "^2.0.0", "@actions/tool-cache": "^3.0.1", "@octokit/core": "^7.0.8", - "@octokit/plugin-paginate-rest": "^15.0.0", + "@octokit/plugin-paginate-rest": "^16.0.0", "@octokit/plugin-rest-endpoint-methods": "^18.0.0", "@octokit/plugin-retry": "^8.1.1", "archiver": "^8.0.0", - "fast-deep-equal": "^3.1.3", - "follow-redirects": "^1.16.0", + "follow-redirects": "^1.16.1", "get-folder-size": "^5.0.0", "https-proxy-agent": "^7.0.6", - "js-yaml": "^5.4.2", + "js-yaml": "^5.4.3", "jsonschema": "1.5.0", "long": "^5.3.2", "node-forge": "^1.4.0", @@ -58,14 +57,14 @@ "eslint-import-resolver-typescript": "^4.4.5", "eslint-plugin-github": "^6.1.2", "eslint-plugin-import-x": "^4.17.1", - "eslint-plugin-jsdoc": "^65.0.1", + "eslint-plugin-jsdoc": "^65.2.0", "eslint-plugin-no-async-foreach": "^0.1.1", "glob": "^13.0.6", - "globals": "^17.12.0", + "globals": "^17.13.0", "nock": "^14.0.17", "sinon": "^22.1.0", "typescript": "^6.0.3", - "typescript-eslint": "^8.70.1" + "typescript-eslint": "^8.71.1" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -459,19 +458,19 @@ } }, "node_modules/@actions/cache": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.2.0.tgz", - "integrity": "sha512-1R1Oc8cuDNCygsIP7gLiKLGCymOw/k5FkGQkXZFcLz6/RWyMImkfP0dZX6kjA9SRAmANcKNocI2XrsIaZ1it8w==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.3.0.tgz", + "integrity": "sha512-VqJBlQFt1lpp7op7o/Z0syWywX9cN8TxjFCPjHyGHmXCiczU5NII5ZdEpGpTelUnOGFG2bO7viUx9q3q7WR/Gg==", "license": "MIT", "dependencies": { - "@actions/core": "^2.0.0", + "@actions/core": "^2.0.3", "@actions/exec": "^2.0.0", "@actions/glob": "^0.5.1", "@actions/http-client": "^3.0.2", "@actions/io": "^2.0.0", "@azure/abort-controller": "^1.1.0", - "@azure/core-rest-pipeline": "^1.22.0", - "@azure/storage-blob": "^12.29.1", + "@azure/core-rest-pipeline": "^1.25.0", + "@azure/storage-blob": "^12.34.0", "@protobuf-ts/runtime-rpc": "^2.11.1", "semver": "^6.3.1" } @@ -2205,12 +2204,12 @@ "license": "MIT" }, "node_modules/@octokit/plugin-paginate-rest": { - "version": "15.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-15.0.0.tgz", - "integrity": "sha512-lw9A9YL5s4VPj+VEx8uMxaxQm2YTgrPDkrLEuZuu18R8TK3oPcXF4K6t52nx6xn1RcogZC9i188sAr/4XYJaQQ==", + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-16.0.0.tgz", + "integrity": "sha512-7RtUeGZypAK4EA4LrjTCnsLALNOoUcYh5vOnCNXpdIQVTQCPh4OFu7324iPqAls3KGgVnZktKUnNKZCOKyHrlA==", "license": "MIT", "dependencies": { - "@octokit/types": "^17.0.0" + "@octokit/types": "^18.0.0" }, "engines": { "node": ">= 20" @@ -2219,21 +2218,6 @@ "@octokit/core": ">=6" } }, - "node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/openapi-types": { - "version": "28.0.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-28.0.0.tgz", - "integrity": "sha512-0rFyLuyHvIj6uuZWuDslxkowFYdPXoNIkeAv4b27dzm2Tf4vGWXnPsMcxs7d65kLdMERgP3wc1AEPlqMz8e1cQ==", - "license": "MIT" - }, - "node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/types": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-17.0.0.tgz", - "integrity": "sha512-ByP1v7YL5SMveFPP7+sj0/ZuWCOOg/Chs4NafOMpq6WNIM/hdGY0S7C0TCGDBWu1aGmOxmUIhMx3cO+IdwYZ1Q==", - "license": "MIT", - "dependencies": { - "@octokit/openapi-types": "^28.0.0" - } - }, "node_modules/@octokit/plugin-request-log": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz", @@ -2718,17 +2702,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.70.1.tgz", - "integrity": "sha512-nDNrUQ/4ruSNYbu749TRY7cfrzPtoLHEXSNBI8aaNY32LlZCajixqRf3FqcKC4p5Cam4VOHYx/t+i5+nKXvrqA==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.71.1.tgz", + "integrity": "sha512-nNlBf6HuotqMgZvSkWD5hNdemiBIxQ2NmrlgfcUIeZRs+BbakjscCQRq/Hb74EFVnFiSWWdL12JruqwBy3ERDw==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.70.1", - "@typescript-eslint/type-utils": "8.70.1", - "@typescript-eslint/utils": "8.70.1", - "@typescript-eslint/visitor-keys": "8.70.1", + "@typescript-eslint/scope-manager": "8.71.1", + "@typescript-eslint/type-utils": "8.71.1", + "@typescript-eslint/utils": "8.71.1", + "@typescript-eslint/visitor-keys": "8.71.1", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -2741,7 +2725,7 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.70.1", + "@typescript-eslint/parser": "^8.71.1", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } @@ -2757,16 +2741,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.70.1.tgz", - "integrity": "sha512-nO974WLllwhSFWQXnMLj6nDGa8f0khKEz1JzpPJ1u7Vm/4X1X6ZHajpoknU4bb41vJyMB0HHVyS2GqdhWfIXZw==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.71.1.tgz", + "integrity": "sha512-oM/5sAqz/l1v/zYK1qTOPrn2+JIrBGC1V6uNYucRO5gh6eT9vWJ/RhPbGE59byvZEUQ4VP6XkLBaS5Jti5jpvw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.70.1", - "@typescript-eslint/types": "8.70.1", - "@typescript-eslint/typescript-estree": "8.70.1", - "@typescript-eslint/visitor-keys": "8.70.1", + "@typescript-eslint/scope-manager": "8.71.1", + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/typescript-estree": "8.71.1", + "@typescript-eslint/visitor-keys": "8.71.1", "debug": "^4.4.3" }, "engines": { @@ -2800,14 +2784,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.70.1.tgz", - "integrity": "sha512-62xOgboPfwc3/IgPSX/W6oQR3ZbF04194FPGUGH8HL8iLFHbt/456/8Ph1wLNUgVF+s94FlHoipBsz+v7+LMnA==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.71.1.tgz", + "integrity": "sha512-Oijc9RUsohHjncg6iGi7gCtjnEjYt9FWv9u6ygK8uKcHK5eLjLAkqERQ9BaytbpceOFdk6kifPCS/zAZE+A99g==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.70.1", - "@typescript-eslint/types": "^8.70.1", + "@typescript-eslint/tsconfig-utils": "^8.71.1", + "@typescript-eslint/types": "^8.71.1", "debug": "^4.4.3" }, "engines": { @@ -2840,14 +2824,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.70.1.tgz", - "integrity": "sha512-Pa0EeSeAusQc1WbjQMac+YfenewYTBu0KjgYvkUKwhXaHUKbFog23Dm/rp0DX/6tyYOQ3Xl1a+3EcFNZynGHCw==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.71.1.tgz", + "integrity": "sha512-1YUDZXdTnXLlob03SFHBipdyMBsDVm7zoSz0ytTJ39dk5J1TgsTK03VlR/dLXG/RLLUrPcYbD4rp23BmHxHP0w==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.70.1", - "@typescript-eslint/visitor-keys": "8.70.1" + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/visitor-keys": "8.71.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2858,9 +2842,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.70.1.tgz", - "integrity": "sha512-jumze1fPI+sDOaM2TWGQdn39PDxTr7TZGeuyLkAbNyx2vtMT3uRnVKChN0hfht5V2TugphJzF6bYXvBcE09qqg==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.71.1.tgz", + "integrity": "sha512-oTvkml5SxXhgg+WWKhod5qWQICDXtOB+/Hi9VdPKFAANJ2b7YOgMffgvzXuqog7R6A/JtrzRf128dsxummyWhg==", "dev": true, "license": "MIT", "engines": { @@ -2875,15 +2859,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.70.1.tgz", - "integrity": "sha512-7zKTnyvaVWqzLZHPFQtX1hVHqgkMC+WebPWakNCSyrQVbIP1AM0L0TlBZtACldIRb6PptI8Odk+jyZ5kP3B1VA==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.71.1.tgz", + "integrity": "sha512-kH3t3jZCYv2PZSBEWPKTariLrCaoF1CLoPitYFBJOhAGEwWnSRAtGEifrfrpBa4K9JlwWNZotgA5w3/wLSk/FQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.70.1", - "@typescript-eslint/typescript-estree": "8.70.1", - "@typescript-eslint/utils": "8.70.1", + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/typescript-estree": "8.71.1", + "@typescript-eslint/utils": "8.71.1", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -2918,9 +2902,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.70.1.tgz", - "integrity": "sha512-Dm1ypdhhrGCTyyehxElhgJ6kgk8MVCv5qXdoOVqPr1uqk42jX8KjrZqhROvdShczA8qrDoYiOWn1ykWlx2k81Q==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.71.1.tgz", + "integrity": "sha512-ybYnPTUwg3VQQOFEiBPLs8Jxl1ry2vXdn1kVKguomBbvxpetdu3MKTNDqFNUrlG8ylP9MpZosmXMFYlGQHk1oQ==", "dev": true, "license": "MIT", "engines": { @@ -2932,16 +2916,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.70.1.tgz", - "integrity": "sha512-TU8PwyGN0PQJUcE96mw8eCQ44SmxGdQlJmlWakHaHQ15eIuuvye5yNtmh/i6oS88jzXVQB71xdNkbkB/fMwL0g==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.71.1.tgz", + "integrity": "sha512-pSKSEK1JJpHs6KiKVtABCE4iJK5d7FLFzDXQNBQ2oRY7LEd3UwOt3TZemTgu9syTIf56dJWlTn/pdmrO9oKUXQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.70.1", - "@typescript-eslint/tsconfig-utils": "8.70.1", - "@typescript-eslint/types": "8.70.1", - "@typescript-eslint/visitor-keys": "8.70.1", + "@typescript-eslint/project-service": "8.71.1", + "@typescript-eslint/tsconfig-utils": "8.71.1", + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/visitor-keys": "8.71.1", "debug": "^4.4.3", "minimatch": "^10.2.2", "semver": "^7.7.3", @@ -3017,16 +3001,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.70.1.tgz", - "integrity": "sha512-Esgul8MsnKnRLdYU2Eb2cRV9bS5HJYtKj1ByJnOzzG2M58DGdSUQ1jUuILxipqcpB2h9WLrbD5GijIWUjX/Tqw==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.71.1.tgz", + "integrity": "sha512-CBjT6gfAz3DW2j9Q4moFnqt208Aq+506sVGXfpRcyAeqn0EpayL0mjdWoCO2t3RC7GewNrFxdeehuEaPg6DMzQ==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.70.1", - "@typescript-eslint/types": "8.70.1", - "@typescript-eslint/typescript-estree": "8.70.1" + "@typescript-eslint/scope-manager": "8.71.1", + "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/typescript-estree": "8.71.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3041,13 +3025,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.70.1.tgz", - "integrity": "sha512-Vwj9lUIW5Xq3wQ9w6gv3R86g1hMK8f2zNOdGTAgeXUMMXFK78G9ruCjjqutHMNJc0+CH7LYRnHeUB9IT8wFmcw==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.71.1.tgz", + "integrity": "sha512-0GxiUGqMU0qXJt58cBsiG3DP8lUmBaFo2vChtUX+CT7PnR3v/VGLLrzVP4K9r1lNiZXjHYefMBbPunplr09v6w==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.70.1", + "@typescript-eslint/types": "8.71.1", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -5381,9 +5365,9 @@ } }, "node_modules/eslint-plugin-jsdoc": { - "version": "65.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-65.0.1.tgz", - "integrity": "sha512-7IvB+ZS71WCw5tGKh6f6D5k55qtXKdrGTnIpQTBKWdpyZ5IfhGHfh0i6ArWlCJ4JEtz22YRk5Bqu1MvbOlpMKQ==", + "version": "65.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-65.2.0.tgz", + "integrity": "sha512-IMZaNwdDa5otUQYGWN1pzywZLsGKswitvFFNhcO8IOsBfaWpWIDXYuZh2sYhe9MNyKN9hz0YryOFaKdpbTP5Bw==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -5817,6 +5801,7 @@ }, "node_modules/fast-deep-equal": { "version": "3.1.3", + "dev": true, "license": "MIT" }, "node_modules/fast-diff": { @@ -6007,9 +5992,9 @@ "license": "ISC" }, "node_modules/follow-redirects": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", - "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.1.tgz", + "integrity": "sha512-FNvFGzoMLWmE6Yj9spb/zjd7yiNCHiAW9/Tg9CXrQ8wuu32HtlJOwWO11OJafl5FfY3DxTdQ0vj42zU1kvv5jg==", "funding": [ { "type": "individual", @@ -6293,9 +6278,9 @@ } }, "node_modules/globals": { - "version": "17.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-17.12.0.tgz", - "integrity": "sha512-cezEd/DTyyht9cvSSURyygXPfy04GtWO/5e6ZPvH7fCtjKz9PYOmuawphw1Ctd1f6C+5JypXfGD7ahNMXvevBA==", + "version": "17.13.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-17.13.0.tgz", + "integrity": "sha512-RwMTC61u7hrG3ZJMkZQOK4JLJrKS8QtoTii63EmWvFXHqycY9FObBJQCbsLxSO8kjKhWE5kV1GC+Vb1g3RI0Zg==", "dev": true, "license": "MIT", "engines": { @@ -7136,9 +7121,9 @@ } }, "node_modules/js-yaml": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.2.tgz", - "integrity": "sha512-m+aqu+LwO1O6sIopafj8HUVl5aawITwZQe/yHpMCKjaWBaA/d07B/QdMb3529REftiU+RMMHL3Vlsw3hON7vWg==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.3.tgz", + "integrity": "sha512-yzzNtgczwgoVHNigCyKTXcQJU4Y8t/ikU4UxXW0BvrLfHTGWZhsNcOT2s/a7vn81/4KqVnNmHjaUEPlvWnNwVw==", "funding": [ { "type": "github", @@ -7494,9 +7479,9 @@ } }, "node_modules/mdast-util-from-markdown": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.3.tgz", - "integrity": "sha512-W4mAWTvSlKvf8L6J+VN9yLSqQ9AOAAvHuoDAmPkz4dHf553m5gVj2ejadHJhoJmcmxEnOv6Pa8XJhpxE93kb8Q==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.1.0.tgz", + "integrity": "sha512-KRLgmPaP2H1ul2bpoJkOS+9pAcDAAj9Nu1mqLnh8NLeJG5tlvj42TH80PIGBpROWlRXLk0lDrWNuZCFy/tsB4A==", "license": "MIT", "dependencies": { "@types/mdast": "^4.0.0", @@ -9996,16 +9981,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.70.1", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.70.1.tgz", - "integrity": "sha512-AcWG7KDjZ2THNXsgwttMaGmzVi0VFRlFYfqFHYQRbDpF3owuYbuiL8c7UUrd2k8s3PoSfIQrWfrGXfcElrWLYA==", + "version": "8.71.1", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.71.1.tgz", + "integrity": "sha512-oiNVPC3/NbV1FpaHU07l8O6ynqG9v4PAiW2WvTrAmZdR0f2HI/gE668ElMLCK7Xbsu5k2fK5C4fXNiq05j7/nQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.70.1", - "@typescript-eslint/parser": "8.70.1", - "@typescript-eslint/typescript-estree": "8.70.1", - "@typescript-eslint/utils": "8.70.1" + "@typescript-eslint/eslint-plugin": "8.71.1", + "@typescript-eslint/parser": "8.71.1", + "@typescript-eslint/typescript-estree": "8.71.1", + "@typescript-eslint/utils": "8.71.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -10500,10 +10485,10 @@ "@actions/core": "^2.0.3", "@actions/github": "^8.0.1", "@octokit/core": "^7.0.8", - "@octokit/plugin-paginate-rest": ">=15.0.0", + "@octokit/plugin-paginate-rest": ">=16.0.0", "@octokit/plugin-rest-endpoint-methods": "^18.0.0", "lite-matter": "^0.1.2", - "mdast-util-from-markdown": "^2.0.3", + "mdast-util-from-markdown": "^2.1.0", "semver": "^7.8.5", "yaml": "^2.9.1" }, diff --git a/package.json b/package.json index 51fd4a450..209ded679 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codeql", - "version": "4.39.0", + "version": "4.39.1", "private": true, "description": "CodeQL action", "scripts": { @@ -22,7 +22,7 @@ "dependencies": { "@actions/artifact": "^5.0.3", "@actions/artifact-legacy": "npm:@actions/artifact@^1.1.2", - "@actions/cache": "^5.2.0", + "@actions/cache": "^5.3.0", "@actions/core": "^2.0.3", "@actions/exec": "^2.0.0", "@actions/github": "^8.0.1", @@ -31,15 +31,14 @@ "@actions/io": "^2.0.0", "@actions/tool-cache": "^3.0.1", "@octokit/core": "^7.0.8", - "@octokit/plugin-paginate-rest": "^15.0.0", + "@octokit/plugin-paginate-rest": "^16.0.0", "@octokit/plugin-rest-endpoint-methods": "^18.0.0", "@octokit/plugin-retry": "^8.1.1", "archiver": "^8.0.0", - "fast-deep-equal": "^3.1.3", - "follow-redirects": "^1.16.0", + "follow-redirects": "^1.16.1", "get-folder-size": "^5.0.0", "https-proxy-agent": "^7.0.6", - "js-yaml": "^5.4.2", + "js-yaml": "^5.4.3", "jsonschema": "1.5.0", "long": "^5.3.2", "node-forge": "^1.4.0", @@ -66,14 +65,14 @@ "eslint-import-resolver-typescript": "^4.4.5", "eslint-plugin-github": "^6.1.2", "eslint-plugin-import-x": "^4.17.1", - "eslint-plugin-jsdoc": "^65.0.1", + "eslint-plugin-jsdoc": "^65.2.0", "eslint-plugin-no-async-foreach": "^0.1.1", "glob": "^13.0.6", - "globals": "^17.12.0", + "globals": "^17.13.0", "nock": "^14.0.17", "sinon": "^22.1.0", "typescript": "^6.0.3", - "typescript-eslint": "^8.70.1" + "typescript-eslint": "^8.71.1" }, "overrides": { "@actions/tool-cache": { diff --git a/pr-checks/changenotes.ts b/pr-checks/changenotes.ts index 26035527b..d9ccd8461 100755 --- a/pr-checks/changenotes.ts +++ b/pr-checks/changenotes.ts @@ -50,6 +50,28 @@ function getChangenotes(): ChangenoteFile[] { }); } +/** + * Populates the '[UNRELEASED]' section of CHANGELOG.md with the contents + * of the changenotes in {@link CHANGENOTES_DIR} and then deletes those changenotes. + * @param contents The contents of CHANGELOG.md + * @returns The updated contents of CHANGELOG.md + */ +export function transferChangenotesToChangelog(contents: string): string { + const changenotes = getChangenotes(); + const changenoteBodies = changenotes.map((c) => c.content.trim()); + const changenotePaths = changenotes.map((c) => c.absolutePath); + + const changelog = parseChangelog(contents); + addBodyLinesToUnreleasedSection(changelog, changenoteBodies); + const updatedChangelog = renderChangelog(changelog); + + for (const p of changenotePaths) { + fs.unlinkSync(p); + } + + return updatedChangelog; +} + const entryPoint = process.argv[1]; if (entryPoint && import.meta.url === pathToFileURL(entryPoint).href) { try { @@ -91,26 +113,13 @@ function usage(): ExitCode { function assemble(): ExitCode { try { - const changenotes = getChangenotes(); - const changenoteBodies = changenotes.map((c) => c.content); - const changenotePaths = changenotes.map((c) => c.absolutePath); - withChangelog((contents) => { - const changelog = parseChangelog(contents); - addBodyLinesToUnreleasedSection(changelog, changenoteBodies); - return renderChangelog(changelog); + return transferChangenotesToChangelog(contents); }, {}); - - // Delete changenotes only after successful processing. - for (const p of changenotePaths) { - fs.unlinkSync(p); - } - return ExitCode.Success; } catch (e) { console.error("Failed to assemble changenotes to 'CHANGELOG.md'", e); } - return ExitCode.Failure; } diff --git a/pr-checks/checks/analysis-kinds.yml b/pr-checks/checks/analysis-kinds.yml index 5b2aaf4aa..ef7cb80e1 100644 --- a/pr-checks/checks/analysis-kinds.yml +++ b/pr-checks/checks/analysis-kinds.yml @@ -46,7 +46,7 @@ steps: post-processed-sarif-path: "${{ runner.temp }}/post-processed" - name: Upload SARIF files - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: | analysis-kinds-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }} @@ -54,7 +54,7 @@ steps: retention-days: 7 - name: Upload post-processed SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: | post-processed-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }} diff --git a/pr-checks/checks/config-export.yml b/pr-checks/checks/config-export.yml index 93c640735..205754151 100644 --- a/pr-checks/checks/config-export.yml +++ b/pr-checks/checks/config-export.yml @@ -14,7 +14,7 @@ steps: output: "${{ runner.temp }}/results" upload-database: false - name: Upload SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: config-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json path: "${{ runner.temp }}/results/javascript.sarif" diff --git a/pr-checks/checks/diagnostics-export.yml b/pr-checks/checks/diagnostics-export.yml index 61b9ae5ef..93b3a8f60 100644 --- a/pr-checks/checks/diagnostics-export.yml +++ b/pr-checks/checks/diagnostics-export.yml @@ -27,7 +27,7 @@ steps: output: "${{ runner.temp }}/results" upload-database: false - name: Upload SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: diagnostics-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json path: "${{ runner.temp }}/results/javascript.sarif" diff --git a/pr-checks/checks/export-file-baseline-information.yml b/pr-checks/checks/export-file-baseline-information.yml index ce22ec5d5..da3237238 100644 --- a/pr-checks/checks/export-file-baseline-information.yml +++ b/pr-checks/checks/export-file-baseline-information.yml @@ -27,7 +27,7 @@ steps: with: output: "${{ runner.temp }}/results" - name: Upload SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: with-baseline-information-${{ matrix.os }}-${{ matrix.version }}.sarif.json path: "${{ runner.temp }}/results/javascript.sarif" diff --git a/pr-checks/checks/job-run-uuid-sarif.yml b/pr-checks/checks/job-run-uuid-sarif.yml index b86725d94..879da226c 100644 --- a/pr-checks/checks/job-run-uuid-sarif.yml +++ b/pr-checks/checks/job-run-uuid-sarif.yml @@ -12,7 +12,7 @@ steps: with: output: "${{ runner.temp }}/results" - name: Upload SARIF - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: ${{ matrix.os }}-${{ matrix.version }}.sarif.json path: "${{ runner.temp }}/results/javascript.sarif" diff --git a/pr-checks/package.json b/pr-checks/package.json index 3d6b3d07e..3f20d119d 100644 --- a/pr-checks/package.json +++ b/pr-checks/package.json @@ -6,10 +6,10 @@ "@actions/core": "^2.0.3", "@actions/github": "^8.0.1", "@octokit/core": "^7.0.8", - "@octokit/plugin-paginate-rest": ">=15.0.0", + "@octokit/plugin-paginate-rest": ">=16.0.0", "@octokit/plugin-rest-endpoint-methods": "^18.0.0", "lite-matter": "^0.1.2", - "mdast-util-from-markdown": "^2.0.3", + "mdast-util-from-markdown": "^2.1.0", "semver": "^7.8.5", "yaml": "^2.9.1" }, diff --git a/pr-checks/sync.ts b/pr-checks/sync.ts index 1d70d5c7f..57fa3cab3 100755 --- a/pr-checks/sync.ts +++ b/pr-checks/sync.ts @@ -219,8 +219,8 @@ const languageSetups: LanguageSetups = { name: "Install Node.js", uses: pinnedUses( "actions/setup-node", - "820762786026740c76f36085b0efc47a31fe5020", - "v7.0.0", + "949feb2413d6458794dcd2491c4babbbce0c15c1", + "v7.1.0", ), with: { "node-version": defaultLanguageVersions.javascript, diff --git a/pr-checks/update-release-branch.ts b/pr-checks/update-release-branch.ts index 93e50f7ad..9d46fd3ec 100755 --- a/pr-checks/update-release-branch.ts +++ b/pr-checks/update-release-branch.ts @@ -23,7 +23,13 @@ import { parseArgs } from "node:util"; import { type ApiClient, getApiClient } from "./api-client"; import * as changelog from "./changelog"; -import { DryRunOption, REPO_ROOT } from "./config"; +import { transferChangenotesToChangelog } from "./changenotes"; +import { + CHANGELOG_FILE, + CHANGENOTES_DIR, + DryRunOption, + REPO_ROOT, +} from "./config"; import { getCurrentVersion, replaceVersionInPackageJson, @@ -693,11 +699,14 @@ export async function prepareNewBranch( console.log("Updating changelog"); changelog.withChangelog( - (contents) => changelog.setVersionAndDate(version, contents), + (contents) => { + const populatedContents = transferChangenotesToChangelog(contents); + return changelog.setVersionAndDate(version, populatedContents); + }, { ...options, initChangelog: true }, ); - runGit(["add", "CHANGELOG.md"], { + runGit(["add", CHANGELOG_FILE, CHANGENOTES_DIR], { dryRun: options.dryRun, }); runGit(["commit", "-m", `Update changelog for v${version}`], { diff --git a/src/actions-util.ts b/src/actions-util.ts index 62ab42440..13e33a8e9 100644 --- a/src/actions-util.ts +++ b/src/actions-util.ts @@ -93,7 +93,7 @@ export function getActionVersion(): string { * * This will be "dynamic" for default setup workflow runs. */ -export function getWorkflowEventName(env: Env = getEnv()) { +export function getWorkflowEventName(env: ReadOnlyEnv = getEnv()) { return env.getRequired(ActionsEnvVars.GITHUB_EVENT_NAME); } @@ -101,7 +101,7 @@ export function getWorkflowEventName(env: Env = getEnv()) { * Returns whether the current workflow is executing a local copy of the Action, e.g. we're running * a workflow on the codeql-action repo itself. */ -export function isRunningLocalAction(env: Env = getEnv()): boolean { +export function isRunningLocalAction(env: ReadOnlyEnv = getEnv()): boolean { const relativeScriptPath = getRelativeScriptPath(env); return ( relativeScriptPath.startsWith("..") || path.isAbsolute(relativeScriptPath) @@ -113,14 +113,14 @@ export function isRunningLocalAction(env: Env = getEnv()): boolean { * * This can be used to get the Action's name or tell if we're running a local Action. */ -function getRelativeScriptPath(env: Env): string { +function getRelativeScriptPath(env: ReadOnlyEnv): string { const runnerTemp = env.getRequired(ActionsEnvVars.RUNNER_TEMP); const actionsDirectory = path.join(path.dirname(runnerTemp), "_actions"); return path.relative(actionsDirectory, __filename); } /** Returns the contents of `GITHUB_EVENT_PATH` as a JSON object. */ -export function getWorkflowEvent(env: Env = getEnv()): any { +export function getWorkflowEvent(env: ReadOnlyEnv = getEnv()): any { const eventJsonFile = env.getRequired(ActionsEnvVars.GITHUB_EVENT_PATH); try { return JSON.parse(fs.readFileSync(eventJsonFile, "utf-8")); diff --git a/src/analyze-action.test.ts b/src/analyze-action.test.ts index 923908a64..ffba5a03d 100644 --- a/src/analyze-action.test.ts +++ b/src/analyze-action.test.ts @@ -45,6 +45,7 @@ test.serial( requiredInputStub.withArgs("token").returns("fake-token"); requiredInputStub.withArgs("upload-database").returns("false"); requiredInputStub.withArgs("output").returns("out"); + requiredInputStub.withArgs("checkout_path").returns(""); const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput"); optionalInputStub.withArgs("expect-error").returns("false"); sinon.stub(api, "getGitHubVersion").resolves(gitHubVersion); @@ -104,6 +105,7 @@ test.serial( requiredInputStub.withArgs("token").returns("fake-token"); requiredInputStub.withArgs("upload-database").returns("false"); requiredInputStub.withArgs("output").returns("out"); + requiredInputStub.withArgs("checkout_path").returns(""); const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput"); optionalInputStub.withArgs("expect-error").returns("false"); sinon.stub(api, "getGitHubVersion").resolves(gitHubVersion); diff --git a/src/analyze-action.ts b/src/analyze-action.ts index 865564741..9efbb529b 100644 --- a/src/analyze-action.ts +++ b/src/analyze-action.ts @@ -4,12 +4,18 @@ import { performance } from "perf_hooks"; import * as core from "@actions/core"; -import { Action, ActionState, runInActions } from "./action-common"; +import { + Action, + ActionState, + extendActionState, + runInActions, +} from "./action-common"; import * as actionsUtil from "./actions-util"; import * as analyses from "./analyses"; import { CodeQLAnalysisError, dbIsFinalized, + determineCheckoutPath, QueriesStatusReport, runFinalize, runQueries, @@ -212,14 +218,11 @@ async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) { await runAutobuild(config, BuiltInLanguage.go, logger); } -async function run({ - startedAt, - env, - logger, - actions, -}: ActionState<["Base", "Env", "Logger", "Actions"]>) { +async function run(action: ActionState<["Base", "Logger", "Env", "Actions"]>) { // To capture errors appropriately, keep as much code within the try-catch as // possible, and only use safe functions outside. + const startedAt = action.startedAt; + const logger = action.logger; let uploadResults: | Partial> @@ -277,7 +280,7 @@ async function run({ const apiDetails = getApiDetails(); const outputDir = actionsUtil.getRequiredInput("output"); - env.export(EnvVar.SARIF_RESULTS_OUTPUT_DIR, outputDir); + action.env.export(EnvVar.SARIF_RESULTS_OUTPUT_DIR, outputDir); const threads = util.getThreadsFlag( actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger, @@ -301,7 +304,7 @@ async function run({ logger, ); - const checkoutPath = actions.getRequiredInput("checkout_path"); + const checkoutPath = await determineCheckoutPath(action, config); // Setup diff informed analysis if needed (based on whether init created the file) const diffRangePackDir = await setupDiffInformedQueryRun( @@ -393,11 +396,13 @@ async function run({ checkoutPath, ); + const actionWithFeatures = extendActionState(action, { features }); + // Possibly upload the database bundles for remote queries. // Note: Take care with the ordering of this call since databases may be cleaned up // at the `overlay` or `clear` level. databaseUploadResults = await cleanupAndUploadDatabases( - { logger, features }, + actionWithFeatures, repositoryNwo, codeql, config, @@ -446,7 +451,7 @@ async function run({ `expect-error input was set to true but no error was thrown.`, ); } - env.export(EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY, "true"); + action.env.export(EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY, "true"); } catch (unwrappedError) { const error = util.wrapError(unwrappedError); if ( diff --git a/src/analyze.test.ts b/src/analyze.test.ts index 80fc7a547..e14d87d10 100644 --- a/src/analyze.test.ts +++ b/src/analyze.test.ts @@ -10,10 +10,12 @@ import { resolveQuerySuiteAlias, addSarifExtension, diffRangeExtensionPackContents, + determineCheckoutPath, } from "./analyze"; import { createStubCodeQL } from "./codeql"; import { defaultSuites } from "./config/db-config"; import { Feature } from "./feature-flags"; +import * as gitUtils from "./git-utils"; import { BuiltInLanguage } from "./languages"; import { getRunnerLogger } from "./logging"; import { @@ -21,12 +23,98 @@ import { setupActionsVars, createFeatures, createTestConfig, + callee, } from "./testing-utils"; import * as uploadLib from "./upload-lib"; import * as util from "./util"; setupTests(test); +test.serial( + "determineCheckoutPath - logs when checkout_path is not in a work tree", + async (t) => { + const expectedPath = path.resolve("/checkout/path"); + const target = callee(determineCheckoutPath) + .withActions((actions) => { + sinon + .stub(actions, "getRequiredInput") + .withArgs("checkout_path") + .returns(expectedPath); + }) + .withArgs(createTestConfig({})); + sinon.stub(gitUtils, "getGitRoot").resolves(undefined); + + await target + .logs(t, "is not in the work tree of a git repository") + .passes(t.is, expectedPath); + }, +); + +test.serial( + "determineCheckoutPath - logs when checkout_path is not a repo root", + async (t) => { + const expectedPath = path.resolve("/checkout/path"); + const target = callee(determineCheckoutPath) + .withActions((actions) => { + sinon + .stub(actions, "getRequiredInput") + .withArgs("checkout_path") + .returns(expectedPath); + }) + .withArgs(createTestConfig({})); + sinon.stub(gitUtils, "getGitRoot").resolves("/checkout"); + + await target + .logs(t, "is not the root of the repository") + .passes(t.is, expectedPath); + }, +); + +test.serial( + "determineCheckoutPath - logs when checkout_path is not the same as repo root in config", + async (t) => { + const expectedPath = path.resolve("/checkout/path"); + const target = callee(determineCheckoutPath) + .withActions((actions) => { + sinon + .stub(actions, "getRequiredInput") + .withArgs("checkout_path") + .returns(expectedPath); + }) + .withArgs(createTestConfig({ repositoryRoot: "/some/other/path" })); + sinon.stub(gitUtils, "getGitRoot").resolves(expectedPath); + + await target + .logs(t, "does not match that found by the 'codeql-action/init' step") + .passes(t.is, expectedPath); + }, +); + +test.serial( + "determineCheckoutPath - doesn't log any of the messages when all is as expected", + async (t) => { + const expectedPath = path.resolve("/checkout/path"); + const target = callee(determineCheckoutPath) + .withActions((actions) => { + sinon + .stub(actions, "getRequiredInput") + .withArgs("checkout_path") + .returns(expectedPath); + }) + .withArgs(createTestConfig({ repositoryRoot: expectedPath })); + sinon.stub(gitUtils, "getGitRoot").resolves(expectedPath); + + await target + .notLogs( + t, + "is not in the work tree of a git repository", + "is not the root of the repository", + "does not match that found by the 'codeql-action/init' step", + ) + .passes(t.is, expectedPath); + }, +); + /** * Checks the status report produced by the analyze Action. * diff --git a/src/analyze.ts b/src/analyze.ts index 4d5fd5354..2da347c13 100644 --- a/src/analyze.ts +++ b/src/analyze.ts @@ -5,6 +5,7 @@ import { performance } from "perf_hooks"; import * as io from "@actions/io"; import * as yaml from "js-yaml"; +import type { ActionState } from "./action-common"; import { getTemporaryDirectory } from "./actions-util"; import * as analyses from "./analyses"; import { setupCppAutobuild } from "./autobuild"; @@ -23,6 +24,7 @@ import { } from "./diff-informed-analysis-utils"; import { EnvVar } from "./environment"; import { FeatureEnablement, Feature } from "./feature-flags"; +import { getGitRoot } from "./git-utils"; import { BuiltInLanguage, Language } from "./languages"; import { Logger, withGroupAsync } from "./logging"; import { OverlayDatabaseMode } from "./overlay/overlay-database-mode"; @@ -87,6 +89,58 @@ export interface QueriesStatusReport event_reports?: EventReport[]; } +/** + * Determines the path at which the repository being analysed is checked out at. + * Returns the value of the required `checkout_path` input and validates that it + * refers to the root of a repository. + * + * @param action The action state. + * @param config The CodeQL Action configuration state. + */ +export async function determineCheckoutPath( + action: ActionState<["Logger", "Actions"]>, + config: configUtils.Config, +) { + const checkoutPathInput = action.actions.getRequiredInput("checkout_path"); + + // Try to obtain the root path of the repository and validate that it matches the input. + const absCheckoutPathInput = path.resolve(checkoutPathInput); + const repositoryRoot = await getGitRoot(absCheckoutPathInput); + + if (repositoryRoot === undefined) { + action.logger.warning( + [ + `The directory at '${absCheckoutPathInput}' is not in the work tree of a git repository.`, + "If the repository being analyzed is checked out elsewhere,", + "you must explicitly set the 'checkout_path' input for the 'codeql-action/analyze' step to", + "the checkout path.", + ].join(" "), + ); + } else if (repositoryRoot !== absCheckoutPathInput) { + action.logger.warning( + [ + `The directory at '${absCheckoutPathInput}' is not the root of the repository ('${repositoryRoot}').`, + "Set the 'checkout_path' input for the 'codeql-action/analyze' step to the root path of the checkout.", + ].join(" "), + ); + } else if ( + config.repositoryRoot !== undefined && + repositoryRoot !== config.repositoryRoot + ) { + // The repository root that was persisted by the `init` step doesn't match the one we have found here. + action.logger.warning( + [ + `The repository path at '${repositoryRoot}' does not match that found by the 'codeql-action/init' step: '${config.repositoryRoot}'.`, + "Ensure that the 'checkout_path' input for the 'codeql-action/analyze' step is set to the path of the same repository that", + "the 'codeql-action/init' step determined. This is either the GitHub Actions workspace or the repository root corresponding to", + "the 'source-root' input if that was provided.", + ].join(" "), + ); + } + + return absCheckoutPathInput; +} + async function setupPythonExtractor(logger: Logger) { const codeqlPython = process.env["CODEQL_PYTHON"]; if (codeqlPython === undefined || codeqlPython.length === 0) { diff --git a/src/codeql.ts b/src/codeql.ts index 6a0440321..5981929c1 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -1230,7 +1230,7 @@ export async function getTrapCachingExtractorConfigArgsForLang( ): Promise { const cacheDir = config.trapCaches[language]; if (cacheDir === undefined) return []; - const write = await isAnalyzingDefaultBranch(); + const write = await isAnalyzingDefaultBranch(getEnv(), config.repositoryRoot); return [ `-O=${language}.trap.cache.dir=${cacheDir}`, `-O=${language}.trap.cache.bound=${TRAP_CACHE_SIZE_MB}`, diff --git a/src/config-utils.test.ts b/src/config-utils.test.ts index b1f5f7134..9ed0187e6 100644 --- a/src/config-utils.test.ts +++ b/src/config-utils.test.ts @@ -172,6 +172,7 @@ test.serial("load empty config", async (t) => { createTestInitConfigInputs({ languagesInput: languages, repository: { owner: "github", repo: "example" }, + sourceRoot: tempDir, tempDir, codeql, logger, @@ -186,6 +187,7 @@ test.serial("load empty config", async (t) => { logger, }), {}, + undefined, ); t.deepEqual(config, expectedConfig); @@ -216,6 +218,7 @@ test.serial("load code quality config", async (t) => { analysisKinds: [AnalysisKind.CodeQuality], languagesInput: languages, repository: { owner: "github", repo: "example" }, + sourceRoot: tempDir, tempDir, codeql, logger, @@ -296,6 +299,7 @@ test.serial( analysisKinds: [AnalysisKind.CodeQuality], languagesInput: languages, repository: { owner: "github", repo: "example" }, + sourceRoot: tempDir, tempDir, codeql, repositoryProperties, @@ -518,6 +522,7 @@ test.serial("load non-empty input", async (t) => { // And the config we expect it to parse to const expectedConfig = createTestConfig({ languages: [BuiltInLanguage.javascript], + repositoryRoot: undefined, buildMode: BuildMode.None, originalUserInput: userConfig, computedConfig: userConfig, @@ -538,6 +543,7 @@ test.serial("load non-empty input", async (t) => { state, createTestInitConfigInputs({ languagesInput, + sourceRoot: tempDir, buildModeInput: "none", configFile: configFilePath, debugArtifactName: "my-artifact", @@ -1105,11 +1111,6 @@ const checkOverlayEnablementMacro = makeMacro({ return lang === BuiltInLanguage.java; }); - // Mock git root detection - if (setup.gitRoot !== undefined) { - sinon.stub(gitUtils, "getGitRoot").resolves(setup.gitRoot); - } - // Mock submodule detection sinon.stub(gitUtils, "hasSubmodules").returns(setup.hasSubmodules); @@ -1122,6 +1123,7 @@ const checkOverlayEnablementMacro = makeMacro({ codeql, features, setup.languages, + setup.gitRoot, // repositoryRoot tempDir, // sourceRoot setup.buildMode, undefined, diff --git a/src/config-utils.ts b/src/config-utils.ts index e0b005db7..de506aac0 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -49,7 +49,7 @@ import { makeTelemetryDiagnostic, } from "./diagnostics"; import { prepareDiffInformedAnalysis } from "./diff-informed-analysis-utils"; -import { EnvVar, exportEnvVar } from "./environment"; +import { EnvVar, exportEnvVar, getEnv } from "./environment"; import * as errorMessages from "./error-messages"; import { Feature, FeatureEnablement, FeatureWithoutCLI } from "./feature-flags"; import { @@ -390,6 +390,7 @@ export async function initActionState( enableFileCoverageInformation, }: InitConfigInputs, userConfig: UserConfig, + repositoryRoot: string | undefined, ): Promise { const languages = await getLanguages( codeql, @@ -441,6 +442,7 @@ export async function initActionState( return { version: getActionVersion(), + repositoryRoot, analysisKinds, languages, buildMode, @@ -470,12 +472,18 @@ async function downloadCacheWithTime( codeQL: CodeQL, languages: Language[], logger: Logger, + repositoryRoot: string | undefined, ): Promise<{ trapCaches: { [language: string]: string }; trapCacheDownloadTime: number; }> { const start = performance.now(); - const trapCaches = await downloadTrapCaches(codeQL, languages, logger); + const trapCaches = await downloadTrapCaches( + codeQL, + languages, + logger, + repositoryRoot, + ); const trapCacheDownloadTime = performance.now() - start; return { trapCaches, trapCacheDownloadTime }; } @@ -723,6 +731,7 @@ export async function checkOverlayEnablement( codeql: CodeQL, features: FeatureEnablement, languages: Language[], + repositoryRoot: string | undefined, sourceRoot: string, buildMode: BuildMode | undefined, ramInput: string | undefined, @@ -752,6 +761,7 @@ export async function checkOverlayEnablement( true, codeql, languages, + repositoryRoot, sourceRoot, buildMode, gitVersion, @@ -825,7 +835,7 @@ export async function checkOverlayEnablement( `Setting overlay database mode to ${overlayDatabaseMode} ` + "with caching because we are analyzing a pull request.", ); - } else if (await isAnalyzingDefaultBranch()) { + } else if (await isAnalyzingDefaultBranch(getEnv(), repositoryRoot)) { overlayDatabaseMode = OverlayDatabaseMode.OverlayBase; logger.info( `Setting overlay database mode to ${overlayDatabaseMode} ` + @@ -841,6 +851,7 @@ export async function checkOverlayEnablement( false, codeql, languages, + repositoryRoot, sourceRoot, buildMode, gitVersion, @@ -860,6 +871,7 @@ async function validateOverlayDatabaseMode( overlayModeSetExplicitly: boolean, codeql: CodeQL, languages: Language[], + repositoryRoot: string | undefined, sourceRoot: string, buildMode: BuildMode | undefined, gitVersion: GitVersionInfo | undefined, @@ -895,8 +907,7 @@ async function validateOverlayDatabaseMode( ); return new Failure(OverlayDisabledReason.IncompatibleCodeQl); } - const gitRoot = await getGitRoot(sourceRoot); - if (gitRoot === undefined) { + if (repositoryRoot === undefined) { logger.warning( `Cannot build an ${overlayDatabaseMode} database because ` + `the source root "${sourceRoot}" is not inside a git repository. ` + @@ -904,7 +915,7 @@ async function validateOverlayDatabaseMode( ); return new Failure(OverlayDisabledReason.NoGitRoot); } - if (hasSubmodules(gitRoot)) { + if (hasSubmodules(repositoryRoot)) { if (gitVersion === undefined) { logger.warning( `Cannot build an ${overlayDatabaseMode} database because ` + @@ -1156,9 +1167,11 @@ export async function initConfig( const { logger, features } = actionState; const { tempDir } = inputs; + const repositoryRoot = await getGitRoot(inputs.sourceRoot); + const userConfig = await determineUserConfig(actionState, tempDir, inputs); - const config = await initActionState(inputs, userConfig); + const config = await initActionState(inputs, userConfig, repositoryRoot); // If Code Quality analysis is the only enabled analysis kind, then we will initialise // the database for Code Quality. That entails disabling the default queries and only @@ -1240,6 +1253,7 @@ export async function initConfig( inputs.codeql, inputs.features, config.languages, + repositoryRoot, inputs.sourceRoot, config.buildMode, inputs.ramInput, @@ -1293,6 +1307,7 @@ export async function initConfig( inputs.codeql, config.languages, logger, + repositoryRoot, ); config.trapCaches = trapCaches; config.trapCacheDownloadTime = trapCacheDownloadTime; diff --git a/src/config/action-config.ts b/src/config/action-config.ts index 10f315028..4990ba675 100644 --- a/src/config/action-config.ts +++ b/src/config/action-config.ts @@ -16,6 +16,11 @@ export interface Config { * The version of the CodeQL Action that the configuration is for. */ version: string; + /** + * The path at which the repository being analysed is checked out at, if available. + * Persisted in the CodeQL Action configuration state, so that we can consult it in later workflow steps. + */ + repositoryRoot: string | undefined; /** * Set of analysis kinds that are enabled. */ diff --git a/src/database-upload.ts b/src/database-upload.ts index 9e4339fd4..35dfd9078 100644 --- a/src/database-upload.ts +++ b/src/database-upload.ts @@ -46,7 +46,7 @@ export interface DatabaseUploadResult { } export async function cleanupAndUploadDatabases( - action: ActionState<["Logger", "FeatureFlags"]>, + action: ActionState<["ReadOnlyEnv", "Logger", "FeatureFlags"]>, repositoryNwo: RepositoryNwo, codeql: CodeQL, config: Config, @@ -81,7 +81,7 @@ export async function cleanupAndUploadDatabases( return []; } - if (!(await gitUtils.isAnalyzingDefaultBranch())) { + if (!(await gitUtils.isAnalyzingDefaultBranch(action.env, checkoutPath))) { // We only want to upload a database if we are analyzing the default branch. logger.debug("Not analyzing default branch. Skipping upload."); return []; @@ -113,7 +113,7 @@ export async function cleanupAndUploadDatabases( includeDiagnostics: false, }); bundledDbSize = fs.statSync(bundledDb).size; - const commitOid = await gitUtils.getCommitOid(checkoutPath); + const commitOid = await gitUtils.getCommitOid(action.env, checkoutPath); // Upload with manual retry logic. We disable Octokit's built-in retries // because the request body is a ReadStream, which can only be consumed // once. diff --git a/src/dependency-caching.ts b/src/dependency-caching.ts index f04d38f46..e6495f3a7 100644 --- a/src/dependency-caching.ts +++ b/src/dependency-caching.ts @@ -313,6 +313,7 @@ export async function downloadDependencyCaches( const primaryKey = await cacheKey(codeql, features, language, patterns); const restoreKeys: string[] = [ + primaryKey, await cachePrefix(codeql, features, language), ]; diff --git a/src/environment.ts b/src/environment.ts index c3aad9086..9f6107025 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -346,6 +346,13 @@ export class Env< this.changed = true; } + /** Sets all environment variables given by `vars`. */ + public setAll(vars: Record): void { + for (const [key, val] of Object.entries(vars)) { + this.set(key, val); + } + } + /** * Wrapper around `core.exportVariable` which does not call `core.exportVariable` * when running unit tests. This is important, because otherwise `core.exportVariable` diff --git a/src/git-utils.test.ts b/src/git-utils.test.ts index 64b76590a..0240a0950 100644 --- a/src/git-utils.test.ts +++ b/src/git-utils.test.ts @@ -7,35 +7,42 @@ import test from "ava"; import * as sinon from "sinon"; import * as actionsUtil from "./actions-util"; +import { ActionsEnvVars, EnvVar } from "./environment"; import * as gitUtils from "./git-utils"; -import { setupActionsVars, setupTests } from "./testing-utils"; +import { getTestEnv, setupActionsVars, setupTests } from "./testing-utils"; import { withTmpDir } from "./util"; setupTests(test); -test.serial("getRef() throws on the empty string", async (t) => { - process.env["GITHUB_REF"] = ""; - await t.throwsAsync(gitUtils.getRef); +test("getRef() throws on the empty string", async (t) => { + const env = getTestEnv({ [ActionsEnvVars.GITHUB_REF]: "" }); + await t.throwsAsync(() => gitUtils.getRef(env, "")); }); test.serial( "getRef() returns merge PR ref if GITHUB_SHA still checked out", async (t) => { await withTmpDir(async (tmpDir: string) => { - setupActionsVars(tmpDir, tmpDir); const expectedRef = "refs/pull/1/merge"; const currentSha = "a".repeat(40); - process.env["GITHUB_REF"] = expectedRef; - process.env["GITHUB_SHA"] = currentSha; + + const env = getTestEnv(); + setupActionsVars(tmpDir, tmpDir, {}, env); + env.setAll({ + [ActionsEnvVars.GITHUB_REF]: expectedRef, + [ActionsEnvVars.GITHUB_SHA]: currentSha, + }); const callback = sinon.stub(gitUtils, "getCommitOid"); - callback.withArgs(sinon.match.string, "HEAD").resolves(currentSha); + callback + .withArgs(sinon.match.any, sinon.match.string, "HEAD") + .resolves(currentSha); - const actualRef = await gitUtils.getRef(); + const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, expectedRef); t.is(callback.callCount, 1); - t.true(callback.calledOnceWith(tmpDir, "HEAD")); + t.true(callback.calledOnceWith(env, tmpDir, "HEAD")); }); }, ); @@ -44,24 +51,33 @@ test.serial( "getRef() returns merge PR ref if GITHUB_REF still checked out but sha has changed (actions checkout@v1)", async (t) => { await withTmpDir(async (tmpDir: string) => { - setupActionsVars(tmpDir, tmpDir); const expectedRef = "refs/pull/1/merge"; - process.env["GITHUB_REF"] = expectedRef; - process.env["GITHUB_SHA"] = "b".repeat(40); + const env = getTestEnv(); + setupActionsVars(tmpDir, tmpDir, {}, env); + env.setAll({ + [ActionsEnvVars.GITHUB_REF]: expectedRef, + [ActionsEnvVars.GITHUB_SHA]: "b".repeat(40), + }); const sha = "a".repeat(40); const callback = sinon.stub(gitUtils, "getCommitOid"); callback - .withArgs(sinon.match.string, "refs/remotes/pull/1/merge") + .withArgs( + sinon.match.any, + sinon.match.string, + "refs/remotes/pull/1/merge", + ) + .resolves(sha); + callback + .withArgs(sinon.match.any, sinon.match.string, "HEAD") .resolves(sha); - callback.withArgs(sinon.match.any, "HEAD").resolves(sha); - const actualRef = await gitUtils.getRef(); + const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, expectedRef); t.is(callback.callCount, 2); - t.true(callback.calledWith(tmpDir, "HEAD")); - t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge")); + t.true(callback.calledWith(env, tmpDir, "HEAD")); + t.true(callback.calledWith(env, tmpDir, "refs/remotes/pull/1/merge")); }); }, ); @@ -70,23 +86,28 @@ test.serial( "getRef() returns head PR ref if GITHUB_REF no longer checked out", async (t) => { await withTmpDir(async (tmpDir: string) => { - setupActionsVars(tmpDir, tmpDir); - process.env["GITHUB_REF"] = "refs/pull/1/merge"; - process.env["GITHUB_SHA"] = "a".repeat(40); + const env = getTestEnv(); + setupActionsVars(tmpDir, tmpDir, {}, env); + env.setAll({ + [ActionsEnvVars.GITHUB_REF]: "refs/pull/1/merge", + [ActionsEnvVars.GITHUB_SHA]: "a".repeat(40), + }); const callback = sinon.stub(gitUtils, "getCommitOid"); callback - .withArgs(tmpDir, "refs/remotes/pull/1/merge") + .withArgs(sinon.match.any, tmpDir, "refs/remotes/pull/1/merge") .resolves("a".repeat(40)); - callback.withArgs(tmpDir, "HEAD").resolves("b".repeat(40)); + callback + .withArgs(sinon.match.any, tmpDir, "HEAD") + .resolves("b".repeat(40)); callback.throws(new Error("Unexpected getCommitOid call in test.")); - const actualRef = await gitUtils.getRef(); + const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, "refs/pull/1/head"); t.is(callback.callCount, 2); - t.true(callback.calledWith(tmpDir, "refs/remotes/pull/1/merge")); - t.true(callback.calledWith(tmpDir, "HEAD")); + t.true(callback.calledWith(env, tmpDir, "refs/remotes/pull/1/merge")); + t.true(callback.calledWith(env, tmpDir, "HEAD")); }); }, ); @@ -95,7 +116,6 @@ test.serial( "getRef() returns ref provided as an input and ignores current HEAD", async (t) => { await withTmpDir(async (tmpDir: string) => { - setupActionsVars(tmpDir, tmpDir); const getAdditionalInputStub = sinon.stub( actionsUtil, "getOptionalInput", @@ -104,14 +124,22 @@ test.serial( getAdditionalInputStub.withArgs("sha").resolves("b".repeat(40)); // These values are be ignored - process.env["GITHUB_REF"] = "refs/pull/1/merge"; - process.env["GITHUB_SHA"] = "a".repeat(40); + const env = getTestEnv(); + setupActionsVars(tmpDir, tmpDir, {}, env); + env.setAll({ + [ActionsEnvVars.GITHUB_REF]: "refs/pull/1/merge", + [ActionsEnvVars.GITHUB_SHA]: "a".repeat(40), + }); const callback = sinon.stub(gitUtils, "getCommitOid"); - callback.withArgs(tmpDir, "refs/pull/1/merge").resolves("b".repeat(40)); - callback.withArgs(sinon.match.any, "HEAD").resolves("b".repeat(40)); + callback + .withArgs(sinon.match.any, tmpDir, "refs/pull/1/merge") + .resolves("b".repeat(40)); + callback + .withArgs(sinon.match.any, sinon.match.string, "HEAD") + .resolves("b".repeat(40)); - const actualRef = await gitUtils.getRef(); + const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, "refs/pull/2/merge"); // getCommitOid shouldn't be called, because the ref should be taken from the input @@ -124,14 +152,17 @@ test.serial( "getRef() returns CODE_SCANNING_REF as a fallback for GITHUB_REF", async (t) => { await withTmpDir(async (tmpDir: string) => { - setupActionsVars(tmpDir, tmpDir); const expectedRef = "refs/pull/1/HEAD"; const currentSha = "a".repeat(40); - process.env["CODE_SCANNING_REF"] = expectedRef; - process.env["GITHUB_REF"] = ""; - process.env["GITHUB_SHA"] = currentSha; + const env = getTestEnv(); + setupActionsVars(tmpDir, tmpDir, {}, env); + env.setAll({ + [EnvVar.CODE_SCANNING_REF]: expectedRef, + [ActionsEnvVars.GITHUB_REF]: "", + [ActionsEnvVars.GITHUB_SHA]: currentSha, + }); - const actualRef = await gitUtils.getRef(); + const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, expectedRef); }); }, @@ -141,14 +172,17 @@ test.serial( "getRef() returns GITHUB_REF over CODE_SCANNING_REF if both are provided", async (t) => { await withTmpDir(async (tmpDir: string) => { - setupActionsVars(tmpDir, tmpDir); const expectedRef = "refs/pull/1/merge"; const currentSha = "a".repeat(40); - process.env["CODE_SCANNING_REF"] = "refs/pull/1/HEAD"; - process.env["GITHUB_REF"] = expectedRef; - process.env["GITHUB_SHA"] = currentSha; + const env = getTestEnv(); + setupActionsVars(tmpDir, tmpDir, {}, env); + env.setAll({ + [EnvVar.CODE_SCANNING_REF]: "refs/pull/1/HEAD", + [ActionsEnvVars.GITHUB_REF]: expectedRef, + [ActionsEnvVars.GITHUB_SHA]: currentSha, + }); - const actualRef = await gitUtils.getRef(); + const actualRef = await gitUtils.getRef(env, tmpDir); t.deepEqual(actualRef, expectedRef); }); }, @@ -158,7 +192,9 @@ test.serial( "getRef() throws an error if only `ref` is provided as an input", async (t) => { await withTmpDir(async (tmpDir: string) => { - setupActionsVars(tmpDir, tmpDir); + const env = getTestEnv(); + setupActionsVars(tmpDir, tmpDir, {}, env); + const getAdditionalInputStub = sinon.stub( actionsUtil, "getOptionalInput", @@ -167,7 +203,7 @@ test.serial( await t.throwsAsync( async () => { - await gitUtils.getRef(); + await gitUtils.getRef(env, tmpDir); }, { instanceOf: Error, @@ -183,8 +219,12 @@ test.serial( "getRef() throws an error if only `sha` is provided as an input", async (t) => { await withTmpDir(async (tmpDir: string) => { - setupActionsVars(tmpDir, tmpDir); - process.env["GITHUB_WORKSPACE"] = "/tmp"; + const env = getTestEnv(); + setupActionsVars(tmpDir, tmpDir, {}, env); + env.setAll({ + [ActionsEnvVars.GITHUB_WORKSPACE]: "/tmp", + }); + const getAdditionalInputStub = sinon.stub( actionsUtil, "getOptionalInput", @@ -193,7 +233,7 @@ test.serial( await t.throwsAsync( async () => { - await gitUtils.getRef(); + await gitUtils.getRef(env, tmpDir); }, { instanceOf: Error, @@ -206,13 +246,16 @@ test.serial( ); test.serial("isAnalyzingDefaultBranch()", async (t) => { - process.env["GITHUB_EVENT_NAME"] = "push"; - process.env["CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH"] = "true"; - t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(), true); - process.env["CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH"] = "false"; + const env = getTestEnv({ + [ActionsEnvVars.GITHUB_EVENT_NAME]: "push", + CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH: "true", + }); + t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(env, ""), true); + + env.set("CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH", "false"); await withTmpDir(async (tmpDir) => { - setupActionsVars(tmpDir, tmpDir); + setupActionsVars(tmpDir, tmpDir, {}, env); const envFile = path.join(tmpDir, "event.json"); fs.writeFileSync( envFile, @@ -222,17 +265,17 @@ test.serial("isAnalyzingDefaultBranch()", async (t) => { }, }), ); - process.env["GITHUB_EVENT_PATH"] = envFile; + env.set(ActionsEnvVars.GITHUB_EVENT_PATH, envFile); - process.env["GITHUB_REF"] = "main"; - process.env["GITHUB_SHA"] = "1234"; - t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(), true); + env.set(ActionsEnvVars.GITHUB_REF, "main"); + env.set(ActionsEnvVars.GITHUB_SHA, "1234"); + t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(env, tmpDir), true); - process.env["GITHUB_REF"] = "refs/heads/main"; - t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(), true); + env.set(ActionsEnvVars.GITHUB_REF, "refs/heads/main"); + t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(env, tmpDir), true); - process.env["GITHUB_REF"] = "feature"; - t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(), false); + env.set(ActionsEnvVars.GITHUB_REF, "feature"); + t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(env, tmpDir), false); fs.writeFileSync( envFile, @@ -240,9 +283,9 @@ test.serial("isAnalyzingDefaultBranch()", async (t) => { schedule: "0 0 * * *", }), ); - process.env["GITHUB_EVENT_NAME"] = "schedule"; - process.env["GITHUB_REF"] = "refs/heads/main"; - t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(), true); + env.set(ActionsEnvVars.GITHUB_EVENT_NAME, "schedule"); + env.set(ActionsEnvVars.GITHUB_REF, "refs/heads/main"); + t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(env, tmpDir), true); const getAdditionalInputStub = sinon.stub(actionsUtil, "getOptionalInput"); getAdditionalInputStub @@ -251,9 +294,9 @@ test.serial("isAnalyzingDefaultBranch()", async (t) => { getAdditionalInputStub .withArgs("sha") .resolves("0000000000000000000000000000000000000000"); - process.env["GITHUB_EVENT_NAME"] = "schedule"; - process.env["GITHUB_REF"] = "refs/heads/main"; - t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(), false); + env.set(ActionsEnvVars.GITHUB_EVENT_NAME, "schedule"); + env.set(ActionsEnvVars.GITHUB_REF, "refs/heads/main"); + t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(env, tmpDir), false); }); }); diff --git a/src/git-utils.ts b/src/git-utils.ts index 0f5bf52a4..9045a7c3d 100644 --- a/src/git-utils.ts +++ b/src/git-utils.ts @@ -13,6 +13,7 @@ import { getWorkflowEvent, getWorkflowEventName, } from "./actions-util"; +import { ActionsEnvVars, EnvVar, type ReadOnlyEnv } from "./environment"; import { ConfigurationError, getRequiredEnvParam } from "./util"; /** @@ -101,6 +102,7 @@ export const runGitCommand = async function ( * Gets the SHA of the commit that is currently checked out. */ export const getCommitOid = async function ( + env: ReadOnlyEnv, checkoutPath: string, ref = "HEAD", ): Promise { @@ -119,7 +121,9 @@ export const getCommitOid = async function ( ); return stdout.trim(); } catch { - return getOptionalInput("sha") || getRequiredEnvParam("GITHUB_SHA"); + return ( + getOptionalInput("sha") || env.getRequired(ActionsEnvVars.GITHUB_SHA) + ); } }; @@ -241,7 +245,7 @@ export const getGitRoot = async function ( ["rev-parse", "--show-toplevel"], `Cannot find Git repository root from the source root ${sourceRoot}.`, ); - return stdout.trim(); + return path.resolve(stdout.trim()); } catch { // Errors are already logged by runGitCommand() return undefined; @@ -314,18 +318,18 @@ export const getFileOidsUnderPath = async function ( return fileOidMap; }; -function getRefFromEnv(): string { +function getRefFromEnv(env: ReadOnlyEnv): string { // To workaround a limitation of Actions dynamic workflows not setting // the GITHUB_REF in some cases, we accept also the ref within the // CODE_SCANNING_REF variable. When possible, however, we prefer to use // the GITHUB_REF as that is a protected variable and cannot be overwritten. let refEnv: string; try { - refEnv = getRequiredEnvParam("GITHUB_REF"); + refEnv = env.getRequired(ActionsEnvVars.GITHUB_REF); } catch (e) { // If the GITHUB_REF is not set, we try to rescue by getting the // CODE_SCANNING_REF. - const maybeRef = process.env["CODE_SCANNING_REF"]; + const maybeRef = env.getOptional(EnvVar.CODE_SCANNING_REF); if (maybeRef === undefined || maybeRef.length === 0) { throw e; } @@ -337,15 +341,16 @@ function getRefFromEnv(): string { /** * Get the ref currently being analyzed. */ -export async function getRef(): Promise { +export async function getRef( + env: ReadOnlyEnv, + checkoutPath: string | undefined, +): Promise { // Will be in the form "refs/heads/master" on a push event // or in the form "refs/pull/N/merge" on a pull_request event const refInput = getOptionalInput("ref"); const shaInput = getOptionalInput("sha"); - const checkoutPath = - getOptionalInput("checkout_path") || - getOptionalInput("source-root") || - getRequiredEnvParam("GITHUB_WORKSPACE"); + checkoutPath = + checkoutPath ?? env.getRequired(ActionsEnvVars.GITHUB_WORKSPACE); const hasRefInput = !!refInput; const hasShaInput = !!shaInput; @@ -356,8 +361,8 @@ export async function getRef(): Promise { ); } - const ref = refInput || getRefFromEnv(); - const sha = shaInput || getRequiredEnvParam("GITHUB_SHA"); + const ref = refInput || getRefFromEnv(env); + const sha = shaInput || env.getRequired(ActionsEnvVars.GITHUB_SHA); // If the ref is a user-provided input, we have to skip logic // and assume that it is really where they want to upload the results. @@ -374,7 +379,7 @@ export async function getRef(): Promise { return ref; } - const head = await getCommitOid(checkoutPath, "HEAD"); + const head = await getCommitOid(env, checkoutPath, "HEAD"); // in actions/checkout@v2+ we can check if git rev-parse HEAD == GITHUB_SHA // in actions/checkout@v1 this may not be true as it checks out the repository @@ -384,6 +389,7 @@ export async function getRef(): Promise { const hasChangedRef = sha !== head && (await getCommitOid( + env, checkoutPath, ref.replace(/^refs\/pull\//, "refs/remotes/pull/"), )) !== head; @@ -410,20 +416,23 @@ function removeRefsHeadsPrefix(ref: string): string { * environment variable can be set in cases where repository information might not be available, for * example dynamic workflows. */ -export async function isAnalyzingDefaultBranch(): Promise { - if (process.env.CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH === "true") { +export async function isAnalyzingDefaultBranch( + env: ReadOnlyEnv, + checkoutPath: string | undefined, +): Promise { + if (env.getOptional("CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH") === "true") { return true; } // Get the current ref and trim and refs/heads/ prefix - let currentRef = await getRef(); + let currentRef = await getRef(env, checkoutPath); currentRef = removeRefsHeadsPrefix(currentRef); - const event = getWorkflowEvent(); + const event = getWorkflowEvent(env); let defaultBranch = event?.repository?.default_branch; - if (getWorkflowEventName() === "schedule") { - defaultBranch = removeRefsHeadsPrefix(getRefFromEnv()); + if (getWorkflowEventName(env) === "schedule") { + defaultBranch = removeRefsHeadsPrefix(getRefFromEnv(env)); } return currentRef === defaultBranch; diff --git a/src/init-action-post-helper.ts b/src/init-action-post-helper.ts index 46d7c77c4..0058bb98f 100644 --- a/src/init-action-post-helper.ts +++ b/src/init-action-post-helper.ts @@ -51,7 +51,7 @@ import { } from "./util"; import { getCategoryInputOrThrow, - getCheckoutPathInputOrThrow, + getRepositoryRootOrThrow, getUploadInputOrThrow, getWorkflow, } from "./workflow"; @@ -156,7 +156,15 @@ async function prepareFailedSarif( }); } const category = getCategoryInputOrThrow(workflow, jobName, matrix); - const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix); + + // Try to determine the path at which the repository that we failed to analyse is checked out at. + // We need this to relativise the paths in the SARIF. + const checkoutPath = getRepositoryRootOrThrow( + workflow, + jobName, + matrix, + config, + ); const result = await generateFailedSarif( logger, diff --git a/src/init-action-post.ts b/src/init-action-post.ts index d7e00081b..071137f54 100644 --- a/src/init-action-post.ts +++ b/src/init-action-post.ts @@ -117,7 +117,10 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) { // do this under these circumstances to avoid slowing down analyses for PRs // and where caching may not be enabled. if ( - (await gitUtils.isAnalyzingDefaultBranch()) && + (await gitUtils.isAnalyzingDefaultBranch( + action.env, + config.repositoryRoot, + )) && hasConfigKey(config, "dependencyCachingEnabled") && config.dependencyCachingEnabled !== CachingKind.None ) { diff --git a/src/overlay/caching.ts b/src/overlay/caching.ts index d24662678..02a3534bd 100644 --- a/src/overlay/caching.ts +++ b/src/overlay/caching.ts @@ -15,6 +15,7 @@ import { CleanupLevel, getBaseDatabaseOidsFilePath, getCodeQLDatabasePath, + getEnv, getErrorMessage, isInTestMode, tryGetFolderBytes, @@ -290,7 +291,7 @@ export async function downloadOverlayBaseDatabaseFromCache( actionsCache.restoreCache( [dbLocation], cacheRestoreKeyPrefix, - undefined, + [cacheRestoreKeyPrefix], { // Azure SDK download (which is the default) uses 128MB segments; see // https://github.com/actions/toolkit/blob/main/packages/cache/README.md. @@ -377,7 +378,7 @@ export async function getCacheSaveKey( `Failed to get workflow run ID or attempt ID. Reason: ${getErrorMessage(e)}`, ); } - const sha = await getCommitOid(checkoutPath); + const sha = await getCommitOid(getEnv(), checkoutPath); const restoreKeyPrefix = await getCacheRestoreKeyPrefix( config, codeQlVersion, diff --git a/src/overlay/status.ts b/src/overlay/status.ts index 3acf38296..1a321af42 100644 --- a/src/overlay/status.ts +++ b/src/overlay/status.ts @@ -130,7 +130,7 @@ export async function getOverlayStatus( await fs.promises.mkdir(path.dirname(statusFile), { recursive: true }); const foundKey = await waitForResultWithTimeLimit( MAX_CACHE_OPERATION_MS, - actionsCache.restoreCache([statusFile], cacheKey), + actionsCache.restoreCache([statusFile], cacheKey, [cacheKey]), () => { logger.warning("Timed out restoring overlay status from cache."); }, diff --git a/src/repository.ts b/src/repository.ts index f1e7f369b..652521fe3 100644 --- a/src/repository.ts +++ b/src/repository.ts @@ -6,6 +6,14 @@ export interface RepositoryNwo { repo: string; } +/** An approximation of what a repository NWO string looks like. */ +export type RepositoryNwoStr = `${string}/${string}`; + +/** A basic check that `val` looks like a `RepositoryNwoStr`. */ +export function isRepositoryNwoStr(val: string): val is RepositoryNwoStr { + return val.includes("/"); +} + /** * Get the repository name with owner from the environment variable * `GITHUB_REPOSITORY`. diff --git a/src/setup-codeql.test.ts b/src/setup-codeql.test.ts index 70a459d93..921a112e5 100644 --- a/src/setup-codeql.test.ts +++ b/src/setup-codeql.test.ts @@ -126,24 +126,6 @@ test.serial("convert to semver", (t) => { } }); -test.serial("getCodeQLActionRepository", (t) => { - const logger = getRunnerLogger(true); - - initializeEnvironment("1.2.3"); - - // isRunningLocalAction() === true - delete process.env["GITHUB_ACTION_REPOSITORY"]; - process.env["RUNNER_TEMP"] = path.dirname(__dirname); - const repoLocalRunner = setupCodeql.getCodeQLActionRepository(logger); - t.deepEqual(repoLocalRunner, "github/codeql-action"); - - // isRunningLocalAction() === false - sinon.stub(actionsUtil, "isRunningLocalAction").returns(false); - process.env["GITHUB_ACTION_REPOSITORY"] = "xxx/yyy"; - const repoEnv = setupCodeql.getCodeQLActionRepository(logger); - t.deepEqual(repoEnv, "xxx/yyy"); -}); - test.serial( "getCodeQLSource sets CLI version for a semver tagged bundle", async (t) => { diff --git a/src/setup-codeql.ts b/src/setup-codeql.ts index daaba174c..07666d630 100644 --- a/src/setup-codeql.ts +++ b/src/setup-codeql.ts @@ -4,7 +4,6 @@ import * as path from "path"; import { performance } from "perf_hooks"; import * as toolcache from "@actions/tool-cache"; -import { default as deepEqual } from "fast-deep-equal"; import * as semver from "semver"; import { v4 as uuidV4 } from "uuid"; @@ -13,7 +12,6 @@ import { isAnalyzingPullRequest, isDynamicWorkflow, isGitHubHostedRunner, - isRunningLocalAction, } from "./actions-util"; import * as api from "./api-client"; import { @@ -44,6 +42,7 @@ import { logPerLanguageBundleFallback, } from "./per-language-bundles"; import { getBundlePlatform } from "./platform"; +import { getCodeQLAssetDownloadURL } from "./setup/repository"; import * as tar from "./tar"; import { deleteToolcacheBundles, @@ -65,7 +64,6 @@ export enum ToolsSource { Download = "DOWNLOAD", } -const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action"; const CODEQL_NIGHTLIES_REPOSITORY_OWNER = "dsp-testing"; const CODEQL_NIGHTLIES_REPOSITORY_NAME = "codeql-cli-nightlies"; @@ -73,75 +71,6 @@ const CODEQL_BUNDLE_VERSION_ALIAS: string[] = ["linked", "latest"]; const CODEQL_NIGHTLY_TOOLS_INPUTS = ["nightly", "nightly-latest"]; const CODEQL_TOOLCACHE_INPUT = "toolcache"; -export function getCodeQLActionRepository(logger: Logger): string { - if (isRunningLocalAction()) { - // This handles the case where the Action does not come from an Action repository, - // e.g. our integration tests which use the Action code from the current checkout. - // In these cases, the GITHUB_ACTION_REPOSITORY environment variable is not set. - logger.info( - "The CodeQL Action is checked out locally. Using the default CodeQL Action repository.", - ); - return CODEQL_DEFAULT_ACTION_REPOSITORY; - } - - return util.getRequiredEnvParam("GITHUB_ACTION_REPOSITORY"); -} - -async function getCodeQLBundleDownloadURL( - tagName: string, - apiDetails: api.GitHubApiDetails, - codeQLBundleName: string, - logger: Logger, -): Promise { - const codeQLActionRepository = getCodeQLActionRepository(logger); - const potentialDownloadSources = [ - // This GitHub instance, and this Action. - [apiDetails.url, codeQLActionRepository], - // This GitHub instance, and the canonical Action. - [apiDetails.url, CODEQL_DEFAULT_ACTION_REPOSITORY], - // GitHub.com, and the canonical Action. - [util.GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY], - ]; - // We now filter out any duplicates. - // Duplicates will happen either because the GitHub instance is GitHub.com, or because the Action is not a fork. - const uniqueDownloadSources = potentialDownloadSources.filter( - (source, index, self) => { - return !self.slice(0, index).some((other) => deepEqual(source, other)); - }, - ); - for (const downloadSource of uniqueDownloadSources) { - const [apiURL, repository] = downloadSource; - // If we've reached the final case, short-circuit the API check since we know the bundle exists and is public. - if ( - apiURL === util.GITHUB_DOTCOM_URL && - repository === CODEQL_DEFAULT_ACTION_REPOSITORY - ) { - break; - } - const [repositoryOwner, repositoryName] = repository.split("/"); - try { - const release = await api.getApiClient().rest.repos.getReleaseByTag({ - owner: repositoryOwner, - repo: repositoryName, - tag: tagName, - }); - for (const asset of release.data.assets) { - if (asset.name === codeQLBundleName) { - logger.info( - `Found CodeQL bundle ${codeQLBundleName} in ${repository} on ${apiURL} with URL ${asset.url}.`, - ); - return asset.url; - } - } - } catch (e) { - logger.info( - `Looked for CodeQL bundle ${codeQLBundleName} in ${repository} on ${apiURL} but got error ${e}.`, - ); - } - } - return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${codeQLBundleName}`; -} - function tryGetBundleVersionFromTagName( tagName: string, logger: Logger, @@ -720,9 +649,10 @@ export async function getCodeQLSource( ? "zstd" : "gzip"; + const action = { env: getEnv(), logger }; const platform = getBundlePlatform(); const perLanguageBundleLanguage = await getPerLanguageBundleLanguage( - { env: getEnv(), features, logger }, + { ...action, features }, { rawLanguages, otherLanguagePacksReason, @@ -735,11 +665,11 @@ export async function getCodeQLSource( // Resolves the combined or per-language bundle URL for the requested release. const resolveBundleURL = (language?: BuiltInLanguage) => - getCodeQLBundleDownloadURL( - bundleTagName, + getCodeQLAssetDownloadURL( + action, apiDetails, + bundleTagName, getCodeQLBundleName(compressionMethod, platform, language), - logger, ); const combinedBundleURL = await resolveBundleURL(); diff --git a/src/setup/repository.test.ts b/src/setup/repository.test.ts new file mode 100644 index 000000000..d1c6d034c --- /dev/null +++ b/src/setup/repository.test.ts @@ -0,0 +1,35 @@ +import * as path from "path"; + +import test from "ava"; +import * as sinon from "sinon"; + +import * as actionsUtil from "../actions-util"; +import { ActionsEnvVars } from "../environment"; +import { callee, getTestEnv, setupTests } from "../testing-utils"; +import { initializeEnvironment } from "../util"; + +import { getCodeQLActionRepository } from "./repository"; + +setupTests(test); + +test.serial("getCodeQLActionRepository", async (t) => { + const initialEnv = getTestEnv({ + [ActionsEnvVars.RUNNER_TEMP]: path.dirname(__dirname), + }); + initializeEnvironment("1.2.3", initialEnv); + + const target = callee(getCodeQLActionRepository) + .withArgs() + .withEnv(initialEnv); + + // isRunningLocalAction() === true + await target.passes(t.deepEqual, "github/codeql-action"); + + // isRunningLocalAction() === false + sinon.stub(actionsUtil, "isRunningLocalAction").returns(false); + await target + .withEnv((env) => { + env.set(ActionsEnvVars.GITHUB_ACTION_REPOSITORY, "xxx/yyy"); + }) + .passes(t.deepEqual, "xxx/yyy"); +}); diff --git a/src/setup/repository.ts b/src/setup/repository.ts new file mode 100644 index 000000000..6da0ea3e9 --- /dev/null +++ b/src/setup/repository.ts @@ -0,0 +1,158 @@ +import { ActionState } from "../action-common"; +import { isRunningLocalAction } from "../actions-util"; +import * as api from "../api-client"; +import { ActionsEnvVars } from "../environment"; +import { + isRepositoryNwoStr, + parseRepositoryNwo, + type RepositoryNwoStr, +} from "../repository"; +import { GITHUB_DOTCOM_URL, type InstanceURL } from "../util"; + +/** The NWO of the standard CodeQL Action repository. */ +export const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action"; + +/** + * Retrieves the NWO of the repository that the CodeQL Action is loaded from. + * Typically, this will be `github/codeql-action`, but it may be something else for + * forks of the Action or in environments other than GitHub.com. + * + * If this function detects that we are running the Action locally (e.g. in tests), + * then we default to `CODEQL_DEFAULT_ACTION_REPOSITORY`. + */ +export function getCodeQLActionRepository( + action: ActionState<["ReadOnlyEnv", "Logger"]>, +): RepositoryNwoStr { + if (isRunningLocalAction(action.env)) { + // This handles the case where the Action does not come from an Action repository, + // e.g. our integration tests which use the Action code from the current checkout. + // In these cases, the GITHUB_ACTION_REPOSITORY environment variable is not set. + action.logger.info( + "The CodeQL Action is checked out locally. Using the default CodeQL Action repository.", + ); + return CODEQL_DEFAULT_ACTION_REPOSITORY; + } + + const actionRepository = action.env.getRequired( + ActionsEnvVars.GITHUB_ACTION_REPOSITORY, + ); + + if (isRepositoryNwoStr(actionRepository)) { + return actionRepository; + } + + throw new Error( + `The value of '${ActionsEnvVars.GITHUB_ACTION_REPOSITORY}' is '${actionRepository}', which does not match the expected 'owner/repo' format.`, + ); +} + +/**A download source is a pair of strings. */ +export type DownloadSource = [InstanceURL, RepositoryNwoStr]; + +/** GitHub.com, and the canonical Action. */ +export const DEFAULT_DOWNLOAD_SOURCE: DownloadSource = [ + GITHUB_DOTCOM_URL, + CODEQL_DEFAULT_ACTION_REPOSITORY, +]; + +/** Decides if the two provided download sources are the same. */ +const isSameDownloadSource = ( + [srcUrl, srcRepo]: DownloadSource, + [otherUrl, otherRepo]: DownloadSource, +) => { + return srcUrl === otherUrl && srcRepo === otherRepo; +}; + +/** A download URL is represented as a string. */ +export type DownloadURL = string; + +/** Gets the default GitHub.com download URL for `assetName` in a release tagged `tagName`. */ +export function getDefaultDotcomDownloadURL( + tagName: string, + assetName: string, +): DownloadURL { + return `${GITHUB_DOTCOM_URL}/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${assetName}`; +} + +/** Enumerates log-friendly descriptions of different kinds of assets we might look for in releases. */ +export type ReleaseAssetKind = "CodeQL bundle" | "private registry proxy"; + +/** + * Tries to find a download URL for `assetName` in a release tagged with `tagName`. + * + * Depending on where and how the CodeQL Action is running, we may be using different `apiDetails` and there may be + * different options for where to source CodeQL releases from. + * + * This function either returns the download URL for the asset for the first release we find, or + * defaults to the assumed download URL for the asset on the default CodeQL Action repository on GitHub.com. + * In the latter case, this function does not guarantee that the asset actually exists. + * + * @param action The Action state. + * @param apiDetails The details of the GitHub API in use. + * @param tagName The name of the release tag we want to obtain the asset from. + * @param assetName The name of the asset we should look for in the release. + * @param [assetKind="CodeQL bundle"] The kind of asset we are looking for to show in log messages. + * @returns A URL that we can use to download the asset. + */ +export async function getCodeQLAssetDownloadURL( + action: ActionState<["ReadOnlyEnv", "Logger"]>, + apiDetails: api.GitHubApiDetails, + tagName: string, + assetName: string, + assetKind: ReleaseAssetKind = "CodeQL bundle", +): Promise { + const codeQLActionRepository = getCodeQLActionRepository(action); + + const potentialDownloadSources: DownloadSource[] = [ + // This GitHub instance, and this Action. + [apiDetails.url, codeQLActionRepository], + // This GitHub instance, and the canonical Action. + [apiDetails.url, CODEQL_DEFAULT_ACTION_REPOSITORY], + // GitHub.com, and the canonical Action. + DEFAULT_DOWNLOAD_SOURCE, + ]; + + // We now filter out any duplicates. + // Duplicates will happen either because the GitHub instance is GitHub.com, or because the Action is not a fork. + const uniqueDownloadSources = potentialDownloadSources.filter( + (source, index, self) => { + return !self + .slice(0, index) + .some((other) => isSameDownloadSource(source, other)); + }, + ); + + for (const [instanceURL, repository] of uniqueDownloadSources) { + // If we've reached the final case, short-circuit the API check since we know the asset exists and is public. + if ( + isSameDownloadSource(DEFAULT_DOWNLOAD_SOURCE, [instanceURL, repository]) + ) { + break; + } + + const { owner: repositoryOwner, repo: repositoryName } = + parseRepositoryNwo(repository); + try { + const release = await api.getApiClient().rest.repos.getReleaseByTag({ + owner: repositoryOwner, + repo: repositoryName, + tag: tagName, + }); + + for (const asset of release.data.assets) { + if (asset.name === assetName) { + action.logger.info( + `Found ${assetKind} ${assetName} in ${repository} on ${instanceURL} with URL ${asset.url}.`, + ); + return asset.url; + } + } + } catch (e) { + action.logger.info( + `Looked for ${assetKind} ${assetName} in ${repository} on ${instanceURL} but got error ${e}.`, + ); + } + } + + return getDefaultDotcomDownloadURL(tagName, assetName); +} diff --git a/src/start-proxy-action.ts b/src/start-proxy-action.ts index bc3351da5..ad1a2e143 100644 --- a/src/start-proxy-action.ts +++ b/src/start-proxy-action.ts @@ -10,7 +10,7 @@ import { runInActions, } from "./action-common"; import * as actionsUtil from "./actions-util"; -import { getGitHubVersion } from "./api-client"; +import { getApiDetails, getGitHubVersion } from "./api-client"; import { FeatureEnablement, initFeatures } from "./feature-flags"; import { BuiltInLanguage, parseBuiltInLanguage } from "./languages"; import { Logger } from "./logging"; @@ -104,9 +104,12 @@ async function run(action: ActionState<["Base", "Logger", "Env", "Actions"]>) { // Start the Proxy const actionWithFeatures = extendActionState(action, { features }); - const proxyBin = await getProxyBinaryPath(actionWithFeatures); + const proxyBin = await getProxyBinaryPath( + actionWithFeatures, + getApiDetails(action.env), + ); const proxyInfo = await startProxy( - proxyBin, + proxyBin.path, proxyConfig, proxyLogFilePath, logger, @@ -122,6 +125,7 @@ async function run(action: ActionState<["Base", "Logger", "Env", "Actions"]>) { languages: language === undefined ? undefined : [language], }, proxyConfig.all_credentials.map((c) => c.type), + { proxy_version: proxyBin.version }, logger, ); } catch (unwrappedError) { diff --git a/src/start-proxy.test.ts b/src/start-proxy.test.ts index bd2489713..78704a38a 100644 --- a/src/start-proxy.test.ts +++ b/src/start-proxy.test.ts @@ -1,22 +1,24 @@ import * as filepath from "path"; -import * as core from "@actions/core"; import * as toolcache from "@actions/tool-cache"; import test, { ExecutionContext } from "ava"; import sinon from "sinon"; import { ActionState } from "./action-common"; +import * as actionsUtil from "./actions-util"; import * as apiClient from "./api-client"; import * as defaults from "./defaults.json"; +import { ActionsEnvVars } from "./environment"; import { setUpFeatureFlagTests } from "./feature-flags/testing-util"; import { UnvalidatedObject, validateSchema } from "./json"; import { makeFromSchema } from "./json/testing-util"; import { BuiltInLanguage } from "./languages"; import { getRunnerLogger, Logger } from "./logging"; import { BundlePlatform, getBundlePlatform } from "./platform"; +import * as repository from "./setup/repository"; import * as startProxyExports from "./start-proxy"; -import * as statusReport from "./status-report"; import { + addSinonAssertions, assertNotLogged, checkExpectedLogMessages, createFeatures, @@ -24,97 +26,14 @@ import { makeMacro, makeTestToken, RecordingLogger, + SAMPLE_DOTCOM_API_DETAILS, setupTests, withRecordingLoggerAsync, } from "./testing-utils"; -import { - ConfigurationError, - GitHubVariant, - GitHubVersion, - withTmpDir, -} from "./util"; +import { GitHubVariant, GitHubVersion, withTmpDir } from "./util"; setupTests(test); -const sendFailedStatusReportTest = makeMacro({ - exec: async ( - t: ExecutionContext, - err: Error, - expectedMessage: string, - expectedStatus: statusReport.ActionStatus = "failure", - ) => { - const now = new Date(); - - // Override core.setFailed to avoid it setting the program's exit code - sinon.stub(core, "setFailed").returns(); - - const createStatusReportBase = sinon.stub( - statusReport, - "createStatusReportBase", - ); - createStatusReportBase.resolves(undefined); - - await withRecordingLoggerAsync(async (logger) => { - await startProxyExports.sendFailedStatusReport( - logger, - now, - undefined, - err, - ); - - // Check that the stub has been called exactly once, with the expected arguments, - // but not with the message from the error. - sinon.assert.calledOnceWithExactly( - createStatusReportBase, - statusReport.ActionName.StartProxy, - expectedStatus, - now, - sinon.match.any, - sinon.match.any, - sinon.match.any, - expectedMessage, - ); - t.false( - createStatusReportBase.calledWith( - statusReport.ActionName.StartProxy, - expectedStatus, - now, - sinon.match.any, - sinon.match.any, - sinon.match.any, - sinon.match((msg: string) => msg.includes(err.message)), - ), - "createStatusReportBase was called with the error message", - ); - }); - }, - - title: (providedTitle = "") => `sendFailedStatusReport - ${providedTitle}`, -}); - -sendFailedStatusReportTest.serial( - "reports generic error message for non-StartProxyError error", - new Error("Something went wrong today"), - "Error from start-proxy Action omitted (Error).", -); - -sendFailedStatusReportTest.serial( - "reports generic error message for non-StartProxyError error with safe error message", - new Error( - startProxyExports.getStartProxyErrorMessage( - startProxyExports.StartProxyErrorType.DownloadFailed, - ), - ), - "Error from start-proxy Action omitted (Error).", -); - -sendFailedStatusReportTest.serial( - "reports generic error message for ConfigurationError error", - new ConfigurationError("Something went wrong today"), - "Error from start-proxy Action omitted (ConfigurationError).", - "user-error", -); - const toEncodedJSON = (data: any) => Buffer.from(JSON.stringify(data)).toString("base64"); @@ -705,18 +624,29 @@ function mockGetApiClient(endpoints: any) { type ReleaseAssets = Array<{ name: string; url?: string }>; -function mockGetReleaseByTag(assets?: ReleaseAssets) { +function mockGetReleaseByTag(expectedTag?: string, assets?: ReleaseAssets) { const getReleaseByTag = assets === undefined ? sinon.stub().rejects() - : sinon.stub().resolves({ - status: 200, - data: { assets }, - headers: {}, - url: "GET /repos/:owner/:repo/releases/tags/:tag", + : sinon.stub().callsFake(({ tag }) => { + if (tag === expectedTag) { + return { + status: 200, + data: { assets }, + headers: {}, + url: "GET /repos/:owner/:repo/releases/tags/:tag", + }; + } else { + return { + status: 404, + }; + } }); - return mockGetApiClient({ repos: { getReleaseByTag } }); + return { + getReleaseByTag, + getApiClient: mockGetApiClient({ repos: { getReleaseByTag } }), + }; } function mockOfflineFeatures(tempDir: string, logger: Logger) { @@ -751,25 +681,33 @@ test.serial( logger, features, }); - const info = await startProxyExports.getDownloadUrl(state); - t.is(info.version, startProxyExports.UPDATEJOB_PROXY_VERSION); - t.is( - info.url, - startProxyExports.getFallbackUrl( - startProxyExports.getProxyPackage(BundlePlatform.Linux64), - ), + // Stub this to always return `true` so we get the default repo for the tests. + sinon.stub(actionsUtil, "isRunningLocalAction").returns(true); + + const info = await startProxyExports.getDownloadUrl( + state, + SAMPLE_DOTCOM_API_DETAILS, ); t.true( logger.hasMessage(`Unsupported platform android on architecture ppc`), ); + + t.is(info.version, defaults.cliVersion); + t.is( + info.url, + repository.getDefaultDotcomDownloadURL( + defaults.bundleVersion, + startProxyExports.getProxyPackage(BundlePlatform.Linux64), + ), + ); }); }, ); test.serial( - "getDownloadUrl returns fallback when `getReleaseByVersion` rejects", + "getDownloadUrl returns default bundle URL for linked version", async (t) => { const logger = new RecordingLogger(); mockGetReleaseByTag(); @@ -777,12 +715,20 @@ test.serial( await withTmpDir(async (tempDir) => { const features = mockOfflineFeatures(tempDir, logger); const state = initAllState({ logger, features }); - const info = await startProxyExports.getDownloadUrl(state); - t.is(info.version, startProxyExports.UPDATEJOB_PROXY_VERSION); + // Stub this to always return `true` so we get the default repo for the tests. + sinon.stub(actionsUtil, "isRunningLocalAction").returns(true); + + const info = await startProxyExports.getDownloadUrl( + state, + SAMPLE_DOTCOM_API_DETAILS, + ); + + t.is(info.version, defaults.cliVersion); t.is( info.url, - startProxyExports.getFallbackUrl( + repository.getDefaultDotcomDownloadURL( + defaults.bundleVersion, startProxyExports.getProxyPackage(getTestPlatform(state)), ), ); @@ -791,7 +737,7 @@ test.serial( ); test.serial( - "getDownloadUrl returns fallback when there's no matching release asset", + "getDownloadUrl doesn't check that the default asset exists", async (t) => { const logger = new RecordingLogger(); const testAssets = [[], [{ name: "foo" }]]; @@ -800,19 +746,28 @@ test.serial( const features = mockOfflineFeatures(tempDir, logger); const state = initAllState({ logger, features }); - for (const assets of testAssets) { - const stub = mockGetReleaseByTag(assets); - const info = await startProxyExports.getDownloadUrl(state); + // Stub this to always return `true` so we get the default repo for the tests. + sinon.stub(actionsUtil, "isRunningLocalAction").returns(true); - t.is(info.version, startProxyExports.UPDATEJOB_PROXY_VERSION); + for (const assets of testAssets) { + const stubs = mockGetReleaseByTag(defaults.bundleVersion, assets); + const info = await startProxyExports.getDownloadUrl( + state, + SAMPLE_DOTCOM_API_DETAILS, + ); + + t.is(info.version, defaults.cliVersion); t.is( info.url, - startProxyExports.getFallbackUrl( + repository.getDefaultDotcomDownloadURL( + defaults.bundleVersion, startProxyExports.getProxyPackage(getTestPlatform(state)), ), ); - stub.restore(); + // mockGetReleaseByTag stubs the global getApiClient; since we are calling + // that in a loop, we need to manually restore it here + stubs.getApiClient.restore(); } }); }, @@ -828,11 +783,22 @@ test.serial("getDownloadUrl returns matching release asset", async (t) => { url: "url-we-want", }, ]; - mockGetReleaseByTag(assets); + const stubs = mockGetReleaseByTag(defaults.bundleVersion, assets); await withTmpDir(async (tempDir) => { + state.env.set(ActionsEnvVars.RUNNER_TEMP, tempDir); const features = mockOfflineFeatures(tempDir, logger); - const info = await startProxyExports.getDownloadUrl({ ...state, features }); + + // Stub this to always return `false` so we force `getCodeQLAssetDownloadURL` to use the (mocked) API. + sinon.stub(actionsUtil, "isRunningLocalAction").returns(false); + state.env.set(ActionsEnvVars.GITHUB_ACTION_REPOSITORY, "test/repo"); + + const info = await startProxyExports.getDownloadUrl( + { ...state, features }, + SAMPLE_DOTCOM_API_DETAILS, + ); + + t.is(stubs.getReleaseByTag.callCount, 1); t.is(info.version, defaults.cliVersion); t.is(info.url, "url-we-want"); @@ -965,16 +931,21 @@ test.serial( const toolcachePath = "/path/to/proxy/dir"; sinon.stub(toolcache, "find").returns(toolcachePath); + // Stub this to always return `true` so we get the default repo for the tests. + sinon.stub(actionsUtil, "isRunningLocalAction").returns(true); + const features = mockOfflineFeatures(tempDir, logger); - const path = await startProxyExports.getProxyBinaryPath( + const result = await startProxyExports.getProxyBinaryPath( initAllState({ logger, features }), + SAMPLE_DOTCOM_API_DETAILS, ); - t.assert(path); + t.assert(result); t.is( - path, + result.path, filepath.join(toolcachePath, startProxyExports.getProxyFilename()), ); + t.is(result.version, defaults.cliVersion); }); }, ); @@ -985,7 +956,7 @@ test.serial( const logger = new RecordingLogger(); const state = initAllState({ logger }); const downloadUrl = "url-we-want"; - mockGetReleaseByTag([ + const stubs = mockGetReleaseByTag(defaults.bundleVersion, [ { name: startProxyExports.getProxyPackage(getTestPlatform(state)), url: downloadUrl, @@ -994,11 +965,6 @@ test.serial( const toolcachePath = "/path/to/proxy/dir"; const find = sinon.stub(toolcache, "find").returns(""); - const getApiDetails = sinon.stub(apiClient, "getApiDetails").returns({ - auth: "", - url: "", - apiURL: "", - }); const getAuthorizationHeaderFor = sinon .stub(apiClient, "getAuthorizationHeaderFor") .returns(undefined); @@ -1012,25 +978,36 @@ test.serial( .resolves(extractedPath); const cacheDir = sinon.stub(toolcache, "cacheDir").resolves(toolcachePath); - const path = await startProxyExports.getProxyBinaryPath({ - ...state, - features: createFeatures([]), - }); + // Stub this to always return `false` so we force `getCodeQLAssetDownloadURL` to use the (mocked) API. + sinon.stub(actionsUtil, "isRunningLocalAction").returns(false); + state.env.set(ActionsEnvVars.GITHUB_ACTION_REPOSITORY, "test/repo"); - t.assert(find.calledOnce); - t.assert(getApiDetails.calledOnce); - t.assert(getAuthorizationHeaderFor.calledOnce); - t.assert(downloadTool.calledOnceWith(downloadUrl)); - t.assert(extractTar.calledOnceWith(archivePath)); - t.assert(cacheDir.calledOnceWith(extractedPath)); - t.assert(path); - t.is( - path, - filepath.join(toolcachePath, startProxyExports.getProxyFilename()), + const result = await startProxyExports.getProxyBinaryPath( + { + ...state, + features: createFeatures([]), + }, + SAMPLE_DOTCOM_API_DETAILS, ); + t.is(stubs.getReleaseByTag.callCount, 1); + t.assert(find.calledOnce); + t.assert(getAuthorizationHeaderFor.calledOnce); + + const st = addSinonAssertions(t); + st.onceWith(downloadTool, downloadUrl); + st.onceWith(extractTar, archivePath); + st.onceWith(cacheDir, extractedPath); + + t.assert(result); + t.is( + result.path, + filepath.join(toolcachePath, startProxyExports.getProxyFilename()), + ); + t.is(result.version, defaults.cliVersion); + checkExpectedLogMessages(t, logger.messages, [ - `Found '${startProxyExports.getProxyPackage(getTestPlatform(state))}' in release '${defaults.bundleVersion}' at '${downloadUrl}'`, + `Found private registry proxy ${startProxyExports.getProxyPackage(getTestPlatform(state))} in test/repo on https://github.com with URL ${downloadUrl}`, ]); }, ); @@ -1040,10 +1017,11 @@ test.serial( async (t) => { const logger = new RecordingLogger(); const state = initAllState({ logger }); - const expectedTag = "codeql-bundle-v2.20.1"; + const expectedVersion = "2.20.1"; + const expectedTag = `codeql-bundle-v${expectedVersion}`; const expectedParams = { - owner: "github", - repo: "codeql-action", + owner: "test", + repo: "repo", tag: expectedTag, }; const downloadUrl = "url-we-want"; @@ -1066,11 +1044,6 @@ test.serial( await withTmpDir(async (tempDir) => { const toolcachePath = "/path/to/proxy/dir"; const find = sinon.stub(toolcache, "find").returns(""); - const getApiDetails = sinon.stub(apiClient, "getApiDetails").returns({ - auth: "", - url: "", - apiURL: "", - }); const getAuthorizationHeaderFor = sinon .stub(apiClient, "getAuthorizationHeaderFor") .returns(undefined); @@ -1098,34 +1071,43 @@ test.serial( const getDefaultCliVersion = sinon .stub(features, "getEnabledDefaultCliVersions") .resolves({ - enabledVersions: [{ cliVersion: "2.20.1", tagName: expectedTag }], + enabledVersions: [ + { cliVersion: expectedVersion, tagName: expectedTag }, + ], }); - const path = await startProxyExports.getProxyBinaryPath({ - ...state, - features, - }); + + // Stub this to always return `false` so we force `getCodeQLAssetDownloadURL` to use the (mocked) API. + sinon.stub(actionsUtil, "isRunningLocalAction").returns(false); + state.env.set(ActionsEnvVars.GITHUB_ACTION_REPOSITORY, "test/repo"); + + const result = await startProxyExports.getProxyBinaryPath( + { + ...state, + features, + }, + SAMPLE_DOTCOM_API_DETAILS, + ); t.assert(getDefaultCliVersion.calledOnce); - sinon.assert.calledOnceWithMatch( - getReleaseByTag, - sinon.match(expectedParams), - ); - t.assert(find.calledOnce); - t.assert(getApiDetails.calledOnce); - t.assert(getAuthorizationHeaderFor.calledOnce); - t.assert(downloadTool.calledOnceWith(downloadUrl)); - t.assert(extractTar.calledOnceWith(archivePath)); - t.assert(cacheDir.calledOnceWith(extractedPath)); - t.assert(path); + const st = addSinonAssertions(t); + st.onceWith(getReleaseByTag, expectedParams); + t.assert(find.calledOnce); + t.assert(getAuthorizationHeaderFor.calledOnce); + st.onceWith(downloadTool, downloadUrl); + st.onceWith(extractTar, archivePath); + st.onceWith(cacheDir, extractedPath); + + t.assert(result); t.is( - path, + result.path, filepath.join(toolcachePath, startProxyExports.getProxyFilename()), ); + t.is(result.version, expectedVersion); }); checkExpectedLogMessages(t, logger.messages, [ - `Found '${startProxyExports.getProxyPackage(getTestPlatform(state))}' in release '${expectedTag}' at '${downloadUrl}'`, + `Found private registry proxy ${startProxyExports.getProxyPackage(getTestPlatform(state))} in test/repo on https://github.com with URL url-we-want.`, ]); }, ); diff --git a/src/start-proxy.ts b/src/start-proxy.ts index 6221c9940..f7b427e74 100644 --- a/src/start-proxy.ts +++ b/src/start-proxy.ts @@ -1,17 +1,14 @@ import * as path from "path"; -import * as core from "@actions/core"; import * as toolcache from "@actions/tool-cache"; import { ActionState } from "./action-common"; import { - getApiClient, - getApiDetails, getAuthorizationHeaderFor, getGitHubVersion, + GitHubApiDetails, } from "./api-client"; import * as artifactScanner from "./artifact-scanner"; -import { Config } from "./config-utils"; import * as defaults from "./defaults.json"; import { CodeQLDefaultVersionInfo, @@ -22,6 +19,11 @@ import * as json from "./json"; import { BuiltInLanguage } from "./languages"; import { Logger } from "./logging"; import { BundlePlatform, getBundlePlatform } from "./platform"; +import { getCodeQLAssetDownloadURL } from "./setup/repository"; +import { + StartProxyError, + StartProxyErrorType, +} from "./start-proxy/status-report"; import { Address, Registry, @@ -32,149 +34,13 @@ import { RawCredential, } from "./start-proxy/types"; import { getAuthConfig } from "./start-proxy/validation"; -import { - ActionName, - createStatusReportBase, - getActionsStatus, - sendStatusReport, - StatusReportBase, -} from "./status-report"; -import * as util from "./util"; import { ConfigurationError, getErrorMessage, isDefined } from "./util"; export * from "./start-proxy/types"; +export * from "./start-proxy/status-report"; -/** - * Enumerates specific error types for which we have corresponding error messages that - * are safe to include in status reports. - */ -export enum StartProxyErrorType { - DownloadFailed, - ExtractionFailed, - CacheFailed, -} - -/** - * @returns The error message corresponding to the error type. - */ -export function getStartProxyErrorMessage( - errorType: StartProxyErrorType, -): string { - switch (errorType) { - case StartProxyErrorType.DownloadFailed: - return "Failed to download proxy archive."; - case StartProxyErrorType.ExtractionFailed: - return "Failed to extract proxy archive."; - case StartProxyErrorType.CacheFailed: - return "Failed to add proxy to toolcache"; - } -} - -/** - * We want to avoid accidentally leaking secrets that may be contained in exception - * messages in the `start-proxy` action. Consequently, we don't report the messages - * of arbitrary exceptions. This type of error ensures that the message is one from - * `StartProxyErrorType` and therefore safe to include in a status report. - */ -export class StartProxyError extends Error { - public readonly errorType: StartProxyErrorType; - - constructor(errorType: StartProxyErrorType) { - super(); - this.errorType = errorType; - } -} - -/** - * Sends a status report for the `start-proxy` action indicating a successful outcome. - * - * @param startedAt When the action was started. - * @param config The configuration used. - * @param registry_types The types of registries that are configured. - * @param logger The logger to use. - */ -export async function sendSuccessStatusReport( - startedAt: Date, - config: Partial, - registry_types: string[], - logger: Logger, -) { - const statusReportBase = await createStatusReportBase( - ActionName.StartProxy, - "success", - startedAt, - config, - await util.checkDiskUsage(logger), - logger, - ); - if (statusReportBase !== undefined) { - const statusReport: StatusReportBase = { - ...statusReportBase, - registry_types: registry_types.join(","), - }; - await sendStatusReport(statusReport); - } -} - -/** - * Returns an error message for `error` that can safely be reported in a status report, - * i.e. that does not contain sensitive information. - * - * @param error The error for which to get an error message. - */ -export function getSafeErrorMessage(error: Error): string { - // If the error is a `StartProxyError`, resolve the error type to the corresponding - // error message. - if (error instanceof StartProxyError) { - return getStartProxyErrorMessage(error.errorType); - } - - // Otherwise, omit the actual error message. - return `Error from start-proxy Action omitted (${error.constructor.name}).`; -} - -/** - * Sends a status report for the `start-proxy` action indicating a failure. - * - * @param logger The logger to use. - * @param startedAt When the action was started. - * @param language The language provided as input, if any. - * @param unwrappedError The exception that was thrown. - */ -export async function sendFailedStatusReport( - logger: Logger, - startedAt: Date, - language: BuiltInLanguage | undefined, - unwrappedError: unknown, -) { - const error = util.wrapError(unwrappedError); - core.setFailed(`start-proxy action failed: ${error.message}`); - - // To avoid the possibility of leaking sensitive information into the telemetry, - // we don't include arbitrary error messages. Instead, `getSafeErrorMessage` will - // return a generic message that includes the type of the error, unless it can decide - // that the message is safe to include. - const statusReportMessage = getSafeErrorMessage(error); - const errorStatusReportBase = await createStatusReportBase( - ActionName.StartProxy, - getActionsStatus(error), - startedAt, - { - languages: language === undefined ? undefined : [language], - }, - await util.checkDiskUsage(logger), - logger, - statusReportMessage, - ); - if (errorStatusReportBase !== undefined) { - await sendStatusReport(errorStatusReportBase); - } -} - +/** The basename of the proxy artifacts. */ export const UPDATEJOB_PROXY = "update-job-proxy"; -export const UPDATEJOB_PROXY_VERSION = "v2.0.20250624110901"; -const UPDATEJOB_PROXY_URL_PREFIX = - "https://github.com/github/codeql-action/releases/download/codeql-bundle-v2.22.0/"; function isPAT(value: string) { return artifactScanner.isAuthToken(value, [ @@ -379,30 +245,6 @@ export function getProxyPackage(platform: BundlePlatform): string { return `${UPDATEJOB_PROXY}-${platform}.tar.gz`; } -/** - * Gets the fallback URL for downloading the proxy release asset. - * - * @param proxyPackage The asset name. - * @returns The full URL to download the specified asset from the fallback release. - */ -export function getFallbackUrl(proxyPackage: string): string { - return `${UPDATEJOB_PROXY_URL_PREFIX}${proxyPackage}`; -} - -/** - * Uses the GitHub API to obtain information about the CodeQL CLI bundle release - * that is tagged by `version`. - * - * @returns The response from the GitHub API. - */ -async function getReleaseByVersion(version: string) { - return getApiClient().rest.repos.getReleaseByTag({ - owner: "github", - repo: "codeql-action", - tag: version, - }); -} - /** Uses `features` to determine the default CLI version. */ async function getCliVersionFromFeatures( features: FeatureEnablement, @@ -419,7 +261,8 @@ async function getCliVersionFromFeatures( * @returns Returns the download URL and version of the proxy package we plan to use. */ export async function getDownloadUrl( - action: ActionState<["Base", "Logger", "FeatureFlags"]>, + action: ActionState<["Base", "ReadOnlyEnv", "Logger", "FeatureFlags"]>, + apiDetails: GitHubApiDetails, ): Promise<{ url: string; version: string }> { // Default to linux64 if we don't recognise the platform+arch pair. // This maintains the behaviour we had before switching to `getBundlePlatform` here. @@ -448,37 +291,26 @@ export async function getDownloadUrl( }; // Try to retrieve information about the CLI bundle release identified by `versionInfo`. - const cliRelease = await getReleaseByVersion(versionInfo.tagName); + const proxyAssetUrl = await getCodeQLAssetDownloadURL( + action, + apiDetails, + versionInfo.tagName, + proxyPackage, + "private registry proxy", + ); - // Search the release's assets to find the one we are looking for. - for (const asset of cliRelease.data.assets) { - if (asset.name === proxyPackage) { - action.logger.info( - `Found '${proxyPackage}' in release '${versionInfo.tagName}' at '${asset.url}'`, - ); - return { - url: asset.url, - // The `update-job-proxy` doesn't have a version as such. Since we now bundle it - // with CodeQL CLI bundle releases, we use the corresponding CLI version to - // differentiate between (potentially) different versions of `update-job-proxy`. - version: versionInfo.cliVersion, - }; - } - } + return { + url: proxyAssetUrl, + // The `update-job-proxy` doesn't have a version as such. Since we now bundle it + // with CodeQL CLI bundle releases, we use the corresponding CLI version to + // differentiate between (potentially) different versions of `update-job-proxy`. + version: versionInfo.cliVersion, + }; } catch (ex) { - action.logger.warning( + throw new Error( `Failed to retrieve information about the linked release: ${getErrorMessage(ex)}`, ); } - - // Fallback to the hard-coded URL. - action.logger.info( - `Did not find '${proxyPackage}' in the linked release, falling back to hard-coded version.`, - ); - return { - url: getFallbackUrl(proxyPackage), - version: UPDATEJOB_PROXY_VERSION, - }; } /** @@ -497,9 +329,14 @@ export async function downloadProxy( try { // Download the proxy archive from `url`. We let `downloadTool` choose where // to store it. The path to the downloaded file will be returned if successful. - return toolcache.downloadTool(url, /* dest: */ undefined, authorization, { - accept: "application/octet-stream", - }); + return await toolcache.downloadTool( + url, + /* dest: */ undefined, + authorization, + { + accept: "application/octet-stream", + }, + ); } catch (error) { logger.error( `Failed to download proxy archive from ${url}: ${getErrorMessage(error)}`, @@ -560,37 +397,70 @@ export function getProxyFilename() { : UPDATEJOB_PROXY; } +export type ProxyBinary = { + /** The path to the proxy binary to run. */ + path: string; + /** + * The version associated with the proxy binary. + * This usually corresponds to the CodeQL CLI release that the binary was obtained from. + */ + version: string; +}; + /** * Gets a path to the proxy binary. If possible, this function will find the proxy in the * runner's tool cache. Otherwise, it downloads and extracts the proxy binary, * and stores it in the tool cache. * * @param action The action state. - * @returns The path to the proxy binary. + * @returns The path to the proxy binary and its version. */ export async function getProxyBinaryPath( - action: ActionState<["Base", "Logger", "FeatureFlags"]>, -): Promise { + action: ActionState<["Base", "ReadOnlyEnv", "Logger", "FeatureFlags"]>, + apiDetails: GitHubApiDetails, +): Promise { const logger = action.logger; - const proxyFileName = getProxyFilename(); - const proxyInfo = await getDownloadUrl(action); + logger.startGroup("Setting up authentication proxy"); - let proxyBin = toolcache.find(proxyFileName, proxyInfo.version); - if (!proxyBin) { - const apiDetails = getApiDetails(); - const authorization = getAuthorizationHeaderFor( - logger, - apiDetails, - proxyInfo.url, - ); - const temp = await downloadProxy(logger, proxyInfo.url, authorization); - const extracted = await extractProxy(logger, temp); - proxyBin = await cacheProxy( - logger, - extracted, - proxyFileName, - proxyInfo.version, + try { + const proxyFileName = getProxyFilename(); + const proxyInfo = await getDownloadUrl(action, apiDetails); + + logger.info( + `Using authentication proxy from CodeQL release ${proxyInfo.version}.`, ); + + let proxyDir = toolcache.find(proxyFileName, proxyInfo.version); + + if (!proxyDir) { + logger.info( + `Authentication proxy is not in the toolcache. Will try to download it from '${proxyInfo.url}'.`, + ); + + const authorization = getAuthorizationHeaderFor( + logger, + apiDetails, + proxyInfo.url, + ); + const temp = await downloadProxy(logger, proxyInfo.url, authorization); + + logger.info(`Downloaded the authentication proxy asset to '${temp}'.`); + + const extracted = await extractProxy(logger, temp); + proxyDir = await cacheProxy( + logger, + extracted, + proxyFileName, + proxyInfo.version, + ); + + logger.info(`Extracted the authentication proxy to '${proxyDir}'.`); + } + return { + path: path.join(proxyDir, proxyFileName), + version: proxyInfo.version, + }; + } finally { + logger.endGroup(); } - return path.join(proxyBin, proxyFileName); } diff --git a/src/start-proxy/status-report.test.ts b/src/start-proxy/status-report.test.ts new file mode 100644 index 000000000..c73478396 --- /dev/null +++ b/src/start-proxy/status-report.test.ts @@ -0,0 +1,136 @@ +import * as core from "@actions/core"; +import test, { ExecutionContext } from "ava"; +import sinon from "sinon"; + +import * as statusReport from "../status-report"; +import { + createTestConfig, + makeMacro, + RecordingLogger, + setupTests, + withRecordingLoggerAsync, +} from "../testing-utils"; +import { ConfigurationError } from "../util"; + +import * as startProxyExports from "./status-report"; + +setupTests(test); + +test.serial("sendSuccessStatusReport", async (t) => { + const logger = new RecordingLogger(); + const now = new Date(); + const config = createTestConfig({}); + const proxy_version = "1.2.3"; + const registry_types = ["git_source", "docker_registry"]; + + const createStatusReportBase = sinon.stub( + statusReport, + "createStatusReportBase", + ); + createStatusReportBase.resolves({ + action_name: statusReport.ActionName.StartProxy, + } as statusReport.StatusReportBase); + + const sendStatusReport = sinon + .stub(statusReport, "sendStatusReport") + .resolves(); + + await startProxyExports.sendSuccessStatusReport( + now, + config, + registry_types, + { proxy_version }, + logger, + ); + + t.is(createStatusReportBase.callCount, 1); + + t.is(sendStatusReport.callCount, 1); + t.is(sendStatusReport.args[0].length, 1); + + const arg = sendStatusReport.args[0][0]; + t.like(arg, { + action_name: statusReport.ActionName.StartProxy, + registry_types: "docker_registry,git_source", + start_proxy: { proxy_version }, + }); +}); + +const sendFailedStatusReportTest = makeMacro({ + exec: async ( + t: ExecutionContext, + err: Error, + expectedMessage: string, + expectedStatus: statusReport.ActionStatus = "failure", + ) => { + const now = new Date(); + + // Override core.setFailed to avoid it setting the program's exit code + sinon.stub(core, "setFailed").returns(); + + const createStatusReportBase = sinon.stub( + statusReport, + "createStatusReportBase", + ); + createStatusReportBase.resolves(undefined); + + await withRecordingLoggerAsync(async (logger) => { + await startProxyExports.sendFailedStatusReport( + logger, + now, + undefined, + err, + ); + + // Check that the stub has been called exactly once, with the expected arguments, + // but not with the message from the error. + sinon.assert.calledOnceWithExactly( + createStatusReportBase, + statusReport.ActionName.StartProxy, + expectedStatus, + now, + sinon.match.any, + sinon.match.any, + sinon.match.any, + expectedMessage, + ); + t.false( + createStatusReportBase.calledWith( + statusReport.ActionName.StartProxy, + expectedStatus, + now, + sinon.match.any, + sinon.match.any, + sinon.match.any, + sinon.match((msg: string) => msg.includes(err.message)), + ), + "createStatusReportBase was called with the error message", + ); + }); + }, + + title: (providedTitle = "") => `sendFailedStatusReport - ${providedTitle}`, +}); + +sendFailedStatusReportTest.serial( + "reports generic error message for non-StartProxyError error", + new Error("Something went wrong today"), + "Error from start-proxy Action omitted (Error).", +); + +sendFailedStatusReportTest.serial( + "reports generic error message for non-StartProxyError error with safe error message", + new Error( + startProxyExports.getStartProxyErrorMessage( + startProxyExports.StartProxyErrorType.DownloadFailed, + ), + ), + "Error from start-proxy Action omitted (Error).", +); + +sendFailedStatusReportTest.serial( + "reports generic error message for ConfigurationError error", + new ConfigurationError("Something went wrong today"), + "Error from start-proxy Action omitted (ConfigurationError).", + "user-error", +); diff --git a/src/start-proxy/status-report.ts b/src/start-proxy/status-report.ts new file mode 100644 index 000000000..76ad3c8da --- /dev/null +++ b/src/start-proxy/status-report.ts @@ -0,0 +1,153 @@ +import * as core from "@actions/core"; + +import type { Config } from "../config-utils"; +import type { BuiltInLanguage } from "../languages"; +import type { Logger } from "../logging"; +import { + ActionName, + createStatusReportBase, + getActionsStatus, + sendStatusReport, + type StatusReportBase, +} from "../status-report"; +import * as util from "../util"; + +/** Additional status report data from `start-proxy`. */ +export interface StartProxyStatus { + proxy_version: string; +} + +/** The type of successful status reports from `start-proxy`. */ +type StartProxySuccessReport = StatusReportBase & { + start_proxy: StartProxyStatus; +}; + +/** + * Sends a status report for the `start-proxy` action indicating a successful outcome. + * + * @param startedAt When the action was started. + * @param config The configuration used. + * @param registry_types The types of registries that are configured. + * @param status Status information. + * @param logger The logger to use. + */ +export async function sendSuccessStatusReport( + startedAt: Date, + config: Partial, + registry_types: string[], + status: StartProxyStatus, + logger: Logger, +) { + const statusReportBase = await createStatusReportBase( + ActionName.StartProxy, + "success", + startedAt, + config, + await util.checkDiskUsage(logger), + logger, + ); + if (statusReportBase !== undefined) { + const statusReport: StartProxySuccessReport = { + ...statusReportBase, + registry_types: registry_types.sort().join(","), + start_proxy: status, + }; + await sendStatusReport(statusReport); + } +} + +/** + * Enumerates specific error types for which we have corresponding error messages that + * are safe to include in status reports. + */ +export enum StartProxyErrorType { + DownloadFailed, + ExtractionFailed, + CacheFailed, +} + +/** + * @returns The error message corresponding to the error type. + */ +export function getStartProxyErrorMessage( + errorType: StartProxyErrorType, +): string { + switch (errorType) { + case StartProxyErrorType.DownloadFailed: + return "Failed to download proxy archive."; + case StartProxyErrorType.ExtractionFailed: + return "Failed to extract proxy archive."; + case StartProxyErrorType.CacheFailed: + return "Failed to add proxy to toolcache"; + } +} + +/** + * We want to avoid accidentally leaking secrets that may be contained in exception + * messages in the `start-proxy` action. Consequently, we don't report the messages + * of arbitrary exceptions. This type of error ensures that the message is one from + * `StartProxyErrorType` and therefore safe to include in a status report. + */ +export class StartProxyError extends Error { + public readonly errorType: StartProxyErrorType; + + constructor(errorType: StartProxyErrorType) { + super(); + this.errorType = errorType; + } +} + +/** + * Returns an error message for `error` that can safely be reported in a status report, + * i.e. that does not contain sensitive information. + * + * @param error The error for which to get an error message. + */ +export function getSafeErrorMessage(error: Error): string { + // If the error is a `StartProxyError`, resolve the error type to the corresponding + // error message. + if (error instanceof StartProxyError) { + return getStartProxyErrorMessage(error.errorType); + } + + // Otherwise, omit the actual error message. + return `Error from start-proxy Action omitted (${error.constructor.name}).`; +} + +/** + * Sends a status report for the `start-proxy` action indicating a failure. + * + * @param logger The logger to use. + * @param startedAt When the action was started. + * @param language The language provided as input, if any. + * @param unwrappedError The exception that was thrown. + */ +export async function sendFailedStatusReport( + logger: Logger, + startedAt: Date, + language: BuiltInLanguage | undefined, + unwrappedError: unknown, +) { + const error = util.wrapError(unwrappedError); + core.setFailed(`start-proxy action failed: ${error.message}`); + + // To avoid the possibility of leaking sensitive information into the telemetry, + // we don't include arbitrary error messages. Instead, `getSafeErrorMessage` will + // return a generic message that includes the type of the error, unless it can decide + // that the message is safe to include. + const statusReportMessage = getSafeErrorMessage(error); + const errorStatusReportBase = await createStatusReportBase( + ActionName.StartProxy, + getActionsStatus(error), + startedAt, + { + languages: language === undefined ? undefined : [language], + }, + await util.checkDiskUsage(logger), + logger, + statusReportMessage, + ); + if (errorStatusReportBase !== undefined) { + await sendStatusReport(errorStatusReportBase); + } +} diff --git a/src/status-report.ts b/src/status-report.ts index fc45e82d6..0731acbe6 100644 --- a/src/status-report.ts +++ b/src/status-report.ts @@ -378,7 +378,7 @@ export async function createStatusReportBase( try { const commitOid = getOptionalInput("sha") || process.env["GITHUB_SHA"] || ""; - const ref = await getRef(); + const ref = await getRef(getEnv(), config?.repositoryRoot); const jobRunUUID = process.env[EnvVar.JOB_RUN_UUID] || ""; const workflowRunID = getWorkflowRunID(); const workflowRunAttempt = getWorkflowRunAttempt(); diff --git a/src/testing-utils.ts b/src/testing-utils.ts index cd6031894..8c38187c4 100644 --- a/src/testing-utils.ts +++ b/src/testing-utils.ts @@ -163,6 +163,46 @@ export function setupTests(testFn: TestFn) { }); } +export interface AvaSinonAssertions { + /** + * Asserts that `stub` must have been called once with at least the `expected` arguments. + */ + onceWith: ( + stub: sinon.SinonStub, + ...expected: sinon.MatchPartialArguments + ) => boolean; +} + +/** Adds additional assertions for use with `sinon` to `t`. */ +export function addSinonAssertions( + t: ExecutionContext, +): ExecutionContext & AvaSinonAssertions { + return { + ...t, + onceWith: ( + stub: sinon.SinonStub, + ...expected: sinon.MatchPartialArguments + ) => { + // Fail if the stub hasn't been called at all so that we can safely compare + // the arguments of the first call in the else branch. + if (stub.callCount === 0) { + t.fail("The stub wasn't called."); + } else { + // Reduce the arguments of each to the same number that was provided, + // so that extra arguments don't lead to a failure. + const actual = stub.args.map>( + (args: TArgs) => + args.slice( + 0, + expected.length, + ) as sinon.MatchPartialArguments, + ); + return t.deepEqual(actual, [expected]); + } + }, + }; +} + /** * Declare a reusable test implementation, with better type safety than `test.macro`. */ @@ -966,6 +1006,7 @@ export function createTestConfig(overrides: Partial): Config { {}, { version: getActionVersion(), + repositoryRoot: undefined, analysisKinds: [AnalysisKind.CodeScanning], languages: [], buildMode: undefined, diff --git a/src/trap-caching.test.ts b/src/trap-caching.test.ts index 478305e57..15ab49481 100644 --- a/src/trap-caching.test.ts +++ b/src/trap-caching.test.ts @@ -182,6 +182,7 @@ test.serial( stubCodeql, [BuiltInLanguage.javascript, BuiltInLanguage.cpp], logger, + undefined, ); t.assert( stubRestore.calledOnceWith( diff --git a/src/trap-caching.ts b/src/trap-caching.ts index a802aac89..d93936832 100644 --- a/src/trap-caching.ts +++ b/src/trap-caching.ts @@ -14,6 +14,7 @@ import { Language } from "./languages"; import { Logger } from "./logging"; import { asHTTPError, + getEnv, getErrorMessage, tryGetFolderBytes, waitForResultWithTimeLimit, @@ -43,6 +44,7 @@ const MAX_CACHE_OPERATION_MS = 120_000; // Two minutes * @param codeql The CodeQL instance to use. * @param languages The languages being analyzed. * @param logger A logger to record some informational messages to. + * @param repositoryRoot The path at which the repository is checked out at. * @returns A partial map from languages to TRAP cache paths on disk, with * languages for which we shouldn't use TRAP caching omitted. */ @@ -50,6 +52,7 @@ export async function downloadTrapCaches( codeql: CodeQL, languages: Language[], logger: Logger, + repositoryRoot: string | undefined, ): Promise<{ [language: string]: string }> { const result: { [language: string]: string } = {}; const languagesSupportingCaching = await getLanguagesSupportingCaching( @@ -72,7 +75,7 @@ export async function downloadTrapCaches( result[language] = cacheDir; } - if (await gitUtils.isAnalyzingDefaultBranch()) { + if (await gitUtils.isAnalyzingDefaultBranch(getEnv(), repositoryRoot)) { logger.info( "Analyzing default branch. Skipping downloading of TRAP caches.", ); @@ -99,6 +102,7 @@ export async function downloadTrapCaches( const found = await waitForResultWithTimeLimit( MAX_CACHE_OPERATION_MS, actionsCache.restoreCache([cacheDir], preferredKey, [ + preferredKey, // Fall back to any cache with the right key prefix await cachePrefix(codeql, language), ]), @@ -132,7 +136,12 @@ export async function uploadTrapCaches( config: Config, logger: Logger, ): Promise { - if (!(await gitUtils.isAnalyzingDefaultBranch())) return false; // Only upload caches from the default branch + // Only upload caches from the default branch + if ( + !(await gitUtils.isAnalyzingDefaultBranch(getEnv(), config.repositoryRoot)) + ) { + return false; + } for (const language of config.languages) { const cacheDir = config.trapCaches[language]; @@ -180,6 +189,8 @@ export async function cleanupTrapCaches( features: FeatureEnablement, logger: Logger, ): Promise { + const env = getEnv(); + if (!(await features.getValue(Feature.CleanupTrapCaches))) { return { trap_cache_cleanup_skipped_because: "feature disabled", @@ -189,7 +200,7 @@ export async function cleanupTrapCaches( "TRAP cache cleanup is deprecated and will be removed in May 2026. " + "We recommend instead disabling TRAP caching by passing the `trap-caching: false` input to the `init` Action.", ); - if (!(await gitUtils.isAnalyzingDefaultBranch())) { + if (!(await gitUtils.isAnalyzingDefaultBranch(env, config.repositoryRoot))) { return { trap_cache_cleanup_skipped_because: "not analyzing default branch", }; @@ -200,7 +211,7 @@ export async function cleanupTrapCaches( const allCaches = await apiClient.listActionsCaches( CODEQL_TRAP_CACHE_PREFIX, - await gitUtils.getRef(), + await gitUtils.getRef(env, config.repositoryRoot), ); for (const language of config.languages) { diff --git a/src/upload-lib.ts b/src/upload-lib.ts index 23b7b91ef..f66feff14 100644 --- a/src/upload-lib.ts +++ b/src/upload-lib.ts @@ -14,7 +14,7 @@ import { getGitHubVersion, wrapApiConfigurationError } from "./api-client"; import { CodeQL, getCodeQL } from "./codeql"; import { getConfig } from "./config-utils"; import { readDiffRangesJsonFile } from "./diff-informed-analysis-utils"; -import { EnvVar, exportEnvVar } from "./environment"; +import { ActionsEnvVars, EnvVar, exportEnvVar } from "./environment"; import { FeatureEnablement } from "./feature-flags"; import * as fingerprints from "./fingerprints"; import * as gitUtils from "./git-utils"; @@ -767,12 +767,13 @@ export async function uploadPostProcessedFiles( const zippedSarif = zlib.gzipSync(sarifPayload).toString("base64"); const checkoutURI = url.pathToFileURL(checkoutPath).href; + const env = util.getEnv(); const payload = uploadTarget.transformPayload( buildPayload( - await gitUtils.getCommitOid(checkoutPath), - await gitUtils.getRef(), + await gitUtils.getCommitOid(env, checkoutPath), + await gitUtils.getRef(env, checkoutPath), postProcessingResults.analysisKey, - util.getRequiredEnvParam("GITHUB_WORKFLOW"), + env.getRequired(ActionsEnvVars.GITHUB_WORKFLOW), zippedSarif, actionsUtil.getWorkflowRunID(), actionsUtil.getWorkflowRunAttempt(), diff --git a/src/util.ts b/src/util.ts index 2cacd4fbb..4d2bf58e4 100644 --- a/src/util.ts +++ b/src/util.ts @@ -20,6 +20,8 @@ import { getRequiredEnvParam, isInTestMode, exportEnvVar, + getEnv, + type Env, } from "./environment"; import * as json from "./json"; import { Language } from "./languages"; @@ -45,10 +47,13 @@ const BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; */ const BROKEN_VERSIONS = ["0.0.0-20211207"]; +/** A string representing a GitHub instance. */ +export type InstanceURL = string; + /** * The URL for github.com. */ -export const GITHUB_DOTCOM_URL = "https://github.com"; +export const GITHUB_DOTCOM_URL: InstanceURL = "https://github.com"; /** * Default name of the debugging artifact. @@ -599,12 +604,12 @@ export function assertNever(value: never): never { * Set some initial environment variables that we can set even without * knowing what version of CodeQL we're running. */ -export function initializeEnvironment(version: string) { - exportEnvVar(EnvVar.FEATURE_MULTI_LANGUAGE, "false"); - exportEnvVar(EnvVar.FEATURE_SANDWICH, "false"); - exportEnvVar(EnvVar.FEATURE_SARIF_COMBINE, "true"); - exportEnvVar(EnvVar.FEATURE_WILL_UPLOAD, "true"); - exportEnvVar(EnvVar.VERSION, version); +export function initializeEnvironment(version: string, env: Env = getEnv()) { + env.export(EnvVar.FEATURE_MULTI_LANGUAGE, "false"); + env.export(EnvVar.FEATURE_SANDWICH, "false"); + env.export(EnvVar.FEATURE_SARIF_COMBINE, "true"); + env.export(EnvVar.FEATURE_WILL_UPLOAD, "true"); + env.export(EnvVar.VERSION, version); } export class HTTPError extends Error { diff --git a/src/workflow.test.ts b/src/workflow.test.ts index c7f168a9d..2373e8bd1 100644 --- a/src/workflow.test.ts +++ b/src/workflow.test.ts @@ -4,10 +4,12 @@ import * as sinon from "sinon"; import * as actionsUtil from "./actions-util"; import { createStubCodeQL, getCodeQLForTesting } from "./codeql"; -import { EnvVar } from "./environment"; +import { ActionsEnvVars, EnvVar } from "./environment"; import { checkExpectedLogMessages, + createTestConfig, getRecordingLogger, + getTestEnv, LoggedMessage, setupTests, } from "./testing-utils"; @@ -1002,3 +1004,124 @@ test.serial( t.is(messages.length, 0); }, ); + +test("getRepositoryRootOrThrow - gets root from config", async (t) => { + const expectedRoot = "/path/to/root"; + const repositoryRoot = workflow.getRepositoryRootOrThrow( + {}, + "testJob", + {}, + createTestConfig({ repositoryRoot: expectedRoot }), + getTestEnv(), + ); + + t.is(repositoryRoot, expectedRoot); +}); + +test("getRepositoryRootOrThrow - gets root from workflow", async (t) => { + const expectedRoot = "/path/to/root"; + const repositoryRoot = workflow.getRepositoryRootOrThrow( + { + jobs: { + testJob: { + steps: [ + { + uses: "github/codeql-action/analyze", + with: { checkout_path: expectedRoot }, + }, + ], + }, + }, + }, + "testJob", + {}, + createTestConfig({}), + getTestEnv(), + ); + + t.is(repositoryRoot, expectedRoot); +}); + +test("getRepositoryRootOrThrow - gets root from environment", async (t) => { + const expectedRoot = "/path/to/root"; + const repositoryRoot = workflow.getRepositoryRootOrThrow( + { + jobs: { testJob: { steps: [{ uses: "github/codeql-action/analyze" }] } }, + }, + "testJob", + {}, + createTestConfig({}), + getTestEnv({ [ActionsEnvVars.GITHUB_WORKSPACE]: expectedRoot }), + ); + + t.is(repositoryRoot, expectedRoot); +}); + +test("getRepositoryRootOrThrow - throws if there's no matching job", async (t) => { + t.throws( + () => + workflow.getRepositoryRootOrThrow( + { + jobs: { + otherJob: { + steps: [ + { + uses: "github/codeql-action/analyze", + with: { checkout_path: "/some/path" }, + }, + ], + }, + }, + }, + "testJob", + {}, + createTestConfig({}), + getTestEnv(), + ), + { message: /since the workflow has no job named testJob./ }, + ); +}); + +test("getRepositoryRootOrThrow - throws if there's no analyze step", async (t) => { + t.throws( + () => + workflow.getRepositoryRootOrThrow( + { + jobs: { + testJob: { steps: [] }, + }, + }, + "testJob", + {}, + createTestConfig({}), + getTestEnv(), + ), + { message: /since the testJob job does not call/ }, + ); +}); + +test("getRepositoryRootOrThrow - throws if the env var is not set", async (t) => { + t.throws( + () => + workflow.getRepositoryRootOrThrow( + { + jobs: { + testJob: { + steps: [ + { + uses: "github/codeql-action/analyze", + }, + ], + }, + }, + }, + "testJob", + {}, + createTestConfig({}), + getTestEnv(), + ), + { + message: `${ActionsEnvVars.GITHUB_WORKSPACE} environment variable must be set`, + }, + ); +}); diff --git a/src/workflow.ts b/src/workflow.ts index 151cfd5c5..fb549250b 100644 --- a/src/workflow.ts +++ b/src/workflow.ts @@ -8,7 +8,8 @@ import * as yaml from "js-yaml"; import { isDynamicWorkflow } from "./actions-util"; import * as api from "./api-client"; import { CodeQL } from "./codeql"; -import { EnvVar } from "./environment"; +import type { Config } from "./config-utils"; +import { ActionsEnvVars, EnvVar, getEnv, ReadOnlyEnv } from "./environment"; import { Logger } from "./logging"; import { getRequiredEnvParam, @@ -441,27 +442,45 @@ export function getUploadInputOrThrow( } /** - * Makes a best effort attempt to retrieve the checkout_path input for the - * particular job, given a set of matrix variables. + * Makes a best effort attempt to determine the root path of the repository that the analysis + * relates to. We need that to make paths in SARIF files relative. + * + * - If available, we take the `repositoryRoot` from the `config`. + * - If it isn't, we fall back to trying to extract a `checkout_path` input from the `workflow`. + * - Finally, we fall back to the value of `GITHUB_WORKSPACE`. * * Typically you'll want to wrap this function in a try/catch block and handle the error. * - * @returns the checkout_path input - * @throws an error if the checkout_path input could not be determined + * @param workflow The workflow specification of the currently running workflow. + * @param jobName The name of the job that is currently running. + * @param matrixVars The matrix variables, if any. + * @param config The CodeQL Action configuration state. + * @param env The environment variables. + * + * @returns The repository root path, or its best approximation. + * @throws `Error` if the repository root could not be determined. */ -export function getCheckoutPathInputOrThrow( +export function getRepositoryRootOrThrow( workflow: Workflow, jobName: string, matrixVars: { [key: string]: string } | undefined, + config: Partial, + env: ReadOnlyEnv = getEnv(), ): string { return ( + // If the CodeQL Action already has a persisted repository root, then we can just use that. + config.repositoryRoot ?? + // Otherwise, try to retrieve it from a `checkout_path` input in the workflow specification. getInputOrThrow( workflow, jobName, getAnalyzeActionName(), "checkout_path", matrixVars, - ) || getRequiredEnvParam("GITHUB_WORKSPACE") // if unspecified, checkout_path defaults to ${{ github.workspace }} + ) ?? + // Finally, if all of the above fail, just use the value of `GITHUB_WORKSPACE` since that + // is what is used by default. + env.getRequired(ActionsEnvVars.GITHUB_WORKSPACE) ); }