Skip to content

Commit 3e023af

Browse files
committed
refactor: move lockfile parser
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
1 parent 4db5a1b commit 3e023af

File tree

2 files changed

+8
-3
lines changed
  • pkg
    • dependency/parser/python/uv
    • fanal/analyzer/language/python/uv

2 files changed

+8
-3
lines changed

pkg/fanal/analyzer/language/python/uv/lock.go renamed to pkg/dependency/parser/python/uv/parser.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ type Dependency struct {
100100
Name string `toml:"name"`
101101
}
102102

103-
type lockParser struct{}
103+
type Parser struct{}
104104

105-
func (p *lockParser) Parse(r xio.ReadSeekerAt) ([]ftypes.Package, []ftypes.Dependency, error) {
105+
func New() *Parser {
106+
return &Parser{}
107+
}
108+
109+
func (p *Parser) Parse(r xio.ReadSeekerAt) ([]ftypes.Package, []ftypes.Dependency, error) {
106110
var lock Lock
107111
if _, err := toml.NewDecoder(r).Decode(&lock); err != nil {
108112
return nil, nil, xerrors.Errorf("failed to decode uv lock file: %w", err)

pkg/fanal/analyzer/language/python/uv/uv.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"golang.org/x/xerrors"
1111

12+
uvparser "github.com/aquasecurity/trivy/pkg/dependency/parser/python/uv"
1213
"github.com/aquasecurity/trivy/pkg/fanal/analyzer"
1314
"github.com/aquasecurity/trivy/pkg/fanal/analyzer/language"
1415
"github.com/aquasecurity/trivy/pkg/fanal/types"
@@ -27,7 +28,7 @@ type uvAnalyzer struct {
2728

2829
func NewUvAnalyzer(_ analyzer.AnalyzerOptions) (analyzer.PostAnalyzer, error) {
2930
return &uvAnalyzer{
30-
lockParser: &lockParser{},
31+
lockParser: uvparser.New(),
3132
}, nil
3233
}
3334

0 commit comments

Comments
 (0)