fix: Moved remaining diagnostic output to stderr so stdout stays pipeable

This commit is contained in:
Tony West committed 2026-09-11 21:44:15 -04:00
1 parent 365f68696f
commit 48c4d83f54
7 files changed
+13 -25

No files matched your search

+1 -3
View File
@@ -24,9 +24,7 @@ func CheckSecuritySchemes(spec map[string]interface{}) {
if !ok || len(securitySchemes) == 0 {
printInfo("No security schemes defined.\n")
} else {
if outputFormat != "json" {
printInfo("Found security schemes:\n")
}
printInfo("Found security schemes:\n")
var apiKey string
var apiKeyName string
+2 -4
View File
@@ -1,7 +1,6 @@
package cmd
import (
"fmt"
"io"
"os"
"path/filepath"
@@ -46,8 +45,7 @@ responds in an abnormal way, manual testing should be conducted (prepare manual
_, err := time.Parse("2006-01-02", customDate)
if err != nil {
fmt.Println("An invalid date was supplied. Please supply a date in '2006-01-02' format.")
os.Exit(1)
die("An invalid date was supplied. Please supply a date in '2006-01-02' format.")
}
var bodyBytes []byte
@@ -55,7 +53,7 @@ responds in an abnormal way, manual testing should be conducted (prepare manual
client, replayClient := CheckAndConfigureProxy()
if strings.ToLower(outputFormat) != "json" {
fmt.Printf("\n")
printInfo("\n")
printInfo("Gathering API details.\n")
}
+1 -1
View File
@@ -378,7 +378,7 @@ func UnmarshalSpec(bodyBytes []byte) (newDoc *openapi3.T) {
} else if strings.HasPrefix(doc.Swagger, "2") {
newDoc, err := openapi2conv.ToV3(&doc)
if err != nil {
fmt.Printf("Error converting v2 document to v3: %s\n", err)
printErr("Error converting v2 document to v3: %s", err)
}
return newDoc
} else if os.Args[1] == "brute" {
+2 -2
View File
@@ -32,7 +32,7 @@ var convertCmd = &cobra.Command{
client, _ := CheckAndConfigureProxy()
if strings.ToLower(outputFormat) != "json" {
fmt.Printf("\n")
printInfo("\n")
printInfo("Gathering API details.\n\n")
}
@@ -65,7 +65,7 @@ var convertCmd = &cobra.Command{
} else if strings.HasPrefix(doc.Swagger, "2") {
newDoc, err := openapi2conv.ToV3(&doc)
if err != nil {
fmt.Printf("Error converting v2 document to v3: %s\n", err)
printErr("Error converting v2 document to v3: %s", err)
}
switch format {
+1 -2
View File
@@ -1,7 +1,6 @@
package cmd
import (
"fmt"
"io"
"os"
"path/filepath"
@@ -25,7 +24,7 @@ This list contains the raw endpoints (parameter values will not be appended or m
var bodyBytes []byte
fmt.Printf("\n")
printInfo("\n")
printInfo("Gathering endpoints.\n\n")
if swaggerURL != "" {
+2 -4
View File
@@ -1,7 +1,6 @@
package cmd
import (
"fmt"
"io"
"os"
"path/filepath"
@@ -25,13 +24,12 @@ This enables you to test specific API functions for common vulnerabilities or mi
_, err := time.Parse("2006-01-02", customDate)
if err != nil {
fmt.Println("An invalid date was supplied. Please supply a date in '2006-01-02' format.")
os.Exit(1)
die("An invalid date was supplied. Please supply a date in '2006-01-02' format.")
}
client, _ := CheckAndConfigureProxy()
fmt.Printf("\n")
printInfo("\n")
printInfo("Gathering API details.\n\n")
if swaggerURL != "" {
bodyBytes, _, _ := MakeRequest(client, "GET", swaggerURL, timeout, nil)
+4 -9
View File
@@ -639,11 +639,7 @@ func GenerateRequests(bodyBytes []byte, client http.Client, replayClient *http.C
for i := range servers {
if srv, ok := servers[i].(map[string]interface{}); ok {
if serverURL, ok := srv["url"].(string); ok {
if strings.Contains(serverURL, "://") {
fmt.Println(serverURL)
} else {
fmt.Println(apiTarget + serverURL)
}
printInfo("%s\n", serverURL)
}
}
}
@@ -827,7 +823,7 @@ func PrintSpecInfo(spec map[string]interface{}) {
if outputFormat == "json" {
specTitle = title
} else {
fmt.Printf("Title: %s\n", title)
printInfo("Title: %s\n", title)
}
}
@@ -836,7 +832,7 @@ func PrintSpecInfo(spec map[string]interface{}) {
if outputFormat == "json" {
specDescription = description
} else {
fmt.Printf("Description: %s\n", description)
printInfo("Description: %s\n", description)
}
}
}
@@ -881,8 +877,7 @@ func SafelyUnmarshalSpec(data []byte) map[string]interface{} {
var doc map[string]interface{}
if err := yaml.Unmarshal(data, &doc); err != nil {
fmt.Printf("Failed to unmarshal API documentation: %v\n", err)
os.Exit(1)
die("Failed to unmarshal API documentation: %v", err)
}
return doc