From 2f3d5125922b619bcaa63cd7095bd4b332ee631f Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Sun, 4 Dec 2022 00:06:05 +0300 Subject: [PATCH 01/15] chore: enable GraphQL code scanning --- .github/workflows/codeql.yml | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000000..ebc0b2387a592 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,74 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '24 10 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go', 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From ac47acd6acbb9fba056c86bdad84049ea8220281 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 20 Dec 2022 07:10:44 +0300 Subject: [PATCH 02/15] removed the top commnets and description. Co-authored-by: Dean Sheather --- .github/workflows/codeql.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ebc0b2387a592..935edca4fc329 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,14 +1,3 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# name: "CodeQL" on: From df4df491e9eb18063dd9738271bed078a2783425 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 20 Dec 2022 07:11:06 +0300 Subject: [PATCH 03/15] Update .github/workflows/codeql.yml Co-authored-by: Dean Sheather --- .github/workflows/codeql.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 935edca4fc329..d9df583c0d2d8 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,7 +29,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: From a3e31ecc9058b75e526af95d0b6ae014789301e1 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 20 Dec 2022 07:11:20 +0300 Subject: [PATCH 04/15] Update .github/workflows/codeql.yml Co-authored-by: Dean Sheather --- .github/workflows/codeql.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d9df583c0d2d8..394cb4ae36554 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -22,8 +22,6 @@ jobs: fail-fast: false matrix: language: [ 'go', 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - name: Checkout repository From 34521c00ee7136e3859eadf31b01f47354ecce3e Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 20 Dec 2022 07:12:07 +0300 Subject: [PATCH 05/15] Update .github/workflows/codeql.yml Co-authored-by: Dean Sheather --- .github/workflows/codeql.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 394cb4ae36554..1d504e90a3281 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -31,12 +31,6 @@ jobs: uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). From be83ef395ee6b1dc048acb33817fe32b86f45532 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 20 Dec 2022 07:13:06 +0300 Subject: [PATCH 06/15] Update .github/workflows/codeql.yml Co-authored-by: Dean Sheather --- .github/workflows/codeql.yml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1d504e90a3281..b88cd68d90417 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,20 +33,9 @@ jobs: languages: ${{ matrix.language }} - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + - name: Download Go Dependencies + if: matrix.language == 'go' + run: go mod download - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 From a4ccadab400f4f68eb2b887c3a7870dddb04af60 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 20 Dec 2022 07:30:43 +0300 Subject: [PATCH 07/15] Comment on when the action schedule runs --- .github/workflows/codeql.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b88cd68d90417..b7acd05afc98a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -7,6 +7,7 @@ on: # The branches below must be a subset of the branches above branches: [ "main" ] schedule: + # run every week at 10:24 on Thursday - cron: '24 10 * * 4' jobs: From 18f3fd97badf2af6754da80aab1ae1a1018d1cb1 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Tue, 20 Dec 2022 14:49:39 +1000 Subject: [PATCH 08/15] Update .github/workflows/codeql.yml --- .github/workflows/codeql.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b7acd05afc98a..37dc87b022a61 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,7 +33,6 @@ jobs: with: languages: ${{ matrix.language }} - - name: Download Go Dependencies if: matrix.language == 'go' run: go mod download From 5a4c169291082a02c9a63f629a242432140f3fe6 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 20 Dec 2022 12:25:44 +0300 Subject: [PATCH 09/15] Update .github/workflows/codeql.yml Co-authored-by: Mathias Fredriksson --- .github/workflows/codeql.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 37dc87b022a61..b481f37d2cbf2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,6 +33,12 @@ jobs: with: languages: ${{ matrix.language }} + - name: Setup Go + if: matrix.language == 'go' + uses: actions/setup-go@v3 + with: + go-version: "~1.19" + - name: Download Go Dependencies if: matrix.language == 'go' run: go mod download From bcde5f3fc5f0e1b4eb772bd39a898bb0348ef6a9 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Tue, 20 Dec 2022 13:09:54 +0200 Subject: [PATCH 10/15] Update .github/workflows/codeql.yml --- .github/workflows/codeql.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b481f37d2cbf2..d5986092f23da 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,15 +33,12 @@ jobs: with: languages: ${{ matrix.language }} - - name: Setup Go - if: matrix.language == 'go' - uses: actions/setup-go@v3 - with: - go-version: "~1.19" - - name: Download Go Dependencies if: matrix.language == 'go' - run: go mod download + run: | + go mod download + # Disable Analysis step from trying to build the project. + rm Makefile - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 From d7df6d48e6e852c0ad7dfb45535018a2b214d277 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 21 Dec 2022 10:56:07 +0300 Subject: [PATCH 11/15] Update codeql.yml Updated as per @mafredri suggestion. --- .github/workflows/codeql.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d5986092f23da..53a816dfc370d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -32,13 +32,12 @@ jobs: uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} - - - name: Download Go Dependencies + + - name: Setup Go if: matrix.language == 'go' - run: | - go mod download - # Disable Analysis step from trying to build the project. - rm Makefile + uses: actions/setup-go@v3 + with: + go-version: "~1.19" - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 From 38ce3f18b6b26940c822e51dae49961e9faa1098 Mon Sep 17 00:00:00 2001 From: Geoffrey Huntley Date: Thu, 22 Dec 2022 07:21:37 +0000 Subject: [PATCH 12/15] add vscode extension recommendation --- .vscode/extensions.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ddecd5626f957..029a9996e8634 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ + "github.vscode-codeql", "golang.go", "hashicorp.terraform", "esbenp.prettier-vscode", From 4aa5c0583b38c18060ad846dfbe95bcae9c10dc9 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Thu, 22 Dec 2022 10:37:02 +0300 Subject: [PATCH 13/15] remove MakeFile --- .github/workflows/codeql.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 53a816dfc370d..7a3da030a9f30 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -38,6 +38,12 @@ jobs: uses: actions/setup-go@v3 with: go-version: "~1.19" + + - name: Remove Makefile # workaround to prevent CodeQL from building site + if: matrix.language == 'go' + run: | + # Disable Analysis step from trying to build the project. + rm Makefile - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 From d7b882fd9d45d68fe477079d822681b617d7085f Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Thu, 22 Dec 2022 18:55:12 +0000 Subject: [PATCH 14/15] Enable go mod cache --- .github/workflows/codeql.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7a3da030a9f30..54518e2a1d288 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -38,6 +38,19 @@ jobs: uses: actions/setup-go@v3 with: go-version: "~1.19" + + - name: Go Cache Paths + if: matrix.language == 'go' + id: go-cache-paths + run: | + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + - name: Go Mod Cache + if: matrix.language == 'go' + uses: actions/cache@v3 + with: + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }} - name: Remove Makefile # workaround to prevent CodeQL from building site if: matrix.language == 'go' From ea08e7aa20d635f7e507981cb6aff1161bad53ec Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Thu, 22 Dec 2022 18:56:20 +0000 Subject: [PATCH 15/15] fmt --- .github/workflows/codeql.yml | 74 ++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 54518e2a1d288..41ab12af3c384 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -2,13 +2,13 @@ name: "CodeQL" on: push: - branches: [ "main" ] + branches: ["main"] pull_request: # The branches below must be a subset of the branches above - branches: [ "main" ] + branches: ["main"] schedule: # run every week at 10:24 on Thursday - - cron: '24 10 * * 4' + - cron: "24 10 * * 4" jobs: analyze: @@ -22,43 +22,43 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'go', 'javascript' ] + language: ["go", "javascript"] steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - - name: Setup Go - if: matrix.language == 'go' - uses: actions/setup-go@v3 - with: - go-version: "~1.19" + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} - - name: Go Cache Paths - if: matrix.language == 'go' - id: go-cache-paths - run: | - echo "::set-output name=go-mod::$(go env GOMODCACHE)" + - name: Setup Go + if: matrix.language == 'go' + uses: actions/setup-go@v3 + with: + go-version: "~1.19" - - name: Go Mod Cache - if: matrix.language == 'go' - uses: actions/cache@v3 - with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }} - - - name: Remove Makefile # workaround to prevent CodeQL from building site - if: matrix.language == 'go' - run: | - # Disable Analysis step from trying to build the project. - rm Makefile + - name: Go Cache Paths + if: matrix.language == 'go' + id: go-cache-paths + run: | + echo "::set-output name=go-mod::$(go env GOMODCACHE)" - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + - name: Go Mod Cache + if: matrix.language == 'go' + uses: actions/cache@v3 + with: + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }} + + - name: Remove Makefile # workaround to prevent CodeQL from building site + if: matrix.language == 'go' + run: | + # Disable Analysis step from trying to build the project. + rm Makefile + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}"