mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 17:03:17 +01:00
27 lines
406 B
Go
27 lines
406 B
Go
package spdx22json
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"io"
|
|
)
|
|
|
|
func validator(reader io.Reader) error {
|
|
type Document struct {
|
|
SPDXID string `json:"SPDXID"`
|
|
}
|
|
|
|
dec := json.NewDecoder(reader)
|
|
|
|
var doc Document
|
|
err := dec.Decode(&doc)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode: %w", err)
|
|
}
|
|
|
|
if doc.SPDXID != "" {
|
|
return nil
|
|
}
|
|
return fmt.Errorf("could not extract document SPDXID")
|
|
}
|