-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
profile
option to load template profile (#5125)
* Add profile option to load template profile * Misc update * Add profile-list option * Misc update * Add tests
- Loading branch information
1 parent
9784ca8
commit 902eb78
Showing
6 changed files
with
140 additions
and
3 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
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,53 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/projectdiscovery/nuclei/v3/pkg/testutils" | ||
errorutil "github.com/projectdiscovery/utils/errors" | ||
) | ||
|
||
var profileLoaderTestcases = []TestCaseInfo{ | ||
{Path: "profile-loader/load-with-filename", TestCase: &profileLoaderByRelFile{}}, | ||
{Path: "profile-loader/load-with-id", TestCase: &profileLoaderById{}}, | ||
{Path: "profile-loader/basic.yml", TestCase: &customProfileLoader{}}, | ||
} | ||
|
||
type profileLoaderByRelFile struct{} | ||
|
||
func (h *profileLoaderByRelFile) Execute(testName string) error { | ||
results, err := testutils.RunNucleiWithArgsAndGetResults(false, "-tl", "-tp", "kev.yml") | ||
if err != nil { | ||
return errorutil.NewWithErr(err).Msgf("failed to load template with id") | ||
} | ||
if len(results) < 267 { | ||
return fmt.Errorf("incorrect result: expected more results than %d, got %v", 267, len(results)) | ||
} | ||
return nil | ||
} | ||
|
||
type profileLoaderById struct{} | ||
|
||
func (h *profileLoaderById) Execute(testName string) error { | ||
results, err := testutils.RunNucleiWithArgsAndGetResults(false, "-tl", "-tp", "kev") | ||
if err != nil { | ||
return errorutil.NewWithErr(err).Msgf("failed to load template with id") | ||
} | ||
if len(results) < 267 { | ||
return fmt.Errorf("incorrect result: expected more results than %d, got %v", 267, len(results)) | ||
} | ||
return nil | ||
} | ||
|
||
type customProfileLoader struct{} | ||
|
||
func (h *customProfileLoader) Execute(filepath string) error { | ||
results, err := testutils.RunNucleiWithArgsAndGetResults(false, "-tl", "-tp", filepath) | ||
if err != nil { | ||
return errorutil.NewWithErr(err).Msgf("failed to load template with id") | ||
} | ||
if len(results) < 267 { | ||
return fmt.Errorf("incorrect result: expected more results than %d, got %v", 267, len(results)) | ||
} | ||
return nil | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tags: | ||
- kev |
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