mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 15:45:27 +00:00
* Add profile option to load template profile * Misc update * Add profile-list option * Misc update * Add tests
54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
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
|
|
}
|