feat: add rules language system attribute to parameter constraint tests#2216
feat: add rules language system attribute to parameter constraint tests#2216vijaygovindaraja wants to merge 1 commit intousnistgov:mainfrom
Conversation
Add a 'system' attribute to the parameter-constraint test assembly that identifies the rules language used to interpret the test expression. This enables automatic validation of parameter values against machine-executable constraints. Well-known system URIs defined: - W3C XML Schema regex for pattern matching - XPath 3.1 for complex expressions - OSCAL numeric range for bounded value validation Includes a proof-of-concept Python validator that demonstrates automatic validation against regex and numeric range constraints. Fixes usnistgov#206 Signed-off-by: Vijay Govindarajan <vijay.govindarajan91@gmail.com>
|
@david-waltermire @aj-stein-nist this addresses the user story in #206 — adding a system attribute to parameter constraint tests so tools can automatically validate parameter values against machine-executable rules. the approach follows the URI-based identification pattern already used in OSCAL. kept it backwards compatible — the attribute is optional, so existing content is unaffected. included a proof-of-concept validator in Python that demonstrates regex and numeric range validation against OSCAL catalog parameters. happy to adjust the well-known URIs or the metaschema modeling based on your feedback. |
iMichaela
left a comment
There was a problem hiding this comment.
@vijaygovindaraja - Thank you for your contribution. Please follow the contributor's guidance available here: https://github.com/usnistgov/OSCAL/wiki/Contributing-to-OSCAL--development-and-maintenance#feature-branches
Also note that the PR needs to be opened per explicit guidance here against a target feature-* branch in OSCAL repo since this is not ready to be included in the next patch release.
In addition, due to the nature of the proposed change (a feature), please note that
- any proposed feature requires support for all formats
- any change (in particular a new feature) to the Catalog schema needs to be supported in the Profiles and Profiles Resolution Specification.
- any new feature requires updates to existing pipeline for automatic testing and validation int the CI/CD pipeline.
Please let me know if you want me to create a branch for your new feature.
|
@iMichaela Thanks for the detailed guidance. Yes, please create a feature branch. I'll rebase against it and update the PR target. I'll also review the contributor docs and scope out the additional format support and profile resolution changes needed. |
|
Related issues:
It is important to distinguished between validating that the value of a parameter that was set , depending on its type, and #1059 that identifies the need for full support of validation #1059 is related to, and will be affected by the proposed solution for #206 and #474 . OSCAL Foundation is currently working on the #1059. |
| <formal-name>Constraint Test</formal-name> | ||
| <description>A test expression which is expected to be evaluated by a tool.</description> | ||
| <group-as name="tests" in-json="ARRAY"/> | ||
| <define-flag name="system" as-type="uri" required="no"> |
There was a problem hiding this comment.
The flag name system" is confusing.
|
Understood — I'll scope this to the parameter validation side and keep clear of the assessment rules work in #1059. Let me know once the feature branch is ready and I'll rebase. |
|
@vijaygovindaraja - I created a branch for this feature: |
|
closing in favor of #2224 which targets the feat-parameter-constraints-test-206-474 branch and renames system to rules-language per the review feedback. |
Fixes #206
Summary
Adds a
systemattribute to theparameter-constraint/testassembly that identifies the rules language used to interpret the test expression. This enables tools to automatically validate that a parameter value meets the constraint, fulfilling the acceptance criteria in #206.Metaschema change
Added
define-flag name="system" as-type="uri"to thetestassembly inoscal_control-common_metaschema.xml. The attribute is optional — when omitted, the expression is treated as informational only (preserving backwards compatibility).Well-known system URIs defined:
http://www.w3.org/TR/xmlschema-2/#regexs— W3C XML Schema regular expressionhttps://www.w3.org/TR/xpath-31/— XPath 3.1 expressionhttps://csrc.nist.gov/ns/oscal/constraints/numeric-range— OSCAL numeric range (e.g., "1-65535")Tool developers can define additional URIs for proprietary or domain-specific constraint languages.
Proof of concept validator
Included a Python proof-of-concept tool (
src/utils/constraint-validator/validate-constraints.py) that demonstrates automatic validation of parameter values against constraint expressions. Supports regex and numeric range systems.Example:
Output:
Design decisions
systemattribute follows the same URI-based identification pattern used elsewhere in OSCAL (e.g.,identification-systemin metadata)expressionfield description to reference thesystemattributeHappy to discuss alternative approaches or adjust the well-known URI definitions based on community feedback.