Skip to content

ci: scan src/*.mc with CodeQL via minicompiler/codeql-mc - #56

Merged
schivei merged 1 commit into
mainfrom
ci/codeql-mc-scanning
Oct 7, 2026
Merged

schivei merged 1 commit into
mainfrom
ci/codeql-mc-scanning

Conversation

@schivei

@schivei schivei commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

What

mc-php's real source is .mc, which GitHub's github/codeql-action cannot analyze — custom languages are unsupported (codeql-action#3015). This adds an independent mc job to .github/workflows/codeql.yml that scans src/*.mc with the minicompiler/codeql-mc extractor and surfaces the results as code-scanning alerts.

The chain (standard hosted runner, no self-hosting):

checkout codeql-mc (pinned SHA)
  → cargo build the extractor pack
  → codeql database create --language=mc --source-root src --search-path <pack>
  → codeql database analyze <db> <mc queries> --format=sarif-latest
  → github/codeql-action/upload-sarif  (language-agnostic; category: mc)

Safety / robustness

  • The mc job is separate from the existing analyze matrix (actions, c-cpp), which is left untouched. A failure in mc cannot cancel or affect those jobs.
  • The job fails loudly (no continue-on-error) if the extractor build or the scan breaks.
  • Everything is pinned: codeql-mc by commit SHA, CodeQL CLI 2.27.1, Rust 1.96.0 (and codeql-mc's own Cargo.lock / extractor rev).

What it finds today

Run locally against the current src/ (33 files, ~17.8k lines), all true positives, no parse-artifact false positives:

mc/empty-control-body (3) — empty control-flow bodies:

  • builtin.mc:1467 if (first) { }
  • ns.mc:216 if (ph_accept("\\", 1)) {} (consume-if-present with an empty body)
  • rc.mc:348 empty first branch of an if/else-if chain

mc/unused-local (2) — locals declared but never read:

  • class.mc:418 i64 save = ph_tid; (the name appears only at its declaration)
  • expr.mc:1160 i64 arop = ph_arith_op(t); (likewise never read)

The two queries are designed so a grammar gap yields a missed finding, never a spurious one (structural check for empty bodies; a conservative name-based use test for unused locals — &x, x += … and x++ all count as uses). See the codeql-mc README for scope and limits.

🤖 Generated with Claude Code

mc-php's real sources are .mc, which github/codeql-action cannot analyze
(custom languages are unsupported, issue #3015). Add an independent `mc` job to
the CodeQL workflow that builds the minicompiler/codeql-mc extractor, creates a
CodeQL database over src/, analyzes it with the mc queries, and uploads the
SARIF through github/codeql-action/upload-sarif (category mc).

The job is separate from the existing actions/c-cpp analyze matrix, so a failure
here cannot affect those jobs, and it fails loudly (no continue-on-error) if the
extractor build or the scan breaks. codeql-mc is pinned by commit SHA; the
CodeQL CLI is pinned to 2.27.1 and Rust to 1.96.0.

On the current src/ the mc queries report 3 empty control-flow bodies and 2
unused locals, all true positives.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 00:23
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The isolated workflow matches the extractor’s integration approach, with no substantiated blocking issues remaining.

Review effort: Balanced
Findings: None

What changed in this PR

Adds CodeQL scanning for mc-php’s compiler sources alongside the existing Actions and C/C++ analysis.

Changes:

  • Adds an independent mc analysis job with pinned extractor and toolchain versions.
  • Scans src/ with two mc queries and uploads SARIF results.
File Description
.github/​workflows/​codeql.yml Builds the extractor, scans mc sources, and uploads alerts.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@schivei
schivei merged commit 466b074 into main Oct 7, 2026
13 checks passed
@schivei
schivei deleted the ci/codeql-mc-scanning branch October 7, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants