mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 14:15:26 +00:00
Added more variables + misc
This commit is contained in:
parent
da1630fc21
commit
2ffffbcc04
@ -2,6 +2,7 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
@ -251,9 +252,11 @@ func generateVariables(parsed *url.URL, trailingSlash bool) map[string]interface
|
|||||||
|
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"BaseURL": parsed.String(),
|
"BaseURL": parsed.String(),
|
||||||
"Domain": domain,
|
"RootURL": fmt.Sprintf("%s://%s", parsed.Scheme, parsed.Host),
|
||||||
"Hostname": parsed.Host,
|
"Hostname": parsed.Host,
|
||||||
"Path": parsed.EscapedPath(),
|
"Host": domain,
|
||||||
"Port": port,
|
"Port": port,
|
||||||
|
"Path": parsed.EscapedPath(),
|
||||||
|
"Scheme": parsed.Scheme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,9 +24,11 @@ func TestVariables(t *testing.T) {
|
|||||||
values := generateVariables(parsed, true)
|
values := generateVariables(parsed, true)
|
||||||
|
|
||||||
require.Equal(t, values["BaseURL"], parsed.String(), "incorrect baseurl")
|
require.Equal(t, values["BaseURL"], parsed.String(), "incorrect baseurl")
|
||||||
require.Equal(t, values["Domain"], "localhost", "incorrect domain name")
|
require.Equal(t, values["RootURL"], "http://localhost:9001", "incorrect rootURL")
|
||||||
|
require.Equal(t, values["Host"], "localhost", "incorrect domain name")
|
||||||
require.Equal(t, values["Path"], "/test/123", "incorrect path")
|
require.Equal(t, values["Path"], "/test/123", "incorrect path")
|
||||||
require.Equal(t, values["Port"], "9001", "incorrect port number")
|
require.Equal(t, values["Port"], "9001", "incorrect port number")
|
||||||
|
require.Equal(t, values["Scheme"], "http", "incorrect scheme")
|
||||||
require.Equal(t, values["Hostname"], "localhost:9001", "incorrect hostname")
|
require.Equal(t, values["Hostname"], "localhost:9001", "incorrect hostname")
|
||||||
|
|
||||||
baseURL = "https://example.com"
|
baseURL = "https://example.com"
|
||||||
@ -34,9 +36,11 @@ func TestVariables(t *testing.T) {
|
|||||||
values = generateVariables(parsed, false)
|
values = generateVariables(parsed, false)
|
||||||
|
|
||||||
require.Equal(t, values["BaseURL"], parsed.String(), "incorrect baseurl")
|
require.Equal(t, values["BaseURL"], parsed.String(), "incorrect baseurl")
|
||||||
require.Equal(t, values["Domain"], "example.com", "incorrect domain name")
|
require.Equal(t, values["Host"], "example.com", "incorrect domain name")
|
||||||
|
require.Equal(t, values["RootURL"], "https://example.com", "incorrect rootURL")
|
||||||
require.Equal(t, values["Path"], "", "incorrect path")
|
require.Equal(t, values["Path"], "", "incorrect path")
|
||||||
require.Equal(t, values["Port"], "443", "incorrect port number")
|
require.Equal(t, values["Port"], "443", "incorrect port number")
|
||||||
|
require.Equal(t, values["Scheme"], "https", "incorrect scheme")
|
||||||
require.Equal(t, values["Hostname"], "example.com", "incorrect hostname")
|
require.Equal(t, values["Hostname"], "example.com", "incorrect hostname")
|
||||||
|
|
||||||
baseURL = "ftp://foobar.com/"
|
baseURL = "ftp://foobar.com/"
|
||||||
@ -44,9 +48,11 @@ func TestVariables(t *testing.T) {
|
|||||||
values = generateVariables(parsed, true)
|
values = generateVariables(parsed, true)
|
||||||
|
|
||||||
require.Equal(t, values["BaseURL"], parsed.String(), "incorrect baseurl")
|
require.Equal(t, values["BaseURL"], parsed.String(), "incorrect baseurl")
|
||||||
require.Equal(t, values["Domain"], "foobar.com", "incorrect domain name")
|
require.Equal(t, values["Host"], "foobar.com", "incorrect domain name")
|
||||||
|
require.Equal(t, values["RootURL"], "ftp://foobar.com", "incorrect rootURL")
|
||||||
require.Equal(t, values["Path"], "", "incorrect path")
|
require.Equal(t, values["Path"], "", "incorrect path")
|
||||||
require.Equal(t, values["Port"], "", "incorrect port number") // Unsupported protocol results in a blank port
|
require.Equal(t, values["Port"], "", "incorrect port number") // Unsupported protocol results in a blank port
|
||||||
|
require.Equal(t, values["Scheme"], "ftp", "incorrect scheme")
|
||||||
require.Equal(t, values["Hostname"], "foobar.com", "incorrect hostname")
|
require.Equal(t, values["Hostname"], "foobar.com", "incorrect hostname")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user