From 58c1abf92e2b83accb35fd4f320cb20ca977e116 Mon Sep 17 00:00:00 2001 From: David Verdeguer Date: Thu, 14 May 2020 15:36:47 +0200 Subject: [PATCH 1/6] Add help link at issue creation --- .github/ISSUE_TEMPLATE/config.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..4f4ce286a2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: true +contact_links: + - name: Github support + url: https://support.github.com/contact?subject=Code+Scanning+Beta+Support&tags=code-scanning-support + about: Code Scanning Beta Support - Get help with GitHub \ No newline at end of file From 25e52568665c3767a22bc99b794c1a67169081ef Mon Sep 17 00:00:00 2001 From: David Verdeguer Date: Mon, 18 May 2020 00:14:03 +0200 Subject: [PATCH 2/6] Add more info about dot syntax --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ec41fa8539..fde1b62c3a 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ The CodeQL action should be run on `push` events, and on a `schedule`. `Push` ev ### Configuration -You may optionally specify additional queries for CodeQL to execute by using a config file. The queries must belong to a [QL pack](https://help.semmle.com/codeql/codeql-cli/reference/qlpack-overview.html) and can be in your repository or any public repository. You can choose a single .ql file, a folder containing multiple .ql files, a .qls [query suite](https://help.semmle.com/codeql/codeql-cli/procedures/query-suites.html) file, or any combination of the above. To use queries from other repositories use the same syntax as when [using an action](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses). +You may optionally specify additional queries for CodeQL to execute by using a config file. The queries must belong to a [QL pack](https://help.semmle.com/codeql/codeql-cli/reference/qlpack-overview.html) and can be in your repository or any public repository. You can choose a single .ql file, a folder containing multiple .ql files, a .qls [query suite](https://help.semmle.com/codeql/codeql-cli/procedures/query-suites.html) file, or any combination of the above. To use queries stored in your repository or from other repositories use the same syntax as when [using an action](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses). Note that for using local queries the path `./` it is not relative to the locatio of the config file, it refers to the root of the repository. You can disable the default queries using `disable-default-queries: true`. From 90c07ef21d6e67d81d28e456cacf0ef909027753 Mon Sep 17 00:00:00 2001 From: David Verdeguer Date: Mon, 18 May 2020 16:11:32 +0200 Subject: [PATCH 3/6] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fde1b62c3a..09e092f1c4 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ The CodeQL action should be run on `push` events, and on a `schedule`. `Push` ev ### Configuration -You may optionally specify additional queries for CodeQL to execute by using a config file. The queries must belong to a [QL pack](https://help.semmle.com/codeql/codeql-cli/reference/qlpack-overview.html) and can be in your repository or any public repository. You can choose a single .ql file, a folder containing multiple .ql files, a .qls [query suite](https://help.semmle.com/codeql/codeql-cli/procedures/query-suites.html) file, or any combination of the above. To use queries stored in your repository or from other repositories use the same syntax as when [using an action](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses). Note that for using local queries the path `./` it is not relative to the locatio of the config file, it refers to the root of the repository. +You may optionally specify additional queries for CodeQL to execute by using a config file. The queries must belong to a [QL pack](https://help.semmle.com/codeql/codeql-cli/reference/qlpack-overview.html) and can be in your repository or any public repository. You can choose a single .ql file, a folder containing multiple .ql files, a .qls [query suite](https://help.semmle.com/codeql/codeql-cli/procedures/query-suites.html) file, or any combination of the above. To use queries stored in your repository or from other repositories use the same syntax as when [using an action](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses). Note that when using local queries starting with `./`, the path is relative to the root of the repository and not to the location of the config file. You can disable the default queries using `disable-default-queries: true`. From da1e237d1ef0c14e3cabd91a7d3bbc47a4bc7f53 Mon Sep 17 00:00:00 2001 From: Robert Brignull Date: Thu, 7 May 2020 14:28:46 +0100 Subject: [PATCH 4/6] Allow pull requests, and report correct commit oid and ref --- .github/workflows/codeql.yml | 12 ++++++- .github/workflows/integration-testing.yml | 24 ++++++-------- README.md | 12 +++++++ lib/upload-lib.js | 2 +- lib/upload-lib.js.map | 2 +- lib/util.js | 38 +++++++++++++++++----- lib/util.js.map | 2 +- src/upload-lib.ts | 2 +- src/util.ts | 39 +++++++++++++++++------ 9 files changed, 97 insertions(+), 36 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 761d70aa53..e18797b729 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,6 +1,6 @@ name: "CodeQL action" -on: [push] +on: [push, pull_request] jobs: build: @@ -11,6 +11,16 @@ jobs: steps: - uses: actions/checkout@v1 + with: + # Must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head of the pull request. + fetch-depth: 2 + + # If this run was triggered by a pull request event then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + - uses: ./init with: languages: javascript diff --git a/.github/workflows/integration-testing.yml b/.github/workflows/integration-testing.yml index e2db985ca6..3f9df52486 100644 --- a/.github/workflows/integration-testing.yml +++ b/.github/workflows/integration-testing.yml @@ -1,6 +1,6 @@ name: "Integration Testing" -on: [push] +on: [push, pull_request] jobs: multi-language-repo_test-autodetect-languages: @@ -16,9 +16,8 @@ jobs: shell: bash run: | mkdir ../action - shopt -s dotglob - mv * ../action/ - mv ../action/tests/multi-language-repo/* . + mv * .github ../action/ + mv ../action/tests/multi-language-repo/{*,.github} . - uses: ./../action/init - name: Build code shell: bash @@ -40,9 +39,8 @@ jobs: shell: bash run: | mkdir ../action - shopt -s dotglob - mv * ../action/ - mv ../action/tests/multi-language-repo/* . + mv * .github ../action/ + mv ../action/tests/multi-language-repo/{*,.github} . - uses: ./../action/init with: languages: cpp,csharp,java,javascript,python @@ -72,9 +70,8 @@ jobs: shell: bash run: | mkdir ../action - shopt -s dotglob - mv * ../action/ - mv ../action/tests/multi-language-repo/* . + mv * .github ../action/ + mv ../action/tests/multi-language-repo/{*,.github} . - uses: ./../action/init with: languages: go @@ -96,9 +93,8 @@ jobs: shell: bash run: | mkdir ../action - shopt -s dotglob - mv * ../action/ - mv ../action/tests/multi-language-repo/* . + mv * .github ../action/ + mv ../action/tests/multi-language-repo/{*,.github} . - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -117,4 +113,4 @@ jobs: with: sarif_file: rubocop.sarif env: - TEST_MODE: true \ No newline at end of file + TEST_MODE: true diff --git a/README.md b/README.md index 09e092f1c4..94181b4372 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ name: "Code Scanning - Action" on: push: + pull_request: schedule: - cron: '0 0 * * 0' @@ -33,6 +34,17 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 + with: + # Must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head of the pull request. + # Only include this option if you are running this workflow on pull requests. + fetch-depth: 2 + + # If this run was triggered by a pull request event then checkout + # the head of the pull request instead of the merge commit. + # Only include this step if you are running this workflow on pull requests. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 19b9e685a2..af4e1a3fef 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -133,7 +133,7 @@ async function uploadFiles(sarifFiles) { return false; } core.exportVariable(sentinelEnvVar, sentinelEnvVar); - const commitOid = util.getRequiredEnvParam('GITHUB_SHA'); + const commitOid = await util.getCommitOid(); const workflowRunIDStr = util.getRequiredEnvParam('GITHUB_RUN_ID'); const ref = util.getRef(); const analysisKey = await util.getAnalysisKey(); diff --git a/lib/upload-lib.js.map b/lib/upload-lib.js.map index 55db2311de..be05da3dd1 100644 --- a/lib/upload-lib.js.map +++ b/lib/upload-lib.js.map @@ -1 +1 @@ -{"version":3,"file":"upload-lib.js","source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newline at end of file diff --git a/lib/util.js b/lib/util.js index 16cd362f95..adf4aa3650 100644 --- a/lib/util.js +++ b/lib/util.js @@ -11,6 +11,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); +const exec = __importStar(require("@actions/exec")); const http = __importStar(require("@actions/http-client")); const auth = __importStar(require("@actions/http-client/auth")); const octokit = __importStar(require("@octokit/rest")); @@ -33,12 +34,6 @@ function should_abort(actionName, requireInitActionHasRun) { core.setFailed('GITHUB_REF must be set.'); return true; } - // Should abort if called on a merge commit for a pull request. - if (ref.startsWith('refs/pull/')) { - core.warning('The CodeQL ' + actionName + ' action is intended for workflows triggered on `push` events, ' - + 'but the current workflow is running on a pull request. Aborting.'); - return true; - } // If the init action is required, then check the it completed successfully. if (requireInitActionHasRun && process.env[sharedEnv.CODEQL_ACTION_INIT_COMPLETED] === undefined) { core.setFailed('The CodeQL ' + actionName + ' action cannot be used unless the CodeQL init action is run first. Aborting.'); @@ -151,6 +146,21 @@ async function getLanguages() { return languages; } exports.getLanguages = getLanguages; +/** + * Gets the SHA of the commit that is currently checked out. + */ +async function getCommitOid() { + let commitOid = ''; + await exec.exec('git', ['rev-parse', 'HEAD'], { + silent: true, + listeners: { + stdout: (data) => { commitOid += data.toString(); }, + stderr: (data) => { process.stderr.write(data); } + } + }); + return commitOid.trim(); +} +exports.getCommitOid = getCommitOid; /** * Get the path of the currently executing workflow. */ @@ -196,8 +206,20 @@ exports.getAnalysisKey = getAnalysisKey; * Get the ref currently being analyzed. */ function getRef() { - // it's in the form "refs/heads/master" - return getRequiredEnvParam('GITHUB_REF'); + // 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 ref = getRequiredEnvParam('GITHUB_REF'); + // For pull request refs we want to convert from the 'merge' ref + // to the 'head' ref, as that is what we want to analyse. + // There should have been some code earlier in the workflow to do + // the checkout, but we have no way of verifying that here. + const pull_ref_regex = /refs\/pull\/(\d+)\/merge/; + if (pull_ref_regex.test(ref)) { + return ref.replace(pull_ref_regex, 'refs/pull/$1/head'); + } + else { + return ref; + } } exports.getRef = getRef; /** diff --git a/lib/util.js.map b/lib/util.js.map index 6e83d9e685..0711f51fc1 100644 --- a/lib/util.js.map +++ b/lib/util.js.map @@ -1 +1 @@ -{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsC;AACtC,2DAA6C;AAC7C,gEAAkD;AAClD,uDAAyC;AACzC,0EAAgD;AAChD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAE7B,gEAAkD;AAElD;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,UAAkB,EAAE,uBAAgC;IAE7E,6DAA6D;IAC7D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACtC,IAAI,GAAG,KAAK,SAAS,EAAE;QACnB,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;KACf;IAED,+DAA+D;IAC/D,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QAC9B,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,UAAU,GAAG,gEAAgE;cACpG,kEAAkE,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC;KACf;IAED,4EAA4E;IAC5E,IAAI,uBAAuB,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,4BAA4B,CAAC,KAAK,SAAS,EAAE;QAC9F,IAAI,CAAC,SAAS,CAAC,aAAa,GAAG,UAAU,GAAG,8EAA8E,CAAC,CAAC;QAC5H,OAAO,IAAI,CAAC;KACf;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAvBD,oCAuBC;AAED;;GAEG;AACH,SAAgB,eAAe;IAC3B,IAAI,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;I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AAG,IAAI,CAAC;SACjC;KACJ;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAbD,oCAaC;AAED,6FAA6F;AAC7F,wCAAwC;AACjC,KAAK,UAAU,UAAU,CAAI,IAAoC;IACpE,MAAM,MAAM,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AAClB,CAAC;AALD,gCAKC"} \ No newline at end of file diff --git a/src/upload-lib.ts b/src/upload-lib.ts index 0db8ee40b1..fa1b52a77c 100644 --- a/src/upload-lib.ts +++ b/src/upload-lib.ts @@ -136,7 +136,7 @@ async function uploadFiles(sarifFiles: string[]): Promise { } core.exportVariable(sentinelEnvVar, sentinelEnvVar); - const commitOid = util.getRequiredEnvParam('GITHUB_SHA'); + const commitOid = await util.getCommitOid(); const workflowRunIDStr = util.getRequiredEnvParam('GITHUB_RUN_ID'); const ref = util.getRef(); const analysisKey = await util.getAnalysisKey(); diff --git a/src/util.ts b/src/util.ts index a236216b83..bb133295d5 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,4 +1,5 @@ import * as core from '@actions/core'; +import * as exec from '@actions/exec'; import * as http from '@actions/http-client'; import * as auth from '@actions/http-client/auth'; import * as octokit from '@octokit/rest'; @@ -25,13 +26,6 @@ export function should_abort(actionName: string, requireInitActionHasRun: boolea return true; } - // Should abort if called on a merge commit for a pull request. - if (ref.startsWith('refs/pull/')) { - core.warning('The CodeQL ' + actionName + ' action is intended for workflows triggered on `push` events, ' - + 'but the current workflow is running on a pull request. Aborting.'); - return true; - } - // If the init action is required, then check the it completed successfully. if (requireInitActionHasRun && process.env[sharedEnv.CODEQL_ACTION_INIT_COMPLETED] === undefined) { core.setFailed('The CodeQL ' + actionName + ' action cannot be used unless the CodeQL init action is run first. Aborting.'); @@ -152,6 +146,21 @@ export async function getLanguages(): Promise { return languages; } +/** + * Gets the SHA of the commit that is currently checked out. + */ +export async function getCommitOid(): Promise { + let commitOid = ''; + await exec.exec('git', ['rev-parse', 'HEAD'], { + silent: true, + listeners: { + stdout: (data) => { commitOid += data.toString(); }, + stderr: (data) => { process.stderr.write(data); } + } + }); + return commitOid.trim(); +} + /** * Get the path of the currently executing workflow. */ @@ -204,8 +213,20 @@ export async function getAnalysisKey(): Promise { * Get the ref currently being analyzed. */ export function getRef(): string { - // it's in the form "refs/heads/master" - return getRequiredEnvParam('GITHUB_REF'); + // 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 ref = getRequiredEnvParam('GITHUB_REF'); + + // For pull request refs we want to convert from the 'merge' ref + // to the 'head' ref, as that is what we want to analyse. + // There should have been some code earlier in the workflow to do + // the checkout, but we have no way of verifying that here. + const pull_ref_regex = /refs\/pull\/(\d+)\/merge/; + if (pull_ref_regex.test(ref)) { + return ref.replace(pull_ref_regex, 'refs/pull/$1/head'); + } else { + return ref; + } } interface StatusReport { From 3ca3147cd4687ef7ccb483f34f984827de4c6dae Mon Sep 17 00:00:00 2001 From: David Verdeguer <47184891+Daverlo@users.noreply.github.com> Date: Fri, 29 May 2020 08:22:30 +0200 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Justin Hutchings --- .github/ISSUE_TEMPLATE/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 4f4ce286a2..ccbe84d83b 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: true contact_links: - - name: Github support + - name: Contact GitHub Support url: https://support.github.com/contact?subject=Code+Scanning+Beta+Support&tags=code-scanning-support - about: Code Scanning Beta Support - Get help with GitHub \ No newline at end of file + about: Contact Support about code scanning From 2909e97a328962a918cc46d159a576bacb61a7ec Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 1 Jun 2020 09:44:48 +0100 Subject: [PATCH 6/6] Update codeql.yml --- .github/workflows/codeql.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index e18797b729..a3a5831d36 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v1 - with: - # Must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head of the pull request. - fetch-depth: 2 + with: + # Must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head of the pull request. + fetch-depth: 2 # If this run was triggered by a pull request event then checkout # the head of the pull request instead of the merge commit.