Skip to content

Refactor CodeQL analysis - #144

Open
lavrovvalera wants to merge 3 commits into
eclipse-score:mainfrom
lavrovvalera:vala_codeql_setup
Open

Refactor CodeQL analysis#144
lavrovvalera wants to merge 3 commits into
eclipse-score:mainfrom
lavrovvalera:vala_codeql_setup

Conversation

@lavrovvalera

Copy link
Copy Markdown
Contributor

Description

Improves the MISRA C++:2023 CodeQL analysis pipeline.

Build-level test exclusion

Previously test/mock code entered the CodeQL database and was filtered from
SARIF afterwards. bazel cquery now resolves production-only labels before the
traced build — test sources never enter the database and the SARIF post-processing
filter is removed.

RULE-7-0-4 deviation

CodeQL incorrectly flags overloaded operator<< on stream types as a bitwise
shift (tool defect). 260 false positives suppressed via coding-standards.yaml,
scoped to specific header files. Files with genuine bitwise operations remain
reported.

Tooling layout and CI

  • coding-standards.yaml moved from repo root → tools/static_analysis/
  • codeql.bzl macro introduced — separates module-agnostic wiring from the
    module-specific entry point, making the tooling reusable by other modules
  • CI workflow rewritten: invokes codeql_lint directly (pinned CLI + pinned
    MISRA pack + deviation processing), replacing the shared wrapper that used
    GitHub's unpinned CodeQL and had no deviation support. SARIF is uploaded to
    GitHub Security tab; compliance reports are uploaded as a build artifact.

Related ticket

closes #120 (improvement ticket)

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: 601a5727-3119-4039-9a56-01f7b2f47bdf
Computing main repo mapping: 
WARNING: /home/runner/work/time/time/MODULE.bazel:13:7: The attribute 'compatibility_level' in module() is a no-op and will be removed in a future Bazel release. Please remove it from your MODULE.bazel file.
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 3 packages loaded
Loading: 3 packages loaded
    currently loading: 
Loading: 3 packages loaded
    currently loading: 
Loading: 3 packages loaded
    currently loading: 
Loading: 3 packages loaded
    currently loading: 
Loading: 3 packages loaded
    currently loading: 
Analyzing: target //:license-check (4 packages loaded, 0 targets configured)
Analyzing: target //:license-check (4 packages loaded, 0 targets configured)

Analyzing: target //:license-check (62 packages loaded, 10 targets configured)

Analyzing: target //:license-check (82 packages loaded, 10 targets configured)

Analyzing: target //:license-check (89 packages loaded, 10 targets configured)

Analyzing: target //:license-check (144 packages loaded, 2226 targets configured)

Analyzing: target //:license-check (157 packages loaded, 6170 targets configured)

Analyzing: target //:license-check (157 packages loaded, 6170 targets configured)

Analyzing: target //:license-check (162 packages loaded, 6219 targets configured)

Analyzing: target //:license-check (162 packages loaded, 6219 targets configured)

Analyzing: target //:license-check (167 packages loaded, 8346 targets configured)

Analyzing: target //:license-check (168 packages loaded, 11288 targets configured)

Analyzing: target //:license-check (169 packages loaded, 11296 targets configured)

Analyzing: target //:license-check (169 packages loaded, 11296 targets configured)

INFO: Analyzed target //:license-check (170 packages loaded, 11422 targets configured).
[3 / 14] Expanding template external/score_tooling+/dash/tool/formatters/_dash_format_converter_stage2_bootstrap.py [for tool]; 0s local
[12 / 16] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes; 0s disk-cache, processwrapper-sandbox ... (2 actions running)
INFO: From Generating Dash formatted dependency file ...:
INFO: Successfully converted 2 packages from Cargo.lock to bazel-out/k8-fastbuild/bin/formatted.txt
[15 / 16] [Prepa] Building license.check.license_check.jar ()
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 31.158s, Critical Path: 2.48s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@github-actions

Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

**CodeQL infrastructure**
- Add `tools/static_analysis:codeql_lint` — build-traced scan with vendored
  CodeQL CLI 2.21.4 + pre-compiled MISRA C++:2023 pack v2.61.0
- Add `third_party/codeql/` — Bazel integration + patch for `utils.py`
  (Python 3.12 `\d` warning + MISRA C++:2023 report label)
- Add `coding-standards.yaml` — deviation record for RULE-18-5-2
- Add `build:codeql` to `.bazelrc` — LLVM toolchain + cache-busting flags

**Dependency upgrade**
- Upgrade `score_lifecycle_health` 0.2.0 → 0.3.0; migrate include paths and
  Bazel labels in `time_daemon` and `time_slave` application sources

**Docs & housekeeping**
- Add `tools/static_analysis/README.md` — design, known gaps, local run guide
- Update `README.md` with local run command and output files
- Add `codeql-*/` to `.gitignore`
Replace SARIF post-processing with build-level test exclusion:
- Use bazel cquery --config=codeql with 'except attr(testonly, 1, ...)' to
  resolve production-only labels before the traced build; testonly targets,
  platform-incompatible targets (e.g. QNX-only), and multi-config duplicates
  are all excluded before any source file enters the database
- Add --skip_incompatible_explicit_targets to bazel build so explicit label
  lists tolerate platform-incompatible targets gracefully

Fix BUILD hygiene:
- Add testonly=True to svt_receiver_mock alias (//score/time_daemon/src/ipc)
- Add testonly=True to HighResSteadyTimeBenchmark cc_binary

Add RULE-7-0-4 deviation (tool defect: stream operator<< mis-flagged as shift)

Refactor tooling layout (module-agnostic vs module-specific split):
- Extract codeql.bzl macro; BUILD reduced to a 3-line load + call
- Move coding-standards.yaml to tools/static_analysis/ (process_coding_standards_config
  scans recursively, root location is not required)
- coding-standards.yaml declared as explicit Bazel filegroup for incremental
  rebuild tracking

Update README: file layout section, cquery-based phase descriptions,
build-level test exclusion explanation, remove stale gap eclipse-score#4
@lavrovvalera lavrovvalera changed the title Vala codeql setup Refactor CodeQL analysis Aug 3, 2026
Replace the shared eclipse-score/cicd-workflows CodeQL wrapper with a direct
invocation of tools/static_analysis:codeql_lint, mirroring the local workflow
exactly.

Motivation:
- The shared wrapper used github/codeql-action/init (unpinned CodeQL version)
  and packs: codeql/misra-cpp-coding-standards (downloaded from registry at
  runtime, no deviation processing).
- Our codeql_lint uses the pinned CLI (@codeql_bundle v2.21.4), the pinned
  MISRA pack (@codeql_coding_standards_compiled v2.61.0), and runs
  process_coding_standards_config to apply coding-standards.yaml deviations
  before the analysis. Findings from known tool defects (e.g. RULE-7-0-4)
  are suppressed in the results.

Changes:
- Replace reusable workflow call with a standalone job
- Add more-disk-space (level 4) — CodeQL database + tooling requires headroom
- Run bazel run //tools/static_analysis:codeql_lint with the same arguments
  as the local invocation; output goes to runner.temp
- Upload codeql-time.sarif to GitHub Security tab via upload-sarif@v3
- Upload analysis_reports/ as a build artifact for audit/compliance use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

CI: Establish working CodeQL nightly scan

1 participant