Add rule engine (only the engine) - #407
Draft
bact wants to merge 9 commits into
Draft
Conversation
Split out of PR spdx#393 (rule-engine + SARIF branch) as a standalone, additive PR per the PR-splitting plan. Nothing in the existing checkers imports these modules yet, so this changes no external behavior -- it only adds the schema these modules define. Introduces: - spec.py: frozen dataclasses (Spec, SpecCategory, SpecMaturity, SpecRule, ProbeRef) that model a compliance standard's full rule catalogue, independent of any output format. - spec_loader.py: YAML -> Spec loader with load-time validation (unknown keys, bad enum values, duplicate rule ids, unknown spec_category references, unregistered probe names). - registry.py: discovers and loads every packaged rules/*.yaml at import time, indexed by spec id. - probes/: registered probe functions (name -> callable) that answer presence questions about a parsed SBOM. - rules/ntia.yaml, rules/fsct3.yaml: the NTIA and FSCT3 rule catalogues as data, replacing hardcoded per-standard Python logic. - RULES.md: rule id and schema documentation. Adding a new compliance standard is now "drop a rules/<id>.yaml file" with no Python subclass required. Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
RULES.md documents the rule id scheme as a public contract. Will publish later. Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Collaborator
Author
|
@InduwaraGunasena since you're thinking about this concept as well in the past week, please help review. Particularly the shape and the keywords in the rule (can see ntia_conformance_checker/rules/ntia.yaml as example). Feel free to propose any changes, asking for clarifications, etc. |
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
bact
marked this pull request as draft
July 4, 2026 12:46
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Never called anywhere and not re-exported from probes/__init__.py; base_checker.py calls probes.lookup() directly instead. Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Optional, empty-by-default IRI field to later link each rule's element to a shared semantic concept in an external SBOM ontology (SKOS / SSSOM). No shipped rule populates it yet; the slot is plumbed through the loader and documented in _example.yaml so linking becomes a pure data change. Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
but it does not change any existing file.
ntia_conformance_checker/rules/README.mdto get overview.ntia_conformance_checker/rules/_example.yamlto see how rule will look like declarativelyntia_conformance_checker/spec.pyto see how rules will be represented in Python. spec.py is well documented. Most logic are explained there.Add declarative rule engine foundation (spec model, YAML loader, probes),
preparing for the implementation of rule-based checker in the future.
Spec, represent a compliance standard.Specloader with load-time validationrules/*.yamlat import timeAdding a new compliance standard in the future can be done by adding a rule to
rules/<id>.yamlwith no Python subclass required (but additional Python probes may still required if existing probes cannot answer questions for the new compliance standard).