From 0a9f890fddf0fbb29320909f7aefecd82d87d682 Mon Sep 17 00:00:00 2001 From: mzack Date: Mon, 20 Dec 2021 14:11:55 +0100 Subject: [PATCH 1/2] Removing invalid negative paths for windows --- v2/internal/runner/update_test.go | 20 +-------------- v2/internal/runner/update_unix_test.go | 34 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 v2/internal/runner/update_unix_test.go diff --git a/v2/internal/runner/update_test.go b/v2/internal/runner/update_test.go index e8153b42..0983aa71 100644 --- a/v2/internal/runner/update_test.go +++ b/v2/internal/runner/update_test.go @@ -119,7 +119,7 @@ func TestDownloadReleaseAndUnzipDeletion(t *testing.T) { 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") defer os.RemoveAll(configuredTemplateDirectory) @@ -136,24 +136,6 @@ func TestCalculateTemplateAbsolutePath(t *testing.T) { 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 { diff --git a/v2/internal/runner/update_unix_test.go b/v2/internal/runner/update_unix_test.go new file mode 100644 index 00000000..c9e1a9a2 --- /dev/null +++ b/v2/internal/runner/update_unix_test.go @@ -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) + } + }) +} From 75946f7c0f6b64b479277ddc0b2a789766d93203 Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Mon, 20 Dec 2021 16:23:36 +0100 Subject: [PATCH 2/2] fixing ip/hostname for windows self-contained templates --- integration_tests/http/self-contained.yaml | 2 +- integration_tests/network/self-contained.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/http/self-contained.yaml b/integration_tests/http/self-contained.yaml index 4ecacbbd..b3c9aa99 100644 --- a/integration_tests/http/self-contained.yaml +++ b/integration_tests/http/self-contained.yaml @@ -9,7 +9,7 @@ self-contained: true requests: - raw: - | - GET http://localhost:5431/ HTTP/1.1 + GET http://127.0.0.1:5431/ HTTP/1.1 Host: {{Hostname}} matchers: diff --git a/integration_tests/network/self-contained.yaml b/integration_tests/network/self-contained.yaml index fad3e2ac..711af4f5 100644 --- a/integration_tests/network/self-contained.yaml +++ b/integration_tests/network/self-contained.yaml @@ -8,7 +8,7 @@ info: self-contained: true network: - host: - - "localhost:5431" + - "127.0.0.1:5431" matchers: - type: word