Skip to content

DeepTeam is a framework to red team LLMs and AI agents.

format

A-Vamshi26e162b9a287
diff --git a/deepteam/vulnerabilities/agentic/excessive_agency/excessive_agency.py b/deepteam/vulnerabilities/agentic/excessive_agency/excessive_agency.py
index a2a92210..1cd38675 100644
--- a/deepteam/vulnerabilities/agentic/excessive_agency/excessive_agency.py
+++ b/deepteam/vulnerabilities/agentic/excessive_agency/excessive_agency.py
@@ -34,7 +34,7 @@ class ExcessiveAgency(BaseVulnerability):
types: Optional[List[ExcessiveAgencyLiteral]] = [
type.value for type in ExcessiveAgencyType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=ExcessiveAgencyType
diff --git a/deepteam/vulnerabilities/agentic/goal_theft/goal_theft.py b/deepteam/vulnerabilities/agentic/goal_theft/goal_theft.py
index c7d8f84c..60449797 100644
--- a/deepteam/vulnerabilities/agentic/goal_theft/goal_theft.py
+++ b/deepteam/vulnerabilities/agentic/goal_theft/goal_theft.py
@@ -36,7 +36,7 @@ class GoalTheft(BaseVulnerability):
types: Optional[List[GoalTheftLiteralType]] = [
type.value for type in GoalTheftType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=GoalTheftType
diff --git a/deepteam/vulnerabilities/agentic/recursive_hijacking/recursive_hijacking.py b/deepteam/vulnerabilities/agentic/recursive_hijacking/recursive_hijacking.py
index 54d76092..591d17da 100644
--- a/deepteam/vulnerabilities/agentic/recursive_hijacking/recursive_hijacking.py
+++ b/deepteam/vulnerabilities/agentic/recursive_hijacking/recursive_hijacking.py
@@ -40,7 +40,7 @@ class RecursiveHijacking(BaseVulnerability):
types: Optional[List[RecursiveHijackingLiteralType]] = [
type.value for type in RecursiveHijackingType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=RecursiveHijackingType
diff --git a/deepteam/vulnerabilities/agentic/robustness/robustness.py b/deepteam/vulnerabilities/agentic/robustness/robustness.py
index e0a68e8e..2fa8ce7f 100644
--- a/deepteam/vulnerabilities/agentic/robustness/robustness.py
+++ b/deepteam/vulnerabilities/agentic/robustness/robustness.py
@@ -35,7 +35,7 @@ class Robustness(BaseVulnerability):
types: Optional[List[RobustnessLiteral]] = [
type.value for type in RobustnessType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=RobustnessType
diff --git a/deepteam/vulnerabilities/bfla/bfla.py b/deepteam/vulnerabilities/bfla/bfla.py
index 5d5e1f07..0edcef40 100644
--- a/deepteam/vulnerabilities/bfla/bfla.py
+++ b/deepteam/vulnerabilities/bfla/bfla.py
@@ -34,7 +34,7 @@ class BFLA(BaseVulnerability):
] = "gpt-3.5-turbo-0125",
evaluation_model: Optional[Union[str, DeepEvalBaseLLM]] = "gpt-4o",
types: Optional[List[BFLALiteral]] = [type.value for type in BFLAType],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=BFLAType
diff --git a/deepteam/vulnerabilities/bias/bias.py b/deepteam/vulnerabilities/bias/bias.py
index ac73c9d7..7e54788b 100644
--- a/deepteam/vulnerabilities/bias/bias.py
+++ b/deepteam/vulnerabilities/bias/bias.py
@@ -31,7 +31,7 @@ class Bias(BaseVulnerability):
types: Optional[List[BiasLiteralType]] = [
type.value for type in BiasType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=BiasType
diff --git a/deepteam/vulnerabilities/bola/bola.py b/deepteam/vulnerabilities/bola/bola.py
index 868a8a7a..e14ecbb9 100644
--- a/deepteam/vulnerabilities/bola/bola.py
+++ b/deepteam/vulnerabilities/bola/bola.py
@@ -34,7 +34,7 @@ class BOLA(BaseVulnerability):
] = "gpt-3.5-turbo-0125",
evaluation_model: Optional[Union[str, DeepEvalBaseLLM]] = "gpt-4o",
types: Optional[List[BOLALiteral]] = [type.value for type in BOLAType],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=BOLAType
diff --git a/deepteam/vulnerabilities/competition/competition.py b/deepteam/vulnerabilities/competition/competition.py
index 16a07702..6d096f58 100644
--- a/deepteam/vulnerabilities/competition/competition.py
+++ b/deepteam/vulnerabilities/competition/competition.py
@@ -39,7 +39,7 @@ class Competition(BaseVulnerability):
types: Optional[List[CompetitionLiteralType]] = [
type.value for type in CompetitionType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=CompetitionType
diff --git a/deepteam/vulnerabilities/debug_access/debug_access.py b/deepteam/vulnerabilities/debug_access/debug_access.py
index ff2f020a..a586bccd 100644
--- a/deepteam/vulnerabilities/debug_access/debug_access.py
+++ b/deepteam/vulnerabilities/debug_access/debug_access.py
@@ -36,7 +36,7 @@ class DebugAccess(BaseVulnerability):
types: Optional[List[DebugAccessLiteral]] = [
type.value for type in DebugAccessType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=DebugAccessType
diff --git a/deepteam/vulnerabilities/graphic_content/graphic_content.py b/deepteam/vulnerabilities/graphic_content/graphic_content.py
index 3161e3ff..cd794537 100644
--- a/deepteam/vulnerabilities/graphic_content/graphic_content.py
+++ b/deepteam/vulnerabilities/graphic_content/graphic_content.py
@@ -34,7 +34,7 @@ class GraphicContent(BaseVulnerability):
types: Optional[List[GraphicContentLiteral]] = [
type.value for type in GraphicContentType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=GraphicContentType
diff --git a/deepteam/vulnerabilities/illegal_activity/illegal_activity.py b/deepteam/vulnerabilities/illegal_activity/illegal_activity.py
index 65a94c00..2f47fb65 100644
--- a/deepteam/vulnerabilities/illegal_activity/illegal_activity.py
+++ b/deepteam/vulnerabilities/illegal_activity/illegal_activity.py
@@ -40,7 +40,7 @@ class IllegalActivity(BaseVulnerability):
types: Optional[List[IllegalActivityLiteral]] = [
type.value for type in IllegalActivityType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=IllegalActivityType
diff --git a/deepteam/vulnerabilities/intellectual_property/intellectual_property.py b/deepteam/vulnerabilities/intellectual_property/intellectual_property.py
index 0e2ae628..c392e578 100644
--- a/deepteam/vulnerabilities/intellectual_property/intellectual_property.py
+++ b/deepteam/vulnerabilities/intellectual_property/intellectual_property.py
@@ -39,7 +39,7 @@ class IntellectualProperty(BaseVulnerability):
types: Optional[List[IntellectualPropertyLiteral]] = [
type.value for type in IntellectualPropertyType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=IntellectualPropertyType
diff --git a/deepteam/vulnerabilities/misinformation/misinformation.py b/deepteam/vulnerabilities/misinformation/misinformation.py
index f954d011..c8c0867b 100644
--- a/deepteam/vulnerabilities/misinformation/misinformation.py
+++ b/deepteam/vulnerabilities/misinformation/misinformation.py
@@ -35,7 +35,7 @@ class Misinformation(BaseVulnerability):
types: Optional[List[MisinformationLiteral]] = [
type.value for type in MisinformationType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=MisinformationType
diff --git a/deepteam/vulnerabilities/personal_safety/personal_safety.py b/deepteam/vulnerabilities/personal_safety/personal_safety.py
index ce9c947a..c60519e4 100644
--- a/deepteam/vulnerabilities/personal_safety/personal_safety.py
+++ b/deepteam/vulnerabilities/personal_safety/personal_safety.py
@@ -38,7 +38,7 @@ class PersonalSafety(BaseVulnerability):
types: Optional[List[PersonalSafetyLiteral]] = [
type.value for type in PersonalSafetyType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=PersonalSafetyType
diff --git a/deepteam/vulnerabilities/pii_leakage/pii_leakage.py b/deepteam/vulnerabilities/pii_leakage/pii_leakage.py
index bd41514c..747f2a45 100644
--- a/deepteam/vulnerabilities/pii_leakage/pii_leakage.py
+++ b/deepteam/vulnerabilities/pii_leakage/pii_leakage.py
@@ -37,7 +37,7 @@ class PIILeakage(BaseVulnerability):
types: Optional[List[PIILeakageLiteral]] = [
type.value for type in PIILeakageType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=PIILeakageType
diff --git a/deepteam/vulnerabilities/prompt_leakage/prompt_leakage.py b/deepteam/vulnerabilities/prompt_leakage/prompt_leakage.py
index b4b607ea..3cf66d2d 100644
--- a/deepteam/vulnerabilities/prompt_leakage/prompt_leakage.py
+++ b/deepteam/vulnerabilities/prompt_leakage/prompt_leakage.py
@@ -37,7 +37,7 @@ class PromptLeakage(BaseVulnerability):
types: Optional[List[PromptLeakageLiteral]] = [
type.value for type in PromptLeakageType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=PromptLeakageType
diff --git a/deepteam/vulnerabilities/rbac/rbac.py b/deepteam/vulnerabilities/rbac/rbac.py
index b46a6e4e..21a07971 100644
--- a/deepteam/vulnerabilities/rbac/rbac.py
+++ b/deepteam/vulnerabilities/rbac/rbac.py
@@ -34,7 +34,7 @@ class RBAC(BaseVulnerability):
] = "gpt-3.5-turbo-0125",
evaluation_model: Optional[Union[str, DeepEvalBaseLLM]] = "gpt-4o",
types: Optional[List[RBACLiteral]] = [type.value for type in RBACType],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=RBACType
diff --git a/deepteam/vulnerabilities/shell_injection/shell_injection.py b/deepteam/vulnerabilities/shell_injection/shell_injection.py
index d3b21207..5ffb4c2b 100644
--- a/deepteam/vulnerabilities/shell_injection/shell_injection.py
+++ b/deepteam/vulnerabilities/shell_injection/shell_injection.py
@@ -36,7 +36,7 @@ class ShellInjection(BaseVulnerability):
types: Optional[List[ShellInjectionLiteral]] = [
type.value for type in ShellInjectionType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=ShellInjectionType
diff --git a/deepteam/vulnerabilities/sql_injection/sql_injection.py b/deepteam/vulnerabilities/sql_injection/sql_injection.py
index 0a8434b0..27872af0 100644
--- a/deepteam/vulnerabilities/sql_injection/sql_injection.py
+++ b/deepteam/vulnerabilities/sql_injection/sql_injection.py
@@ -36,7 +36,7 @@ class SQLInjection(BaseVulnerability):
types: Optional[List[SQLInjectionLiteral]] = [
type.value for type in SQLInjectionType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=SQLInjectionType
diff --git a/deepteam/vulnerabilities/ssrf/ssrf.py b/deepteam/vulnerabilities/ssrf/ssrf.py
index fec71930..681c3700 100644
--- a/deepteam/vulnerabilities/ssrf/ssrf.py
+++ b/deepteam/vulnerabilities/ssrf/ssrf.py
@@ -34,7 +34,7 @@ class SSRF(BaseVulnerability):
] = "gpt-3.5-turbo-0125",
evaluation_model: Optional[Union[str, DeepEvalBaseLLM]] = "gpt-4o",
types: Optional[List[SSRFLiteral]] = [type.value for type in SSRFType],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=SSRFType
diff --git a/deepteam/vulnerabilities/toxicity/toxicity.py b/deepteam/vulnerabilities/toxicity/toxicity.py
index 19df0577..bc13543a 100644
--- a/deepteam/vulnerabilities/toxicity/toxicity.py
+++ b/deepteam/vulnerabilities/toxicity/toxicity.py
@@ -32,7 +32,7 @@ class Toxicity(BaseVulnerability):
types: Optional[List[ToxicityLiteral]] = [
type.value for type in ToxicityType
],
- purpose: Optional[str] = None
+ purpose: Optional[str] = None,
):
enum_types = validate_vulnerability_types(
self.get_name(), types=types, allowed_type=ToxicityType
diff --git a/tests/test_core/test_vulnerabilities/test_bfla.py b/tests/test_core/test_vulnerabilities/test_bfla.py
index d17ebb0c..e453a2b9 100644
--- a/tests/test_core/test_vulnerabilities/test_bfla.py
+++ b/tests/test_core/test_vulnerabilities/test_bfla.py
@@ -54,7 +54,10 @@ class TestBFLA:
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "BFLA" for tc in test_cases)
- assert all(tc.vulnerability_type == BFLAType.AUTHORIZATION_BYPASS for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == BFLAType.AUTHORIZATION_BYPASS
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
bfla = BFLA(types=["authorization_bypass"], async_mode=False)
@@ -63,7 +66,10 @@ class TestBFLA:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = bfla.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = bfla.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert BFLAType.AUTHORIZATION_BYPASS in results
assert len(results[BFLAType.AUTHORIZATION_BYPASS]) == 1
test_case = results[BFLAType.AUTHORIZATION_BYPASS][0]
@@ -74,7 +80,9 @@ class TestBFLA:
def test_get_metric_returns_BFLA_metric(self):
from deepteam.metrics import BFLAMetric
- bfla = BFLA(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ bfla = BFLA(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = bfla._get_metric(BFLAType.AUTHORIZATION_BYPASS)
assert isinstance(metric, BFLAMetric)
assert metric.async_mode is True
@@ -96,4 +104,4 @@ class TestBFLA:
assert len(results[BFLAType.AUTHORIZATION_BYPASS]) == 1
test_case = results[BFLAType.AUTHORIZATION_BYPASS][0]
assert hasattr(test_case, "score")
- assert hasattr(test_case, "reason")
\ No newline at end of file
+ assert hasattr(test_case, "reason")
diff --git a/tests/test_core/test_vulnerabilities/test_bias.py b/tests/test_core/test_vulnerabilities/test_bias.py
index 80d382e6..5b9e8c08 100644
--- a/tests/test_core/test_vulnerabilities/test_bias.py
+++ b/tests/test_core/test_vulnerabilities/test_bias.py
@@ -50,7 +50,9 @@ class TestBias:
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Bias" for tc in test_cases)
- assert all(tc.vulnerability_type == BiasType.GENDER for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == BiasType.GENDER for tc in test_cases
+ )
def test_assess_returns_results(self):
bias = Bias(types=["politics"], async_mode=False)
@@ -59,7 +61,10 @@ class TestBias:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = bias.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = bias.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert BiasType.POLITICS in results
assert len(results[BiasType.POLITICS]) == 1
test_case = results[BiasType.POLITICS][0]
@@ -70,7 +75,9 @@ class TestBias:
def test_get_metric_returns_bias_metric(self):
from deepteam.metrics import BiasMetric
- bias = Bias(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ bias = Bias(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = bias._get_metric(BiasType.RACE)
assert isinstance(metric, BiasMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_bola.py b/tests/test_core/test_vulnerabilities/test_bola.py
index 013da96a..6a07b596 100644
--- a/tests/test_core/test_vulnerabilities/test_bola.py
+++ b/tests/test_core/test_vulnerabilities/test_bola.py
@@ -54,7 +54,10 @@ class TestBOLA:
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "BOLA" for tc in test_cases)
- assert all(tc.vulnerability_type == BOLAType.CROSS_CUSTOMER_ACCESS for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == BOLAType.CROSS_CUSTOMER_ACCESS
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
bola = BOLA(types=["cross_customer_access"], async_mode=False)
@@ -63,7 +66,10 @@ class TestBOLA:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = bola.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = bola.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert BOLAType.CROSS_CUSTOMER_ACCESS in results
assert len(results[BOLAType.CROSS_CUSTOMER_ACCESS]) == 1
test_case = results[BOLAType.CROSS_CUSTOMER_ACCESS][0]
@@ -74,7 +80,9 @@ class TestBOLA:
def test_get_metric_returns_BOLA_metric(self):
from deepteam.metrics import BOLAMetric
- bola = BOLA(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ bola = BOLA(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = bola._get_metric(BOLAType.CROSS_CUSTOMER_ACCESS)
assert isinstance(metric, BOLAMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_competition.py b/tests/test_core/test_vulnerabilities/test_competition.py
index 2fe815e2..47d09f71 100644
--- a/tests/test_core/test_vulnerabilities/test_competition.py
+++ b/tests/test_core/test_vulnerabilities/test_competition.py
@@ -56,21 +56,31 @@ class TestCompetition:
def test_simulate_attacks_returns_expected_cases(self):
competition = Competition(types=["competitor mention"])
- test_cases = competition.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = competition.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Competition" for tc in test_cases)
- assert all(tc.vulnerability_type == CompetitionType.COMPETITOR_MENTION for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == CompetitionType.COMPETITOR_MENTION
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
- competition = Competition(types=["competitor_mention"], async_mode=False)
+ competition = Competition(
+ types=["competitor_mention"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = competition.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = competition.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert CompetitionType.COMPETITOR_MENTION in results
assert len(results[CompetitionType.COMPETITOR_MENTION]) == 1
test_case = results[CompetitionType.COMPETITOR_MENTION][0]
@@ -81,7 +91,9 @@ class TestCompetition:
def test_get_metric_returns_Competition_metric(self):
from deepteam.metrics import CompetitorsMetric
- competition = Competition(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ competition = Competition(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = competition._get_metric(CompetitionType.COMPETITOR_MENTION)
assert isinstance(metric, CompetitorsMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_debug_access.py b/tests/test_core/test_vulnerabilities/test_debug_access.py
index 15b036b3..a07ff624 100644
--- a/tests/test_core/test_vulnerabilities/test_debug_access.py
+++ b/tests/test_core/test_vulnerabilities/test_debug_access.py
@@ -57,21 +57,31 @@ class TestDebugAccess:
def test_simulate_attacks_returns_expected_cases(self):
debug_access = DebugAccess(types=["debug_mode_bypass"])
- test_cases = debug_access.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = debug_access.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Debug Access" for tc in test_cases)
- assert all(tc.vulnerability_type == DebugAccessType.DEBUG_MODE_BYPASS for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == DebugAccessType.DEBUG_MODE_BYPASS
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
- debug_access = DebugAccess(types=["debug_mode_bypass"], async_mode=False)
+ debug_access = DebugAccess(
+ types=["debug_mode_bypass"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = debug_access.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = debug_access.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert DebugAccessType.DEBUG_MODE_BYPASS in results
assert len(results[DebugAccessType.DEBUG_MODE_BYPASS]) == 1
test_case = results[DebugAccessType.DEBUG_MODE_BYPASS][0]
@@ -82,7 +92,9 @@ class TestDebugAccess:
def test_get_metric_returns_DebugAccess_metric(self):
from deepteam.metrics import DebugAccessMetric
- debug_access = DebugAccess(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ debug_access = DebugAccess(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = debug_access._get_metric(DebugAccessType.DEBUG_MODE_BYPASS)
assert isinstance(metric, DebugAccessMetric)
assert metric.async_mode is True
@@ -104,4 +116,4 @@ class TestDebugAccess:
assert len(results[DebugAccessType.DEBUG_MODE_BYPASS]) == 1
test_case = results[DebugAccessType.DEBUG_MODE_BYPASS][0]
assert hasattr(test_case, "score")
- assert hasattr(test_case, "reason")
\ No newline at end of file
+ assert hasattr(test_case, "reason")
diff --git a/tests/test_core/test_vulnerabilities/test_excessive_agency.py b/tests/test_core/test_vulnerabilities/test_excessive_agency.py
index 1587125f..6f8f0293 100644
--- a/tests/test_core/test_vulnerabilities/test_excessive_agency.py
+++ b/tests/test_core/test_vulnerabilities/test_excessive_agency.py
@@ -50,12 +50,17 @@ class TestExcessiveAgency:
def test_simulate_attacks_returns_expected_cases(self):
excessive_agency = ExcessiveAgency(types=["autonomy"])
- test_cases = excessive_agency.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = excessive_agency.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Excessive Agency" for tc in test_cases)
- assert all(tc.vulnerability_type == ExcessiveAgencyType.AUTONOMY for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == ExcessiveAgencyType.AUTONOMY
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
excessive_agency = ExcessiveAgency(types=["autonomy"], async_mode=False)
@@ -64,7 +69,10 @@ class TestExcessiveAgency:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = excessive_agency.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = excessive_agency.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert ExcessiveAgencyType.AUTONOMY in results
assert len(results[ExcessiveAgencyType.AUTONOMY]) == 1
test_case = results[ExcessiveAgencyType.AUTONOMY][0]
@@ -75,7 +83,9 @@ class TestExcessiveAgency:
def test_get_metric_returns_ExcessiveAgency_metric(self):
from deepteam.metrics import ExcessiveAgencyMetric
- excessive_agency = ExcessiveAgency(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ excessive_agency = ExcessiveAgency(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = excessive_agency._get_metric(ExcessiveAgencyType.AUTONOMY)
assert isinstance(metric, ExcessiveAgencyMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_goal_theft.py b/tests/test_core/test_vulnerabilities/test_goal_theft.py
index 6ef130ed..1511a7b9 100644
--- a/tests/test_core/test_vulnerabilities/test_goal_theft.py
+++ b/tests/test_core/test_vulnerabilities/test_goal_theft.py
@@ -49,12 +49,17 @@ class TestGoalTheft:
def test_simulate_attacks_returns_expected_cases(self):
goal_theft = GoalTheft(types=["cooperative_dialogue"])
- test_cases = goal_theft.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = goal_theft.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Goal Theft" for tc in test_cases)
- assert all(tc.vulnerability_type == GoalTheftType.COOPERATIVE_DIALOGUE for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == GoalTheftType.COOPERATIVE_DIALOGUE
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
goal_theft = GoalTheft(types=["cooperative_dialogue"], async_mode=False)
@@ -63,7 +68,10 @@ class TestGoalTheft:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = goal_theft.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = goal_theft.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert GoalTheftType.COOPERATIVE_DIALOGUE in results
assert len(results[GoalTheftType.COOPERATIVE_DIALOGUE]) == 1
test_case = results[GoalTheftType.COOPERATIVE_DIALOGUE][0]
@@ -74,7 +82,9 @@ class TestGoalTheft:
def test_get_metric_returns_GoalTheft_metric(self):
from deepteam.metrics.agentic import ExtractionSuccessMetric
- goal_theft = GoalTheft(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ goal_theft = GoalTheft(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = goal_theft._get_metric(GoalTheftType.COOPERATIVE_DIALOGUE)
assert isinstance(metric, ExtractionSuccessMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_graphic_content.py b/tests/test_core/test_vulnerabilities/test_graphic_content.py
index 615f82ad..96860ebe 100644
--- a/tests/test_core/test_vulnerabilities/test_graphic_content.py
+++ b/tests/test_core/test_vulnerabilities/test_graphic_content.py
@@ -53,21 +53,31 @@ class TestGraphicContent:
def test_simulate_attacks_returns_expected_cases(self):
graphic_content = GraphicContent(types=["graphic_content"])
- test_cases = graphic_content.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = graphic_content.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Graphic Content" for tc in test_cases)
- assert all(tc.vulnerability_type == GraphicContentType.GRAPHIC_CONTENT for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == GraphicContentType.GRAPHIC_CONTENT
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
- graphic_content = GraphicContent(types=["graphic_content"], async_mode=False)
+ graphic_content = GraphicContent(
+ types=["graphic_content"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = graphic_content.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = graphic_content.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert GraphicContentType.GRAPHIC_CONTENT in results
assert len(results[GraphicContentType.GRAPHIC_CONTENT]) == 1
test_case = results[GraphicContentType.GRAPHIC_CONTENT][0]
@@ -78,7 +88,9 @@ class TestGraphicContent:
def test_get_metric_returns_GraphicContent_metric(self):
from deepteam.metrics import GraphicMetric
- graphic_content = GraphicContent(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ graphic_content = GraphicContent(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = graphic_content._get_metric(GraphicContentType.GRAPHIC_CONTENT)
assert isinstance(metric, GraphicMetric)
assert metric.async_mode is True
@@ -86,7 +98,9 @@ class TestGraphicContent:
@pytest.mark.asyncio
async def test_a_assess_returns_async_results(self):
- graphic_content = GraphicContent(types=["cooperative_dialogue"], async_mode=True)
+ graphic_content = GraphicContent(
+ types=["cooperative_dialogue"], async_mode=True
+ )
async def dummy_model_callback(prompt):
return prompt
@@ -101,4 +115,3 @@ class TestGraphicContent:
test_case = results[GraphicContentType.GRAPHIC_CONTENT][0]
assert hasattr(test_case, "score")
assert hasattr(test_case, "reason")
-
diff --git a/tests/test_core/test_vulnerabilities/test_illegal_activity.py b/tests/test_core/test_vulnerabilities/test_illegal_activity.py
index 34961fea..bb05380f 100644
--- a/tests/test_core/test_vulnerabilities/test_illegal_activity.py
+++ b/tests/test_core/test_vulnerabilities/test_illegal_activity.py
@@ -4,6 +4,7 @@ from deepteam.vulnerabilities import IllegalActivity
from deepteam.vulnerabilities.illegal_activity import IllegalActivityType
from deepteam.test_case import RTTestCase
+
class TestIllegalActivity:
def test_illegal_activity_all_types(self):
@@ -97,7 +98,10 @@ class TestIllegalActivity:
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Illegal Activity" for tc in test_cases)
- assert all(tc.vulnerability_type == IllegalActivityType.WEAPONS for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == IllegalActivityType.WEAPONS
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
illegal = IllegalActivity(types=["weapons"], async_mode=False)
@@ -106,7 +110,10 @@ class TestIllegalActivity:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = illegal.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = illegal.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert IllegalActivityType.WEAPONS in results
assert len(results[IllegalActivityType.WEAPONS]) == 1
test_case = results[IllegalActivityType.WEAPONS][0]
@@ -117,7 +124,9 @@ class TestIllegalActivity:
def test_get_metric_returns_IllegalActivity_metric(self):
from deepteam.metrics import IllegalMetric
- illegal = IllegalActivity(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ illegal = IllegalActivity(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = illegal._get_metric(IllegalActivityType.WEAPONS)
assert isinstance(metric, IllegalMetric)
assert metric.async_mode is True
@@ -125,7 +134,9 @@ class TestIllegalActivity:
@pytest.mark.asyncio
async def test_a_assess_returns_async_results(self):
- illegal = IllegalActivity(types=["cooperative_dialogue"], async_mode=True)
+ illegal = IllegalActivity(
+ types=["cooperative_dialogue"], async_mode=True
+ )
async def dummy_model_callback(prompt):
return prompt
diff --git a/tests/test_core/test_vulnerabilities/test_intellectual_property.py b/tests/test_core/test_vulnerabilities/test_intellectual_property.py
index a0511f4b..b3f37182 100644
--- a/tests/test_core/test_vulnerabilities/test_intellectual_property.py
+++ b/tests/test_core/test_vulnerabilities/test_intellectual_property.py
@@ -68,21 +68,33 @@ class TestIntellectualProperty:
def test_simulate_attacks_returns_expected_cases(self):
intellectual = IntellectualProperty(types=["imitation"])
- test_cases = intellectual.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = intellectual.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
- assert all(tc.vulnerability == "Intellectual Property" for tc in test_cases)
- assert all(tc.vulnerability_type == IntellectualPropertyType.IMITATION for tc in test_cases)
+ assert all(
+ tc.vulnerability == "Intellectual Property" for tc in test_cases
+ )
+ assert all(
+ tc.vulnerability_type == IntellectualPropertyType.IMITATION
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
- intellectual = IntellectualProperty(types=["imitation"], async_mode=False)
+ intellectual = IntellectualProperty(
+ types=["imitation"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = intellectual.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = intellectual.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert IntellectualPropertyType.IMITATION in results
assert len(results[IntellectualPropertyType.IMITATION]) == 1
test_case = results[IntellectualPropertyType.IMITATION][0]
@@ -93,7 +105,9 @@ class TestIntellectualProperty:
def test_get_metric_returns_IntellectualProperty_metric(self):
from deepteam.metrics import IntellectualPropertyMetric
- intellectual = IntellectualProperty(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ intellectual = IntellectualProperty(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = intellectual._get_metric(IntellectualPropertyType.IMITATION)
assert isinstance(metric, IntellectualPropertyMetric)
assert metric.async_mode is True
@@ -101,7 +115,9 @@ class TestIntellectualProperty:
@pytest.mark.asyncio
async def test_a_assess_returns_async_results(self):
- intellectual = IntellectualProperty(types=["cooperative_dialogue"], async_mode=True)
+ intellectual = IntellectualProperty(
+ types=["cooperative_dialogue"], async_mode=True
+ )
async def dummy_model_callback(prompt):
return prompt
@@ -115,4 +131,4 @@ class TestIntellectualProperty:
assert len(results[IntellectualPropertyType.IMITATION]) == 1
test_case = results[IntellectualPropertyType.IMITATION][0]
assert hasattr(test_case, "score")
- assert hasattr(test_case, "reason")
\ No newline at end of file
+ assert hasattr(test_case, "reason")
diff --git a/tests/test_core/test_vulnerabilities/test_misinformation.py b/tests/test_core/test_vulnerabilities/test_misinformation.py
index 3dcbfea7..44037040 100644
--- a/tests/test_core/test_vulnerabilities/test_misinformation.py
+++ b/tests/test_core/test_vulnerabilities/test_misinformation.py
@@ -67,21 +67,31 @@ class TestMisinformation:
def test_simulate_attacks_returns_expected_cases(self):
misinformation = Misinformation(types=["factual_errors"])
- test_cases = misinformation.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = misinformation.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Misinformation" for tc in test_cases)
- assert all(tc.vulnerability_type == MisinformationType.FACTUAL_ERRORS for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == MisinformationType.FACTUAL_ERRORS
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
- misinformation = Misinformation(types=["factual_errors"], async_mode=False)
+ misinformation = Misinformation(
+ types=["factual_errors"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = misinformation.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = misinformation.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert MisinformationType.FACTUAL_ERRORS in results
assert len(results[MisinformationType.FACTUAL_ERRORS]) == 1
test_case = results[MisinformationType.FACTUAL_ERRORS][0]
@@ -92,7 +102,9 @@ class TestMisinformation:
def test_get_metric_returns_Misinformation_metric(self):
from deepteam.metrics.agentic import MisinterpretationMetric
- misinformation = Misinformation(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ misinformation = Misinformation(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = misinformation._get_metric(MisinformationType.FACTUAL_ERRORS)
assert isinstance(metric, MisinterpretationMetric)
assert metric.async_mode is True
@@ -100,7 +112,9 @@ class TestMisinformation:
@pytest.mark.asyncio
async def test_a_assess_returns_async_results(self):
- misinformation = Misinformation(types=["cooperative_dialogue"], async_mode=True)
+ misinformation = Misinformation(
+ types=["cooperative_dialogue"], async_mode=True
+ )
async def dummy_model_callback(prompt):
return prompt
diff --git a/tests/test_core/test_vulnerabilities/test_personal_safety.py b/tests/test_core/test_vulnerabilities/test_personal_safety.py
index 1105d351..26b6a153 100644
--- a/tests/test_core/test_vulnerabilities/test_personal_safety.py
+++ b/tests/test_core/test_vulnerabilities/test_personal_safety.py
@@ -80,7 +80,10 @@ class TestPersonalSafety:
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Personal Safety" for tc in test_cases)
- assert all(tc.vulnerability_type == PersonalSafetyType.BULLYING for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == PersonalSafetyType.BULLYING
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
safety = PersonalSafety(types=["bullying"], async_mode=False)
@@ -89,7 +92,10 @@ class TestPersonalSafety:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = safety.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = safety.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert PersonalSafetyType.BULLYING in results
assert len(results[PersonalSafetyType.BULLYING]) == 1
test_case = results[PersonalSafetyType.BULLYING][0]
@@ -100,7 +106,9 @@ class TestPersonalSafety:
def test_get_metric_returns_PersonalSafety_metric(self):
from deepteam.metrics import SafetyMetric
- safety = PersonalSafety(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ safety = PersonalSafety(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = safety._get_metric(PersonalSafetyType.BULLYING)
assert isinstance(metric, SafetyMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_pii_leakage.py b/tests/test_core/test_vulnerabilities/test_pii_leakage.py
index 78dae15b..0472160f 100644
--- a/tests/test_core/test_vulnerabilities/test_pii_leakage.py
+++ b/tests/test_core/test_vulnerabilities/test_pii_leakage.py
@@ -56,12 +56,17 @@ class TestPIILeakage:
def test_simulate_attacks_returns_expected_cases(self):
pii_lekage = PIILeakage(types=["session_leak"])
- test_cases = pii_lekage.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = pii_lekage.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "PII Lekage" for tc in test_cases)
- assert all(tc.vulnerability_type == PIILeakageType.SESSION_LEAK for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == PIILeakageType.SESSION_LEAK
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
pii_lekage = PIILeakage(types=["session_leak"], async_mode=False)
@@ -70,7 +75,10 @@ class TestPIILeakage:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = pii_lekage.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = pii_lekage.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert PIILeakageType.SESSION_LEAK in results
assert len(results[PIILeakageType.SESSION_LEAK]) == 1
test_case = results[PIILeakageType.SESSION_LEAK][0]
@@ -81,7 +89,9 @@ class TestPIILeakage:
def test_get_metric_returns_PIILeakage_metric(self):
from deepteam.metrics import PIIMetric
- pii_lekage = PIILeakage(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ pii_lekage = PIILeakage(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = pii_lekage._get_metric(PIILeakageType.SESSION_LEAK)
assert isinstance(metric, PIIMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_prompt_leakage.py b/tests/test_core/test_vulnerabilities/test_prompt_leakage.py
index 7e127038..2a7d8770 100644
--- a/tests/test_core/test_vulnerabilities/test_prompt_leakage.py
+++ b/tests/test_core/test_vulnerabilities/test_prompt_leakage.py
@@ -66,21 +66,31 @@ class TestPromptLeakage:
def test_simulate_attacks_returns_expected_cases(self):
prompt_lekage = PromptLeakage(types=["secrets_and_credentials"])
- test_cases = prompt_lekage.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = prompt_lekage.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Prompt Lekage" for tc in test_cases)
- assert all(tc.vulnerability_type == PromptLeakageType.SECRETS_AND_CREDENTIALS for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == PromptLeakageType.SECRETS_AND_CREDENTIALS
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
- prompt_lekage = PromptLeakage(types=["secrets_and_credentials"], async_mode=False)
+ prompt_lekage = PromptLeakage(
+ types=["secrets_and_credentials"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = prompt_lekage.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = prompt_lekage.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert PromptLeakageType.SECRETS_AND_CREDENTIALS in results
assert len(results[PromptLeakageType.SECRETS_AND_CREDENTIALS]) == 1
test_case = results[PromptLeakageType.SECRETS_AND_CREDENTIALS][0]
@@ -91,15 +101,21 @@ class TestPromptLeakage:
def test_get_metric_returns_PromptLeakage_metric(self):
from deepteam.metrics import PromptExtractionMetric
- prompt_lekage = PromptLeakage(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
- metric = prompt_lekage._get_metric(PromptLeakageType.SECRETS_AND_CREDENTIALS)
+ prompt_lekage = PromptLeakage(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
+ metric = prompt_lekage._get_metric(
+ PromptLeakageType.SECRETS_AND_CREDENTIALS
+ )
assert isinstance(metric, PromptExtractionMetric)
assert metric.async_mode is True
assert metric.verbose_mode is True
@pytest.mark.asyncio
async def test_a_assess_returns_async_results(self):
- prompt_lekage = PromptLeakage(types=["cooperative_dialogue"], async_mode=True)
+ prompt_lekage = PromptLeakage(
+ types=["cooperative_dialogue"], async_mode=True
+ )
async def dummy_model_callback(prompt):
return prompt
@@ -114,4 +130,3 @@ class TestPromptLeakage:
test_case = results[PromptLeakageType.SECRETS_AND_CREDENTIALS][0]
assert hasattr(test_case, "score")
assert hasattr(test_case, "reason")
-
diff --git a/tests/test_core/test_vulnerabilities/test_rbac.py b/tests/test_core/test_vulnerabilities/test_rbac.py
index 153bd5f4..4874f397 100644
--- a/tests/test_core/test_vulnerabilities/test_rbac.py
+++ b/tests/test_core/test_vulnerabilities/test_rbac.py
@@ -54,7 +54,9 @@ class TestRBAC:
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "RBAC" for tc in test_cases)
- assert all(tc.vulnerability_type == RBACType.ROLE_BYPASS for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == RBACType.ROLE_BYPASS for tc in test_cases
+ )
def test_assess_returns_results(self):
rbac = RBAC(types=["role_bypass"], async_mode=False)
@@ -63,7 +65,10 @@ class TestRBAC:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = rbac.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = rbac.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert RBACType.ROLE_BYPASS in results
assert len(results[RBACType.ROLE_BYPASS]) == 1
test_case = results[RBACType.ROLE_BYPASS][0]
@@ -74,7 +79,9 @@ class TestRBAC:
def test_get_metric_returns_RBAC_metric(self):
from deepteam.metrics import RBACMetric
- rbac = RBAC(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ rbac = RBAC(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = rbac._get_metric(RBACType.ROLE_BYPASS)
assert isinstance(metric, RBACMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_recursive_hijacking.py b/tests/test_core/test_vulnerabilities/test_recursive_hijacking.py
index ade9b6d0..5e5f1e61 100644
--- a/tests/test_core/test_vulnerabilities/test_recursive_hijacking.py
+++ b/tests/test_core/test_vulnerabilities/test_recursive_hijacking.py
@@ -58,24 +58,41 @@ class TestRecursiveHijacking:
RecursiveHijacking(types=types)
def test_simulate_attacks_returns_expected_cases(self):
- recursive_hijack = RecursiveHijacking(types=["goal_propagation_attacks"])
- test_cases = recursive_hijack.simulate_attacks(attacks_per_vulnerability_type=2)
+ recursive_hijack = RecursiveHijacking(
+ types=["goal_propagation_attacks"]
+ )
+ test_cases = recursive_hijack.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
- assert all(tc.vulnerability == "Recursive Hijacking" for tc in test_cases)
- assert all(tc.vulnerability_type == RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS for tc in test_cases)
+ assert all(
+ tc.vulnerability == "Recursive Hijacking" for tc in test_cases
+ )
+ assert all(
+ tc.vulnerability_type
+ == RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
- recursive_hijack = RecursiveHijacking(types=["goal_propagation_attacks"], async_mode=False)
+ recursive_hijack = RecursiveHijacking(
+ types=["goal_propagation_attacks"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = recursive_hijack.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = recursive_hijack.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS in results
- assert len(results[RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS]) == 1
+ assert (
+ len(results[RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS]) == 1
+ )
test_case = results[RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS][0]
# The score and reason will depend on the real metric evaluation
assert hasattr(test_case, "score")
@@ -84,15 +101,21 @@ class TestRecursiveHijacking:
def test_get_metric_returns_RecursiveHijacking_metric(self):
from deepteam.metrics.agentic import SubversionSuccessMetric
- recursive_hijack = RecursiveHijacking(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
- metric = recursive_hijack._get_metric(RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS)
+ recursive_hijack = RecursiveHijacking(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
+ metric = recursive_hijack._get_metric(
+ RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS
+ )
assert isinstance(metric, SubversionSuccessMetric)
assert metric.async_mode is True
assert metric.verbose_mode is True
@pytest.mark.asyncio
async def test_a_assess_returns_async_results(self):
- recursive_hijack = RecursiveHijacking(types=["cooperative_dialogue"], async_mode=True)
+ recursive_hijack = RecursiveHijacking(
+ types=["cooperative_dialogue"], async_mode=True
+ )
async def dummy_model_callback(prompt):
return prompt
@@ -103,7 +126,9 @@ class TestRecursiveHijacking:
)
assert RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS in results
- assert len(results[RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS]) == 1
+ assert (
+ len(results[RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS]) == 1
+ )
test_case = results[RecursiveHijackingType.GOAL_PROPAGATION_ATTACKS][0]
assert hasattr(test_case, "score")
assert hasattr(test_case, "reason")
diff --git a/tests/test_core/test_vulnerabilities/test_robustness.py b/tests/test_core/test_vulnerabilities/test_robustness.py
index 58e0137b..9348ede0 100644
--- a/tests/test_core/test_vulnerabilities/test_robustness.py
+++ b/tests/test_core/test_vulnerabilities/test_robustness.py
@@ -32,15 +32,20 @@ class TestRobustness:
types = ["input_overreliance", "hijacking", "invalid"]
with pytest.raises(ValueError):
Robustness(types=types)
-
+
def test_simulate_attacks_returns_expected_cases(self):
robustness = Robustness(types=["hijacking"])
- test_cases = robustness.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = robustness.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Robustness" for tc in test_cases)
- assert all(tc.vulnerability_type == RobustnessType.HIJACKING for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == RobustnessType.HIJACKING
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
robustness = Robustness(types=["hijacking"], async_mode=False)
@@ -49,7 +54,10 @@ class TestRobustness:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = robustness.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = robustness.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert RobustnessType.HIJACKING in results
assert len(results[RobustnessType.HIJACKING]) == 1
test_case = results[RobustnessType.HIJACKING][0]
@@ -60,7 +68,9 @@ class TestRobustness:
def test_get_metric_returns_Robustness_overreliance_metric(self):
from deepteam.metrics import OverrelianceMetric
- robustness = Robustness(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ robustness = Robustness(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = robustness._get_metric(RobustnessType.INPUT_OVERRELIANCE)
assert isinstance(metric, OverrelianceMetric)
assert metric.async_mode is True
@@ -69,7 +79,9 @@ class TestRobustness:
def test_get_metric_returns_Robustness_hijacking_metric(self):
from deepteam.metrics import HijackingMetric
- robustness = Robustness(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ robustness = Robustness(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = robustness._get_metric(RobustnessType.HIJACKING)
assert isinstance(metric, HijackingMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_shell_injection.py b/tests/test_core/test_vulnerabilities/test_shell_injection.py
index 402dc18a..084696fa 100644
--- a/tests/test_core/test_vulnerabilities/test_shell_injection.py
+++ b/tests/test_core/test_vulnerabilities/test_shell_injection.py
@@ -57,21 +57,31 @@ class TestShellInjection:
def test_simulate_attacks_returns_expected_cases(self):
shell_injection = ShellInjection(types=["command_injection"])
- test_cases = shell_injection.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = shell_injection.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Shell Injection" for tc in test_cases)
- assert all(tc.vulnerability_type == ShellInjectionType.COMMAND_INJECTION for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == ShellInjectionType.COMMAND_INJECTION
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
- shell_injection = ShellInjection(types=["command_injection"], async_mode=False)
+ shell_injection = ShellInjection(
+ types=["command_injection"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = shell_injection.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = shell_injection.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert ShellInjectionType.COMMAND_INJECTION in results
assert len(results[ShellInjectionType.COMMAND_INJECTION]) == 1
test_case = results[ShellInjectionType.COMMAND_INJECTION][0]
@@ -82,15 +92,21 @@ class TestShellInjection:
def test_get_metric_returns_ShellInjection_metric(self):
from deepteam.metrics import ShellInjectionMetric
- shell_injection = ShellInjection(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
- metric = shell_injection._get_metric(ShellInjectionType.COMMAND_INJECTION)
+ shell_injection = ShellInjection(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
+ metric = shell_injection._get_metric(
+ ShellInjectionType.COMMAND_INJECTION
+ )
assert isinstance(metric, ShellInjectionMetric)
assert metric.async_mode is True
assert metric.verbose_mode is True
@pytest.mark.asyncio
async def test_a_assess_returns_async_results(self):
- shell_injection = ShellInjection(types=["cooperative_dialogue"], async_mode=True)
+ shell_injection = ShellInjection(
+ types=["cooperative_dialogue"], async_mode=True
+ )
async def dummy_model_callback(prompt):
return prompt
diff --git a/tests/test_core/test_vulnerabilities/test_sql_injection.py b/tests/test_core/test_vulnerabilities/test_sql_injection.py
index 5e00c17a..e37bb1a8 100644
--- a/tests/test_core/test_vulnerabilities/test_sql_injection.py
+++ b/tests/test_core/test_vulnerabilities/test_sql_injection.py
@@ -57,21 +57,31 @@ class TestSQLInjection:
def test_simulate_attacks_returns_expected_cases(self):
sql_injection = SQLInjection(types=["blind_sql_injection"])
- test_cases = sql_injection.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = sql_injection.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "SQL Injection" for tc in test_cases)
- assert all(tc.vulnerability_type == SQLInjectionType.BLIND_SQL_INJECTION for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == SQLInjectionType.BLIND_SQL_INJECTION
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
- sql_injection = SQLInjection(types=["blind_sql_injection"], async_mode=False)
+ sql_injection = SQLInjection(
+ types=["blind_sql_injection"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = sql_injection.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = sql_injection.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert SQLInjectionType.BLIND_SQL_INJECTION in results
assert len(results[SQLInjectionType.BLIND_SQL_INJECTION]) == 1
test_case = results[SQLInjectionType.BLIND_SQL_INJECTION][0]
@@ -82,7 +92,9 @@ class TestSQLInjection:
def test_get_metric_returns_SQLInjection_metric(self):
from deepteam.metrics import SQLInjectionMetric
- sql_injection = SQLInjection(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ sql_injection = SQLInjection(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = sql_injection._get_metric(SQLInjectionType.BLIND_SQL_INJECTION)
assert isinstance(metric, SQLInjectionMetric)
assert metric.async_mode is True
@@ -90,7 +102,9 @@ class TestSQLInjection:
@pytest.mark.asyncio
async def test_a_assess_returns_async_results(self):
- sql_injection = SQLInjection(types=["cooperative_dialogue"], async_mode=True)
+ sql_injection = SQLInjection(
+ types=["cooperative_dialogue"], async_mode=True
+ )
async def dummy_model_callback(prompt):
return prompt
diff --git a/tests/test_core/test_vulnerabilities/test_ssrf.py b/tests/test_core/test_vulnerabilities/test_ssrf.py
index 8b02af06..198358eb 100644
--- a/tests/test_core/test_vulnerabilities/test_ssrf.py
+++ b/tests/test_core/test_vulnerabilities/test_ssrf.py
@@ -54,7 +54,10 @@ class TestSSRF:
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "SSRF" for tc in test_cases)
- assert all(tc.vulnerability_type == SSRFType.CLOUD_METADATA_ACCESS for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == SSRFType.CLOUD_METADATA_ACCESS
+ for tc in test_cases
+ )
def test_assess_returns_results(self):
ssrf = SSRF(types=["cloud_metadata_access"], async_mode=False)
@@ -63,7 +66,10 @@ class TestSSRF:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = ssrf.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = ssrf.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert SSRFType.CLOUD_METADATA_ACCESS in results
assert len(results[SSRFType.CLOUD_METADATA_ACCESS]) == 1
test_case = results[SSRFType.CLOUD_METADATA_ACCESS][0]
@@ -74,7 +80,9 @@ class TestSSRF:
def test_get_metric_returns_SSRF_metric(self):
from deepteam.metrics import SSRFMetric
- ssrf = SSRF(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ ssrf = SSRF(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = ssrf._get_metric(SSRFType.CLOUD_METADATA_ACCESS)
assert isinstance(metric, SSRFMetric)
assert metric.async_mode is True
diff --git a/tests/test_core/test_vulnerabilities/test_toxicity.py b/tests/test_core/test_vulnerabilities/test_toxicity.py
index 7b256071..e23cf998 100644
--- a/tests/test_core/test_vulnerabilities/test_toxicity.py
+++ b/tests/test_core/test_vulnerabilities/test_toxicity.py
@@ -50,7 +50,9 @@ class TestToxicity:
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Toxicity" for tc in test_cases)
- assert all(tc.vulnerability_type == ToxicityType.INSULTS for tc in test_cases)
+ assert all(
+ tc.vulnerability_type == ToxicityType.INSULTS for tc in test_cases
+ )
def test_assess_returns_results(self):
toxicity = Toxicity(types=["insults"], async_mode=False)
@@ -59,7 +61,10 @@ class TestToxicity:
# Provide a simple pass-through or minimal callback if required by your real env
return prompt
- results = toxicity.assess(model_callback=dummy_model_callback, attacks_per_vulnerability_type=1)
+ results = toxicity.assess(
+ model_callback=dummy_model_callback,
+ attacks_per_vulnerability_type=1,
+ )
assert ToxicityType.INSULTS in results
assert len(results[ToxicityType.INSULTS]) == 1
test_case = results[ToxicityType.INSULTS][0]
@@ -70,7 +75,9 @@ class TestToxicity:
def test_get_metric_returns_Toxicity_metric(self):
from deepteam.metrics import ToxicityMetric
- toxicity = Toxicity(async_mode=True, verbose_mode=True, evaluation_model="gpt-4o")
+ toxicity = Toxicity(
+ async_mode=True, verbose_mode=True, evaluation_model="gpt-4o"
+ )
metric = toxicity._get_metric(ToxicityType.INSULTS)
assert isinstance(metric, ToxicityMetric)
assert metric.async_mode is True