mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 07:40:48 -08:00
refactor(sbom): add sbom prefix + filepaths for decode log messages (#7074)
This commit is contained in:
@@ -37,7 +37,7 @@ func NewArtifact(filePath string, c cache.ArtifactCache, opt artifact.Option) (a
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a Artifact) Inspect(_ context.Context) (artifact.Reference, error) {
|
||||
func (a Artifact) Inspect(ctx context.Context) (artifact.Reference, error) {
|
||||
f, err := os.Open(a.filePath)
|
||||
if err != nil {
|
||||
return artifact.Reference{}, xerrors.Errorf("failed to open sbom file error: %w", err)
|
||||
@@ -51,7 +51,8 @@ func (a Artifact) Inspect(_ context.Context) (artifact.Reference, error) {
|
||||
}
|
||||
log.Info("Detected SBOM format", log.String("format", string(format)))
|
||||
|
||||
bom, err := sbom.Decode(f, format)
|
||||
ctx = log.WithContextAttrs(ctx, log.FilePath(a.filePath))
|
||||
bom, err := sbom.Decode(ctx, f, format)
|
||||
if err != nil {
|
||||
return artifact.Reference{}, xerrors.Errorf("SBOM decode error: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user