diff --git a/CHANGELOG.md b/CHANGELOG.md index 1287d42e85..22ef6e2bc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Note that the only difference between `v2` and `v3` of the CodeQL Action is the - Update default CodeQL bundle version to 2.16.2. [#2124](https://github.com/github/codeql-action/pull/2124) - The CodeQL action no longer fails if it can't write to the telemetry api endpoint. [#2121](https://github.com/github/codeql-action/pull/2121) +- Users of GHES3.9+ and GHEC will no longer need to include `actions: read` permissions to use `upload-sarif` in private repositories. ## 3.24.0 - 02 Feb 2024 diff --git a/lib/api-client.js b/lib/api-client.js index c6bb8e32fb..ad3c372c82 100644 --- a/lib/api-client.js +++ b/lib/api-client.js @@ -103,6 +103,16 @@ exports.getGitHubVersion = getGitHubVersion; * Get the path of the currently executing workflow relative to the repository root. */ async function getWorkflowRelativePath() { + const workflow_ref = process.env["GITHUB_WORKFLOW_REF"]; + if (workflow_ref !== undefined) { + const workflowRegExp = new RegExp("^[^/]+/[^/]+/(.*?)@.*"); + const match = workflow_ref.match(workflowRegExp); + if (match) { + return new Promise((resolve) => { + resolve(match[1]); + }); + } + } const repo_nwo = (0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY").split("/"); const owner = repo_nwo[0]; const repo = repo_nwo[1]; diff --git a/lib/api-client.js.map b/lib/api-client.js.map index 1da064eb90..d16acd1589 100644 --- a/lib/api-client.js.map +++ b/lib/api-client.js.map @@ -1 +1 @@ -{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,uEAAyD;AACzD,6DAA+C;AAC/C,0EAAgD;AAEhD,iDAAoE;AACpE,iCAOgB;AAEhB,MAAM,gCAAgC,GAAG,6BAA6B,CAAC;AAEvE,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,+FAAc,CAAA;IACd,+FAAc,CAAA;AAChB,CAAC,EAHW,0BAA0B,0CAA1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AAoB,EACpB,WAA+B;IAE/B,IAAI,YAAY,GAAG,GAAG,YAAY,GAAG,CAAC;IAEtC,MAAM,MAAM,GAAG,IAAA,uBAAgB,EAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,uDAAuD;QACvD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAClD,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACjC,YAAY,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,qDAAqD;gBACrD,6CAA6C;gBAC7C,YAAY,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;YAClC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AArBD,kDAqBC"} \ No newline at end of file diff --git a/src/api-client.ts b/src/api-client.ts index a80542def4..82ebd47b82 100644 --- a/src/api-client.ts +++ b/src/api-client.ts @@ -119,6 +119,16 @@ export async function getGitHubVersion(): Promise { * Get the path of the currently executing workflow relative to the repository root. */ export async function getWorkflowRelativePath(): Promise { + const workflow_ref = process.env["GITHUB_WORKFLOW_REF"]; + if (workflow_ref !== undefined) { + const workflowRegExp = new RegExp("^[^/]+/[^/]+/(.*?)@.*"); + const match = workflow_ref.match(workflowRegExp); + if (match) { + return new Promise((resolve) => { + resolve(match[1]); + }); + } + } const repo_nwo = getRequiredEnvParam("GITHUB_REPOSITORY").split("/"); const owner = repo_nwo[0]; const repo = repo_nwo[1];