mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-22 22:15:37 +00:00
* added custom config flag * config.yaml file in custom directory * lint error fix * few updates and error checks * fix lint error * copy config.yaml file if the dest folder does not exist * lint error check * added integration test * improved test cases * lint error fix
39 lines
931 B
Go
39 lines
931 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
|
|
)
|
|
|
|
type customConfigDirTest struct{}
|
|
|
|
var customConfigDirTestCases = map[string]testutils.TestCase{
|
|
"dns/cname-fingerprint.yaml": &customConfigDirTest{},
|
|
}
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
func (h *customConfigDirTest) Execute(filePath string) error {
|
|
customTempDirectory, err := os.MkdirTemp("", "")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer os.RemoveAll(customTempDirectory)
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "8x8exch02.8x8.com", debug, "-config-directory", customTempDirectory)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(results) == 0 {
|
|
return nil
|
|
}
|
|
files, err := os.ReadDir(customTempDirectory)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var fileNames []string
|
|
for _, file := range files {
|
|
fileNames = append(fileNames, file.Name())
|
|
}
|
|
return expectResultsCount(fileNames, 3)
|
|
}
|