2022-03-21 16:11:58 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
|
2023-03-14 16:57:48 +01:00
|
|
|
errorutil "github.com/projectdiscovery/utils/errors"
|
2022-03-21 16:11:58 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var templatesDirTestCases = map[string]testutils.TestCase{
|
|
|
|
|
"dns/cname-fingerprint.yaml": &templateDirWithTargetTest{},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type templateDirWithTargetTest struct{}
|
|
|
|
|
|
|
|
|
|
// Execute executes a test case and returns an error if occurred
|
|
|
|
|
func (h *templateDirWithTargetTest) Execute(filePath string) error {
|
2023-03-14 16:57:48 +01:00
|
|
|
tempdir, err := os.MkdirTemp("", "nuclei-update-dir-*")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return errorutil.NewWithErr(err).Msgf("failed to create temp dir")
|
|
|
|
|
}
|
|
|
|
|
defer os.RemoveAll(tempdir)
|
2022-03-21 16:11:58 -05:00
|
|
|
|
2023-03-14 16:57:48 +01:00
|
|
|
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "8x8exch02.8x8.com", debug, "-ud", tempdir)
|
2022-03-21 16:11:58 -05:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2023-01-03 08:24:33 +01:00
|
|
|
|
2022-03-21 16:11:58 -05:00
|
|
|
return expectResultsCount(results, 1)
|
|
|
|
|
}
|