feat(python): add packaging detector and respective hook (#1223)

Co-authored-by: knqyf263 <knqyf263@gmail.com>
This commit is contained in:
Ankush K
2021-09-13 23:29:11 +05:30
committed by GitHub
parent 19c0b70d26
commit dbc7a83e8c
25 changed files with 191 additions and 99 deletions

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT.
//go:generate wire
//go:generate go run github.com/google/wire/cmd/wire
//+build !wireinject
package client
@@ -11,6 +11,7 @@ import (
"github.com/aquasecurity/fanal/analyzer/config"
image2 "github.com/aquasecurity/fanal/artifact/image"
"github.com/aquasecurity/fanal/cache"
"github.com/aquasecurity/fanal/hook"
"github.com/aquasecurity/fanal/image"
"github.com/aquasecurity/trivy-db/pkg/db"
"github.com/aquasecurity/trivy/pkg/result"
@@ -22,7 +23,7 @@ import (
// Injectors from inject.go:
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, timeout time.Duration, disabled []analyzer.Type, configScannerOption config.ScannerOption) (scanner.Scanner, func(), error) {
func initializeDockerScanner(ctx context.Context, imageName string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, timeout time.Duration, disabled []analyzer.Type, disabledhook []hook.Type, configScannerOption config.ScannerOption) (scanner.Scanner, func(), error) {
scannerScanner := client.NewProtobufClient(url)
clientScanner := client.NewScanner(customHeaders, scannerScanner)
dockerOption, err := types.GetDockerOption(timeout)
@@ -33,7 +34,7 @@ func initializeDockerScanner(ctx context.Context, imageName string, artifactCach
if err != nil {
return scanner.Scanner{}, nil, err
}
artifact, err := image2.NewArtifact(imageImage, artifactCache, disabled, configScannerOption)
artifact, err := image2.NewArtifact(imageImage, artifactCache, disabled, disabledhook, configScannerOption)
if err != nil {
cleanup()
return scanner.Scanner{}, nil, err
@@ -44,14 +45,14 @@ func initializeDockerScanner(ctx context.Context, imageName string, artifactCach
}, nil
}
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, timeout time.Duration, disabled []analyzer.Type, configScannerOption config.ScannerOption) (scanner.Scanner, error) {
func initializeArchiveScanner(ctx context.Context, filePath string, artifactCache cache.ArtifactCache, customHeaders client.CustomHeaders, url client.RemoteURL, timeout time.Duration, disabled []analyzer.Type, disabledhook []hook.Type, configScannerOption config.ScannerOption) (scanner.Scanner, error) {
scannerScanner := client.NewProtobufClient(url)
clientScanner := client.NewScanner(customHeaders, scannerScanner)
imageImage, err := image.NewArchiveImage(filePath)
if err != nil {
return scanner.Scanner{}, err
}
artifact, err := image2.NewArtifact(imageImage, artifactCache, disabled, configScannerOption)
artifact, err := image2.NewArtifact(imageImage, artifactCache, disabled, disabledhook, configScannerOption)
if err != nil {
return scanner.Scanner{}, err
}