Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/cmd/integration-test/custom-dir.go
2070 views
1
package main
2
3
import (
4
"os"
5
6
"github.com/projectdiscovery/nuclei/v3/pkg/testutils"
7
)
8
9
type customConfigDirTest struct{}
10
11
var customConfigDirTestCases = []TestCaseInfo{
12
{Path: "protocols/dns/cname-fingerprint.yaml", TestCase: &customConfigDirTest{}},
13
}
14
15
// Execute executes a test case and returns an error if occurred
16
func (h *customConfigDirTest) Execute(filePath string) error {
17
customTempDirectory, err := os.MkdirTemp("", "")
18
if err != nil {
19
return err
20
}
21
defer func() {
22
_ = os.RemoveAll(customTempDirectory)
23
}()
24
results, err := testutils.RunNucleiBareArgsAndGetResults(debug, []string{"NUCLEI_CONFIG_DIR=" + customTempDirectory}, "-t", filePath, "-u", "8x8exch02.8x8.com")
25
if err != nil {
26
return err
27
}
28
if len(results) == 0 {
29
return nil
30
}
31
files, err := os.ReadDir(customTempDirectory)
32
if err != nil {
33
return err
34
}
35
var fileNames []string
36
for _, file := range files {
37
fileNames = append(fileNames, file.Name())
38
}
39
return expectResultsCount(fileNames, 4)
40
}
41
42