Skip to content

Commit

Permalink
Clone transport (#231)
Browse files Browse the repository at this point in the history
* Clone http.DefaultTransport so proxy works
* Add updated go.mod

Signed-off-by: Peter Zandbergen <peter.zandbergen@myhops.com>

* Add updated go.mod

Signed-off-by: Peter Zandbergen <peter.zandbergen@myhops.com>

* Merge branch 'clone-transport' of github-myhops.com:myhops/bomber into clone-transport
  • Loading branch information
myhops authored Sep 21, 2024
1 parent ae7eeef commit f6fbbaf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
6 changes: 4 additions & 2 deletions enrichers/epss/epss.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ type Enricher struct{}
var client *resty.Client

func init() {
client = resty.New().
SetTransport(&http.Transport{TLSHandshakeTimeout: 60 * time.Second})
// Cloning the transport ensures a proper working http client that respects the proxy settings
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSHandshakeTimeout = 60 * time.Second
client = resty.New().SetTransport(transport)
}

// TODO: this needs to be refactored so we can batch the scanning and de-duplicate. Each component has it's own list of []models.Vulnerability and this function is called multiple times. At least the implementation here reduces the calls by batching per component.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sashabaranov/go-openai v1.28.1
github.com/sashabaranov/go-openai v1.28.2
github.com/spf13/pflag v1.0.5 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/net v0.28.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sashabaranov/go-openai v1.28.1 h1:aREx6faUTeOZNMDTNGAY8B9vNmmN7qoGvDV0Ke2J1Mc=
github.com/sashabaranov/go-openai v1.28.1/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
github.com/sashabaranov/go-openai v1.28.2 h1:Q3pi34SuNYNN7YrqpHlHbpeYlf75ljgHOAVM/r1yun0=
github.com/sashabaranov/go-openai v1.28.2/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
Expand Down
6 changes: 4 additions & 2 deletions providers/ossindex/OSSIndex.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ const ossindexURL = "https://ossindex.sonatype.org/api/v3/authorized/component-r
var client *resty.Client

func init() {
client = resty.New().
SetTransport(&http.Transport{TLSHandshakeTimeout: 60 * time.Second})
// Cloning the transport ensures a proper working http client that respects the proxy settings
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSHandshakeTimeout = 60 * time.Second
client = resty.New().SetTransport(transport)
}

// Provider represents the OSSIndex provider
Expand Down
6 changes: 4 additions & 2 deletions providers/osv/osv.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ const (
var client *resty.Client

func init() {
client = resty.New().
SetTransport(&http.Transport{TLSHandshakeTimeout: 60 * time.Second})
// Cloning the transport ensures a proper working http client that respects the proxy settings
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSHandshakeTimeout = 60 * time.Second
client = resty.New().SetTransport(transport)
}

// Provider represents the OSSIndex provider
Expand Down

0 comments on commit f6fbbaf

Please sign in to comment.