Merge pull request #1688 from projectdiscovery/issue-1214-truncated-resp

Adding truncation info on debug
This commit is contained in:
Sandeep Singh 2022-03-09 00:36:50 +05:30 committed by GitHub
commit 80e969f917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -564,7 +564,8 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate
} }
responseContentType := resp.Header.Get("Content-Type") responseContentType := resp.Header.Get("Content-Type")
dumpResponse(event, request.options, response.fullResponse, formedURL, responseContentType) isResponseTruncated := len(gotData) >= request.MaxSize
dumpResponse(event, request.options, response.fullResponse, formedURL, responseContentType, isResponseTruncated)
callback(event) callback(event)
} }
@ -622,7 +623,7 @@ func (request *Request) setCustomHeaders(req *generatedRequest) {
const CRLF = "\r\n" const CRLF = "\r\n"
func dumpResponse(event *output.InternalWrappedEvent, requestOptions *protocols.ExecuterOptions, redirectedResponse []byte, formedURL string, responseContentType string) { func dumpResponse(event *output.InternalWrappedEvent, requestOptions *protocols.ExecuterOptions, redirectedResponse []byte, formedURL string, responseContentType string, isResponseTruncated bool) {
cliOptions := requestOptions.Options cliOptions := requestOptions.Options
if cliOptions.Debug || cliOptions.DebugResponse { if cliOptions.Debug || cliOptions.DebugResponse {
response := string(redirectedResponse) response := string(redirectedResponse)
@ -634,7 +635,12 @@ func dumpResponse(event *output.InternalWrappedEvent, requestOptions *protocols.
highlightedResult = responsehighlighter.Highlight(event.OperatorsResult, response, cliOptions.NoColor, false) highlightedResult = responsehighlighter.Highlight(event.OperatorsResult, response, cliOptions.NoColor, false)
} }
gologger.Debug().Msgf("[%s] Dumped HTTP response for %s\n\n%s", requestOptions.TemplateID, formedURL, highlightedResult) msg := "[%s] Dumped HTTP response %s\n\n%s"
if isResponseTruncated {
msg = "[%s] Dumped HTTP response (Truncated) %s\n\n%s"
}
gologger.Debug().Msgf(msg, requestOptions.TemplateID, formedURL, highlightedResult)
} }
} }