Skip to content
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

Boostrap oscal generator and subcommand #194

Merged
merged 6 commits into from
Feb 21, 2025
Merged

Conversation

puerco
Copy link
Member

@puerco puerco commented Feb 19, 2025

This command initializes the first oscal output and generator for the base line data.

This lets us generate a first draft of an OSCAL catalog to start testing and iterating on the format.

Here's a sample of the output for feedback
https://gist.github.com/puerco/e4a18354c281d45fc900cfb626adf286

/cc @brandtkeller

Signed-off-by: Adolfo García Veytia (Puerco) [email protected]

Comment on lines 64 to 69
Parts: &[]oscal.Part{
{
ID: strings.TrimPrefix(criteria.ID, "OSPS-") + "_level",
Name: "maturity-level",
Prose: fmt.Sprintf("%d", criteria.MaturityLevel),
},
Copy link
Contributor

@xee5ch xee5ch Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would strongly recommend using OSCAL props: [] in the JSON data format) over parts for this.

Here is the official OSCAL documentation for that in the catalog model. They nest inside the control similarly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, love the suggestion! I've pushed a new commit moving maturity level to a property. Check out the new output here
https://gist.github.com/puerco/e4a18354c281d45fc900cfb626adf286


enc := json.NewEncoder(w)
enc.SetIndent("", " ")
if err := enc.Encode(catalog); err != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will produce the file for all of the content within the catalog model - but if we look at a catalog example we need the catalog object key included for validity of the model.

This can be done a number of ways. Typically we use the complete schema to reference the catalog and encode the complete schema.

go-oscal has a CLI with a validate command that can perform schema validation of models if that is helpful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks for the tip! I've wrapped the doc into a "catalog" label and fixed the validation:

go run . validate --input-file ../ossf/security-baseline/cmd/oscal.json  
go-oscal: 2025/02/20 19:05:13 Successfully validated ../ossf/security-baseline/cmd/oscal.json is valid OSCAL version 1.1.3 catalog

Comment on lines 64 to 69
Props: &[]oscal.Property{
{
Name: "maturity-level",
UUID: catalogUUID,
Value: fmt.Sprintf("%d", criteria.MaturityLevel),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the update here to use prop, but another minor recommendation given extending and customizing data, it might make sense to namespace (with ns) that maturity-level has a specific meaning in the context of OpenSSF and if other organizations have a similar prop, they do not "collide" with its use or downstream code assumes some other group's use of the term applies here. The go-oscal library seems to support this, so I'd recommend picking a ns URL to use in props and other things and sticking to it through the codebase for namespacing per the guidance.

I am not saying it has to be that specific value, but just giving you an idea of where I am going with it.

Suggested change
Props: &[]oscal.Property{
{
Name: "maturity-level",
UUID: catalogUUID,
Value: fmt.Sprintf("%d", criteria.MaturityLevel),
},
Props: &[]oscal.Property{
{
Ns: "http://openssf.org/ns/oscal",
Name: "maturity-level",
UUID: catalogUUID,
Value: fmt.Sprintf("%d", criteria.MaturityLevel),
},

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took out the maturity level for now as I need to introduce some changes to the new schema to handle them properly.

Comment on lines 87 to 91
pts := append(*newCtl.Parts, oscal.Part{
ID: strings.TrimPrefix(criteria.ID, "OSPS-") + "_implementation",
Name: "implementation",
Prose: strings.TrimSpace(criteria.Implementation),
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend per the OSCAL docs on /catalog/parts/@name to change this to example.

Suggested change
pts := append(*newCtl.Parts, oscal.Part{
ID: strings.TrimPrefix(criteria.ID, "OSPS-") + "_implementation",
Name: "implementation",
Prose: strings.TrimSpace(criteria.Implementation),
})
pts := append(*newCtl.Parts, oscal.Part{
ID: strings.TrimPrefix(criteria.ID, "OSPS-") + "_example",
Name: "example",
Prose: strings.TrimSpace(criteria.Implementation),
})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was also deprecated with the new schema

This command initializes the first oscal output and
generator for the baseline data.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@puerco puerco force-pushed the oscal branch 2 times, most recently from cc8786c to 7988aa8 Compare February 21, 2025 01:08
@puerco
Copy link
Member Author

puerco commented Feb 21, 2025

@xee5ch I see that the NIST namespace url (https://csrc.nist.gov/ns/oscal) does not return anything. Does this mean that the IRI is just used as a label?

Going through the docs it seems that the namespace does not really need to be defined anywhere, other linked data formats namespace with an URI/IRI but also expect a definition file (for example the Context in JSONLD).

I guess we are fine just defining our namespace and not really worrying about writing a definition?

@xee5ch
Copy link
Contributor

xee5ch commented Feb 21, 2025

Correct it is just a label.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@puerco
Copy link
Member Author

puerco commented Feb 21, 2025

OK, I pushed commits with updates for the new schema and to fix the validation with @defenseunicorns go-oscal.

The new output is published here: https://gist.github.com/puerco/e4a18354c281d45fc900cfb626adf286

@puerco puerco mentioned this pull request Feb 21, 2025
@funnelfiasco funnelfiasco merged commit b75b30f into ossf:main Feb 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants