mirror of
https://github.com/BishopFox/sj.git
synced 2026-11-07 10:26:01 -10:00
Fixed bug in verbose JSON output
This commit is contained in:
1 parent
4526ddbf23
commit
d7b34598d2
3 files changed
+24
-7
No files matched your search
+9
-1
@@ -65,7 +65,7 @@ func writeLog(sc int, target, method, errorMsg, response string) {
|
||||
} else if sc == 1 {
|
||||
logDangerous(target, method, tempLogger)
|
||||
} else if sc == 8899 {
|
||||
logJSON(target, method)
|
||||
logVerboseJSON(target, method)
|
||||
} else {
|
||||
logVerboseManual(sc, target, method, errorMsg, response, tempLogger)
|
||||
}
|
||||
@@ -224,3 +224,11 @@ func logJSON(title, description string) {
|
||||
"results": jsonResultArray,
|
||||
}).Println("Done")
|
||||
}
|
||||
|
||||
func logVerboseJSON(title, description string) {
|
||||
tempLogger.WithFields(log.Fields{
|
||||
"apiTitle": title,
|
||||
"description": description,
|
||||
"results": jsonVerboseResultArray,
|
||||
}).Println("Done")
|
||||
}
|
||||
+1
-1
@@ -48,7 +48,7 @@ $ sj convert -u https://petstore.swagger.io/v2/swagger.json -o openapi.json`,
|
||||
log.Error("Command not specified. See the --help flag for usage.")
|
||||
}
|
||||
},
|
||||
Version: "1.8.5",
|
||||
Version: "1.8.6",
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
|
||||
+14
-5
@@ -40,6 +40,7 @@ var accessibleEndpoints []string
|
||||
var consoleResults map[int][]any
|
||||
var jsonResultsStringArray []string
|
||||
var jsonResultArray []Result
|
||||
var jsonVerboseResultArray []VerboseResult
|
||||
|
||||
func GenerateRequests(bodyBytes []byte, client http.Client) []string {
|
||||
|
||||
@@ -113,12 +114,20 @@ func GenerateRequests(bodyBytes []byte, client http.Client) []string {
|
||||
for r := range jsonResultsStringArray {
|
||||
|
||||
var result Result
|
||||
err := json.Unmarshal([]byte(strings.TrimPrefix(jsonResultsStringArray[r], ",")), &result)
|
||||
if err != nil {
|
||||
log.Fatal("Error marshalling JSON:", err)
|
||||
var verboseResult VerboseResult
|
||||
if verbose {
|
||||
err := json.Unmarshal([]byte(strings.TrimPrefix(jsonResultsStringArray[r], ",")), &verboseResult)
|
||||
if err != nil {
|
||||
log.Fatal("Error marshalling JSON:", err)
|
||||
}
|
||||
jsonVerboseResultArray = append(jsonVerboseResultArray, verboseResult)
|
||||
} else {
|
||||
err := json.Unmarshal([]byte(strings.TrimPrefix(jsonResultsStringArray[r], ",")), &result)
|
||||
if err != nil {
|
||||
log.Fatal("Error marshalling JSON:", err)
|
||||
}
|
||||
jsonResultArray = append(jsonResultArray, result)
|
||||
}
|
||||
|
||||
jsonResultArray = append(jsonResultArray, result)
|
||||
}
|
||||
|
||||
if os.Args[1] == "automate" {
|
||||
|
||||
Reference in new issue
Block a user