Re: [PATCH v2 07/11] kconfig-audit: Add support for policy overlays

From: sashiko-bot

Date: Fri Dec 04 2026 - 17:50:45 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] kconfig-audit: PolicyOverlayFile and Overlayer silently drop
pattern_prio
- [Low] kconfig-audit: Overlayer._update_rule() ignores empty rationale
overrides
--

commit 77e7af9fe203f534d6486ee41fb9f2863605bc4c
Author: Ahmed S. Darwish <darwi@xxxxxxxxxxxxx>

kconfig-audit: Add support for policy overlays

This commit adds policy overlay support to tools/kconfig-audit/audit.py,
allowing a YAML overlay file to override fields on existing rules, update
docs_url, or add new rules via the -o/--overlay option.

> diff --git a/tools/kconfig-audit/audit.py b/tools/kconfig-audit/audit.py
> index 94ff427715d11..ba6ba86f2791f 100755
> --- a/tools/kconfig-audit/audit.py
> +++ b/tools/kconfig-audit/audit.py

[ ... ]

> @@ -546,6 +551,195 @@ class PolicyFile(VersionedYamlFile):

[ ... ]

> +@dataclass
> +class RuleOverlay:
> + """Typed overlay for a (symbol or regex) .config rule"""
> +
> + target: OverlayTarget
> + expected: Optional[ExpectedValue]
> + severity: Optional[Severity]
> + rationale: Optional[str]
> + docs_hint: Optional[str]

[ ... ]

> + return RuleOverlay(
> + target,
> + expected,
> + severity,
> + rule.get('rationale'),
> + rule.get('docs_hint'),
> + )

[Severity: Medium]
Does this silently drop pattern_prio from overlay rules?

policy-overlay-v1.yml allows pattern_prio on name_pattern rules via rule.yml,
but RuleOverlay has no pattern_prio field, PolicyOverlayFile._parse_rule()
ignores it, and Overlayer._update_rule() and Overlayer._new_rule() never
propagate it to PatternRule (leaving new rules at priority 0).

A new overlay pattern rule with a higher pattern_prio is downgraded to 0 and
can lose to a higher-priority base pattern rule, letting non-compliant configs
pass, or collide with a priority-0 base rule in Checker._map_pattern_rules()
and abort with os.EX_DATAERR. Overrides on existing rules are also ignored.

[ ... ]

> + @staticmethod
> + def _update_rule(overlay: RuleOverlay, rule: Rule) -> None:
> + """Apply an overlay's specified fields to an existing rule"""
> + if overlay.expected:
> + rule.expected = overlay.expected
> +
> + if overlay.severity:
> + rule.severity = overlay.severity
> +
> + if overlay.rationale:
> + rule.rationale = overlay.rationale
> +
> + if overlay.docs_hint:
> + rule.docs_hint = overlay.docs_hint
> + rule._normalize_docs_hint()

[Severity: Low]
Should this check overlay.rationale is not None instead of testing truthiness?

rule.yml defines rationale as a string with no minimum length and rejects
null, so an empty string is the only schema-valid way to clear an inherited
rationale. Because an empty string is falsy, the assignment is skipped and
the base rule's stale rationale remains in the audit report.

--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203224916.118064-1-darwi@xxxxxxxxxxxxx?part=7