From 398d4deae1ddb79a8fc8f3332d93633273367778 Mon Sep 17 00:00:00 2001 From: knakul853 Date: Sat, 17 May 2025 20:23:38 +0530 Subject: [PATCH 1/5] add missing file --- cmd/functional-test/run.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/functional-test/run.sh b/cmd/functional-test/run.sh index a3caf7222c..00dd90ef26 100755 --- a/cmd/functional-test/run.sh +++ b/cmd/functional-test/run.sh @@ -7,6 +7,10 @@ if [ "${CURRENT_OS}" == "windows-latest" ];then extension=.exe fi +# Create necessary config directories and files +mkdir -p .nuclei-config/nuclei/ +touch .nuclei-config/nuclei/.nuclei-ignore + echo "::group::Building functional-test binary" go build -o functional-test$extension echo "::endgroup::" From a7e8c74f99d74c5e47fa620533e327d67a8cf74b Mon Sep 17 00:00:00 2001 From: knakul853 Date: Sat, 17 May 2025 21:29:31 +0530 Subject: [PATCH 2/5] increase file descriptor limit --- .github/workflows/tests.yaml | 12 ++++++++++++ cmd/functional-test/run.sh | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index af6ad9d7e3..554d732be1 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -94,6 +94,18 @@ jobs: - uses: actions/checkout@v4 - uses: projectdiscovery/actions/setup/go@v1 - uses: projectdiscovery/actions/setup/python@v1 + # Increase file descriptor limits on macOS + - name: Increase file descriptor limits + if: matrix.os == 'macOS-latest' + run: | + sudo sysctl -w kern.maxfiles=524288 + sudo sysctl -w kern.maxfilesperproc=524288 + ulimit -n 65536 || true + sudo launchctl limit maxfiles 65536 524288 + echo "File descriptor limits:" + ulimit -n + sysctl kern.maxfiles + sysctl kern.maxfilesperproc - run: bash run.sh "${{ matrix.os }}" env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/cmd/functional-test/run.sh b/cmd/functional-test/run.sh index 00dd90ef26..167461ba41 100755 --- a/cmd/functional-test/run.sh +++ b/cmd/functional-test/run.sh @@ -27,5 +27,29 @@ echo "::group::Building latest release of nuclei" go build -o nuclei$extension -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei echo "::endgroup::" +echo "::group::Validating templates" +# Basic template validation +./nuclei_dev$extension -ut + +# Check .nuclei-ignore file format +echo "::debug::Content of .nuclei-ignore file:" +cat .nuclei-config/nuclei/.nuclei-ignore + +# Validate templates with more verbose output +./nuclei_dev$extension -validate -debug -v + +# List templates that will be used +echo "::debug::Templates that will be loaded:" +./nuclei_dev$extension -tl | head -20 +echo "::endgroup::" + +# For macOS, ensure we're not hitting file descriptor limits +if [ "${CURRENT_OS}" == "macOS-latest" ]; then + echo "::group::Setting macOS specific configurations" + ulimit -n 65536 || true + echo "Current file descriptor limit: $(ulimit -n)" + echo "::endgroup::" +fi + echo 'Starting Nuclei functional test' ./functional-test$extension -main ./nuclei$extension -dev ./nuclei_dev$extension -testcases testcases.txt From 11a5ca1fbc6a3508dbffbc4b0c3c8299a9d1e53b Mon Sep 17 00:00:00 2001 From: knakul853 Date: Sun, 18 May 2025 01:29:24 +0530 Subject: [PATCH 3/5] removed debugging code --- .github/workflows/tests.yaml | 6 +----- cmd/functional-test/run.sh | 16 +--------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 554d732be1..2191dc6a13 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -100,12 +100,8 @@ jobs: run: | sudo sysctl -w kern.maxfiles=524288 sudo sysctl -w kern.maxfilesperproc=524288 - ulimit -n 65536 || true sudo launchctl limit maxfiles 65536 524288 - echo "File descriptor limits:" - ulimit -n - sysctl kern.maxfiles - sysctl kern.maxfilesperproc + ulimit -n 65536 || true - run: bash run.sh "${{ matrix.os }}" env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/cmd/functional-test/run.sh b/cmd/functional-test/run.sh index 167461ba41..4a24ee6c80 100755 --- a/cmd/functional-test/run.sh +++ b/cmd/functional-test/run.sh @@ -28,27 +28,13 @@ go build -o nuclei$extension -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei echo "::endgroup::" echo "::group::Validating templates" -# Basic template validation ./nuclei_dev$extension -ut - -# Check .nuclei-ignore file format -echo "::debug::Content of .nuclei-ignore file:" -cat .nuclei-config/nuclei/.nuclei-ignore - -# Validate templates with more verbose output -./nuclei_dev$extension -validate -debug -v - -# List templates that will be used -echo "::debug::Templates that will be loaded:" -./nuclei_dev$extension -tl | head -20 +./nuclei_dev$extension -validate echo "::endgroup::" # For macOS, ensure we're not hitting file descriptor limits if [ "${CURRENT_OS}" == "macOS-latest" ]; then - echo "::group::Setting macOS specific configurations" ulimit -n 65536 || true - echo "Current file descriptor limit: $(ulimit -n)" - echo "::endgroup::" fi echo 'Starting Nuclei functional test' From 7918a49ec7d1ff8c22ce33106fa5670c7e400992 Mon Sep 17 00:00:00 2001 From: knakul853 Date: Sun, 18 May 2025 01:32:37 +0530 Subject: [PATCH 4/5] fixed lower case --- cmd/functional-test/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/functional-test/run.sh b/cmd/functional-test/run.sh index 4a24ee6c80..b4897f1bbc 100755 --- a/cmd/functional-test/run.sh +++ b/cmd/functional-test/run.sh @@ -33,7 +33,7 @@ echo "::group::Validating templates" echo "::endgroup::" # For macOS, ensure we're not hitting file descriptor limits -if [ "${CURRENT_OS}" == "macOS-latest" ]; then +if [ "${CURRENT_OS}" == "macos-latest" ]; then ulimit -n 65536 || true fi From f1cc3e986a47986e9d78d068d185d617cb61c762 Mon Sep 17 00:00:00 2001 From: Dwi Siswanto Date: Sun, 18 May 2025 19:11:29 +0700 Subject: [PATCH 5/5] test: tweaks on script * uses CI runtime env vars (`RUNNER_OS` & `RUNNER_DEBUG`) * restores originial `ulimit` Signed-off-by: Dwi Siswanto --- .github/workflows/tests.yaml | 10 +-------- cmd/functional-test/main.go | 2 +- cmd/functional-test/run.sh | 42 +++++++++++++++++++----------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2191dc6a13..7cbfd2f129 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -94,15 +94,7 @@ jobs: - uses: actions/checkout@v4 - uses: projectdiscovery/actions/setup/go@v1 - uses: projectdiscovery/actions/setup/python@v1 - # Increase file descriptor limits on macOS - - name: Increase file descriptor limits - if: matrix.os == 'macOS-latest' - run: | - sudo sysctl -w kern.maxfiles=524288 - sudo sysctl -w kern.maxfilesperproc=524288 - sudo launchctl limit maxfiles 65536 524288 - ulimit -n 65536 || true - - run: bash run.sh "${{ matrix.os }}" + - run: bash run.sh env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" working-directory: cmd/functional-test/ diff --git a/cmd/functional-test/main.go b/cmd/functional-test/main.go index 8a5cebc59b..78114fdb35 100644 --- a/cmd/functional-test/main.go +++ b/cmd/functional-test/main.go @@ -27,7 +27,7 @@ var ( func main() { flag.Parse() - debug := os.Getenv("DEBUG") == "true" + debug := os.Getenv("DEBUG") == "true" || os.Getenv("RUNNER_DEBUG") == "1" if err, errored := runFunctionalTests(debug); err != nil { log.Fatalf("Could not run functional tests: %s\n", err) diff --git a/cmd/functional-test/run.sh b/cmd/functional-test/run.sh index b4897f1bbc..a955ad8a7f 100755 --- a/cmd/functional-test/run.sh +++ b/cmd/functional-test/run.sh @@ -1,41 +1,43 @@ #!/bin/bash -# reading os type from arguments -CURRENT_OS=$1 - -if [ "${CURRENT_OS}" == "windows-latest" ];then - extension=.exe +if [ "${RUNNER_OS}" == "Windows" ]; then + EXT=".exe" +elif [ "${RUNNER_OS}" == "macOS" ]; then + if [ "${CI}" == "true" ]; then + sudo sysctl -w kern.maxfiles{,perproc}=524288 + sudo launchctl limit maxfiles 65536 524288 + fi + + ORIGINAL_ULIMIT="$(ulimit -n)" + ulimit -n 65536 || true fi -# Create necessary config directories and files mkdir -p .nuclei-config/nuclei/ touch .nuclei-config/nuclei/.nuclei-ignore echo "::group::Building functional-test binary" -go build -o functional-test$extension +go build -o "functional-test${EXT}" echo "::endgroup::" echo "::group::Building Nuclei binary from current branch" -go build -o nuclei_dev$extension ../nuclei +go build -o "nuclei-dev${EXT}" ../nuclei echo "::endgroup::" -echo "::group::Installing nuclei templates" -./nuclei_dev$extension -update-templates +echo "::group::Building latest release of nuclei" +go build -o "nuclei${EXT}" -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei echo "::endgroup::" -echo "::group::Building latest release of nuclei" -go build -o nuclei$extension -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei +echo "::group::Installing nuclei templates" +eval "./nuclei-dev${EXT} -update-templates" echo "::endgroup::" echo "::group::Validating templates" -./nuclei_dev$extension -ut -./nuclei_dev$extension -validate +eval "./nuclei-dev${EXT} -validate" echo "::endgroup::" -# For macOS, ensure we're not hitting file descriptor limits -if [ "${CURRENT_OS}" == "macos-latest" ]; then - ulimit -n 65536 || true -fi +echo "Starting Nuclei functional test" +eval "./functional-test${EXT} -main ./nuclei${EXT} -dev ./nuclei-dev${EXT} -testcases testcases.txt" -echo 'Starting Nuclei functional test' -./functional-test$extension -main ./nuclei$extension -dev ./nuclei_dev$extension -testcases testcases.txt +if [ "${RUNNER_OS}" == "macOS" ]; then + ulimit -n "${ORIGINAL_ULIMIT}" || true +fi