KernelGuard-AI is an AI-assisted static analysis framework focused on Linux kernel–style C code.
This repository is a starter kit for building tools that:
- Scan kernel C files for memory safety, concurrency, and style issues.
- Provide JSON / human-readable reports.
- Integrate future LLM-based explanations and remediation suggestions.
⚠️ This is a scaffolding project: most components are implemented as clean, extendable stubs so you can add real static analysis and LLM logic.
- CLI to analyze single files or folders.
- Rule-based analysis engine (memory, concurrency, style categories).
- Pluggable rule system (
kernelguard_ai.rules.*). - Simple C token/structure parser placeholder (
parser.py) ready to be replaced with Clang / tree-sitter. - JSON report output + pretty console summaries.
- LLM integration hook (
kernelguard_ai.llm.explain) where you can connect OpenAI, local models, etc. - Basic tests with
pytest.
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # on Windows: .venv\Scripts\activate
# Install in editable mode (once you add dependencies)
pip install -e .
# Run analysis on example file
kernelguard-ai analyze examples/sample_kernel.c --format table
# Or as a module
python -m kernelguard_ai.cli analyze examples/sample_kernel.c --format jsonKernelGuard-AI/
kernelguard_ai/
analyzer/
rules/
llm/
cli.py
config.py
examples/
tests/
- Replace
parser.pywith a real C AST parser (Clang, pycparser, or tree-sitter). - Implement real kernel-specific rules (locking, RCU, reference counting).
- Add SARIF output for IDE and CI integration.
- Connect
kernelguard_ai.llmto an LLM API for natural-language explanations and patch suggestions. - Build a simple web UI (FastAPI + React / Next.js) on top of the core engine.
Choose your own (MIT / Apache-2.0 recommended). This starter kit ships without a license so you can decide.