Skip to content

Commit

Permalink
store installed files in struct package
Browse files Browse the repository at this point in the history
Co-authored-by: lebauce <lebauce@gmail.com>
  • Loading branch information
AliDatadog committed Oct 2, 2023
1 parent 3be5e6b commit 7b2076f
Show file tree
Hide file tree
Showing 6 changed files with 509 additions and 283 deletions.
8 changes: 5 additions & 3 deletions pkg/fanal/analyzer/pkg/apk/apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type alpinePkgAnalyzer struct{}

func (a alpinePkgAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInput) (*analyzer.AnalysisResult, error) {
scanner := bufio.NewScanner(input.Content)
parsedPkgs, installedFiles := a.parseApkInfo(scanner)
parsedPkgs, installedFiles := a.parseApkInfo(scanner, &input.Options)

return &analyzer.AnalysisResult{
PackageInfos: []types.PackageInfo{
Expand All @@ -47,7 +47,7 @@ func (a alpinePkgAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInp
}, nil
}

func (a alpinePkgAnalyzer) parseApkInfo(scanner *bufio.Scanner) ([]types.Package, []string) {
func (a alpinePkgAnalyzer) parseApkInfo(scanner *bufio.Scanner, opts *analyzer.AnalysisOptions) ([]types.Package, []string) {
var (
pkgs []types.Package
pkg types.Package
Expand Down Expand Up @@ -89,7 +89,9 @@ func (a alpinePkgAnalyzer) parseApkInfo(scanner *bufio.Scanner) ([]types.Package
case "F:":
dir = line[2:]
case "R:":
installedFiles = append(installedFiles, path.Join(dir, line[2:]))
absPath := path.Join(dir, line[2:])
pkg.InstalledFiles = append(pkg.InstalledFiles, absPath)
installedFiles = append(installedFiles, absPath)
case "p:": // provides (corresponds to provides in PKGINFO, concatenated by spaces into a single line)
a.parseProvides(line, pkg.ID, provides)
case "D:": // dependencies (corresponds to depend in PKGINFO, concatenated by spaces into a single line)
Expand Down
Loading

0 comments on commit 7b2076f

Please sign in to comment.