pyrit.prompt_target.HTTPTarget#

class HTTPTarget(http_request: str, prompt_regex_string: str = '{PROMPT}', use_tls: bool = True, callback_function: Callable = None, max_requests_per_minute: int | None = None, **httpx_client_kwargs: Any | None)[source]#

Bases: PromptTarget

HTTP_Target is for endpoints that do not have an API and instead require HTTP request(s) to send a prompt

Parameters:
  • http_request (str) – the header parameters as a request (i.e., from Burp)

  • prompt_regex_string (str) – the placeholder for the prompt (default is {PROMPT}) which will be replaced by the actual prompt. make sure to modify the http request to have this included, otherwise it will not be properly replaced!

  • use_tls – (bool): whether to use TLS or not. Default is True

  • callback_function (function) – function to parse HTTP response. These are the customizable functions which determine how to parse the output

  • httpx_client_kwargs – (dict): additional keyword arguments to pass to the HTTP client

__init__(http_request: str, prompt_regex_string: str = '{PROMPT}', use_tls: bool = True, callback_function: Callable = None, max_requests_per_minute: int | None = None, **httpx_client_kwargs: Any | None) None[source]#

Methods

__init__(http_request[, ...])

dispose_db_engine()

Dispose DuckDB database engine to release database connections and resources.

get_identifier()

parse_raw_http_request()

Parses the HTTP request string into a dictionary of headers

send_prompt_async(*, prompt_request)

Sends prompt to HTTP endpoint and returns the response

Attributes

supported_converters

parse_raw_http_request()[source]#

Parses the HTTP request string into a dictionary of headers

Returns:

dictionary of all http header values body (str): string with body data url (str): string with URL http_method (str): method (ie GET vs POST) http_version (str): HTTP version to use

Return type:

headers_dict (dict)

async send_prompt_async(*, prompt_request: PromptRequestResponse) PromptRequestResponse[source]#

Sends prompt to HTTP endpoint and returns the response