diff --git a/.github/codeql/README.md b/.github/codeql/README.md new file mode 100644 index 00000000000..b4a441c9e63 --- /dev/null +++ b/.github/codeql/README.md @@ -0,0 +1,9 @@ +# Security analysis + +The CodeQL workflow runs the `security-extended` query suite for the SDK language and GitHub Actions on pull requests, pushes, merge queues and a weekly schedule. It can also be started manually. + +The SDK scan traces a clean Clang build of the SDK, OpenTelemetry plugins and examples, with tests and compiler caching disabled. Compiled dependencies and generated headers remain part of extraction. + +Results are published to **Security and quality → Code scanning**, with a separate category for each language. Review initial findings and record a reason for every dismissed alert. + +After merging, require both **CodeQL (c-cpp)** and **CodeQL (actions)** job checks for supported branches. Also enable **Require code scanning results → CodeQL → Security alerts: High or higher** in the branch ruleset. Successful workflow execution alone does not enforce this threshold. Track the latest analysis commit/date, extraction errors and open findings by security severity. diff --git a/.github/codeql/actions.yml b/.github/codeql/actions.yml new file mode 100644 index 00000000000..57959b9da0b --- /dev/null +++ b/.github/codeql/actions.yml @@ -0,0 +1,4 @@ +name: GitHub Actions security baseline + +queries: + - uses: security-extended diff --git a/.github/codeql/sdk.yml b/.github/codeql/sdk.yml new file mode 100644 index 00000000000..61d31213b26 --- /dev/null +++ b/.github/codeql/sdk.yml @@ -0,0 +1,4 @@ +name: SDK security baseline + +queries: + - uses: security-extended diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000000..d01d770f095 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,70 @@ +name: CodeQL + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + merge_group: + schedule: + - cron: '23 3 * * 1' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: codeql-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + analyze: + name: CodeQL (${{ matrix.language }}) + runs-on: ubuntu-24.04 + timeout-minutes: 90 + permissions: + contents: read + security-events: write + strategy: + fail-fast: false + matrix: + include: + - language: c-cpp + build-mode: manual + config: .github/codeql/sdk.yml + - language: actions + build-mode: none + config: .github/codeql/actions.yml + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Install C++ build dependencies + if: matrix.language == 'c-cpp' + uses: ./.github/actions/prepare_vm + + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + config-file: ${{ matrix.config }} + + - name: Build C++ SDK, plugins and examples without compiler cache + if: matrix.language == 'c-cpp' + env: + CCACHE_DISABLE: '1' + run: | + cmake --preset release-clang \ + -DYDB_SDK_TESTS=OFF \ + -DYDB_SDK_EXAMPLES=ON \ + -DYDB_SDK_ENABLE_OTEL_METRICS=ON \ + -DYDB_SDK_ENABLE_OTEL_TRACE=ON \ + -DCMAKE_C_COMPILER_LAUNCHER= \ + -DCMAKE_CXX_COMPILER_LAUNCHER= + cmake --build --preset default --parallel 2 + + - name: Analyze and upload results + uses: github/codeql-action/analyze@v4 + with: + category: /language:${{ matrix.language }}