From abe17b5b3e98720a47edec464bec5ee7c299bb43 Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Thu, 8 Feb 2024 23:35:08 -0500 Subject: [PATCH] Use GITHUB_WORKFLOW_REF Introduced with GHES 3.9: https://docs.github.com/en/enterprise-server@3.9/actions/learn-github-actions/variables GITHUB_WORKFLOW_REF means that actions don't need to use `actions: read` to determine the path to the running workflow. --- CHANGELOG.md | 2 +- lib/api-client.js | 17 ++++--------- lib/api-client.js.map | 2 +- .../default-setup-environment-variables.ql | 5 ++-- src/api-client.ts | 25 +++++-------------- 5 files changed, 16 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b38cfd7d14..2b3bfeb006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Note that the only difference between `v2` and `v3` of the CodeQL Action is the ## [UNRELEASED] -No user facing changes. +- Users will no longer need to include `actions: read` permissions to use `upload-sarif` in private repositories. ## 3.25.6 - 20 May 2024 diff --git a/lib/api-client.js b/lib/api-client.js index 938e235ee8..098dc79060 100644 --- a/lib/api-client.js +++ b/lib/api-client.js @@ -103,19 +103,12 @@ exports.getGitHubVersion = getGitHubVersion; * Get the path of the currently executing workflow relative to the repository root. */ async function getWorkflowRelativePath() { - const repo_nwo = (0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY").split("/"); - const owner = repo_nwo[0]; - const repo = repo_nwo[1]; - const run_id = Number((0, util_1.getRequiredEnvParam)("GITHUB_RUN_ID")); - const apiClient = getApiClient(); - const runsResponse = await apiClient.request("GET /repos/:owner/:repo/actions/runs/:run_id?exclude_pull_requests=true", { - owner, - repo, - run_id, + const workflow_ref = process.env["GITHUB_WORKFLOW_REF"]; + const workflowRegExp = new RegExp("^[^/]+/[^/]+/(.*?)@.*"); + const match = workflow_ref?.match(workflowRegExp); + return new Promise((resolve) => { + resolve(match ? match[1] : ''); }); - const workflowUrl = runsResponse.data.workflow_url; - const workflowResponse = await apiClient.request(`GET ${workflowUrl}`); - return workflowResponse.data.path; } exports.getWorkflowRelativePath = getWorkflowRelativePath; /** diff --git a/lib/api-client.js.map b/lib/api-client.js.map index 11f89647f4..3caf288602 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,iCASgB;AAEhB,MAAM,gCAAgC,GAAG,6BAA6B,CAAC;AAEvE,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,+FAAc,CAAA;IACd,+FAAc,CAAA;AAChB,CAAC,EAHW,0BAA0B,0CAA1B,0BAA0B,QAGrC;AAiBD,SAAS,0BAA0B,CACjC,UAAoC,EACpC,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,EAAE;IAE9B,MAAM,IAAI,GACR,CAAC,aAAa,IAAI,UAAU,CAAC,gBAAgB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC;IACpE,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,IAAI,eAAe,CACxB,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE;QAClC,OAAO,EAAE,UAAU,CAAC,MAAM;QAC1B,SAAS,EAAE,iBAAiB,IAAA,+BAAgB,GAAE,EAAE;QAChD,GAAG,EAAE,IAAA,2BAAe,EAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;KACzC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,IAAA,+BAAgB,EAAC,OAAO,CAAC;QAC/B,GAAG,EAAE,IAAA,0BAAmB,EAAC,mBAAmB,CAAC;QAC7C,MAAM,E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CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YACtC,uCAAuC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EACvD,CAAC;YACD,OAAO,IAAI,yBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAXD,8DAWC"} \ No newline at end of file +{"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,iCASgB;AAEhB,MAAM,gCAAgC,GAAG,6BAA6B,CAAC;AAEvE,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,+FAAc,CAAA;IACd,+FAAc,CAAA;AAChB,CAAC,EAHW,0BAA0B,0CAA1B,0BAA0B,QAGrC;AAiBD,SAAS,0BAA0B,CACjC,UAAoC,EACpC,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,EAAE;IAE9B,MAAM,IAAI,GACR,CAAC,aAAa,IAAI,UAAU,CAAC,gBAAgB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC;IACpE,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,IAAI,eAAe,CACxB,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE;QAClC,OAAO,EAAE,UAAU,CAAC,MAAM;QAC1B,SAAS,EAAE,iBAAiB,IAAA,+BAAgB,GAAE,EAAE;QAChD,GAAG,EAAE,IAAA,2BAAe,EAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;KACzC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,IAAA,+BAAgB,EAAC,OAA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IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAXD,8DAWC"} \ No newline at end of file diff --git a/queries/default-setup-environment-variables.ql b/queries/default-setup-environment-variables.ql index e456409419..779306742c 100644 --- a/queries/default-setup-environment-variables.ql +++ b/queries/default-setup-environment-variables.ql @@ -22,8 +22,9 @@ predicate isSafeForDefaultSetup(string envVar) { "GITHUB_ACTION_REF", "GITHUB_ACTION_REPOSITORY", "GITHUB_ACTOR", "GITHUB_API_URL", "GITHUB_BASE_REF", "GITHUB_EVENT_NAME", "GITHUB_JOB", "GITHUB_RUN_ATTEMPT", "GITHUB_RUN_ID", "GITHUB_SHA", "GITHUB_REPOSITORY", "GITHUB_SERVER_URL", "GITHUB_TOKEN", "GITHUB_WORKFLOW", - "GITHUB_WORKSPACE", "GOFLAGS", "ImageVersion", "JAVA_TOOL_OPTIONS", "RUNNER_ARCH", - "RUNNER_ENVIRONMENT", "RUNNER_NAME", "RUNNER_OS", "RUNNER_TEMP", "RUNNER_TOOL_CACHE" + "GITHUB_WORKFLOW_REF", "GITHUB_WORKSPACE", "GOFLAGS", "ImageVersion", "JAVA_TOOL_OPTIONS", + "RUNNER_ARCH", "RUNNER_ENVIRONMENT", "RUNNER_NAME", "RUNNER_OS", "RUNNER_TEMP", + "RUNNER_TOOL_CACHE" ] } diff --git a/src/api-client.ts b/src/api-client.ts index 249bec2576..5231371a73 100644 --- a/src/api-client.ts +++ b/src/api-client.ts @@ -121,25 +121,12 @@ export async function getGitHubVersion(): Promise { * Get the path of the currently executing workflow relative to the repository root. */ export async function getWorkflowRelativePath(): Promise { - const repo_nwo = getRequiredEnvParam("GITHUB_REPOSITORY").split("/"); - const owner = repo_nwo[0]; - const repo = repo_nwo[1]; - const run_id = Number(getRequiredEnvParam("GITHUB_RUN_ID")); - - const apiClient = getApiClient(); - const runsResponse = await apiClient.request( - "GET /repos/:owner/:repo/actions/runs/:run_id?exclude_pull_requests=true", - { - owner, - repo, - run_id, - }, - ); - const workflowUrl = runsResponse.data.workflow_url; - - const workflowResponse = await apiClient.request(`GET ${workflowUrl}`); - - return workflowResponse.data.path; + const workflow_ref = process.env["GITHUB_WORKFLOW_REF"]; + const workflowRegExp = new RegExp("^[^/]+/[^/]+/(.*?)@.*"); + const match = workflow_ref?.match(workflowRegExp); + return new Promise((resolve) => { + resolve(match ? match[1] : ''); + }); } /**