Skip to content

Commit

Permalink
Merge pull request #6 from rapid7/winhttp_automaticProxyConfScript
Browse files Browse the repository at this point in the history
added the support for automatic configuration script proxy on windows
  • Loading branch information
kasadzadeh-r7 authored Nov 5, 2018
2 parents 790ca9f + 5d35042 commit fbcd32a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion proxy/provider_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Returns:
nil: A proxy was not found, or an error occurred
*/
func (p *providerDarwin) Get(protocol string, targetUrlStr string) (Proxy) {
targetUrl := ParseTargetURL(targetUrlStr)
targetUrl := ParseTargetURL(targetUrlStr, protocol)
if proxy := p.provider.get(protocol, targetUrl); proxy != nil {
return proxy
}
Expand Down
14 changes: 7 additions & 7 deletions proxy/provider_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestParseScutildata_Read_HTTPS_HTTP(t *testing.T) {

commands := getDarwinProviderTestsNoBypass(ScutilDataHttpsHttp)

targetUrl := ParseTargetURL("")
targetUrl := ParseTargetURL("", "")

protocols := [4]string{"http", "https", "HTTP", "HTTPS"}
for _, protocol := range protocols {
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestParseScutildata_Read_HTTPS(t *testing.T) {

commands := getDarwinProviderTestsNoBypass(ScutilDataHttps)

targetUrl := ParseTargetURL("")
targetUrl := ParseTargetURL("", "")

protocols := [4]string{"http", "https", "HTTP", "HTTPS"}
for _, protocol := range protocols {
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestParseScutildata_Read_HTTP(t *testing.T) {

commands := getDarwinProviderTestsNoBypass(ScutilDataHttp)

targetUrl := ParseTargetURL("")
targetUrl := ParseTargetURL("", "")

protocols := [4]string{"http", "https", "HTTP", "HTTPS"}
for _, protocol := range protocols {
Expand Down Expand Up @@ -248,7 +248,7 @@ func TestExecCommandsHandledProperly(t *testing.T) {

c := newDarwinTestProvider()

targetUrl := ParseTargetURL("")
targetUrl := ParseTargetURL("", "")
expectedProxy, err := c.parseScutildata("", targetUrl, "exit", "")

a.Equal(isTimedOut(err), true)
Expand All @@ -273,7 +273,7 @@ func TestParseScutildata_Read_HTTPS_BYPASS_TARGET_URL(t *testing.T) {
protocol := "https"

// test empty target URL
targetUrl := ParseTargetURL("")
targetUrl := ParseTargetURL("", "")
expectedProxy, err := c.parseScutildata(protocol, targetUrl, "echo", command)
// test error is nil
a.Nil(err)
Expand All @@ -287,7 +287,7 @@ func TestParseScutildata_Read_HTTPS_BYPASS_TARGET_URL(t *testing.T) {
for _, tests := range bypassProxySettingsHostsDomains {
for _, test := range tests {
for urlStr, result := range test {
targetUrl := ParseTargetURL(urlStr)
targetUrl := ParseTargetURL(urlStr, "")
expectedProxy, err := c.parseScutildata(protocol, targetUrl, "echo", command)
// test error is nil
a.Nil(err)
Expand All @@ -308,7 +308,7 @@ func TestParseScutildata_Read_HTTPS_BYPASS_TARGET_URL(t *testing.T) {
for _, tests := range bypassProxySettingsHostsDomains {
for _, test := range tests {
for urlStr, _ := range test {
targetUrl := ParseTargetURL(urlStr)
targetUrl := ParseTargetURL(urlStr, "")
expectedProxy, err := c.parseScutildata(protocol, targetUrl, "echo", command)
// test error is returned correctly
a.Equal(isNotFound(err), true)
Expand Down
2 changes: 1 addition & 1 deletion proxy/provider_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Returns:
nil: A proxy was not found, or an error occurred
*/
func (p *providerLinux) Get(protocol string, targetUrlStr string) (Proxy) {
return p.provider.get(protocol, ParseTargetURL(targetUrlStr))
return p.provider.get(protocol, ParseTargetURL(targetUrlStr, protocol))
}

/*
Expand Down
2 changes: 1 addition & 1 deletion proxy/provider_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Returns:
nil: A proxy was not found, or an error occurred
*/
func (p *providerWindows) Get(protocol string, targetUrlStr string) (Proxy) {
targetUrl := ParseTargetURL(targetUrlStr)
targetUrl := ParseTargetURL(targetUrlStr, protocol)
proxy := p.provider.get(protocol, targetUrl)
if proxy != nil {
return proxy
Expand Down
4 changes: 2 additions & 2 deletions proxy/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ Returns:
* Fragment
The given URL string need not be a valid URL
*/
func ParseTargetURL(targetUrl string) (*url.URL) {
parsedUrl, err := ParseURL(targetUrl, "")
func ParseTargetURL(targetUrl, defaultScheme string) (*url.URL) {
parsedUrl, err := ParseURL(targetUrl, defaultScheme)
if err != nil {
return &url.URL{Host:"*"}
}
Expand Down
2 changes: 1 addition & 1 deletion proxy/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestParseTargetURL(t *testing.T) {
for _, tt := range dataParseTargetURL {
t.Run(tt.rawUrl, func(t *testing.T) {
a := assert.New(t)
a.Equal(tt.expectUrl, ParseTargetURL(tt.rawUrl))
a.Equal(tt.expectUrl, ParseTargetURL(tt.rawUrl, ""))
})
}
}
Expand Down

0 comments on commit fbcd32a

Please sign in to comment.