-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
refactor(sbom): add sbom prefix + filepaths for decode log messages #7074
Changes from 3 commits
a4b1b73
47c0e0b
82c2620
e0b36ca
21ec7cd
cf30a86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,7 @@ | ||||||||
package cyclonedx_test | ||||||||
|
||||||||
import ( | ||||||||
"context" | ||||||||
"encoding/json" | ||||||||
"os" | ||||||||
"testing" | ||||||||
|
@@ -10,6 +11,7 @@ import ( | |||||||
"github.com/stretchr/testify/require" | ||||||||
|
||||||||
ftypes "github.com/aquasecurity/trivy/pkg/fanal/types" | ||||||||
"github.com/aquasecurity/trivy/pkg/log" | ||||||||
"github.com/aquasecurity/trivy/pkg/purl" | ||||||||
"github.com/aquasecurity/trivy/pkg/sbom/cyclonedx" | ||||||||
sbomio "github.com/aquasecurity/trivy/pkg/sbom/io" | ||||||||
|
@@ -757,7 +759,8 @@ func TestUnmarshaler_Unmarshal(t *testing.T) { | |||||||
require.NoError(t, err) | ||||||||
|
||||||||
var got types.SBOM | ||||||||
err = sbomio.NewDecoder(cdx.BOM).Decode(&got) | ||||||||
ctx := log.WithContextAttrs(context.Background(), log.String("filepath", tt.inputFile)) | ||||||||
err = sbomio.NewDecoder(cdx.BOM).Decode(ctx, &got) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to pass attributes in tests.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed e0b36ca |
||||||||
require.NoError(t, err) | ||||||||
|
||||||||
got.BOM = nil | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package spdx_test | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"os" | ||
"sort" | ||
|
@@ -11,6 +12,7 @@ import ( | |
"github.com/stretchr/testify/require" | ||
|
||
ftypes "github.com/aquasecurity/trivy/pkg/fanal/types" | ||
"github.com/aquasecurity/trivy/pkg/log" | ||
sbomio "github.com/aquasecurity/trivy/pkg/sbom/io" | ||
"github.com/aquasecurity/trivy/pkg/sbom/spdx" | ||
"github.com/aquasecurity/trivy/pkg/types" | ||
|
@@ -357,7 +359,8 @@ func TestUnmarshaler_Unmarshal(t *testing.T) { | |
} | ||
|
||
var got types.SBOM | ||
err = sbomio.NewDecoder(v.BOM).Decode(&got) | ||
ctx := log.WithContextAttrs(context.Background(), log.String("filepath", tt.inputFile)) | ||
err = sbomio.NewDecoder(v.BOM).Decode(ctx, &got) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed in e0b36ca |
||
require.NoError(t, err) | ||
|
||
// Not compare BOM | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if adding
log.FilePath(filePath string)
inpkg/log
and using it so we can use the consistent key name?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added (5f3f694 + ae1e4d8)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they should be another PR. And merge the change into this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. The number of filepaths used was more than i expected.
I created #7080
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Merged #7080.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated this PR