From b51821f453122121d6d4bbd205886adb9ca0b56f Mon Sep 17 00:00:00 2001 From: Bhaskar Ram Date: Sun, 22 Sep 2024 14:20:44 +0530 Subject: [PATCH 1/2] deprecation of the ioutil package --- getS3Domains.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getS3Domains.go b/getS3Domains.go index 70f2de3..71ff174 100644 --- a/getS3Domains.go +++ b/getS3Domains.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strings" ) @@ -40,7 +40,7 @@ func getS3Domains(domains []string) { defer resp.Body.Close() // Read response - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) // Updated here if err != nil { fmt.Printf("Failed to read response body: %v\n", err) return From 69c5325add03ca3aa02b1224df2416985fa78faa Mon Sep 17 00:00:00 2001 From: Bhaskar Ram Date: Sun, 22 Sep 2024 14:29:13 +0530 Subject: [PATCH 2/2] added API Paths checker function --- extractApiPaths.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/extractApiPaths.go b/extractApiPaths.go index 232dbf7..b548623 100644 --- a/extractApiPaths.go +++ b/extractApiPaths.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strings" ) @@ -40,7 +40,7 @@ func getApiPaths(domains []string) { defer resp.Body.Close() // Read response - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) // Updated from ioutil.ReadAll if err != nil { fmt.Printf("Failed to read response body: %v\n", err) return @@ -54,14 +54,19 @@ func getApiPaths(domains []string) { return } - // Access and print API paths - if apiPaths, ok := response["apiPaths"].([]interface{}); ok { - for _, path := range apiPaths { - if pathStr, ok := path.(string); ok { - fmt.Println(pathStr) - } else { - fmt.Println("Error: Invalid type in 'apiPaths'") - } + // Check if "apiPaths" exists in the response + apiPaths, ok := response["apiPaths"].([]interface{}) + if !ok { + fmt.Println("Error: 'apiPaths' missing or invalid in response") + return + } + + // Print the API paths + for _, path := range apiPaths { + if pathStr, ok := path.(string); ok { + fmt.Println(pathStr) + } else { + fmt.Println("Error: Invalid type in 'apiPaths'") } } }