Class OpenSearchClientWrapper

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

public class OpenSearchClientWrapper extends Object
Wraps OpenSearch connection tests and document push operations for the exporter.

This facade coordinates OpenSearch writes with file export, retry handling, and runtime authentication settings so callers can use a small API surface.

  • Constructor Details

    • OpenSearchClientWrapper

      public OpenSearchClientWrapper()
  • Method Details

    • testConnection

      public static OpenSearchClientWrapper.OpenSearchStatus testConnection(String baseUrl)
      Tests OpenSearch connectivity without authentication.
      Parameters:
      baseUrl - OpenSearch base URL
      Returns:
      structured connection status
    • testConnection

      public static OpenSearchClientWrapper.OpenSearchStatus testConnection(String baseUrl, String username, String password)
      Tests connectivity with optional basic auth. Performs a raw GET / so logs show the actual HTTP version and status line from the wire; on 200 parses the response body for version/distribution.
      Parameters:
      baseUrl - OpenSearch base URL
      username - optional basic-auth username
      password - optional basic-auth password
      Returns:
      structured connection status
    • safeTestConnection

      public static OpenSearchClientWrapper.OpenSearchStatus safeTestConnection(String baseUrl)
      Tests OpenSearch connectivity without authentication, converting runtime failures into a failed status result.
      Parameters:
      baseUrl - OpenSearch base URL
      Returns:
      structured connection status
    • safeTestConnection

      public static OpenSearchClientWrapper.OpenSearchStatus safeTestConnection(String baseUrl, String username, String password)
      Tests OpenSearch connectivity and converts runtime failures into a failed status result.
      Parameters:
      baseUrl - OpenSearch base URL
      username - optional basic-auth username
      password - optional basic-auth password
      Returns:
      structured connection status
    • pushDocument

      public static boolean pushDocument(String baseUrl, String indexName, String indexKey, Map<String,Object> document)
      Pushes a single document. Delegates to the retry coordinator (one attempt, then queue on failure).

      Documents are filtered to include only fields enabled in the Fields panel before push.

      Parameters:
      baseUrl - OpenSearch base URL
      indexName - target index name
      document - the document to index (filtered by ExportFieldFilter)
      Returns:
      true if indexed successfully, false otherwise
    • pushBulk

      public static int pushBulk(String baseUrl, String indexName, String indexKey, List<Map<String,Object>> documents)
      Pushes documents in bulk. Delegates to the retry coordinator (retries with backoff, then queue failed items).

      Documents are filtered to include only fields enabled in the Fields panel before push.

      Bulk-path responsibilities

      The exporter deliberately uses two distinct bulk paths with different guarantees:

      Snapshot reporters stay on pushBulk because losing retry + drain-queue fallback would regress reliability for one-shot waves. Live traffic stays on ChunkedBulkSender because its backpressure and streaming body are required under sustained throughput. Both paths route file-sink writes through FileExportService and attribute success/failure through TrafficRouteBucket, so traffic accounting is consistent regardless of which path a document takes.

      Parameters:
      baseUrl - OpenSearch base URL
      indexName - target index name
      documents - documents to index (each filtered by ExportFieldFilter)
      Returns:
      number of documents successfully indexed