Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/scanners/trivy/trivy.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ func main() {
log.Info("trivy version", "trivy version", trivyVersion)
log.Info("config", "config", *config)

if _, err := os.Stat(trivyCommandName); err != nil {
if os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "trivy binary not found at %s\n", trivyCommandName)
os.Exit(generalErr)
}
log.Error(err, "unable to stat trivy binary")
os.Exit(generalErr)
}

userConfig := *DefaultConfig()
if *config != "" {
var err error
Expand Down
7 changes: 6 additions & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ func GetConn(ctx context.Context, socketPath string) (conn *grpc.ClientConn, err
return nil, err
}

// Use a timeout context so we fail fast instead of hanging indefinitely
// when the CRI socket is inaccessible (e.g. permission denied).
connCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()

//nolint:staticcheck // SA1019: grpc.DialContext is deprecated but maintains required blocking behavior
return grpc.DialContext(
ctx,
connCtx,
addr,
//nolint:staticcheck // SA1019: grpc.WithBlock is deprecated but ensures synchronous CRI connection
grpc.WithBlock(),
Expand Down