Skip to content

Commit

Permalink
Enable loading of remote JSON schemas on --force flag
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Rutkowski <[email protected]>
  • Loading branch information
mrutkows committed Nov 8, 2024
1 parent f9ca245 commit 83d9290
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
"args": ["validate", "-i", "examples/cyclonedx/SBOM/protonmail-webclient-v4-0912dff/bom.json"],
"dlvFlags": ["--check-go-version=false"]
},
{
"showGlobalVariables": true,
"name": "Debug: validate",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "main.go", // "program": "${file}",
"args": ["validate", "-i", "examples/cyclonedx/SBOM/protonmail-webclient-v4-0912dff/bom.json"],
"dlvFlags": ["--check-go-version=false"]
},
{
"showGlobalVariables": true,
"name": "Debug: query: SELECT * FROM metadata.component",
Expand Down
4 changes: 2 additions & 2 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ func Validate(writer io.Writer, persistentFlags utils.PersistentCommandFlags, va
return INVALID, bom, schemaErrors, errSchemaURI
}

getLogger().Infof("Loading schema: '%s'...", schemaName)
schemaLoader = gojsonschema.NewReferenceLoader(schemaName)
getLogger().Infof("Loading schema: '%s'...", forcedSchemaFile)
schemaLoader = gojsonschema.NewReferenceLoader(forcedSchemaFile)
getLogger().Infof("Validating document using forced schema (i.e., '--force %s')", forcedSchemaFile)
} else {
// Load the matching JSON schema (format, version and variant) from embedded resources
Expand Down

0 comments on commit 83d9290

Please sign in to comment.