Skip to content

Commit

Permalink
Fix issue #13.
Browse files Browse the repository at this point in the history
  • Loading branch information
mprencipe committed Mar 1, 2024
1 parent 2baaed9 commit 40c3954
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,11 @@ func fuzz(url string, httpHeaders []string, httpClient *http.Client, fuzzChannel
}
}

func getHostName(swaggerResp swagger.SwaggerResponse) string {
func getHostName(swaggerResp swagger.SwaggerResponse) *string {
if swaggerResp.OpenApi != nil {
if swaggerResp.Servers == nil || len(swaggerResp.Servers) == 0 {
fmt.Println("Null or empty array in OpenAPI definition")
os.Exit(1)
}
return *&swaggerResp.Servers[0].Url
return nil
}
return *swaggerResp.Host
return swaggerResp.Host
}

func main() {
Expand Down Expand Up @@ -214,6 +210,9 @@ func main() {

scheme := url.Scheme + "://"
hostname := getHostName(*swaggerResp)
if hostname == nil {
hostname = &url.Host
}

for _, api := range paths {
if len(api.Params) == 0 {
Expand All @@ -222,7 +221,7 @@ func main() {
fuzzChannel := make(chan string)

for i := 0; i < *fuzzCount; i++ {
fullUrl, fuzzableUrlErr := buildFuzzableUrl(&api, scheme, hostname, *fuzzWord)
fullUrl, fuzzableUrlErr := buildFuzzableUrl(&api, scheme, *hostname, *fuzzWord)
if fuzzableUrlErr != nil {
fmt.Println("Couldn't build fuzzable URL for " + api.Path)
}
Expand Down

0 comments on commit 40c3954

Please sign in to comment.