From 707f0dcaad952770d68fd5c38a05a1f30d1ba98f Mon Sep 17 00:00:00 2001 From: Morten Olsen Date: Sat, 13 Dec 2025 08:08:48 +0100 Subject: [PATCH] fix: missing nuclei path --- internal/jobmanager/jobmanager.go | 8 ++++++++ internal/scanner/scanner.go | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/internal/jobmanager/jobmanager.go b/internal/jobmanager/jobmanager.go index cbcf6e2..96e7142 100644 --- a/internal/jobmanager/jobmanager.go +++ b/internal/jobmanager/jobmanager.go @@ -460,6 +460,14 @@ func (m *JobManager) buildJob(scan *nucleiv1alpha1.NucleiScan) *batchv1.Job { }, }, }, + { + Name: "NUCLEI_BINARY_PATH", + Value: "/usr/local/bin/nuclei", + }, + { + Name: "NUCLEI_TEMPLATES_PATH", + Value: "", // Empty means use default location (~/.nuclei/templates) + }, }, }, }, diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index c44286f..1c1371c 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -122,13 +122,23 @@ func (s *NucleiScanner) Scan(ctx context.Context, targets []string, options Scan logger.Info("Targets file created", "targetsFile", targetsFile, "targetCount", len(targets)) // Check if nuclei binary exists and is executable + // First try the exact path if _, err := os.Stat(s.nucleiBinaryPath); os.IsNotExist(err) { - return nil, fmt.Errorf("nuclei binary not found at %s", s.nucleiBinaryPath) + // If not found at exact path, try to find it in PATH + if path, err := exec.LookPath(s.nucleiBinaryPath); err == nil { + logger.Info("Found nuclei binary in PATH", "path", path, "originalPath", s.nucleiBinaryPath) + s.nucleiBinaryPath = path + } else { + return nil, fmt.Errorf("nuclei binary not found at %s and not in PATH: %w", s.nucleiBinaryPath, err) + } } - // Verify nuclei is executable + // Verify nuclei is executable by running version command if err := exec.Command(s.nucleiBinaryPath, "-version").Run(); err != nil { - logger.Error(err, "Failed to execute nuclei -version, nuclei may not be properly installed") + logger.Error(err, "Failed to execute nuclei -version, nuclei may not be properly installed", "path", s.nucleiBinaryPath) + // Don't fail here, just log - the actual scan will fail if nuclei is truly broken + } else { + logger.Info("Nuclei binary verified", "path", s.nucleiBinaryPath) } // Check templates availability if templates path is set