Config-driven MISRA C:2023 static-analysis harness for arbitrary C projects (cppcheck-backed, bring-your-own rule texts).
Project description
misch
Point it at any C project and ratchet it toward MISRA C:2023. misch (MISra-CHeck) is a config-driven static-analysis harness: it wraps cppcheck and its misra.py addon, drives them off a real compile_commands.json, and turns per-project difference into a small misra.toml instead of a forked shell script.
- Bring-your-own rule texts: ships no copyrighted MISRA material (see
docs/rule-texts.md). - Baseline / ratchet: adopt MISRA on an existing codebase without a day-one wall of findings; fail CI only on new ones.
- Deviation records: harvests every
cppcheck-suppress, enforces a justification, and emits an audit-ready record. - No silent scope creep: every file is consciously analysed or excluded, or the run fails.
mischis a guidance + ratchet tool, not a compliance-certification tool: cppcheck's addon covers a subset of MISRA C:2023. The engine sits behind an interface so a certified analyser can slot in later. Seedocs/DESIGN.md.
Install
Requires Python ≥ 3.11 and cppcheck (with its bundled misra.py addon) on PATH. Tested with cppcheck 2.21; any recent release with the misra.py addon should work.
uv tool install misch # or: pipx install misch / pip install misch
From a checkout: uv tool install . (or uv sync && uv run misch ...).
Quick start
cd /path/to/your/c-project
misch init # write a commented misra.toml (flags pre-fill it)
misch run # analyse; categorised report; non-zero exit on findings
misch baseline # accept current findings as the baseline
misch run --baseline # from now on, fail only on NEW findings
misch deviations # audit every suppression + its justification
Bring your own rule texts (optional, for headlines + Mandatory/Required/Advisory):
export MISRA_RULE_TEXTS=/path/to/misra_c_2023_headlines_for_cppcheck.txt
A run against a project with findings looks like this (headline text comes from your own rule-texts file):
──────────────────────────────── MISRA analysis ────────────────────────────────
scope: 1 analysed 0 excluded files with findings: 1
Findings by rule
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Rule ┃ Category ┃ Count ┃ Headline ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ misra-c2012-8.4 │ required │ 2 │ Headline from your licensed MISRA copy │
│ misra-c2012-17.7 │ required │ 1 │ Headline from your licensed MISRA copy │
│ misra-c2012-21.6 │ required │ 1 │ Headline from your licensed MISRA copy │
│ misra-c2012-15.5 │ advisory │ 1 │ Headline from your licensed MISRA copy │
│ misra-c2012-8.7 │ advisory │ 1 │ Headline from your licensed MISRA copy │
└──────────────────┴──────────┴───────┴────────────────────────────────────────┘
Run with -v/--verbose for the per-location listing.
6 MISRA finding(s): 4 required 2 advisory
Commands
| Command | Purpose |
|---|---|
misch init |
Generate a commented misra.toml; flags (--db, --scope, --exclude, --platform, --rule-texts, …) pre-fill each section. |
misch run |
Analyse. Rule table + summary (add -v for per-location detail, or --format json/--format sarif). Exit 1 on findings; --baseline fails only on new ones. |
misch baseline |
Snapshot the current findings as the accepted baseline. |
misch deviations |
Harvest cppcheck-suppress*, enforce justifications, validate rule ids, emit a Markdown deviation record (--format md). |
Exit codes are CI-friendly and format-independent: 0 clean (or no new findings under --baseline), 1 findings (or unjustified/unknown deviations), 2 config, compile-DB, scope, or engine error.
Configuration
misch init writes a documented misra.toml; the essentials:
[project]
scope = ["src/", "include/"] # analysed
exclude = ["tests/", "subprojects/"] # explicitly out of scope
[db]
source = "meson" # meson | cmake | existing
# Plain-Make projects: generate a DB (e.g. `bear -- make`) and use "existing".
[platform]
preset = "unix64" # cppcheck built-in, or [platform].xml
[rules]
texts = "${MISRA_RULE_TEXTS}" # bring-your-own; optional
How it works
compile_commands.json is the universal seam: every build-system and toolchain concern collapses into "produce a normalised compile DB". A single internal Finding model backs every output (terminal, JSON, baseline diff, deviation record), so they can never disagree. Full architecture and rationale in docs/DESIGN.md.
Documentation
docs/DESIGN.md: architecture, the scope and deviation strategy.docs/rule-texts.md: bringing your own MISRA headlines.CONTRIBUTING.md: dev setup, tests, adding engines/normalisers.CHANGELOG.md: release notes.
License
MIT (see LICENSE). misch contains and ships no MISRA material; rule texts are bring-your-own from your licensed copy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file misch-0.1.0.tar.gz.
File metadata
- Download URL: misch-0.1.0.tar.gz
- Upload date:
- Size: 55.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb8db147dba416c4ec4f8b87a86fce469311937866eaa5c5cd24f19194cf0f29
|
|
| MD5 |
319eca58858376a90328ad8075546c9d
|
|
| BLAKE2b-256 |
24884f0abe0502014292dcee140c2e8ca17f4c3bd7480670c845d999bfd29d36
|
Provenance
The following attestation bundles were made for misch-0.1.0.tar.gz:
Publisher:
release.yml on aajll/misch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
misch-0.1.0.tar.gz -
Subject digest:
bb8db147dba416c4ec4f8b87a86fce469311937866eaa5c5cd24f19194cf0f29 - Sigstore transparency entry: 2104424903
- Sigstore integration time:
-
Permalink:
aajll/misch@810b014d451448cfe9c04e6bd3ce90ffb4f740d5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aajll
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@810b014d451448cfe9c04e6bd3ce90ffb4f740d5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file misch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: misch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2be1d12de94015d06c362fcd086fb418f8179114e30f34eaf26b85b37471aef
|
|
| MD5 |
49939fe559f3fbe34a384da8752c7450
|
|
| BLAKE2b-256 |
ca6eee188620a0948962952d61cab58f3613326ffa5151a93b312d7b10288e4f
|
Provenance
The following attestation bundles were made for misch-0.1.0-py3-none-any.whl:
Publisher:
release.yml on aajll/misch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
misch-0.1.0-py3-none-any.whl -
Subject digest:
c2be1d12de94015d06c362fcd086fb418f8179114e30f34eaf26b85b37471aef - Sigstore transparency entry: 2104425247
- Sigstore integration time:
-
Permalink:
aajll/misch@810b014d451448cfe9c04e6bd3ce90ffb4f740d5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aajll
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@810b014d451448cfe9c04e6bd3ce90ffb4f740d5 -
Trigger Event:
push
-
Statement type: