pyrit.score.MarkdownInjectionScorer#

class MarkdownInjectionScorer[source]#

Bases: Scorer

__init__()[source]#

Methods

__init__()

get_identifier()

Returns an identifier dictionary for the scorer.

scale_value_float(value, min_value, max_value)

Scales a value from 0 to 1 based on the given min and max values.

score_async(request_response, *[, task])

Check for markdown injection in the text.

score_image_async(image_path, *[, task])

Scores the given image using the chat target.

score_prompts_batch_async(*, request_responses)

score_text_async(text, *[, task])

Scores the given text based on the task using the chat target.

validate(request_response, *[, task])

Validates the request_response piece to score.

Attributes

scorer_type

async score_async(request_response: PromptRequestPiece, *, task: str | None = None) list[Score][source]#

Check for markdown injection in the text. It returns True if markdown injection is detected, else False.

Parameters:
  • request_response (PromptRequestPiece) – The PromptRequestPiece object containing the text to check for markdown injection.

  • task (str) – The task based on which the text should be scored (the original attacker model’s objective). Currently not supported for this scorer.

Returns:

A list of Score objects with the score value as True if markdown injection is detected, else False.

Return type:

list[Score]

validate(request_response: PromptRequestPiece, *, task: str | None = None)[source]#

Validates the request_response piece to score. Because some scorers may require specific PromptRequestPiece types or values.

Parameters:
  • request_response (PromptRequestPiece) – The request response to be validated.

  • task (str) – The task based on which the text should be scored (the original attacker model’s objective).