pyrit.models.BinaryPathDataTypeSerializer#
- class BinaryPathDataTypeSerializer(*, category: str, prompt_text: str | None = None, extension: str | None = None)[source]#
Bases:
DataTypeSerializerSerializer for generic binary path values stored on disk.
- __init__(*, category: str, prompt_text: str | None = None, extension: str | None = None)[source]#
Initialize a generic binary-path serializer.
This serializer handles generic binary data that doesn’t fit into specific categories like images, audio, or video. Useful for XPIA attacks and storing files like PDFs, documents, or other binary formats.
Methods
__init__(*, category[, prompt_text, extension])Initialize a generic binary-path serializer.
Indicate whether this serializer persists data on disk.
get_data_filename([file_name])Generate or retrieve a unique filename for the data file.
get_extension(file_path)Get the file extension from the file path.
get_mime_type(file_path)Get the MIME type of the file path.
get_sha256()Compute SHA256 hash for this serializer's current value.
read_data()Read data from storage.
read_data_base64()Read data from storage and return it as a base64 string.
save_b64_image(data[, output_filename])Save a base64-encoded image to storage.
save_data(data[, output_filename])Save data to storage.
save_formatted_audio(data[, num_channels, ...])Save PCM16 or similarly formatted audio data to storage.
Attributes
- data_on_disk() bool[source]#
Indicate whether this serializer persists data on disk.
- Returns:
Always True for binary path serializers.
- Return type:
- data_type: PromptDataType#