Skip to content

Commit

Permalink
refactor: scanBinary: rm component and tag args
Browse files Browse the repository at this point in the history
Those are not used except to set result tag and component.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Jul 11, 2023
1 parent 190f911 commit 720e1c7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion node_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ func runNodeScan(ctx context.Context, cfg *Config, root string) []*ScanResults {
continue
}
klog.V(1).InfoS("scanning path", "path", innerPath)
res := scanBinary(ctx, component, tag, ignoreErrors, root, innerPath)
res := scanBinary(ctx, ignoreErrors, root, innerPath)
if res.Skip {
// Do not add skipped binaries to results.
continue
}
res.SetTag(tag).SetComponent(component)
if res.Error == nil {
klog.V(1).InfoS("scanning node success", "path", innerPath, "status", "success")
} else {
Expand Down
3 changes: 2 additions & 1 deletion scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,12 @@ func validateTag(ctx context.Context, tag *v1.TagReference, cfg *Config) *ScanRe
return nil
}
klog.V(1).InfoS("scanning path", "path", path)
res := scanBinary(ctx, component, tag, ignoreErrors, mountPath, innerPath)
res := scanBinary(ctx, ignoreErrors, mountPath, innerPath)
if res.Skip {
// Do not add skipped binaries to results.
return nil
}
res.SetTag(tag).SetComponent(component)
if res.Error == nil {
klog.V(1).InfoS("scanning success", "image", image, "path", innerPath, "status", "success")
} else {
Expand Down
5 changes: 2 additions & 3 deletions validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

"github.com/Masterminds/semver/v3"
mapset "github.com/deckarep/golang-set/v2"
v1 "github.com/openshift/api/image/v1"
)

var (
Expand Down Expand Up @@ -334,11 +333,11 @@ func isElfExe(path string) (bool, error) {
return false, nil
}

func scanBinary(ctx context.Context, component *OpenshiftComponent, tag *v1.TagReference, ignoreErr IgnoreErrors, topDir, innerPath string) *ScanResult {
func scanBinary(ctx context.Context, ignoreErr IgnoreErrors, topDir, innerPath string) *ScanResult {
allFn := validationFns["all"]

baton := &Baton{TopDir: topDir}
res := NewScanResult().SetComponent(component).SetTag(tag).SetPath(innerPath)
res := NewScanResult().SetPath(innerPath)

path := filepath.Join(topDir, innerPath)

Expand Down

0 comments on commit 720e1c7

Please sign in to comment.