-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON Output does not match with OSCAL JSON Schema #15
Comments
Github would not allow me to attach
Let me know if there's any other files I could send on my end to help you |
Hey, @NotReallyJustin I appreciate the feedback! Couple of questions:
Documentation of the library is definitely an issue, but I discovered that the approach taken to build the oscal-pydantic library is inherently limited (for reasons I could discuss at length if you are interested, but can spare you if you're not). I am working now on the "metaschema-python" library here: (https://github.com/Credentive-Sec/metaschema-python). Check the dev branch to see what we're working on. I still use oscal-pydantic v2 for my projects while the metaschema work is being completed, but plan to retire this library as soon as the other one is working. |
I am going on vacation for the next week so won't be as responsive to issues, but please feel free to send me any further questions and I will reply when I can. |
Hello!
Do you maybe have a list of functions/classes for OSCAL Pydantic v2 somewhere I could refer to? I remember seeing a few slides on the NIST website about how OSCAL Pydantic v2 improves on v1, so it'll be cool to fiddle with that a bit |
Hello there! First off, I wanted to say I came across this tool for writing OSCAL and it's been amazing so far. There's just a few issues I came across so far while trying to validate OSCAL Pydantic output with the expected JSON Schema. So far, I've only messed with the catalog model but the issues should be relevant to all models such as SSPs and Profiles.
.json()
inPydantic
will fill in undefined JSON keys withnull
, which breaks the OSCAL schema (proper OSCAL leaves the key-pair out of the final JSON altogether). I've attached a quick CLI tool to fix this in the comments below but there's probably a cleaner way to do it in OSCAL Pydantic_
with-
. The exception to this is"class_"
which should become"class"
2003-04-12T00:00:00.000000-05:00
becomes2003-04-12T00:00:00-05:00
. I would reccomend either adding a custom JSON encoding as a configuration (as shown below inDateTimeISOFix.py
), or changing the datatype fromdatetime
tostr
in/src/oscal_pydantic/*.py
for classes such asPublicationTimestamp
(which might be better since I saw some RegEx being commented out too)This is what OSCAL Pydantic outputs:
This is what's valid according to the schema:
Notice how the JSON is wrapped in another key-pair
{"catalog":...}
.Take this with a grain of salt, since I'm writing this OSCAL Pydantic code without documentation and relying on existing knowledge of the Pydantic library itself and Pylance. If there is already a function that resolves these issues (or if there's any documentation out there in general. It's weird since I found this tool from a NIST presentation but there's nothing else online I could find about OSCAL Pydantic), I would love to know about it.
The text was updated successfully, but these errors were encountered: