Skip to content

Commit f5e1e14

Browse files
authored
fix(latest-version,deployed-version,webhook): respect proxy env vars in requests (#699)
- clone the default transport, ensuring proxy environment variables are respected - HTTP_PROXY, HTTPS_PROXY and NO_PROXY
1 parent 8083828 commit f5e1e14

4 files changed

Lines changed: 22 additions & 14 deletions

File tree

_healthcheck/main.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1+
// Copyright [2025] [Argus]
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
/*
216
./healthcheck http://localhost:8080/api/v1/healthcheck
17+
318
200 == nothing
419
error == os.Exit(1)
520
*/
621
package main
722

823
import (
9-
"crypto/tls"
1024
"fmt"
1125
"net/http"
1226
"os"
@@ -20,7 +34,7 @@ func main() {
2034
url := os.Args[1]
2135

2236
//#nosec G402 -- Ignore TLS for healthcheck.
23-
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
37+
http.DefaultTransport.(*http.Transport).TLSClientConfig.InsecureSkipVerify = true
2438
//#nosec G107 -- explicitly set URL.
2539
if _, err := http.Get(url); err != nil {
2640
fmt.Fprintf(os.Stderr, "error: %v", err)

service/deployed_version/types/web/query.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package web
1717

1818
import (
19-
"crypto/tls"
2019
"errors"
2120
"fmt"
2221
"io"
@@ -86,12 +85,11 @@ func (l *Lookup) query(writeToDB bool, logFrom logutil.LogFrom) error {
8685

8786
// httpRequest makes a HTTP GET request to the URL, and returns the body.
8887
func (l *Lookup) httpRequest(logFrom logutil.LogFrom) ([]byte, error) {
89-
customTransport := &http.Transport{}
88+
customTransport := http.DefaultTransport.(*http.Transport).Clone()
9089
// HTTPS insecure skip verify.
9190
if l.allowInvalidCerts() {
92-
customTransport = http.DefaultTransport.(*http.Transport).Clone()
9391
//#nosec G402 -- explicitly wanted InsecureSkipVerify
94-
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
92+
customTransport.TLSClientConfig.InsecureSkipVerify = true
9593
}
9694

9795
// Create the request.

service/latest_version/types/web/query.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package web
1717

1818
import (
19-
"crypto/tls"
2019
"errors"
2120
"fmt"
2221
"io"
@@ -81,12 +80,11 @@ func (l *Lookup) query(logFrom logutil.LogFrom) (bool, error) {
8180

8281
// httpRequest makes a HTTP GET request to the URL and returns the body.
8382
func (l *Lookup) httpRequest(logFrom logutil.LogFrom) ([]byte, error) {
84-
customTransport := &http.Transport{}
83+
customTransport := http.DefaultTransport.(*http.Transport).Clone()
8584
// HTTPS insecure skip verify.
8685
if l.allowInvalidCerts() {
87-
customTransport = http.DefaultTransport.(*http.Transport).Clone()
8886
//#nosec G402 -- explicitly wanted InsecureSkipVerify
89-
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
87+
customTransport.TLSClientConfig.InsecureSkipVerify = true
9088
}
9189

9290
// Create the request.

webhook/send.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package webhook
1717

1818
import (
1919
"context"
20-
"crypto/tls"
2120
"errors"
2221
"fmt"
2322
"io"
@@ -124,11 +123,10 @@ func (wh *WebHook) try(logFrom logutil.LogFrom) error {
124123
defer cancel()
125124

126125
// HTTPS insecure skip verify.
127-
customTransport := &http.Transport{}
126+
customTransport := http.DefaultTransport.(*http.Transport).Clone()
128127
if wh.GetAllowInvalidCerts() {
129-
customTransport = http.DefaultTransport.(*http.Transport).Clone()
130128
//#nosec G402 -- explicitly wanted InsecureSkipVerify.
131-
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
129+
customTransport.TLSClientConfig.InsecureSkipVerify = true
132130
}
133131

134132
client := &http.Client{Transport: customTransport}

0 commit comments

Comments
 (0)