mirror of https://github.com/daffainfo/nuclei.git
Merge branch 'dev' of https://github.com/projectdiscovery/nuclei into interactsh-first-match-stop
commit
50bad75cb4
|
@ -9,7 +9,7 @@ self-contained: true
|
||||||
requests:
|
requests:
|
||||||
- raw:
|
- raw:
|
||||||
- |
|
- |
|
||||||
GET http://localhost:5431/ HTTP/1.1
|
GET http://127.0.0.1:5431/ HTTP/1.1
|
||||||
Host: {{Hostname}}
|
Host: {{Hostname}}
|
||||||
|
|
||||||
matchers:
|
matchers:
|
||||||
|
|
|
@ -8,7 +8,7 @@ info:
|
||||||
self-contained: true
|
self-contained: true
|
||||||
network:
|
network:
|
||||||
- host:
|
- host:
|
||||||
- "localhost:5431"
|
- "127.0.0.1:5431"
|
||||||
|
|
||||||
matchers:
|
matchers:
|
||||||
- type: word
|
- type: word
|
||||||
|
|
|
@ -119,7 +119,7 @@ func TestDownloadReleaseAndUnzipDeletion(t *testing.T) {
|
||||||
require.Equal(t, "base.yaml", results.deletions[0], "could not get correct new deletions")
|
require.Equal(t, "base.yaml", results.deletions[0], "could not get correct new deletions")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCalculateTemplateAbsolutePath(t *testing.T) {
|
func TestCalculateTemplateAbsolutePathPositiveScenario(t *testing.T) {
|
||||||
configuredTemplateDirectory := filepath.Join(os.TempDir(), "templates")
|
configuredTemplateDirectory := filepath.Join(os.TempDir(), "templates")
|
||||||
defer os.RemoveAll(configuredTemplateDirectory)
|
defer os.RemoveAll(configuredTemplateDirectory)
|
||||||
|
|
||||||
|
@ -136,24 +136,6 @@ func TestCalculateTemplateAbsolutePath(t *testing.T) {
|
||||||
require.False(t, skipFile)
|
require.False(t, skipFile)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("negative scenarios", func(t *testing.T) {
|
|
||||||
filePathsFromZip := []string{
|
|
||||||
"./../nuclei-templates/../cve/test.yaml",
|
|
||||||
"nuclei-templates/../cve/test.yaml",
|
|
||||||
"nuclei-templates/cve/../test.yaml",
|
|
||||||
"nuclei-templates/././../cve/test.yaml",
|
|
||||||
"nuclei-templates/.././../cve/test.yaml",
|
|
||||||
"nuclei-templates/.././../cve/../test.yaml",
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, filePathFromZip := range filePathsFromZip {
|
|
||||||
calculatedTemplateAbsPath, skipFile, err := calculateTemplateAbsolutePath(filePathFromZip, configuredTemplateDirectory)
|
|
||||||
require.Nil(t, err)
|
|
||||||
require.True(t, skipFile)
|
|
||||||
require.Equal(t, "", calculatedTemplateAbsPath)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func zipFromDirectory(zipPath, directory string) error {
|
func zipFromDirectory(zipPath, directory string) error {
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
//go:build !windows
|
||||||
|
|
||||||
|
package runner
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCalculateTemplateAbsolutePathNegativeScenario(t *testing.T) {
|
||||||
|
configuredTemplateDirectory := filepath.Join(os.TempDir(), "templates")
|
||||||
|
defer os.RemoveAll(configuredTemplateDirectory)
|
||||||
|
|
||||||
|
t.Run("negative scenarios", func(t *testing.T) {
|
||||||
|
filePathsFromZip := []string{
|
||||||
|
"./../nuclei-templates/../cve/test.yaml",
|
||||||
|
"nuclei-templates/../cve/test.yaml",
|
||||||
|
"nuclei-templates/cve/../test.yaml",
|
||||||
|
"nuclei-templates/././../cve/test.yaml",
|
||||||
|
"nuclei-templates/.././../cve/test.yaml",
|
||||||
|
"nuclei-templates/.././../cve/../test.yaml",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, filePathFromZip := range filePathsFromZip {
|
||||||
|
calculatedTemplateAbsPath, skipFile, err := calculateTemplateAbsolutePath(filePathFromZip, configuredTemplateDirectory)
|
||||||
|
require.Nil(t, err)
|
||||||
|
require.True(t, skipFile)
|
||||||
|
require.Equal(t, "", calculatedTemplateAbsPath)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue