mirror of
https://github.com/anchore/syft.git
synced 2026-02-13 19:16:43 +01:00
chore: add debug logging for decode errors (#1352)
This commit is contained in:
parent
04880c06ce
commit
0dddf51fd5
@ -2,10 +2,12 @@ package formats
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/internal/log"
|
||||||
"github.com/anchore/syft/syft/formats/cyclonedxjson"
|
"github.com/anchore/syft/syft/formats/cyclonedxjson"
|
||||||
"github.com/anchore/syft/syft/formats/cyclonedxxml"
|
"github.com/anchore/syft/syft/formats/cyclonedxxml"
|
||||||
"github.com/anchore/syft/syft/formats/github"
|
"github.com/anchore/syft/syft/formats/github"
|
||||||
@ -35,6 +37,9 @@ func Formats() []sbom.Format {
|
|||||||
func Identify(by []byte) sbom.Format {
|
func Identify(by []byte) sbom.Format {
|
||||||
for _, f := range Formats() {
|
for _, f := range Formats() {
|
||||||
if err := f.Validate(bytes.NewReader(by)); err != nil {
|
if err := f.Validate(bytes.NewReader(by)); err != nil {
|
||||||
|
if !errors.Is(err, sbom.ErrValidationNotSupported) {
|
||||||
|
log.Debugf("format %s returned err: %+v", f.ID(), err)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return f
|
return f
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import (
|
|||||||
func decoder(reader io.Reader) (*sbom.SBOM, error) {
|
func decoder(reader io.Reader) (*sbom.SBOM, error) {
|
||||||
doc, err := tvloader.Load2_3(reader)
|
doc, err := tvloader.Load2_3(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to decode spdx-json: %w", err)
|
return nil, fmt.Errorf("unable to decode spdx-tag-value: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return spdxhelpers.ToSyftModel(doc)
|
return spdxhelpers.ToSyftModel(doc)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user