nuclei/cmd/integration-test/profile-loader.go
Ramana Reddy 902eb78d34
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
2024-05-04 21:53:50 +05:30

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
}