Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a87b310
introducing execution id
Mzack9999 May 5, 2025
e44e3a4
wip
Mzack9999 May 6, 2025
5d17531
.
Mzack9999 May 6, 2025
f27b251
adding separate execution context id
Mzack9999 May 7, 2025
752bd3b
Merge branch 'dev' into feat-5239-no-singleton
Mzack9999 May 7, 2025
6692c1d
lint
Mzack9999 May 7, 2025
89020a6
vet
Mzack9999 May 7, 2025
781ca16
Merge branch 'dev' into feat-5239-no-singleton
Mzack9999 May 8, 2025
d5066dd
fixing pg dialers
Mzack9999 May 8, 2025
3b8241c
test ignore
Mzack9999 May 9, 2025
736ee5a
fixing loader FD limit
Mzack9999 May 9, 2025
dfc8ed8
test
Mzack9999 May 9, 2025
2a6c6da
fd fix
Mzack9999 May 9, 2025
5656d2b
merge
hdm Jun 18, 2025
2fea8ae
wip: remove CloseProcesses() from dev merge
hdm Jun 18, 2025
cc669a0
wip: fix merge issue
hdm Jun 18, 2025
c1779c8
protocolstate: stop memguarding on last dialer delete
hdm Jun 19, 2025
b47eaad
avoid data race in dialers.RawHTTPClient
hdm Jun 19, 2025
462adb3
use shared logger and avoid race conditions
hdm Jun 20, 2025
44f026f
use shared logger and avoid race conditions
hdm Jun 20, 2025
97a06c9
go mod
hdm Jun 30, 2025
3abee82
patch executionId into compiled template cache
hdm Jun 30, 2025
425c7dd
clean up comment in Parse
hdm Jun 30, 2025
3b4d521
Merge branch 'dev' of https://github.com/projectdiscovery/nuclei into…
hdm Jun 30, 2025
60d02e0
merge upstream
hdm Jul 2, 2025
f1a0ddb
go mod update
hdm Jul 2, 2025
6626c22
bump echarts
hdm Jul 2, 2025
5913ef3
address merge issues
hdm Jul 3, 2025
6516b9d
fix use of gologger
hdm Jul 3, 2025
6ab3732
switch cmd/nuclei to options.Logger
hdm Jul 3, 2025
5151bd0
address merge issues with go.mod
hdm Jul 3, 2025
d09d4ed
go vet: address copy of lock with new Copy function
hdm Jul 3, 2025
672f4d7
fixing tests
Mzack9999 Jul 4, 2025
27ef482
disable speed control
Mzack9999 Jul 4, 2025
159ef60
fix nil ExecuterOptions
Mzack9999 Jul 4, 2025
4ea7374
removing deprecated code
Mzack9999 Jul 5, 2025
9a9d610
fixing result print
Mzack9999 Jul 5, 2025
4b0e0ae
default logger
Mzack9999 Jul 5, 2025
5bbcd5f
cli default logger
Mzack9999 Jul 5, 2025
7b19c61
filter warning from results
Mzack9999 Jul 5, 2025
7afd63e
fix performance test
Mzack9999 Jul 6, 2025
cf12ca8
hardcoding path
Mzack9999 Jul 6, 2025
114fbe6
disable upload
Mzack9999 Jul 6, 2025
593110f
Merge branch 'dev' into pr/6296
Mzack9999 Jul 7, 2025
a181013
Merge branch 'dev' into pr/6296
Mzack9999 Jul 7, 2025
f702555
refactor(runner): uses `Warning` instead of `Print` for `pdcpUploadEr…
dwisiswant0 Jul 8, 2025
82cab3b
Revert "disable upload"
dwisiswant0 Jul 8, 2025
49937ed
Merge branch 'dev' into feat-5239-no-singleton-continued
dwisiswant0 Jul 8, 2025
e1d7e7a
Merge branch 'dev' into feat-5239-no-singleton-continued
dwisiswant0 Jul 8, 2025
e17c045
Revert "hardcoding path"
dwisiswant0 Jul 8, 2025
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
8 changes: 5 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ jobs:
working-directory: examples/simple/
# - run: go run . # Temporarily disabled very flaky in github actions
# working-directory: examples/advanced/
- name: "with Speed Control"
run: go run .
working-directory: examples/with_speed_control/

# TODO: FIX with ExecutionID (ref: https://github.com/projectdiscovery/nuclei/pull/6296)
# - name: "with Speed Control"
# run: go run .
# working-directory: examples/with_speed_control/

integration:
name: "Integration tests"
Expand Down
4 changes: 2 additions & 2 deletions cmd/functional-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func runFunctionalTests(debug bool) (error, bool) {
return errors.Wrap(err, "could not open test cases"), true
}
defer func() {
_ = file.Close()
}()
_ = file.Close()
}()

errored, failedTestCases := runTestCases(file, debug)

Expand Down
8 changes: 4 additions & 4 deletions cmd/integration-test/headless.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ func (h *headlessFileUpload) Execute(filePath string) error {
}

defer func() {
_ = file.Close()
}()
_ = file.Close()
}()

content, err := io.ReadAll(file)
if err != nil {
Expand Down Expand Up @@ -238,8 +238,8 @@ func (h *headlessFileUploadNegative) Execute(filePath string) error {
}

defer func() {
_ = file.Close()
}()
_ = file.Close()
}()

content, err := io.ReadAll(file)
if err != nil {
Expand Down
16 changes: 8 additions & 8 deletions cmd/integration-test/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,8 @@ func (h *httpRequestSelfContained) Execute(filePath string) error {
_ = server.ListenAndServe()
}()
defer func() {
_ = server.Close()
}()
_ = server.Close()
}()

results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "", debug, "-esc")
if err != nil {
Expand Down Expand Up @@ -986,8 +986,8 @@ func (h *httpRequestSelfContainedWithParams) Execute(filePath string) error {
_ = server.ListenAndServe()
}()
defer func() {
_ = server.Close()
}()
_ = server.Close()
}()

results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "", debug, "-esc")
if err != nil {
Expand Down Expand Up @@ -1021,8 +1021,8 @@ func (h *httpRequestSelfContainedFileInput) Execute(filePath string) error {
_ = server.ListenAndServe()
}()
defer func() {
_ = server.Close()
}()
_ = server.Close()
}()

// create temp file
FileLoc, err := os.CreateTemp("", "self-contained-payload-*.txt")
Expand All @@ -1033,8 +1033,8 @@ func (h *httpRequestSelfContainedFileInput) Execute(filePath string) error {
return errorutil.NewWithErr(err).Msgf("failed to write payload to temp file")
}
defer func() {
_ = FileLoc.Close()
}()
_ = FileLoc.Close()
}()

results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "", debug, "-V", "test="+FileLoc.Name(), "-esc")
if err != nil {
Expand Down
27 changes: 24 additions & 3 deletions cmd/integration-test/integration-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"flag"
"fmt"
"os"
"regexp"
"runtime"
"strings"

Expand Down Expand Up @@ -90,8 +91,8 @@ func main() {
defer fuzzplayground.Cleanup()
server := fuzzplayground.GetPlaygroundServer()
defer func() {
_ = server.Close()
}()
_ = server.Close()
}()
go func() {
if err := server.Start("localhost:8082"); err != nil {
if !strings.Contains(err.Error(), "Server closed") {
Expand Down Expand Up @@ -210,7 +211,7 @@ func execute(testCase testutils.TestCase, templatePath string) (string, error) {
}

func expectResultsCount(results []string, expectedNumbers ...int) error {
results = filterHeadlessLogs(results)
results = filterLines(results)
match := sliceutil.Contains(expectedNumbers, len(results))
if !match {
return fmt.Errorf("incorrect number of results: %d (actual) vs %v (expected) \nResults:\n\t%s\n", len(results), expectedNumbers, strings.Join(results, "\n\t")) // nolint:all
Expand All @@ -224,6 +225,13 @@ func normalizeSplit(str string) []string {
})
}

// filterLines applies all filtering functions to the results
func filterLines(results []string) []string {
results = filterHeadlessLogs(results)
results = filterUnsignedTemplatesWarnings(results)
return results
}

// if chromium is not installed go-rod installs it in .cache directory
// this function filters out the logs from download and installation
func filterHeadlessLogs(results []string) []string {
Expand All @@ -237,3 +245,16 @@ func filterHeadlessLogs(results []string) []string {
}
return filtered
}

// filterUnsignedTemplatesWarnings filters out warning messages about unsigned templates
func filterUnsignedTemplatesWarnings(results []string) []string {
filtered := []string{}
unsignedTemplatesRegex := regexp.MustCompile(`Loading \d+ unsigned templates for scan\. Use with caution\.`)
for _, result := range results {
if unsignedTemplatesRegex.MatchString(result) {
continue
}
filtered = append(filtered, result)
}
return filtered
}
14 changes: 9 additions & 5 deletions cmd/integration-test/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,21 @@ func executeNucleiAsLibrary(templatePath, templateURL string) ([]string, error)
cache := hosterrorscache.New(30, hosterrorscache.DefaultMaxHostsCount, nil)
defer cache.Close()

defaultOpts := types.DefaultOptions()
defaultOpts.ExecutionId = "test"

mockProgress := &testutils.MockProgressClient{}
reportingClient, err := reporting.New(&reporting.Options{}, "", false)
reportingClient, err := reporting.New(&reporting.Options{ExecutionId: defaultOpts.ExecutionId}, "", false)
if err != nil {
return nil, err
}
defer reportingClient.Close()

defaultOpts := types.DefaultOptions()
_ = protocolstate.Init(defaultOpts)
_ = protocolinit.Init(defaultOpts)

defer protocolstate.Close(defaultOpts.ExecutionId)

defaultOpts.Templates = goflags.StringSlice{templatePath}
defaultOpts.ExcludeTags = config.ReadIgnoreFile().Tags

Expand All @@ -100,7 +104,7 @@ func executeNucleiAsLibrary(templatePath, templateURL string) ([]string, error)
ratelimiter := ratelimit.New(context.Background(), 150, time.Second)
defer ratelimiter.Stop()

executerOpts := protocols.ExecutorOptions{
executerOpts := &protocols.ExecutorOptions{
Output: outputWriter,
Options: defaultOpts,
Progress: mockProgress,
Expand All @@ -116,7 +120,7 @@ func executeNucleiAsLibrary(templatePath, templateURL string) ([]string, error)
engine := core.New(defaultOpts)
engine.SetExecuterOptions(executerOpts)

workflowLoader, err := parsers.NewLoader(&executerOpts)
workflowLoader, err := parsers.NewLoader(executerOpts)
if err != nil {
log.Fatalf("Could not create workflow loader: %s\n", err)
}
Expand All @@ -128,7 +132,7 @@ func executeNucleiAsLibrary(templatePath, templateURL string) ([]string, error)
}
store.Load()

_ = engine.Execute(context.Background(), store.Templates(), provider.NewSimpleInputProviderWithUrls(templateURL))
_ = engine.Execute(context.Background(), store.Templates(), provider.NewSimpleInputProviderWithUrls(defaultOpts.ExecutionId, templateURL))
engine.WorkPool().Wait() // Wait for the scan to finish

return results, nil
Expand Down
24 changes: 12 additions & 12 deletions cmd/integration-test/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func (h *networkBasic) Execute(filePath string) error {

ts := testutils.NewTCPServer(nil, defaultStaticPort, func(conn net.Conn) {
defer func() {
_ = conn.Close()
}()
_ = conn.Close()
}()

data, err := reader.ConnReadNWithTimeout(conn, 4, time.Duration(5)*time.Second)
if err != nil {
Expand Down Expand Up @@ -71,8 +71,8 @@ func (h *networkMultiStep) Execute(filePath string) error {

ts := testutils.NewTCPServer(nil, defaultStaticPort, func(conn net.Conn) {
defer func() {
_ = conn.Close()
}()
_ = conn.Close()
}()

data, err := reader.ConnReadNWithTimeout(conn, 5, time.Duration(5)*time.Second)
if err != nil {
Expand Down Expand Up @@ -119,8 +119,8 @@ type networkRequestSelContained struct{}
func (h *networkRequestSelContained) Execute(filePath string) error {
ts := testutils.NewTCPServer(nil, defaultStaticPort, func(conn net.Conn) {
defer func() {
_ = conn.Close()
}()
_ = conn.Close()
}()

_, _ = conn.Write([]byte("Authentication successful"))
})
Expand All @@ -141,8 +141,8 @@ func (h *networkVariables) Execute(filePath string) error {

ts := testutils.NewTCPServer(nil, defaultStaticPort, func(conn net.Conn) {
defer func() {
_ = conn.Close()
}()
_ = conn.Close()
}()

data, err := reader.ConnReadNWithTimeout(conn, 4, time.Duration(5)*time.Second)
if err != nil {
Expand Down Expand Up @@ -171,8 +171,8 @@ type networkPort struct{}
func (n *networkPort) Execute(filePath string) error {
ts := testutils.NewTCPServer(nil, 23846, func(conn net.Conn) {
defer func() {
_ = conn.Close()
}()
_ = conn.Close()
}()

data, err := reader.ConnReadNWithTimeout(conn, 4, time.Duration(5)*time.Second)
if err != nil {
Expand Down Expand Up @@ -206,8 +206,8 @@ func (n *networkPort) Execute(filePath string) error {
// this is positive test case where we expect port to be overridden and 34567 to be used
ts2 := testutils.NewTCPServer(nil, 34567, func(conn net.Conn) {
defer func() {
_ = conn.Close()
}()
_ = conn.Close()
}()

data, err := reader.ConnReadNWithTimeout(conn, 4, time.Duration(5)*time.Second)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/integration-test/profile-loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var profileLoaderTestcases = []TestCaseInfo{
type profileLoaderByRelFile struct{}

func (h *profileLoaderByRelFile) Execute(testName string) error {
results, err := testutils.RunNucleiWithArgsAndGetResults(false, "-tl", "-tp", "cloud.yml")
results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", "cloud.yml")
if err != nil {
return errorutil.NewWithErr(err).Msgf("failed to load template with id")
}
Expand All @@ -29,7 +29,7 @@ func (h *profileLoaderByRelFile) Execute(testName string) error {
type profileLoaderById struct{}

func (h *profileLoaderById) Execute(testName string) error {
results, err := testutils.RunNucleiWithArgsAndGetResults(false, "-tl", "-tp", "cloud")
results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", "cloud")
if err != nil {
return errorutil.NewWithErr(err).Msgf("failed to load template with id")
}
Expand All @@ -43,7 +43,7 @@ func (h *profileLoaderById) Execute(testName string) error {
type customProfileLoader struct{}

func (h *customProfileLoader) Execute(filepath string) error {
results, err := testutils.RunNucleiWithArgsAndGetResults(false, "-tl", "-tp", filepath)
results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", filepath)
if err != nil {
return errorutil.NewWithErr(err).Msgf("failed to load template with id")
}
Expand Down
Loading
Loading