Closed mike-winberry closed 2 months ago
Changes look great! Testing various commands and want to request one modification.
Can you update the
validate
command and maybe migrate it away fromRunE
?Noted duplicative output for the results to stdout:
dev@dev:~/work/go-oscal$ ./bin/go-oscal validate -f testdata/validation/invalid-catalog.yaml -r output.yaml go-oscal: 2024/07/18 17:16:31 WARNING: Currently using OSCAL version 1.0.4. The latest version is 1.1.2 Error: invalid OSCAL document, results: { "valid": false, "timeStamp": "2024-07-18T17:16:31.413900279Z", "errors": [ { "keywordLocation": "/oneOf/0/properties/catalog/$ref/properties/metadata/$ref/required", "absoluteKeywordLocation": "https://github.com/defenseunicorns/go-oscal/tree/main/src/internal/schemas/oscal_complete_schema-1-0-4.json#/definitions/oscal-complete-oscal-metadata:metadata/required", "instanceLocation": "/catalog/metadata", "error": "\"missing property 'title'\"" }, { "keywordLocation": "/oneOf/0/properties/catalog/$ref/properties/metadata/$ref/properties/parties/items/$ref/properties/uuid/pattern", "absoluteKeywordLocation": "https://github.com/defenseunicorns/go-oscal/tree/main/src/internal/schemas/oscal_complete_schema-1-0-4.json#/definitions/oscal-complete-oscal-metadata:party/properties/uuid/pattern", "instanceLocation": "/catalog/metadata/parties/0/uuid", "error": "\"'invalid-uuid' does not match pattern '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[45][0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'\"", "failedValue": "invalid-uuid" }, { "keywordLocation": "/oneOf/0/properties/catalog/$ref/properties/metadata/$ref/properties/links/items/$ref/properties/rel/pattern", "absoluteKeywordLocation": "https://github.com/defenseunicorns/go-oscal/tree/main/src/internal/schemas/oscal_complete_schema-1-0-4.json#/definitions/oscal-complete-oscal-metadata:link/properties/rel/pattern", "instanceLocation": "/catalog/metadata/links/0/rel", "error": "\"'https://something.com' does not match pattern '^(\\\\\\\\p{L}|_)(\\\\\\\\p{L}|\\\\\\\\p{N}|[.\\\\\\\\-_])*$'\"", "failedValue": "https://something.com" } ], "metadata": { "documentPath": "testdata/validation/invalid-catalog.yaml", "documentType": "catalog", "documentVersion": "1.0.4", "schemaVersion": "1.0.4" } } Usage: go-oscal validate [flags] Flags: -h, --help help for validate -f, --input-file string the path to a oscal json schema file -r, --validation-result string the path to a validation result file Global Flags: -l, --log-file string the name of the file to write the log to (outputs to STDERR by default) go-oscal: 2024/07/18 17:16:31 invalid OSCAL document, results: { "valid": false, "timeStamp": "2024-07-18T17:16:31.413900279Z", "errors": [ { "keywordLocation": "/oneOf/0/properties/catalog/$ref/properties/metadata/$ref/required", "absoluteKeywordLocation": "https://github.com/defenseunicorns/go-oscal/tree/main/src/internal/schemas/oscal_complete_schema-1-0-4.json#/definitions/oscal-complete-oscal-metadata:metadata/required", "instanceLocation": "/catalog/metadata", "error": "\"missing property 'title'\"" }, { "keywordLocation": "/oneOf/0/properties/catalog/$ref/properties/metadata/$ref/properties/parties/items/$ref/properties/uuid/pattern", "absoluteKeywordLocation": "https://github.com/defenseunicorns/go-oscal/tree/main/src/internal/schemas/oscal_complete_schema-1-0-4.json#/definitions/oscal-complete-oscal-metadata:party/properties/uuid/pattern", "instanceLocation": "/catalog/metadata/parties/0/uuid", "error": "\"'invalid-uuid' does not match pattern '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[45][0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'\"", "failedValue": "invalid-uuid" }, { "keywordLocation": "/oneOf/0/properties/catalog/$ref/properties/metadata/$ref/properties/links/items/$ref/properties/rel/pattern", "absoluteKeywordLocation": "https://github.com/defenseunicorns/go-oscal/tree/main/src/internal/schemas/oscal_complete_schema-1-0-4.json#/definitions/oscal-complete-oscal-metadata:link/properties/rel/pattern", "instanceLocation": "/catalog/metadata/links/0/rel", "error": "\"'https://something.com' does not match pattern '^(\\\\\\\\p{L}|_)(\\\\\\\\p{L}|\\\\\\\\p{N}|[.\\\\\\\\-_])*$'\"", "failedValue": "https://something.com" } ], "metadata": { "documentPath": "testdata/validation/invalid-catalog.yaml", "documentType": "catalog", "documentVersion": "1.0.4", "schemaVersion": "1.0.4" } }
Fixed duplicative output and noisy usage messages.
go-oscal: 2024/07/29 10:07:29 WARNING: Currently using OSCAL version 1.0.4. The latest version is 1.1.2
go-oscal: 2024/07/29 10:07:29 invalid OSCAL document, results: {
"valid": false,
"timeStamp": "2024-07-29T10:07:29.693433-07:00",
"errors": [
{
"keywordLocation": "/oneOf/0/properties/catalog/$ref/properties/metadata/$ref/required",
"absoluteKeywordLocation": "https://github.com/defenseunicorns/go-oscal/tree/main/src/internal/schemas/oscal_complete_schema-1-0-4.json#/definitions/oscal-complete-oscal-metadata:metadata/required",
"instanceLocation": "/catalog/metadata",
"error": "\"missing property 'title'\""
},
{
"keywordLocation": "/oneOf/0/properties/catalog/$ref/properties/metadata/$ref/properties/links/items/$ref/properties/rel/pattern",
"absoluteKeywordLocation": "https://github.com/defenseunicorns/go-oscal/tree/main/src/internal/schemas/oscal_complete_schema-1-0-4.json#/definitions/oscal-complete-oscal-metadata:link/properties/rel/pattern",
"instanceLocation": "/catalog/metadata/links/0/rel",
"error": "\"'https://something.com' does not match pattern '^(\\\\\\\\p{L}|_)(\\\\\\\\p{L}|\\\\\\\\p{N}|[.\\\\\\\\-_])*$'\"",
"failedValue": "https://something.com"
},
{
"keywordLocation": "/oneOf/0/properties/catalog/$ref/properties/metadata/$ref/properties/parties/items/$ref/properties/uuid/pattern",
"absoluteKeywordLocation": "https://github.com/defenseunicorns/go-oscal/tree/main/src/internal/schemas/oscal_complete_schema-1-0-4.json#/definitions/oscal-complete-oscal-metadata:party/properties/uuid/pattern",
"instanceLocation": "/catalog/metadata/parties/0/uuid",
"error": "\"'invalid-uuid' does not match pattern '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[45][0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$'\"",
"failedValue": "invalid-uuid"
}
],
"metadata": {
"documentPath": "testdata/validation/invalid-catalog.yaml",
"documentType": "catalog",
"documentVersion": "1.0.4",
"schemaVersion": "1.0.4"
}
}
Description
jsonschema/v6 contains many changes to the compiler as well as the
ValidationError
leading to breaking changes in thevalidation
package. Using the tests currently in place the updates should be made to ensure the maintenance of current behavior.validationError.ExtractErrors
now takes a*jsonschema.OutputUnit
instead ofjsonschema.Basic
as that field no longer exists inv6
validator.Validate
now uses thevalidationErr.DetailedOutput()
instead ofBasicOutput()
as the necessary information is no longer within theBasicOutput
validationError.ExtractErrors
now properly removes top level noise if there are "actual" (instance) errors, if there are no other errors the top level errors are reintroducedRelated Issue
274 #269 #253
Type of change
Checklist before merging