diff --git a/README.md b/README.md index 5f39b93..c716f65 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Also, checkout the [`examples`](./example_test.go) to get an idea of how this li |:---------------------:|:---------------------:|:------------------------:| | < v0.4.0 | 1.14+ | 1.2 | | == v0.4.0 | 1.14+ | 1.3 | -| >= v0.5.0 | 1.15+ | 1.4 | +| >= v0.5.0, < v0.7.0 | 1.15+ | 1.4 | | >= v0.7.0 | 1.17+ | 1.0-1.4 | We're aiming to support all [officially supported](https://golang.org/doc/devel/release.html#policy) Go versions, plus diff --git a/copy.go b/copy.go index 55fe1bb..6dc9f4b 100644 --- a/copy.go +++ b/copy.go @@ -24,7 +24,7 @@ import ( ) // copy creates a deep copy of the BOM in a given destination. -// Copying is currently done be encoding and decoding the BOM struct using the gop. +// Copying is currently done by encoding and decoding the BOM struct using gob. // In the future we may choose to switch to a more efficient strategy, // and consider to export this API. func (b BOM) copy(dst *BOM) error { diff --git a/cyclonedx.go b/cyclonedx.go index cca1f62..50d23cf 100644 --- a/cyclonedx.go +++ b/cyclonedx.go @@ -19,6 +19,7 @@ package cyclonedx import ( "encoding/xml" + "errors" "fmt" "regexp" ) @@ -29,6 +30,8 @@ const ( BOMFormat = "CycloneDX" ) +var ErrInvalidSpecVersion = errors.New("invalid specification version") + type Advisory struct { Title string `json:"title,omitempty" xml:"title,omitempty"` URL string `json:"url" xml:"url"` diff --git a/cyclonedx_json.go b/cyclonedx_json.go index 013578f..3d3e71f 100644 --- a/cyclonedx_json.go +++ b/cyclonedx_json.go @@ -17,7 +17,9 @@ package cyclonedx -import "encoding/json" +import ( + "encoding/json" +) func (sv SpecVersion) MarshalJSON() ([]byte, error) { return json.Marshal(sv.String()) @@ -41,6 +43,8 @@ func (sv *SpecVersion) UnmarshalJSON(bytes []byte) error { *sv = SpecVersion1_3 case SpecVersion1_4.String(): *sv = SpecVersion1_4 + default: + return ErrInvalidSpecVersion } return nil diff --git a/cyclonedx_xml.go b/cyclonedx_xml.go index 655e1bd..6431094 100644 --- a/cyclonedx_xml.go +++ b/cyclonedx_xml.go @@ -183,6 +183,8 @@ func (sv *SpecVersion) UnmarshalXML(d *xml.Decoder, start xml.StartElement) erro *sv = SpecVersion1_3 case SpecVersion1_4.String(): *sv = SpecVersion1_4 + default: + return ErrInvalidSpecVersion } return nil