From a41152331cca82dc693af41cd3f1cbf9d9aeb391 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Sat, 9 Nov 2024 19:18:06 +0100 Subject: [PATCH] feat: introduce $FUZZYMONKEY_SSL_NO_VERIFY Signed-off-by: Pierre Fenoll --- README.md | 1 + Tagfile | 2 +- pkg/modeler/openapiv3/caller_http.go | 34 +++++++++++++++------------- usage.go | 1 + 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index fc281b4f..ec379c74 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Options: Try: export FUZZYMONKEY_API_KEY=fm_42 + export FUZZYMONKEY_SSL_NO_VERIFY=1 monkey update monkey -f fm.star exec reset monkey fuzz --only /pets --calls-without-input=NewPet --seed=$(monkey pastseed) diff --git a/Tagfile b/Tagfile index 564edf82..c5d4cee3 100644 --- a/Tagfile +++ b/Tagfile @@ -1 +1 @@ -0.50.0 +0.51.0 diff --git a/pkg/modeler/openapiv3/caller_http.go b/pkg/modeler/openapiv3/caller_http.go index 7120519b..e2619ed0 100644 --- a/pkg/modeler/openapiv3/caller_http.go +++ b/pkg/modeler/openapiv3/caller_http.go @@ -3,6 +3,7 @@ package openapiv3 import ( "bytes" "context" + "crypto/tls" "fmt" "io/ioutil" "log" @@ -10,6 +11,7 @@ import ( "net/http" "net/http/httputil" "net/url" + "os" "sort" "strconv" "strings" @@ -250,23 +252,23 @@ func (c *tCapHTTP) Do(ctx context.Context) { func (c *tCapHTTP) RoundTrip(req *http.Request) (rep *http.Response, err error) { // TODO: stricter/smaller timeouts https://pkg.go.dev/github.com/asecurityteam/transport#Option - t := &http.Transport{ - Proxy: func(req *http.Request) (*url.URL, error) { - // TODO: snap the envs that ProxyFromEnvironment reads - log.Println("[NFO] HTTP proxying is work in progress...") - return nil, nil - }, - DialContext: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - DualStack: true, - }).DialContext, - // ForceAttemptHTTP2: true, - MaxIdleConns: 100, - IdleConnTimeout: 90 * time.Second, - TLSHandshakeTimeout: 10 * time.Second, - ExpectContinueTimeout: 1 * time.Second, + t := http.DefaultTransport.(*http.Transport).Clone() + t.Proxy = func(req *http.Request) (*url.URL, error) { + // TODO: snap the envs that ProxyFromEnvironment reads + log.Println("[NFO] HTTP proxying is work in progress...") + return nil, nil } + t.DialContext = (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + DualStack: true, + }).DialContext + // t.ForceAttemptHTTP2 = true + t.MaxIdleConns = 100 + t.IdleConnTimeout = 90 * time.Second + t.TLSHandshakeTimeout = 10 * time.Second + t.ExpectContinueTimeout = 1 * time.Second + t.TLSClientConfig = &tls.Config{InsecureSkipVerify: os.Getenv("FUZZYMONKEY_SSL_NO_VERIFY") == "1"} start := time.Now() rep, err = t.RoundTrip(req) diff --git a/usage.go b/usage.go index 6e936b4e..7bc13130 100644 --- a/usage.go +++ b/usage.go @@ -93,6 +93,7 @@ Options: Try: export FUZZYMONKEY_API_KEY=fm_42 + export FUZZYMONKEY_SSL_NO_VERIFY=1 ` + B + ` update ` + B + ` -f fm.star exec reset ` + B + ` fuzz --only /pets --calls-without-input=NewPet --seed=$(monkey pastseed)