Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nil pointer dereference during evidence conversion #194

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,15 @@ func convertEvidence(c *Component, specVersion SpecVersion) {
}

if specVersion < SpecVersion1_6 {
for i := range *c.Evidence.Occurrences {
occ := &(*c.Evidence.Occurrences)[i]

occ.Line = nil
occ.Offset = nil
occ.Symbol = ""
occ.AdditionalContext = ""
if c.Evidence.Occurrences != nil {
for i := range *c.Evidence.Occurrences {
occ := &(*c.Evidence.Occurrences)[i]

occ.Line = nil
occ.Offset = nil
occ.Symbol = ""
occ.AdditionalContext = ""
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion validate_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package cyclonedx

import (
"errors"
"fmt"

"github.com/xeipuuv/gojsonschema"
Expand Down Expand Up @@ -60,5 +61,5 @@ func (jv jsonValidator) Validate(bom []byte, specVersion SpecVersion) error {
errSummary += fmt.Sprintf("\n - %s", verr.String())
}

return fmt.Errorf(errSummary)
return errors.New(errSummary)
}
Loading