Skip to content

Commit 773a379

Browse files
committed
refactor: native tests
Signed-off-by: Dwi Siswanto <git@dw1.io>
1 parent 9e2366f commit 773a379

File tree

325 files changed

+3068
-2559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+3068
-2559
lines changed

.github/workflows/tests.yaml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- run: make test
5757
env:
5858
PDCP_API_KEY: "${{ secrets.PDCP_API_KEY }}"
59-
- run: go run -race . -l ../functional-test/targets.txt -id tech-detect,tls-version
59+
- run: go run -race . -l ${{ github.workspace }}/internal/tests/functional/testdata/targets.txt -id tech-detect,tls-version
6060
if: ${{ matrix.os != 'windows-latest' }} # known issue: https://github.com/golang/go/issues/46099
6161
working-directory: cmd/nuclei/
6262

@@ -94,15 +94,16 @@ jobs:
9494
runs-on: ${{ matrix.os }}
9595
steps:
9696
- uses: actions/checkout@v6
97-
- uses: projectdiscovery/actions/setup/go@v1
98-
- uses: projectdiscovery/actions/cache/nuclei@v1
9997
- uses: projectdiscovery/actions/setup/python@v1
100-
- uses: projectdiscovery/actions/cache/go-rod-browser@v1
101-
- run: bash run.sh "${{ matrix.os }}"
98+
- uses: projectdiscovery/actions/setup/go@v1
99+
- uses: projectdiscovery/nuclei-action@v3
100+
with:
101+
version: latest
102+
install-only: true
103+
- run: make integration
102104
env:
103105
PDCP_API_KEY: "${{ secrets.PDCP_API_KEY }}"
104106
timeout-minutes: 50
105-
working-directory: integration_tests/
106107

107108
functional:
108109
name: "Functional tests"
@@ -116,12 +117,13 @@ jobs:
116117
runs-on: ${{ matrix.os }}
117118
steps:
118119
- uses: actions/checkout@v6
119-
- uses: projectdiscovery/actions/setup/go@v1
120-
- uses: projectdiscovery/actions/cache/nuclei@v1
121120
- uses: projectdiscovery/actions/setup/python@v1
122-
- uses: projectdiscovery/actions/cache/go-rod-browser@v1
123-
- run: bash run.sh
124-
working-directory: cmd/functional-test/
121+
- uses: projectdiscovery/actions/setup/go@v1
122+
- uses: projectdiscovery/nuclei-action@v3
123+
with:
124+
version: latest
125+
install-only: true
126+
- run: make functional
125127

126128
validate:
127129
name: "Template validate"

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
/scrapefunc
2929
/scrapefuncs
3030
/tsgen
31-
/integration_tests/integration-test
32-
/integration_tests/nuclei
31+
*.test
3332

3433
# Templates
3534
/*.yaml

.run/DSLFunctionsIT.run.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.run/IntegrationTests.run.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.run/RegressionTests.run.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

CLAUDE.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Nuclei is a modern, high-performance vulnerability scanner built in Go that leve
1111
### Building and Testing
1212
- `make build` - Build the main nuclei binary to ./bin/nuclei
1313
- `make test` - Run unit tests with race detection
14-
- `make integration` - Run integration tests (builds and runs test suite)
15-
- `make functional` - Run functional tests
14+
- `make integration` - Run the native integration suite via `go test -tags=integration ./internal/tests/integration`
15+
- `make functional` - CI-only functional suite entry point
1616
- `make vet` - Run go vet for code analysis
1717
- `make tidy` - Clean up go modules
1818

@@ -29,7 +29,7 @@ Nuclei is a modern, high-performance vulnerability scanner built in Go that leve
2929

3030
### Testing Specific Components
3131
- Run single test: `go test -v ./pkg/path/to/package -run TestName`
32-
- Integration tests are in `integration_tests/` and can be run via `make integration`
32+
- Integration tests are in `internal/tests/integration/` and run via `go test -tags=integration ./internal/tests/integration`
3333

3434
## Architecture Overview
3535

@@ -77,7 +77,8 @@ Each protocol (HTTP, DNS, Network, etc.) implements:
7777
## Key Directories
7878
- **lib/** - SDK for embedding nuclei as a library
7979
- **examples/** - Usage examples for different scenarios
80-
- **integration_tests/** - Integration test suite with protocol-specific tests
80+
- **internal/tests/integration/** - Native integration suite and owned testdata for harness coverage
81+
- **internal/tests/functional/** - CI-only native functional comparison suite and testcase assets
8182
- **pkg/fuzz/** - Fuzzing engine and DAST capabilities
8283
- **pkg/input/** - Input processing for various formats (Burp, OpenAPI, etc.)
8384
- **pkg/reporting/** - Result export and issue tracking integrations

DESIGN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ func (template *Template) compileProtocolRequests(options protocols.ExecuterOpti
454454
}
455455
```
456456

457-
That's it, you've added a new protocol to Nuclei. The next good step would be to write integration tests which are described in `integration-tests` and `cmd/integration-tests` directories.
457+
That's it, you've added a new protocol to Nuclei. The next good step would be to add native integration coverage under `internal/tests/integration` and run it with `go test -tags=integration ./internal/tests/integration`.
458458

459459

460460
## Profiling and Tracing

Makefile

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
GOCMD := go
33
GOBUILD := $(GOCMD) build
44
GOBUILD_OUTPUT :=
5+
GOBUILD_OUTPUT_EXT :=
56
GOBUILD_PACKAGES :=
67
GOBUILD_ADDITIONAL_ARGS :=
78
GOMOD := $(GOCMD) mod
@@ -13,10 +14,14 @@ LDFLAGS := -s -w
1314
ifneq ($(shell go env GOOS),darwin)
1415
LDFLAGS += -extldflags "-static"
1516
endif
17+
18+
ifeq ($(shell go env GOOS),windows)
19+
GOBUILD_OUTPUT_EXT := .exe
20+
endif
1621

1722
.PHONY: all build build-stats clean devtools-all devtools-bindgen devtools-scrapefuncs
1823
.PHONY: devtools-tsgen docs docgen dsl-docs functional fuzzplayground go-build lint lint-strict syntax-docs
19-
.PHONY: integration jsupdate-all jsupdate-bindgen jsupdate-tsgen memogen scan-charts test test-with-lint
24+
.PHONY: integration integration-debug jsupdate-all jsupdate-bindgen jsupdate-tsgen memogen scan-charts test test-with-lint
2025
.PHONY: tidy ts verify download vet template-validate
2126

2227
all: build
@@ -29,7 +34,7 @@ go-build:
2934
CGO_ENABLED=0 $(GOBUILD) -trimpath $(GOFLAGS) -ldflags '${LDFLAGS}' $(GOBUILD_ADDITIONAL_ARGS) \
3035
-o '${GOBUILD_OUTPUT}' $(GOBUILD_PACKAGES)
3136

32-
build: GOFLAGS = -v -pgo=auto
37+
build: GOFLAGS = -pgo=auto
3338
build: GOBUILD_OUTPUT = ./bin/nuclei
3439
build: GOBUILD_PACKAGES = cmd/nuclei/main.go
3540
build: go-build
@@ -40,7 +45,7 @@ build-test: GOBUILD_PACKAGES = ./cmd/nuclei/
4045
build-test: clean
4146
build-test:
4247
CGO_ENABLED=0 $(GOCMD) test -c -trimpath $(GOFLAGS) -ldflags '${LDFLAGS}' $(GOBUILD_ADDITIONAL_ARGS) \
43-
-o '${GOBUILD_OUTPUT}' ${GOBUILD_PACKAGES}
48+
-o '${GOBUILD_OUTPUT}${GOBUILD_OUTPUT_EXT}' ${GOBUILD_PACKAGES}
4449

4550
build-stats: GOBUILD_OUTPUT = ./bin/nuclei-stats
4651
build-stats: GOBUILD_PACKAGES = cmd/nuclei/main.go
@@ -75,15 +80,25 @@ syntax-docs: docgen
7580
syntax-docs:
7681
./bin/docgen SYNTAX-REFERENCE.md nuclei-jsonschema.json
7782

78-
test: GOFLAGS = -race -v -timeout 30m -count 1
83+
test: GOFLAGS = -race -v -timeout 1h -count 1
7984
test:
8085
$(GOTEST) $(GOFLAGS) ./...
8186

8287
integration:
83-
cd integration_tests; bash run.sh
84-
85-
functional:
86-
cd cmd/functional-test; bash run.sh
88+
$(GOTEST) -tags=integration -timeout 1h ./internal/tests/integration
89+
90+
integration-debug:
91+
$(GOTEST) -tags=integration ./internal/tests/integration -v $(GO_TEST_ARGS) -args $(INTEGRATION_ARGS)
92+
93+
functional: build
94+
@test "$$CI" = "true" || (echo "functional target is CI-only" && exit 1)
95+
@release_binary="$$(command -v nuclei.exe 2>/dev/null || command -v nuclei 2>/dev/null)"; \
96+
if [ -z "$$release_binary" ]; then \
97+
echo "release nuclei binary not found on PATH"; \
98+
exit 1; \
99+
fi; \
100+
RELEASE_BINARY="$$release_binary" DEV_BINARY="$(PWD)/bin/nuclei" \
101+
$(GOTEST) -tags=functional -timeout 1h ./internal/tests/functional
87102

88103
tidy:
89104
$(GOMOD) tidy

_typos.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ extend-exclude = [
99
"README_PT-BR.md",
1010
"README_TR.md",
1111
# Test fixtures and data files
12-
"integration_tests/",
12+
"internal/tests/integration/testdata/",
1313
"pkg/input/formats/testdata/",
1414
"pkg/output/stats/waf/",
1515
# Deserialization test data
1616
"pkg/protocols/common/helpers/deserialization/testdata/",
1717
# Certificate/encoded data in test utilities
18-
"pkg/testutils/integration.go",
18+
"internal/tests/testutils/integration.go",
1919
# Vendor directory
2020
"vendor/",
2121
# Go checksum file

cmd/functional-test/main.go

Lines changed: 0 additions & 127 deletions
This file was deleted.

0 commit comments

Comments
 (0)