Class OpenSearchLogFormat
java.lang.Object
ai.attackframework.tools.burp.utils.opensearch.OpenSearchLogFormat
Shared formatting for OpenSearch HTTP request/response logging (Test Connection only).
Produces one log entry per request and per response, with indented raw content from the wire.
Protocol reflects actual HTTP version when known; otherwise "HTTP (version unknown)" (e.g. SSL failure before any response).
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildRawResponseWithHeaders(String body, String protocol, int statusCode, String reasonPhrase, List<String> headerLines) Builds a response string from real status and headers (redacted).static StringformatRequestForLog(String method, String path, String baseUrl, String protocol, boolean authUsed) Builds the actual request as sent for logging: request line, Host, and redacted Authorization when auth was used.static StringPrefixes each line so raw request/response aligns with wrapped-line indent in the log.static StringExtracts the HTTP protocol from an OpenSearch/HttpClient exception message when present.static StringExtracts reason phrase from exception (e.g.static intExtracts status code from exception; returns 500 if not parseable.static booleanshouldRedactHeader(String name) Returns true for header names that should have their value redacted in logs (e.g.
-
Method Details
-
formatRequestForLog
public static String formatRequestForLog(String method, String path, String baseUrl, String protocol, boolean authUsed) Builds the actual request as sent for logging: request line, Host, and redacted Authorization when auth was used. Use for Test Connection so the log reflects what was on the wire (with credentials redacted). -
buildRawResponseWithHeaders
public static String buildRawResponseWithHeaders(String body, String protocol, int statusCode, String reasonPhrase, List<String> headerLines) Builds a response string from real status and headers (redacted). Use for Test Connection. If headerLines is null or empty, omits header block and uses only status line + body. -
shouldRedactHeader
Returns true for header names that should have their value redacted in logs (e.g. Authorization, Set-Cookie). -
parseProtocolFromException
Extracts the HTTP protocol from an OpenSearch/HttpClient exception message when present. e.g. "status line [HTTP/2.0 401 Unauthorized]" -> "HTTP/2.0"; "status line [HTTP/1.1 200 OK]" -> "HTTP/1.1".- Returns:
- protocol string or null if not found
-
parseStatusCodeFromException
Extracts status code from exception; returns 500 if not parseable. -
parseReasonFromException
Extracts reason phrase from exception (e.g. "Unauthorized" from "status line [HTTP/2.0 401 Unauthorized]"). -
indentRaw
Prefixes each line so raw request/response aligns with wrapped-line indent in the log.
-