Skip to content

Fix script to handle SARIF file recategorization #531

Fix script to handle SARIF file recategorization

Fix script to handle SARIF file recategorization #531

# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
name: "CodeQL - Multi-Repo Source Scan"
on:
pull_request:
types: [opened, reopened, synchronize]
merge_group:
types: [checks_requested]
push:
branches:
- main
release:
types: [created]
workflow_dispatch:
permissions:
contents: write
# Do not flood CI with unneeded previous runs in PR
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: ${{ github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
jobs:
analyze-repos:
name: Analyze Multiple Repositories
runs-on: ubuntu-latest
permissions:
security-events: write
packages: read
actions: read
contents: read
steps:
- name: Checkout central repository
uses: actions/checkout@v4
- name: Checkout CodeQL Coding Standards scripts
uses: actions/checkout@v4
with:
repository: github/codeql-coding-standards
path: codeql-coding-standards-repo # Klonen in diesen Ordner
ref: main # Oder eine spezifische Release-Version, z.B. 'v2.53.0-dev'
# Add coding standard packages and dependencies
- name: Install Python dependencies for Coding Standards scripts
run: |
python3 -m pip install --upgrade pip
pip3 install pyyaml jsonpath-ng jsonschema jsonpatch jsonpointer pytest sarif-tools
- name: Parse known_good.json and create repos.json
id: parse-repos
run: |
scripts/workflow/parse_repos.sh
- name: Checkout all pinned repositories
id: checkout-repos
run: |
scripts/workflow/checkout_repos.sh
- name: List files in repos directory (debug)
run: |
echo "Listing all files in repos directory before CodeQL analysis:"
find repos || echo "repos directory not found"
- name: Initialize CodeQL for all repositories
uses: github/codeql-action/init@v4
with:
languages: cpp
build-mode: none
packs: codeql/misra-cpp-coding-standards
config-file: ./.github/codeql/codeql-config.yml
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
upload-database: false # Don't upload databases for each repo
output: sarif-results/
category: "multi-repo-scan"
- name: Recategorize Guidelines
if: always()
run: |
scripts/workflow/recategorize_guidelines.sh
- name: Generate HTML Report from SARIF
run: |
SARIF_FILE="sarif-results/cpp.sarif"
sarif html "$SARIF_FILE" --output codeql-report.html
- name: Upload SARIF results as artifact
uses: actions/upload-artifact@v4
with:
name: codeql-sarif-results
path: sarif-results/
- name: Upload HTML Report as artifact
uses: actions/upload-artifact@v4
with:
name: codeql-html-report
path: codeql-report.html