Skip to content

Commit

Permalink
rename PkgInstalledFiles to SystemInstalledFiles for backward compati…
Browse files Browse the repository at this point in the history
…bility
  • Loading branch information
AliDatadog committed Oct 2, 2023
1 parent bc4f854 commit ede18a4
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
24 changes: 12 additions & 12 deletions pkg/fanal/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ type AnalysisOptions struct {
}

type AnalysisResult struct {
m sync.Mutex
OS types.OS
Repository *types.Repository
PackageInfos []types.PackageInfo
Applications []types.Application
Misconfigurations []types.Misconfiguration
Secrets []types.Secret
Licenses []types.LicenseFile
PkgInstalledFiles []string // A list of files installed by OS package manager
m sync.Mutex
OS types.OS
Repository *types.Repository
PackageInfos []types.PackageInfo
Applications []types.Application
Misconfigurations []types.Misconfiguration
Secrets []types.Secret
Licenses []types.LicenseFile
SystemInstalledFiles []string // A list of files installed by OS package manager

// Digests contains SHA-256 digests of unpackaged files
// used to search for SBOM attestation.
Expand All @@ -178,7 +178,7 @@ func NewAnalysisResult() *AnalysisResult {

func (r *AnalysisResult) isEmpty() bool {
return lo.IsEmpty(r.OS) && r.Repository == nil && len(r.PackageInfos) == 0 && len(r.Applications) == 0 &&
len(r.Misconfigurations) == 0 && len(r.Secrets) == 0 && len(r.Licenses) == 0 && len(r.PkgInstalledFiles) == 0 &&
len(r.Misconfigurations) == 0 && len(r.Secrets) == 0 && len(r.Licenses) == 0 && len(r.SystemInstalledFiles) == 0 &&
r.BuildInfo == nil && len(r.Digests) == 0 && len(r.CustomResources) == 0
}

Expand Down Expand Up @@ -272,7 +272,7 @@ func (r *AnalysisResult) Merge(newResult *AnalysisResult) {
r.Misconfigurations = append(r.Misconfigurations, new.Misconfigurations...)

Check failure on line 272 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / K8s Integration Test

cannot select on new (built-in)

Check failure on line 272 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Module Integration Test

cannot select on new (built-in)

Check failure on line 272 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Integration Test

cannot select on new (built-in)

Check failure on line 272 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

cannot select on new (built-in)

Check failure on line 272 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

cannot select on new (built-in)

Check failure on line 272 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

cannot select on new (built-in)

Check failure on line 272 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / VM Integration Test

cannot select on new (built-in)

Check failure on line 272 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Build Test (windows-latest)

cannot select on new (built-in)
r.Secrets = append(r.Secrets, new.Secrets...)

Check failure on line 273 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / K8s Integration Test

cannot select on new (built-in)

Check failure on line 273 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Module Integration Test

cannot select on new (built-in)

Check failure on line 273 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Integration Test

cannot select on new (built-in)

Check failure on line 273 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

cannot select on new (built-in)

Check failure on line 273 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

cannot select on new (built-in)

Check failure on line 273 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

cannot select on new (built-in)

Check failure on line 273 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / VM Integration Test

cannot select on new (built-in)

Check failure on line 273 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Build Test (windows-latest)

cannot select on new (built-in)
r.Licenses = append(r.Licenses, new.Licenses...)

Check failure on line 274 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / K8s Integration Test

cannot select on new (built-in)

Check failure on line 274 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Module Integration Test

cannot select on new (built-in)

Check failure on line 274 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Integration Test

cannot select on new (built-in)

Check failure on line 274 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

cannot select on new (built-in)

Check failure on line 274 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

cannot select on new (built-in)

Check failure on line 274 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

cannot select on new (built-in)

Check failure on line 274 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / VM Integration Test

cannot select on new (built-in)

Check failure on line 274 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Build Test (windows-latest)

cannot select on new (built-in)
r.PkgInstalledFiles = append(r.PkgInstalledFiles, new.PkgInstalledFiles...)
r.SystemInstalledFiles = append(r.SystemInstalledFiles, new.SystemInstalledFiles...)

Check failure on line 275 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / K8s Integration Test

cannot select on new (built-in)

Check failure on line 275 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Module Integration Test

cannot select on new (built-in)

Check failure on line 275 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Integration Test

cannot select on new (built-in)

Check failure on line 275 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

cannot select on new (built-in) (typecheck)

Check failure on line 275 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

cannot select on new (built-in)) (typecheck)

Check failure on line 275 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Test (macos-latest)

cannot select on new (built-in)

Check failure on line 275 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / VM Integration Test

cannot select on new (built-in)

Check failure on line 275 in pkg/fanal/analyzer/analyzer.go

View workflow job for this annotation

GitHub Actions / Build Test (windows-latest)

cannot select on new (built-in)

if newResult.BuildInfo != nil {
if r.BuildInfo == nil {
Expand Down Expand Up @@ -470,7 +470,7 @@ func (ag AnalyzerGroup) PostAnalyze(ctx context.Context, compositeFS *CompositeF
continue
}

skippedFiles := result.PkgInstalledFiles
skippedFiles := result.SystemInstalledFiles
for _, app := range result.Applications {
skippedFiles = append(skippedFiles, app.FilePath)
for _, lib := range app.Libraries {
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/analyzer/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func TestAnalyzerGroup_AnalyzeFile(t *testing.T) {
},
},
},
PkgInstalledFiles: []string{
SystemInstalledFiles: []string{
"lib/libc.musl-x86_64.so.1",
"lib/ld-musl-x86_64.so.1",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/analyzer/pkg/apk/apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (a alpinePkgAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInp
Packages: parsedPkgs,
},
},
PkgInstalledFiles: installedFiles,
SystemInstalledFiles: installedFiles,
}, nil
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/fanal/analyzer/pkg/dpkg/dpkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (
)

func (a dpkgAnalyzer) PostAnalyze(_ context.Context, input analyzer.PostAnalysisInput) (*analyzer.AnalysisResult, error) {
var PkgInstalledFiles []string
var SystemInstalledFiles []string
var packageInfos []types.PackageInfo

// parse `available` file to get digest for packages
Expand All @@ -74,7 +74,7 @@ func (a dpkgAnalyzer) PostAnalyze(_ context.Context, input analyzer.PostAnalysis
if err != nil {
return err
}
PkgInstalledFiles = append(PkgInstalledFiles, systemFiles...)
SystemInstalledFiles = append(SystemInstalledFiles, systemFiles...)
return nil
}
// parse status files
Expand All @@ -90,8 +90,8 @@ func (a dpkgAnalyzer) PostAnalyze(_ context.Context, input analyzer.PostAnalysis
}

return &analyzer.AnalysisResult{
PackageInfos: packageInfos,
PkgInstalledFiles: PkgInstalledFiles,
PackageInfos: packageInfos,
SystemInstalledFiles: SystemInstalledFiles,
}, nil

}
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/analyzer/pkg/dpkg/dpkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ func Test_dpkgAnalyzer_Analyze(t *testing.T) {
name: "info list",
testFiles: map[string]string{"./testdata/tar.list": "var/lib/dpkg/info/tar.list"},
want: &analyzer.AnalysisResult{
PkgInstalledFiles: []string{
SystemInstalledFiles: []string{
"/bin/tar",
"/etc",
"/usr/lib/mime/packages/tar",
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/analyzer/pkg/rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (a rpmPkgAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInput)
Packages: parsedPkgs,
},
},
PkgInstalledFiles: installedFiles,
SystemInstalledFiles: installedFiles,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/handler/sysfile/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func newSystemFileFilteringPostHandler(artifact.Option) (handler.PostHandler, er
// Handle removes files installed by OS package manager such as yum.
func (h systemFileFilteringPostHandler) Handle(_ context.Context, result *analyzer.AnalysisResult, blob *types.BlobInfo) error {
var systemFiles []string
for _, file := range append(result.PkgInstalledFiles, defaultSystemFiles...) {
for _, file := range append(result.SystemInstalledFiles, defaultSystemFiles...) {
// Trim leading slashes to be the same format as the path in container images.
systemFile := strings.TrimPrefix(file, "/")
// We should check the root filepath ("/") and ignore it.
Expand Down
6 changes: 3 additions & 3 deletions pkg/fanal/handler/sysfile/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func Test_systemFileFilterHook_Hook(t *testing.T) {
{
name: "happy path",
result: &analyzer.AnalysisResult{
PkgInstalledFiles: []string{
SystemInstalledFiles: []string{
"/",
"/usr/bin/pydoc",
"/usr/bin/python",
Expand Down Expand Up @@ -200,7 +200,7 @@ func Test_systemFileFilterHook_Hook(t *testing.T) {
{
name: "go binaries",
result: &analyzer.AnalysisResult{
PkgInstalledFiles: []string{
SystemInstalledFiles: []string{
"usr/local/bin/goreleaser",
},
},
Expand All @@ -223,7 +223,7 @@ func Test_systemFileFilterHook_Hook(t *testing.T) {
{
name: "Rust will not be skipped",
result: &analyzer.AnalysisResult{
PkgInstalledFiles: []string{
SystemInstalledFiles: []string{
"app/Cargo.lock",
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/fanal/handler/unpackaged/unpackaged.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewUnpackagedHandler(opt artifact.Option) (handler.PostHandler, error) {
func (h unpackagedHook) Handle(ctx context.Context, res *analyzer.AnalysisResult, blob *types.BlobInfo) error {
for filePath, digest := range res.Digests {
// Skip files installed by OS package managers.
if slices.Contains(res.PkgInstalledFiles, filePath) {
if slices.Contains(res.SystemInstalledFiles, filePath) {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/module/serialize/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type AnalysisResult struct {
//PackageInfos []types.PackageInfo
//Applications []types.Application
//Secrets []types.Secret
//PkgInstalledFiles []string // A list of files installed by OS package manager
//SystemInstalledFiles []string // A list of files installed by OS package manager

// Currently it supports custom resources only
CustomResources []CustomResource
Expand Down

0 comments on commit ede18a4

Please sign in to comment.