mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 18:15:42 +01:00
ensure HTTP requests use proxy env vars (#597)
* fix: ensure HTTP requests use proxy env vars Updated all instances of `http.Transport` to include the `Proxy` field set to `http.ProxyFromEnvironment`. This ensures that the application respects proxy configuration defined by the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` environment variables. ### Changes: - Modified `http.Transport` initialization across the codebase to use: ```go Proxy: http.ProxyFromEnvironment ``` - Ensured TLS configurations remain intact by preserving `TLSClientConfig`. ### Why: - Previously, HTTP requests bypassed proxy settings due to missing configuration in the transport layer. - This fix enables compatibility with proxied environments, aligning with standard Go behavior. ### Impact: - All HTTP and HTTPS traffic now adheres to proxy settings. - Domains listed in `NO_PROXY` bypass the proxy as expected. ### Verification: - Tested with proxy environment variables set (`HTTP_PROXY`, `HTTPS_PROXY`). - Verified requests route through the proxy and `NO_PROXY` works as intended. * reformat with fmt --------- Co-authored-by: Cormac Doherty <cormac.doherty@ncsc.gov.ie>
This commit is contained in:
parent
18af28f475
commit
1daaed2c51
5 changed files with 6 additions and 0 deletions
|
|
@ -284,6 +284,7 @@ func (c *config) httpClient(p *provider) util.Client {
|
||||||
|
|
||||||
hClient.Transport = &http.Transport{
|
hClient.Transport = &http.Transport{
|
||||||
TLSClientConfig: &tlsConfig,
|
TLSClientConfig: &tlsConfig,
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
}
|
}
|
||||||
|
|
||||||
client := util.Client(&hClient)
|
client := util.Client(&hClient)
|
||||||
|
|
|
||||||
|
|
@ -430,6 +430,7 @@ func (p *processor) fullClient() util.Client {
|
||||||
|
|
||||||
hClient.Transport = &http.Transport{
|
hClient.Transport = &http.Transport{
|
||||||
TLSClientConfig: &tlsConfig,
|
TLSClientConfig: &tlsConfig,
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
}
|
}
|
||||||
|
|
||||||
client := util.Client(&hClient)
|
client := util.Client(&hClient)
|
||||||
|
|
@ -460,6 +461,7 @@ func (p *processor) basicClient() *http.Client {
|
||||||
if p.cfg.Insecure {
|
if p.cfg.Insecure {
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
}
|
}
|
||||||
return &http.Client{Transport: tr}
|
return &http.Client{Transport: tr}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ func (d *downloader) httpClient() util.Client {
|
||||||
|
|
||||||
hClient.Transport = &http.Transport{
|
hClient.Transport = &http.Transport{
|
||||||
TLSClientConfig: &tlsConfig,
|
TLSClientConfig: &tlsConfig,
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
}
|
}
|
||||||
|
|
||||||
client := util.Client(&hClient)
|
client := util.Client(&hClient)
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ func (f *forwarder) httpClient() util.Client {
|
||||||
|
|
||||||
hClient.Transport = &http.Transport{
|
hClient.Transport = &http.Transport{
|
||||||
TLSClientConfig: &tlsConfig,
|
TLSClientConfig: &tlsConfig,
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
}
|
}
|
||||||
|
|
||||||
client := util.Client(&hClient)
|
client := util.Client(&hClient)
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ func (p *processor) httpClient() *http.Client {
|
||||||
|
|
||||||
client.Transport = &http.Transport{
|
client.Transport = &http.Transport{
|
||||||
TLSClientConfig: &tlsConfig,
|
TLSClientConfig: &tlsConfig,
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &client
|
return &client
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue