1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

Fix crash if remote validator is not configured. Small cosmetics.

This commit is contained in:
Sascha L. Teichmann 2023-01-30 08:23:05 +01:00
parent adf98736cc
commit 6a60e8d8ce

View file

@ -41,7 +41,7 @@ func main() {
}
if len(files) == 0 {
log.Println("No domains given.")
log.Println("No files given.")
return
}
@ -86,21 +86,23 @@ func run(opts *options, files []string) error {
fmt.Printf(" * %s\n", vErr)
}
} else {
fmt.Printf("%s passes the schema validation.\n", file)
fmt.Printf("%q passes the schema validation.\n", file)
}
// Validate against remote validator.
validate, err := validator.Validate(doc)
if err != nil {
return fmt.Errorf("remote validation of %q failed: %w",
file, err)
if validator != nil {
validate, err := validator.Validate(doc)
if err != nil {
return fmt.Errorf("remote validation of %q failed: %w",
file, err)
}
var passes string
if validate {
passes = "passes"
} else {
passes = "does not pass"
}
fmt.Printf("%q %s remote validation.\n", file, passes)
}
var passes string
if validate {
passes = "passes"
} else {
passes = "does not pass"
}
fmt.Printf("%q %s remote validation.\n", file, passes)
}
return nil