1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 18:15:42 +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 { if len(files) == 0 {
log.Println("No domains given.") log.Println("No files given.")
return return
} }
@ -86,21 +86,23 @@ func run(opts *options, files []string) error {
fmt.Printf(" * %s\n", vErr) fmt.Printf(" * %s\n", vErr)
} }
} else { } else {
fmt.Printf("%s passes the schema validation.\n", file) fmt.Printf("%q passes the schema validation.\n", file)
} }
// Validate against remote validator. // Validate against remote validator.
validate, err := validator.Validate(doc) if validator != nil {
if err != nil { validate, err := validator.Validate(doc)
return fmt.Errorf("remote validation of %q failed: %w", if err != nil {
file, err) 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 return nil