2022-03-21 16:11:58 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
|
|
|
|
|
2023-10-17 17:44:13 +05:30
|
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/testutils"
|
2025-08-20 05:28:23 +05:30
|
|
|
"github.com/projectdiscovery/utils/errkit"
|
2022-03-21 16:11:58 -05:00
|
|
|
)
|
|
|
|
|
|
2023-07-28 18:50:57 +03:00
|
|
|
var templatesDirTestCases = []TestCaseInfo{
|
2023-08-04 20:21:22 +05:30
|
|
|
{Path: "protocols/dns/cname-fingerprint.yaml", TestCase: &templateDirWithTargetTest{}},
|
2022-03-21 16:11:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 {
|
2025-08-25 15:06:58 +07:00
|
|
|
return errkit.Wrap(err, "failed to create temp dir")
|
2023-03-14 16:57:48 +01:00
|
|
|
}
|
2025-07-01 00:40:44 +07:00
|
|
|
defer func() {
|
|
|
|
|
_ = 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)
|
|
|
|
|
}
|