Article View: linux.kernel
Article #62Re: [PATCH v2 05/11] kconfig-audit: Split policy schema for component reuse
From: sashiko-bot
Date: Fri, 04 Dec 2026 23:10
Date: Fri, 04 Dec 2026 23:10
117 lines
7037 bytes
7037 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] kconfig-audit: deprecated RefResolver in
SchemaFile._create_validator()
- [Low] kconfig-audit: symlinked schemas break $ref in
SchemaFile.parse()
- [Low] kconfig-audit: uncaught RefResolutionError in
Helpers.validate_yaml()
--
commit 754cf81ebb9a7fce9acd73e9326b44ad0a081fd7
Author: Ahmed S. Darwish <darwi@linutronix.de>
kconfig-audit: Split policy schema for component reuse
This commit extracts the common rule schema into schema/rule.yml so
policy-v1.yml can reference it via $ref, and updates audit.py to build a
Draft7Validator with a local file:// RefResolver for sibling schema
files.
> diff --git a/tools/kconfig-audit/audit.py b/tools/kconfig-audit/audit.py
> index eac25740becab..94ff427715d11 100755
> --- a/tools/kconfig-audit/audit.py
> +++ b/tools/kconfig-audit/audit.py
[ ... ]
> @@ -249,12 +249,7 @@ class Helpers:
> def validate_yaml(yaml: YamlDict, schema: Schema, f_name: str) -> None:
> """Validate a parsed YAML mapping against passed JSON Schema"""
> try:
> - # For regex validation, manually enforce a format checker
> - jsonschema.validate(
> - yaml,
> - schema,
> - format_checker=jsonschema.FormatChecker(),
> - )
> + schema.validator.validate(yaml)
> except jsonschema.exceptions.ValidationError as e:
> error(
> f'{f_name} does not match its schema\n'
[Severity: Low]
Should validate_yaml() also catch jsonschema.exceptions.RefResolutionError?
Draft7Validator.check_schema() only validates metaschema grammar, so $ref
targets are resolved lazily during schema.validator.validate(). Because
RefResolutionError does not inherit from ValidationError, a broken $ref
escapes with a traceback and exit status 1 instead of os.EX_DATAERR.
[ ... ]
> def parse(self) -> Schema:
> """Parse and validate a policy schema file"""
>
> - schema = Schema(self.yaml)
> + rule_schema_f = self.schema_f.parent / 'rule.yml'
> + rule_schema_y = Helpers.load_yaml(rule_schema_f)
> +
> + self._check_schema(rule_schema_f, rule_schema_y)
> + self._check_schema(self.schema_f, self.schema_y)
> +
> + validator = self._create_validator({
> + rule_schema_f.resolve().as_uri(): rule_schema_y,
> + })
[Severity: Low]
Can resolving rule_schema_f and self.schema_f independently break $ref
lookup when schema files are symlinked?
If policy-v1.yml or rule.yml is individually symlinked to a different
directory or basename (as in Nix or symlink-farm packaging), resolving
rule.yml relative to base_uri in _create_validator() will miss the
preloaded store key and fall back to remote loading, failing validation.
Resolving self.schema_f.parent once and deriving both URIs from that
directory would keep base_uri and the store keys aligned.
[ ... ]
> + def _create_validator(self, store: dict[str, YamlDict]) -> YamlValidator:
> + """Create a schema validator for resolving sibling '$ref' entries"""
> +
> + resolver = jsonschema.RefResolver(
> + base_uri=self.schema_f.resolve().as_uri(),
> + referrer=self.schema_y,
> + store=store,
> + )
> +
> + return jsonschema.Draft7Validator(
> + self.schema_y,
> + resolver=resolver,
> + # For regex entries validation, manually enforce a format checker
> + format_checker=jsonschema.FormatChecker(),
> + )
[Severity: Low]
Will jsonschema.RefResolver and the resolver= argument emit deprecation
warnings on jsonschema >= 4.18.0?
Both were deprecated in favor of referencing.Registry passed via registry=.
Because audit.py runs as __main__, Python's default warning filter prints
both DeprecationWarning messages to stderr on every run, and fails under
python3 -W error or once jsonschema removes RefResolver.
Preferring referencing.Registry when available and falling back to
RefResolver for older jsonschema would avoid the warnings while keeping
compatibility.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203224916.118064-1-darwi@linutronix.de?part=5
Technical Details
Message-ID:
<O6KzD-g1p2-5@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!bofh.it!news.nic.it!robomodReferences:
<O6o65-fPfD-3@gated-at.bofh.it> <O6o65-fPfD-19@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!bofh.it!news.nic.it!robomod From: sashiko-bot@kernel.org Newsgroups: linux.debian.kernel,linux.kernel Subject: Re: [PATCH v2 05/11] kconfig-audit: Split policy schema for component reuse Date: Sat, 05 Dec 2026 00:10:01 +0100 Message-ID: <O6KzD-g1p2-5@gated-at.bofh.it> References: <O6o65-fPfD-3@gated-at.bofh.it> <O6o65-fPfD-19@gated-at.bofh.it> X-Original-To: "Ahmed S. Darwish" <darwi@linutronix.de>, "Nathan Chancellor" <nathan@kernel.org>, "Nicolas Schier" <nsc@kernel.org>, "Julian Braha" <julianbraha@gmail.com>, "Emanuele Rocca" <ema@debian.org>, "Clark Williams" <clrkwllms@kernel.org>, "Steven Rostedt" <rostedt@goodmis.org>, "Ingo Molnar" <mingo@redhat.com> X-Mailbox-Line: From debian-kernel-request@lists.debian.org Fri Dec 4 23:06:42 2026 Old-Return-Path: <sashiko-bot@kernel.org> X-Amavis-Spam-Status: No, score=-4.401 tagged_above=-10000 required=5.3 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham autolearn_force=no X-Policyd-Weight: using cached result; rate: -5.5 Reply-To: sashiko-reviews@lists.linux.dev Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Mailing-List: <debian-kernel@lists.debian.org> archive/latest/158752 List-ID: <debian-kernel.lists.debian.org> List-URL: <https://lists.debian.org/debian-kernel/> List-Archive: https://lists.debian.org/msgid-search/sashiko-outbox-250777@kernel.org Approved: robomod@news.nic.it Lines: 117 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Cc: "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>, "Frederic Weisbecker" <frederic@kernel.org>, "John Ogness" <john.ogness@linutronix.de>, "Derek Barbosa" <debarbos@redhat.com>, Zbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>, "Daan De Meyer" <daan.j.demeyer@gmail.com>, "Luca Boccassi" <luca.boccassi@gmail.com>, linux-rt-devel@lists.linux.dev, debian-kernel@lists.debian.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org X-Original-Date: Fri, 04 Dec 2026 22:50:13 +0000 X-Original-Message-ID: <sashiko-outbox-250777@kernel.org> X-Original-References: <20261203224916.118064-1-darwi@linutronix.de> <20261203224916.118064-6-darwi@linutronix.de>