refactor(sbom): add intermediate representation for BOM (#6240)

Signed-off-by: knqyf263 <knqyf263@gmail.com>
Co-authored-by: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com>
This commit is contained in:
Teppei Fukuda
2024-03-12 10:56:10 +04:00
committed by GitHub
parent fb8c516ded
commit 8fcef352b3
148 changed files with 4959 additions and 6190 deletions

View File

@@ -7,7 +7,7 @@ import (
"github.com/liamg/jfather"
"golang.org/x/xerrors"
"github.com/aquasecurity/trivy/pkg/dependency/parser/types"
"github.com/aquasecurity/trivy/pkg/dependency/types"
xio "github.com/aquasecurity/trivy/pkg/x/io"
)
@@ -39,9 +39,14 @@ func (p *Parser) Parse(r xio.ReadSeekerAt) ([]types.Library, []types.Dependency,
var libs []types.Library
for pkgName, dependency := range lockFile.Default {
libs = append(libs, types.Library{
Name: pkgName,
Version: strings.TrimLeft(dependency.Version, "="),
Locations: []types.Location{{StartLine: dependency.StartLine, EndLine: dependency.EndLine}},
Name: pkgName,
Version: strings.TrimLeft(dependency.Version, "="),
Locations: []types.Location{
{
StartLine: dependency.StartLine,
EndLine: dependency.EndLine,
},
},
})
}
return libs, nil, nil