2024-05-04 21:53:50 +05:30
|
|
|
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 {
|
2025-07-09 14:47:26 -05:00
|
|
|
results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", "cloud.yml")
|
2024-05-04 21:53:50 +05:30
|
|
|
if err != nil {
|
|
|
|
|
return errorutil.NewWithErr(err).Msgf("failed to load template with id")
|
|
|
|
|
}
|
2024-05-11 00:44:14 +05:30
|
|
|
if len(results) <= 10 {
|
|
|
|
|
return fmt.Errorf("incorrect result: expected more results than %d, got %v", 10, len(results))
|
2024-05-04 21:53:50 +05:30
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type profileLoaderById struct{}
|
|
|
|
|
|
|
|
|
|
func (h *profileLoaderById) Execute(testName string) error {
|
2025-07-09 14:47:26 -05:00
|
|
|
results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", "cloud")
|
2024-05-04 21:53:50 +05:30
|
|
|
if err != nil {
|
|
|
|
|
return errorutil.NewWithErr(err).Msgf("failed to load template with id")
|
|
|
|
|
}
|
2024-05-11 00:44:14 +05:30
|
|
|
if len(results) <= 10 {
|
|
|
|
|
return fmt.Errorf("incorrect result: expected more results than %d, got %v", 10, len(results))
|
2024-05-04 21:53:50 +05:30
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-11 00:44:14 +05:30
|
|
|
// this profile with load kevs
|
2024-05-04 21:53:50 +05:30
|
|
|
type customProfileLoader struct{}
|
|
|
|
|
|
|
|
|
|
func (h *customProfileLoader) Execute(filepath string) error {
|
2025-07-09 14:47:26 -05:00
|
|
|
results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", filepath)
|
2024-05-04 21:53:50 +05:30
|
|
|
if err != nil {
|
|
|
|
|
return errorutil.NewWithErr(err).Msgf("failed to load template with id")
|
|
|
|
|
}
|
2024-05-11 00:44:14 +05:30
|
|
|
if len(results) < 1 {
|
|
|
|
|
return fmt.Errorf("incorrect result: expected more results than %d, got %v", 1, len(results))
|
2024-05-04 21:53:50 +05:30
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|