Skip to content

Commit

Permalink
create new unrestricted analyzer client to not filter out unsafe succ…
Browse files Browse the repository at this point in the history
…ess requests (#3841)
  • Loading branch information
abmussani authored Jan 14, 2025
1 parent ea62086 commit 9e28c7a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions pkg/analyzer/analyzers/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func CreateLogFileName(baseName string) string {
return logFileName
}

// This returns a client that is restricted and filters out unsafe requests returning a success status code.
func NewAnalyzeClient(cfg *config.Config) *http.Client {
client := &http.Client{
Transport: AnalyzerRoundTripper{parent: http.DefaultTransport},
Expand All @@ -43,6 +44,22 @@ func NewAnalyzeClient(cfg *config.Config) *http.Client {
}
}

// This returns a client that is unrestricted and does not filter out unsafe requests returning a success status code.
func NewAnalyzeClientUnrestricted(cfg *config.Config) *http.Client {
client := &http.Client{
Transport: http.DefaultTransport,
}
if cfg == nil || !cfg.LoggingEnabled {
return client
}
return &http.Client{
Transport: LoggingRoundTripper{
parent: client.Transport,
logFile: cfg.LogFile,
},
}
}

type LoggingRoundTripper struct {
parent http.RoundTripper
// TODO: io.Writer
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/analyzers/opsgenie/opsgenie.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (h *HttpStatusTest) RunTest(cfg *config.Config, headers map[string]string)
}

// Create new HTTP request
client := analyzers.NewAnalyzeClient(cfg)
client := analyzers.NewAnalyzeClientUnrestricted(cfg)
req, err := http.NewRequest(h.Method, h.Endpoint, data)
if err != nil {
return false, err
Expand Down

0 comments on commit 9e28c7a

Please sign in to comment.