mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-25 11:05:28 +00:00
* Added workflow names based condition * Added conditional filtering to workflow executor * Replaced names with single name stringslice * Added probing for URL + input based on protocol * Remove debug comments * Fixed typo * Fixed failing tests * Fixed workflow matcher condition + tests * Fixed workflow item name * Switch to if-else * Fixed review comment strict * Increase bulk size * Added default port for SSL protocol + misc changes * Fixed failing tests * Fixed misc changes to executer * Fixed failing self-contained and offlinehttp tests * Fixed atomic increment operation * misc update * Fixed failing builds Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
65 lines
2.0 KiB
Go
65 lines
2.0 KiB
Go
package input
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/projectdiscovery/hmap/store/hybrid"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestConvertInputToType(t *testing.T) {
|
|
helper := &Helper{}
|
|
|
|
hm, err := hybrid.New(hybrid.DefaultDiskOptions)
|
|
require.NoError(t, err, "could not create hybrid map")
|
|
helper.InputsHTTP = hm
|
|
defer hm.Close()
|
|
|
|
_ = hm.Set("google.com", []byte("https://google.com"))
|
|
|
|
tests := []struct {
|
|
input string
|
|
inputType inputType
|
|
result string
|
|
defaultPort string
|
|
}{
|
|
// host
|
|
{"google.com", inputTypeHost, "google.com", ""},
|
|
{"google.com:443", inputTypeHost, "google.com", ""},
|
|
{"https://google.com", inputTypeHost, "google.com", ""},
|
|
{"https://google.com:443", inputTypeHost, "google.com", ""},
|
|
|
|
// url
|
|
{"test.com", inputTypeURL, "", ""},
|
|
{"google.com", inputTypeURL, "https://google.com", ""},
|
|
{"https://google.com", inputTypeURL, "https://google.com", ""},
|
|
|
|
// file
|
|
{"google.com:443", inputTypeFilepath, "", ""},
|
|
{"https://google.com:443", inputTypeFilepath, "", ""},
|
|
{"/example/path", inputTypeFilepath, "/example/path", ""},
|
|
{"input_test.go", inputTypeFilepath, "input_test.go", ""},
|
|
{"../input", inputTypeFilepath, "../input", ""},
|
|
{"input_test.*", inputTypeFilepath, "input_test.*", ""},
|
|
|
|
// host-port
|
|
{"google.com", inputTypeHostPort, "", ""},
|
|
{"google.com:443", inputTypeHostPort, "google.com:443", ""},
|
|
{"https://google.com", inputTypeHostPort, "google.com:443", ""},
|
|
{"https://google.com:443", inputTypeHostPort, "google.com:443", ""},
|
|
// host-port with default port
|
|
{"google.com", inputTypeHostPort, "google.com:443", "443"},
|
|
|
|
// websocket
|
|
{"google.com", inputTypeWebsocket, "", ""},
|
|
{"google.com:443", inputTypeWebsocket, "", ""},
|
|
{"https://google.com:443", inputTypeWebsocket, "", ""},
|
|
{"wss://google.com", inputTypeWebsocket, "wss://google.com", ""},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
result := helper.convertInputToType(test.input, test.inputType, test.defaultPort)
|
|
require.Equal(t, test.result, result, "could not get correct result %+v", test)
|
|
}
|
|
}
|