Skip to content

Commit

Permalink
fix some test cases that do not pass schema validation
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Rutkowski <[email protected]>
  • Loading branch information
mrutkows committed Nov 7, 2024
1 parent a4c57dd commit 99dc8c3
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package cmd

// "github.com/iancoleman/orderedmap"
import (
"bytes"
"encoding/json"
Expand All @@ -31,7 +30,7 @@ import (
"github.com/CycloneDX/sbom-utility/schema"
"github.com/CycloneDX/sbom-utility/utils"
"github.com/spf13/cobra"
"github.com/xeipuuv/gojsonschema"
"github.com/xeipuuv/gojsonschema" // TODO: switch to: https://github.com/santhosh-tekuri/jsonschema
)

const (
Expand Down Expand Up @@ -377,3 +376,23 @@ func validateCustom(document *schema.BOM, policyConfig *schema.LicensePolicyConf

return VALID, nil
}

// func isJSONSchema(filePath string) (isSchema bool, err error) {
// isSchema = false
// file, err := os.Open(filePath)
// if err != nil {
// return
// }
// defer file.Close()
// // decode
// decoder := json.NewDecoder(file)
// var jsonData map[string]interface{}
// err = decoder.Decode(&jsonData)
// if err != nil {
// return
// }
// // if schema tag present then likely a schema file (for now)
// _, hasSchema := jsonData["$schema"]
// isSchema = hasSchema
// return
// }

0 comments on commit 99dc8c3

Please sign in to comment.