Class OpenSearchLogFormat

java.lang.Object
ai.attackframework.tools.burp.utils.opensearch.OpenSearchLogFormat

public final class OpenSearchLogFormat extends Object
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 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

      public static boolean shouldRedactHeader(String name)
      Returns true for header names that should have their value redacted in logs (e.g. Authorization, Set-Cookie).
    • parseProtocolFromException

      public static String parseProtocolFromException(Throwable t)
      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

      public static int parseStatusCodeFromException(Throwable t)
      Extracts status code from exception; returns 500 if not parseable.
    • parseReasonFromException

      public static String parseReasonFromException(Throwable t)
      Extracts reason phrase from exception (e.g. "Unauthorized" from "status line [HTTP/2.0 401 Unauthorized]").
    • indentRaw

      public static String indentRaw(String raw)
      Prefixes each line so raw request/response aligns with wrapped-line indent in the log.