Explain a SEI CERT finding and suggest a fix
explain_findingExplains a single flagged finding with its rule summary, match rationale, closest compliant/noncompliant examples, diff, and concrete fix steps so you can resolve it.
Instructions
Explain one finding: a short rule summary, why the finding matches the rule (checker mapping, APIs, shared identifiers), the rule's noncompliant/compliant example pair most similar to the flagged code (token overlap), a unified diff between them, and concrete fix steps derived from that compliant example plus per-API and per-category advice. Use after check_files or check_diff when you need to explain or fix a finding; pass the finding object unchanged, or rule_id with file and line, or with a code snippet. Use get_rule instead for the full rule text and all examples, and validate_findings (not this tool) to check that a manually written finding is grounded. Deterministic and offline: reads only the bundled rules and the named file. An unknown rule_id returns an error listing close matches.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"finding": "<finding>"
},
"name": "explain_finding"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| finding | Yes | The finding: an item of check_files/check_diff `findings` as is, or {rule_id, file, line} or {rule_id, code}. | |
| profile | No | Review profile: 'default' (plain SEI CERT), 'ceph' (Ceph severities, suppressions and idioms), 'misra' (MISRA C:2012 + MISRA C++:2023), 'autosar' (AUTOSAR C++14) or an absolute path to a profile .yaml file. | default |
| context_lines | No | Lines shown around the flagged line in finding.snippet (and used as fallback tokens when the line is blank). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fix | Yes | summary (one-line advice), steps[] (ordered advice: follow the compliant example, API replacements, lines it adds), example_diff (unified diff noncompliant -> compliant), category_advice. | |
| why | Yes | Reasons the finding matches the rule: checker mapping (rule-specific or general), message, APIs the rule discusses, identifiers shared with the CERT example, profile notes. | |
| rule | Yes | id, title, lang, category, url, severity, priority, level, cwe[], summary (first sentence of the rule), coverage (checker tier). | |
| example | Yes | Closest CERT example pair: index, similarity (token Jaccard 0-1), shared_tokens[], noncompliant {heading, code}, compliant {heading, code, text}; null when the rule has no example pair. | |
| finding | Yes | Echo of the input: file, line, tool, checker, message, code (flagged line) and snippet (numbered lines around it, read from the file). | |
| profile | Yes | Profile used for notes and disabled rules. | |
| alternatives | Yes | Next best example pairs {index, heading, score}; pass a different code snippet to steer the choice. |