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

chore: add debug logging for decode errors #1352

Merged
merged 1 commit into from
Nov 21, 2022
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
5 changes: 5 additions & 0 deletions syft/formats/formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package formats

import (
"bytes"
"errors"
"fmt"
"io"
"strings"

"github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/formats/cyclonedxjson"
"github.com/anchore/syft/syft/formats/cyclonedxxml"
"github.com/anchore/syft/syft/formats/github"
Expand Down Expand Up @@ -35,6 +37,9 @@ func Formats() []sbom.Format {
func Identify(by []byte) sbom.Format {
for _, f := range Formats() {
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
}
return f
Expand Down
2 changes: 1 addition & 1 deletion syft/formats/spdxtagvalue/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func decoder(reader io.Reader) (*sbom.SBOM, error) {
doc, err := tvloader.Load2_3(reader)
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)
Expand Down