Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/cmd/integration-test/profile-loader.go
2070 views
1
package main
2
3
import (
4
"fmt"
5
6
"github.com/projectdiscovery/nuclei/v3/pkg/testutils"
7
"github.com/projectdiscovery/utils/errkit"
8
)
9
10
var profileLoaderTestcases = []TestCaseInfo{
11
{Path: "profile-loader/load-with-filename", TestCase: &profileLoaderByRelFile{}},
12
{Path: "profile-loader/load-with-id", TestCase: &profileLoaderById{}},
13
{Path: "profile-loader/basic.yml", TestCase: &customProfileLoader{}},
14
}
15
16
type profileLoaderByRelFile struct{}
17
18
func (h *profileLoaderByRelFile) Execute(testName string) error {
19
results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", "cloud.yml")
20
if err != nil {
21
return errkit.Wrap(err, "failed to load template with id")
22
}
23
if len(results) <= 10 {
24
return fmt.Errorf("incorrect result: expected more results than %d, got %v", 10, len(results))
25
}
26
return nil
27
}
28
29
type profileLoaderById struct{}
30
31
func (h *profileLoaderById) Execute(testName string) error {
32
results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", "cloud")
33
if err != nil {
34
return errkit.Wrap(err, "failed to load template with id")
35
}
36
if len(results) <= 10 {
37
return fmt.Errorf("incorrect result: expected more results than %d, got %v", 10, len(results))
38
}
39
return nil
40
}
41
42
// this profile with load kevs
43
type customProfileLoader struct{}
44
45
func (h *customProfileLoader) Execute(filepath string) error {
46
results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", filepath)
47
if err != nil {
48
return errkit.Wrap(err, "failed to load template with id")
49
}
50
if len(results) < 1 {
51
return fmt.Errorf("incorrect result: expected more results than %d, got %v", 1, len(results))
52
}
53
return nil
54
}
55
56