Skip to content

Commit 39a1d8f

Browse files
authored
Merge pull request #57 from CycloneDX/tweaks
Tweaks
2 parents c2db05e + 124f2be commit 39a1d8f

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Also, checkout the [`examples`](./example_test.go) to get an idea of how this li
3030
|:---------------------:|:---------------------:|:------------------------:|
3131
| < v0.4.0 | 1.14+ | 1.2 |
3232
| == v0.4.0 | 1.14+ | 1.3 |
33-
| >= v0.5.0 | 1.15+ | 1.4 |
33+
| >= v0.5.0, < v0.7.0 | 1.15+ | 1.4 |
3434
| >= v0.7.0 | 1.17+ | 1.0-1.4 |
3535

3636
We're aiming to support all [officially supported](https://golang.org/doc/devel/release.html#policy) Go versions, plus

copy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
// copy creates a deep copy of the BOM in a given destination.
27-
// Copying is currently done be encoding and decoding the BOM struct using the gop.
27+
// Copying is currently done by encoding and decoding the BOM struct using gob.
2828
// In the future we may choose to switch to a more efficient strategy,
2929
// and consider to export this API.
3030
func (b BOM) copy(dst *BOM) error {

cyclonedx.go

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package cyclonedx
1919

2020
import (
2121
"encoding/xml"
22+
"errors"
2223
"fmt"
2324
"regexp"
2425
)
@@ -29,6 +30,8 @@ const (
2930
BOMFormat = "CycloneDX"
3031
)
3132

33+
var ErrInvalidSpecVersion = errors.New("invalid specification version")
34+
3235
type Advisory struct {
3336
Title string `json:"title,omitempty" xml:"title,omitempty"`
3437
URL string `json:"url" xml:"url"`

cyclonedx_json.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
package cyclonedx
1919

20-
import "encoding/json"
20+
import (
21+
"encoding/json"
22+
)
2123

2224
func (sv SpecVersion) MarshalJSON() ([]byte, error) {
2325
return json.Marshal(sv.String())
@@ -41,6 +43,8 @@ func (sv *SpecVersion) UnmarshalJSON(bytes []byte) error {
4143
*sv = SpecVersion1_3
4244
case SpecVersion1_4.String():
4345
*sv = SpecVersion1_4
46+
default:
47+
return ErrInvalidSpecVersion
4448
}
4549

4650
return nil

cyclonedx_xml.go

+2
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ func (sv *SpecVersion) UnmarshalXML(d *xml.Decoder, start xml.StartElement) erro
183183
*sv = SpecVersion1_3
184184
case SpecVersion1_4.String():
185185
*sv = SpecVersion1_4
186+
default:
187+
return ErrInvalidSpecVersion
186188
}
187189

188190
return nil

0 commit comments

Comments
 (0)