From 341c4329f4a90fedbb24a092f24b0bc5322bfe62 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Thu, 22 Dec 2022 23:12:55 +0300 Subject: [PATCH] ci: enable CodeQL code scanning (#5279) Co-authored-by: Dean Sheather Co-authored-by: Mathias Fredriksson Co-authored-by: Geoffrey Huntley --- .github/workflows/codeql.yml | 64 ++++++++++++++++++++++++++++++++++++ .vscode/extensions.json | 1 + 2 files changed, 65 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 0000000000..41ab12af3c --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,64 @@ +name: "CodeQL" + +on: + push: + branches: ["main"] + pull_request: + # 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: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ["go", "javascript"] + + steps: + - 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: 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' + 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}}" diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ddecd5626f..029a9996e8 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ + "github.vscode-codeql", "golang.go", "hashicorp.terraform", "esbenp.prettier-vscode",