Skip to content

Instantly share code, notes, and snippets.

@drsm79
Last active August 5, 2020 00:02
Show Gist options
  • Save drsm79/eb31c00efad434a672387219e0be4f0b to your computer and use it in GitHub Desktop.
Save drsm79/eb31c00efad434a672387219e0be4f0b to your computer and use it in GitHub Desktop.
Build python objects from OSCAL schemas

This uses a patched datamodel-code-generator, and assumes you have that installed in a venv or similar.

Once that's in place, you should be able to run build.sh, which will pull in the OSCAL git repos, and then build the objects for all the layers/models.

#! /usr/bin/zsh
git submodule add https://github.com/usnistgov/OSCAL.git
git submodule update --init --recursive
for i in `ls OSCAL/json/schema| sed -e 's/oscal_\(.*\)_schema.json/\1/'`
do
echo OSCAL/json/schema/oscal_${i}_schema.json
echo $i:s/-/_/
datamodel-codegen --input-file-type jsonschema --input OSCAL/json/schema/oscal_${i}_schema.json --output $i:s/-/_/
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment