-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ignore version parsing error (#3984)
* ignore version parsing error * hide no parameter error * integration test+ DEBUG.md * typo fix in DEBUG.md * go mod tidy --------- Co-authored-by: sandeep <[email protected]>
- Loading branch information
1 parent
9adce97
commit 6bdef68
Showing
9 changed files
with
204 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Debugging Nuclei | ||
|
||
While Adding new features or fixing bugs or writing new templates to properly understand the behavior of that component, it is essential to understand what debugging options are available in nuclei. This guide lists all the debugging options available in nuclei. | ||
|
||
### Template related debugging | ||
|
||
- `-debug` flag | ||
|
||
When this flag is provided, nuclei will print all requests that are being sent by nuclei to the target as well as the response received from the target. | ||
|
||
- `-debug-req` flag | ||
|
||
When this flag is provided, nuclei will print all requests that are being sent by nuclei to the target. | ||
|
||
- `-debug-resp` flag | ||
|
||
When this flag is provided, nuclei will print all responses that are being received by nuclei from the target. | ||
|
||
- `-ldf` flag | ||
|
||
When this flag is provided, nuclei will print the list of all helper functions available in this release of nuclei and exit. | ||
|
||
- `-svd` flag | ||
|
||
When this flag is provided, nuclei will print all `variables` pre and post execution of a request for a template. This is useful to understand what variables are available for a template and what values they have. | ||
|
||
- `-elog = errors.txt` flag | ||
|
||
When this flag is provided, nuclei will log all errors to the file specified. This is helpful when running large scans. | ||
|
||
|
||
|
||
### Environment Variable Switches | ||
|
||
Nuclei was built with some environment variables in mind to help with debugging. These environment variables can be set to enable debugging of a particular component/functionality for nuclei. | ||
|
||
| Environment Variable | Description | | ||
| ---------------------- | -------------------------------------------------------- | | ||
| `DEBUG=true` | Enables Printing Stack Traces for all errors | | ||
| `SHOW_DSL_ERRORS=true` | Enables Printing DSL Errors (that are hidden by default) | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
id: basic-example | ||
|
||
info: | ||
name: Test HTTP Template | ||
author: pdteam | ||
severity: info | ||
reference: | | ||
test case for default behaviour of version warning (dsl parsing error) | ||
http: | ||
- method: GET | ||
path: | ||
- "{{BaseURL}}" | ||
|
||
matchers: | ||
- type: dsl | ||
dsl: | ||
- compare_versions("GG", '< 4.8.5') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
id: basic-example | ||
|
||
info: | ||
name: Test HTTP Template | ||
author: pdteam | ||
severity: info | ||
reference: | | ||
test case where version warning is shown when env `SHOW_DSL_ERRORS=true` is set | ||
http: | ||
- method: GET | ||
path: | ||
- "{{BaseURL}}" | ||
|
||
matchers: | ||
- type: dsl | ||
dsl: | ||
- compare_versions("GG", '< 4.8.5') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"net/http/httptest" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
"github.com/projectdiscovery/nuclei/v2/pkg/testutils" | ||
) | ||
|
||
var dslTestcases = map[string]testutils.TestCase{ | ||
"dsl/hide-version-warning.yaml": &dslVersionWarning{}, | ||
"dsl/show-version-warning.yaml": &dslShowVersionWarning{}, | ||
} | ||
|
||
type dslVersionWarning struct{} | ||
|
||
func (d *dslVersionWarning) Execute(templatePath string) error { | ||
router := httprouter.New() | ||
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
fmt.Fprintf(w, "DSL version parsing warning test") | ||
}) | ||
ts := httptest.NewServer(router) | ||
defer ts.Close() | ||
results, err := testutils.RunNucleiArgsAndGetErrors(debug, nil, "-t", templatePath, "-target", ts.URL, "-v") | ||
if err != nil { | ||
return err | ||
} | ||
return expectResultsCount(results, 0) | ||
} | ||
|
||
type dslShowVersionWarning struct{} | ||
|
||
func (d *dslShowVersionWarning) Execute(templatePath string) error { | ||
router := httprouter.New() | ||
router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
fmt.Fprintf(w, "DSL version parsing warning test") | ||
}) | ||
ts := httptest.NewServer(router) | ||
defer ts.Close() | ||
results, err := testutils.RunNucleiArgsAndGetErrors(debug, []string{"SHOW_DSL_ERRORS=true"}, "-t", templatePath, "-target", ts.URL, "-v") | ||
if err != nil { | ||
return err | ||
} | ||
return expectResultsCount(results, 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters