Skip to content

Commit 9e28c7a

Browse files
authored
create new unrestricted analyzer client to not filter out unsafe success requests (#3841)
1 parent ea62086 commit 9e28c7a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

pkg/analyzer/analyzers/client.go

+17
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func CreateLogFileName(baseName string) string {
2828
return logFileName
2929
}
3030

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

47+
// This returns a client that is unrestricted and does not filter out unsafe requests returning a success status code.
48+
func NewAnalyzeClientUnrestricted(cfg *config.Config) *http.Client {
49+
client := &http.Client{
50+
Transport: http.DefaultTransport,
51+
}
52+
if cfg == nil || !cfg.LoggingEnabled {
53+
return client
54+
}
55+
return &http.Client{
56+
Transport: LoggingRoundTripper{
57+
parent: client.Transport,
58+
logFile: cfg.LogFile,
59+
},
60+
}
61+
}
62+
4663
type LoggingRoundTripper struct {
4764
parent http.RoundTripper
4865
// TODO: io.Writer

pkg/analyzer/analyzers/opsgenie/opsgenie.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (h *HttpStatusTest) RunTest(cfg *config.Config, headers map[string]string)
132132
}
133133

134134
// Create new HTTP request
135-
client := analyzers.NewAnalyzeClient(cfg)
135+
client := analyzers.NewAnalyzeClientUnrestricted(cfg)
136136
req, err := http.NewRequest(h.Method, h.Endpoint, data)
137137
if err != nil {
138138
return false, err

0 commit comments

Comments
 (0)