Why
foxguard currently parses 10 source languages (JS/TS, Python, Go, Ruby, Java, PHP, Rust, C#, Swift, Kotlin) plus 5 config formats. C is not among them. This blocks every kernel/system-software security pattern, including the Dirty Frag class rules drafted on feat/dirty-frag-rules (commit 70813a9).
Concrete trigger: the Dirty Frag advisory (2026-05-07) is structurally analyzable — `splice → MSG_SPLICE_PAGES → in-place crypto on shared frag`. We want foxguard's existing Semgrep-compat regex engine and structural rule pipeline to apply to `.c` / `.h` files so the kernel rules already drafted can actually run.
What
Surgical addition. Five edits across three files:
- `Cargo.toml` — add `tree-sitter-c = "0.23"` (matches the version pin used by all other tree-sitter crates).
- `src/lib.rs` — add `Language::C` variant + Display impl (`"c"`).
- `src/engine/parser.rs` — register `Language::C => tree_sitter_c::LANGUAGE.into()` in `parse_file`.
- `src/engine/scanner.rs` — map `"c" | "h"` extensions to `Language::C` in `detect_language`. Add to comment-prefix list (`&["//", "/*"]`).
- `src/rules/semgrep_compat.rs` — add `"c"` to the `languages:` mapping (around line 808-817).
Acceptance
Scope (intentionally narrow)
- Do not ship built-in C rules in this PR. That belongs to the dependent issue.
- Do not add C++ support (`.cpp`/`.cc`/`.hpp`) yet — separate tree-sitter crate, separate review surface.
- Do not add taint-flow for C — only structural / regex rules need to work in this MVP.
Effort
~2–3 hours. Mostly mechanical. The risk surface is the rules registry (does anything assume the language set is closed?) which a full `cargo test` will surface.
Related
Why
foxguard currently parses 10 source languages (JS/TS, Python, Go, Ruby, Java, PHP, Rust, C#, Swift, Kotlin) plus 5 config formats. C is not among them. This blocks every kernel/system-software security pattern, including the Dirty Frag class rules drafted on
feat/dirty-frag-rules(commit70813a9).Concrete trigger: the Dirty Frag advisory (2026-05-07) is structurally analyzable — `splice → MSG_SPLICE_PAGES → in-place crypto on shared frag`. We want foxguard's existing Semgrep-compat regex engine and structural rule pipeline to apply to `.c` / `.h` files so the kernel rules already drafted can actually run.
What
Surgical addition. Five edits across three files:
Acceptance
Scope (intentionally narrow)
Effort
~2–3 hours. Mostly mechanical. The risk surface is the rules registry (does anything assume the language set is closed?) which a full `cargo test` will surface.
Related