writeResultToOutput writes a result to the output file. In JSON mode, it accumulates results (thread-safe via jsonResultsMutex). In plain mode, it writes immediately — caller MUST hold printMutex.
(result Result, technique string)
| 84 | // In JSON mode, it accumulates results (thread-safe via jsonResultsMutex). |
| 85 | // In plain mode, it writes immediately — caller MUST hold printMutex. |
| 86 | func writeResultToOutput(result Result, technique string) { |
| 87 | if outputWriter == nil && !jsonOutput && !jsonLines { |
| 88 | return |
| 89 | } |
| 90 | |
| 91 | if jsonOutput || jsonLines { |
| 92 | jsonResultsMutex.Lock() |
| 93 | jsonResults = append(jsonResults, JSONResult{ |
| 94 | StatusCode: result.statusCode, |
| 95 | ContentLength: result.contentLength, |
| 96 | Technique: technique, |
| 97 | Payload: result.line, |
| 98 | Score: result.score, |
| 99 | Likelihood: result.likelihood, |
| 100 | ScoreReason: result.scoreReason, |
| 101 | BodyHash: result.bodyHash, |
| 102 | Location: result.location, |
| 103 | ContentType: result.contentType, |
| 104 | Server: result.server, |
| 105 | ReproCurl: result.reproCurl, |
| 106 | }) |
| 107 | jsonResultsMutex.Unlock() |
| 108 | |
| 109 | // If no output file, write JSON to stdout at close |
| 110 | return |
| 111 | } |
| 112 | |
| 113 | if outputWriter != nil { |
| 114 | fmt.Fprintf(outputWriter, "%d\t[%d %s]\t%d bytes\t%s\n", result.statusCode, result.score, result.likelihood, result.contentLength, result.line) |
| 115 | if result.reproCurl != "" { |
| 116 | fmt.Fprintf(outputWriter, "curl\t%s\n", result.reproCurl) |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | // flushJSONToStdout writes JSON results to stdout when no output file is specified. |
| 122 | func flushJSONToStdout() { |
no outgoing calls