Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/cmd/integration-test/file.go
2070 views
1
package main
2
3
import (
4
"github.com/projectdiscovery/nuclei/v3/pkg/testutils"
5
)
6
7
var fileTestcases = []TestCaseInfo{
8
{Path: "protocols/file/matcher-with-or.yaml", TestCase: &fileWithOrMatcher{}},
9
{Path: "protocols/file/matcher-with-and.yaml", TestCase: &fileWithAndMatcher{}},
10
{Path: "protocols/file/matcher-with-nested-and.yaml", TestCase: &fileWithAndMatcher{}},
11
{Path: "protocols/file/extract.yaml", TestCase: &fileWithExtractor{}},
12
}
13
14
type fileWithOrMatcher struct{}
15
16
// Execute executes a test case and returns an error if occurred
17
func (h *fileWithOrMatcher) Execute(filePath string) error {
18
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "protocols/file/data/", debug, "-file")
19
if err != nil {
20
return err
21
}
22
23
return expectResultsCount(results, 1)
24
}
25
26
type fileWithAndMatcher struct{}
27
28
// Execute executes a test case and returns an error if occurred
29
func (h *fileWithAndMatcher) Execute(filePath string) error {
30
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "protocols/file/data/", debug, "-file")
31
if err != nil {
32
return err
33
}
34
35
return expectResultsCount(results, 1)
36
}
37
38
type fileWithExtractor struct{}
39
40
// Execute executes a test case and returns an error if occurred
41
func (h *fileWithExtractor) Execute(filePath string) error {
42
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "protocols/file/data/", debug, "-file")
43
if err != nil {
44
return err
45
}
46
47
return expectResultsCount(results, 1)
48
}
49
50