Generate security tests $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)" aria-label="Copy link to this element" class="headerlink" data-tooltip="Copy link to this element" href="#">
This section will guide you through generating security-focused test cases using the Hub interface.
Security testing is a critical component of LLM agent evaluation. It focuses on identifying vulnerabilities that could be exploited by malicious actors or lead to unintended behavior.
Adversarial Security Testing $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)" aria-label="Copy link to this element" class="headerlink" data-tooltip="Copy link to this element" href="#" x-intersect.margin.0%.0%.-70%.0%="activeSection = '#adversarial-security-testing'">
The generate_adversarial method creates test cases designed to expose security vulnerabilities and robustness issues in your AI agents. This is particularly useful for:
# Generate adversarial test cases for security testing
security_dataset = hub.datasets.generate_adversarial(
model_id=model.id,
dataset_name="Security Test Cases",
description="Adversarial test cases for security vulnerability detection",
categories=[
{
"id": "prompt_injection",
"name": "Prompt Injection",
"desc": "Tests for prompt injection vulnerabilities"
},
{
"id": "harmful_content",
"name": "Harmful Content",
"desc": "Tests for harmful content generation"
},
{
"id": "information_disclosure",
"name": "Information Disclosure",
"desc": "Tests for unintended information leakage"
}
],
n_examples=20 # Optional: number of chat test cases per category to generate
)
# Wait for the dataset to be created
security_dataset.wait_for_completion()
# List the chat test cases in the dataset
for chat_test_case in security_dataset.chat_test_cases:
print(chat_test_case.messages[0].content)
Note
You can also use the Giskard Hub UI to generate security test cases if you prefer a visual interface.
Next steps $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)" aria-label="Copy link to this element" class="headerlink" data-tooltip="Copy link to this element" href="#" x-intersect.margin.0%.0%.-70%.0%="activeSection = '#next-steps'">
Agentic vulnerability detection - Try Launch vulnerability scans
Generate business failures - Try Generate business tests
Review test case - Make sure to Evaluate tests and assign validation rules