diff --git a/.github/codeql/codeql-config.yaml b/.github/codeql/codeql-config.yaml new file mode 100644 index 000000000..90bf25727 --- /dev/null +++ b/.github/codeql/codeql-config.yaml @@ -0,0 +1,9 @@ +name: "CodeQL configuration" + +paths-ignore: + - "**/zz_generated*.go" + - "**/fake/**" + - "testdata/" + +queries: + - uses: security-extended diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..69cdbe906 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,69 @@ +name: CodeQL + +on: + push: + branches: + - "main" + - "release-*" + paths-ignore: + - "docs/**" + - "**/*.md" + - "OWNERS" + - "CODEOWNERS" + - "external-images.yaml" + - "renovate.json" + pull_request: + branches: + - "main" + - "release-*" + paths-ignore: + - "docs/**" + - "**/*.md" + - "OWNERS" + - "CODEOWNERS" + - "external-images.yaml" + - "renovate.json" + schedule: + - cron: '35 7 * * 1' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + runs-on: ubuntu-latest + permissions: + security-events: write + packages: read + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: actions + build-mode: none + - language: go + build-mode: manual + - language: javascript-typescript + build-mode: none + + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Initialize CodeQL + uses: github/codeql-action/init@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + config-file: .github/codeql/codeql-config.yaml + + - name: Run manual build steps + if: matrix.build-mode == 'manual' + shell: bash + run: make build-for-codeql + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3 + with: + category: "/language:${{matrix.language}}" diff --git a/Makefile b/Makefile index 128f04979..d201dfa59 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,10 @@ verify: ## Run all verification checks. build: ## Build the kyma CLI binary. GOFIPS140=v1.0.0 go build -ldflags="-X github.com/kyma-project/cli.v3/internal/cmd/version.version=local-$(shell git rev-parse --short HEAD)" -o bin/kyma main.go +.PHONY: build-for-codeql +build-for-codeql: ## Build all binaries for CodeQL analysis. + go build -o /dev/null ./... + .PHONY: docs docs: ## Generate CLI documentation. go mod tidy