Skip to content

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

reformat

penguine11621812171d
diff --git a/deepteam/red_teamer/red_teamer.py b/deepteam/red_teamer/red_teamer.py
index db9fa914..33a99fb0 100644
--- a/deepteam/red_teamer/red_teamer.py
+++ b/deepteam/red_teamer/red_teamer.py
@@ -208,8 +208,10 @@ class RedTeamer:
for simulated_attack in simulated_attacks:
for vulnerability in vulnerabilities:
if vulnerability_type in vulnerability.types:
- metric: BaseRedTeamingMetric = vulnerability._get_metric(
- vulnerability_type
+ metric: BaseRedTeamingMetric = (
+ vulnerability._get_metric(
+ vulnerability_type
+ )
)
break
diff --git a/deepteam/vulnerabilities/agentic/excessive_agency/excessive_agency.py b/deepteam/vulnerabilities/agentic/excessive_agency/excessive_agency.py
index 72a04123..07253841 100644
--- a/deepteam/vulnerabilities/agentic/excessive_agency/excessive_agency.py
+++ b/deepteam/vulnerabilities/agentic/excessive_agency/excessive_agency.py
@@ -34,14 +34,14 @@ class ExcessiveAgency(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: ExcessiveAgencyType,
- ):
+ self,
+ type: ExcessiveAgencyType,
+ ):
return ExcessiveAgencyMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/agentic/goal_theft/goal_theft.py b/deepteam/vulnerabilities/agentic/goal_theft/goal_theft.py
index 93b4e257..46f1b882 100644
--- a/deepteam/vulnerabilities/agentic/goal_theft/goal_theft.py
+++ b/deepteam/vulnerabilities/agentic/goal_theft/goal_theft.py
@@ -5,7 +5,9 @@ from deepeval.models import DeepEvalBaseLLM
from deepteam.vulnerabilities import BaseVulnerability
from deepteam.vulnerabilities.agentic.goal_theft import GoalTheftType
from deepteam.vulnerabilities.utils import validate_vulnerability_types
-from deepteam.metrics.agentic.extraction_success.extraction_success import ExtractionSuccessMetric
+from deepteam.metrics.agentic.extraction_success.extraction_success import (
+ ExtractionSuccessMetric,
+)
GoalTheftLiteralType = Literal[
"escalating_probing", "cooperative_dialogue", "social_engineering"
@@ -33,14 +35,14 @@ class GoalTheft(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: GoalTheftType,
- ):
+ self,
+ type: GoalTheftType,
+ ):
return ExtractionSuccessMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/agentic/recursive_hijacking/recursive_hijacking.py b/deepteam/vulnerabilities/agentic/recursive_hijacking/recursive_hijacking.py
index b8e97d56..c011a480 100644
--- a/deepteam/vulnerabilities/agentic/recursive_hijacking/recursive_hijacking.py
+++ b/deepteam/vulnerabilities/agentic/recursive_hijacking/recursive_hijacking.py
@@ -7,7 +7,9 @@ from deepteam.vulnerabilities.agentic.recursive_hijacking import (
RecursiveHijackingType,
)
from deepteam.vulnerabilities.utils import validate_vulnerability_types
-from deepteam.metrics.agentic.subversion_success.subversion_success import SubversionSuccessMetric
+from deepteam.metrics.agentic.subversion_success.subversion_success import (
+ SubversionSuccessMetric,
+)
RecursiveHijackingLiteralType = Literal[
"self_modifying_goals",
@@ -37,14 +39,14 @@ class RecursiveHijacking(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: RecursiveHijackingType,
- ):
+ self,
+ type: RecursiveHijackingType,
+ ):
return SubversionSuccessMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/agentic/robustness/robustness.py b/deepteam/vulnerabilities/agentic/robustness/robustness.py
index e371d3e4..244eeede 100644
--- a/deepteam/vulnerabilities/agentic/robustness/robustness.py
+++ b/deepteam/vulnerabilities/agentic/robustness/robustness.py
@@ -32,22 +32,22 @@ class Robustness(BaseVulnerability):
# TODO: Different metrics for different types. Forces us to use type in the `_get_metric` call.
def _get_metric(
- self,
- type: RobustnessType,
- ):
- if type == RobustnessType.HIJACKING:
+ self,
+ type: RobustnessType,
+ ):
+ if type == RobustnessType.HIJACKING:
return HijackingMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
if type == RobustnessType.INPUT_OVERRELIANCE:
return OverrelianceMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
raise ValueError(
"Invalid type passed in the 'get_metric' function. Please pass an enum from 'RobustnessType'"
diff --git a/deepteam/vulnerabilities/base_vulnerability.py b/deepteam/vulnerabilities/base_vulnerability.py
index 846b447e..bf3400fd 100644
--- a/deepteam/vulnerabilities/base_vulnerability.py
+++ b/deepteam/vulnerabilities/base_vulnerability.py
@@ -28,7 +28,7 @@ class BaseVulnerability(ABC):
:return: List of string values from the Enum types.
"""
return [t.value for t in self.types]
-
+
def _get_metric(self) -> BaseRedTeamingMetric:
"""
Get the corresponding metric of the vulnerability.
diff --git a/deepteam/vulnerabilities/bfla/bfla.py b/deepteam/vulnerabilities/bfla/bfla.py
index d103d196..53e8406f 100644
--- a/deepteam/vulnerabilities/bfla/bfla.py
+++ b/deepteam/vulnerabilities/bfla/bfla.py
@@ -33,14 +33,14 @@ class BFLA(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: BFLAType,
- ):
+ self,
+ type: BFLAType,
+ ):
return BFLAMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/bias/bias.py b/deepteam/vulnerabilities/bias/bias.py
index 3e859565..eeb4ce8a 100644
--- a/deepteam/vulnerabilities/bias/bias.py
+++ b/deepteam/vulnerabilities/bias/bias.py
@@ -19,13 +19,16 @@ from .template import BiasTemplate
BiasLiteralType = Literal["religion", "politics", "gender", "race"]
+
class Bias(BaseVulnerability):
def __init__(
self,
purpose: str,
async_mode: bool = True,
verbose_mode: bool = False,
- simulator_model: Optional[Union[str, DeepEvalBaseLLM]] = "gpt-3.5-turbo-0125",
+ simulator_model: Optional[
+ Union[str, DeepEvalBaseLLM]
+ ] = "gpt-3.5-turbo-0125",
evaluation_model: Optional[Union[str, DeepEvalBaseLLM]] = "gpt-4o",
types: Optional[List[BiasLiteralType]] = [
type.value for type in BiasType
@@ -67,9 +70,11 @@ class Bias(BaseVulnerability):
assert not inspect.iscoroutinefunction(
model_callback
), "`model_callback` needs to be sync. `async_mode` has been set to False."
-
- simulated_attacks = self.simulate_attacks(attacks_per_vulnerability_type)
-
+
+ simulated_attacks = self.simulate_attacks(
+ attacks_per_vulnerability_type
+ )
+
results: Dict[BiasType, List[RedTeamingTestCase]] = dict()
for simulated_attack in simulated_attacks:
@@ -77,8 +82,7 @@ class Bias(BaseVulnerability):
target_output = model_callback(simulated_attack.input)
test_case = LLMTestCase(
- input=simulated_attack.input,
- actual_output=target_output
+ input=simulated_attack.input, actual_output=target_output
)
metric = self._get_metric(vulnerability_type)
@@ -97,7 +101,7 @@ class Bias(BaseVulnerability):
results[vulnerability_type] = results.get(vulnerability_type, [])
results[vulnerability_type].append(red_teaming_test_case)
-
+
return results
async def a_assess(
@@ -120,8 +124,10 @@ class Bias(BaseVulnerability):
async with semaphore:
return await model_callback(prompt)
- simulated_attacks = await self.a_simulate_attacks(attacks_per_vulnerability_type)
-
+ simulated_attacks = await self.a_simulate_attacks(
+ attacks_per_vulnerability_type
+ )
+
results: Dict[BiasType, List[RedTeamingTestCase]] = dict()
async def process_attack(simulated_attack: SimulatedAttack):
@@ -162,13 +168,15 @@ class Bias(BaseVulnerability):
results.setdefault(vulnerability_type, []).append(test_case)
return results
-
+
def simulate_attacks(
- self,
- attacks_per_vulnerability_type: int = 1,
- ) -> List[SimulatedAttack]:
+ self,
+ attacks_per_vulnerability_type: int = 1,
+ ) -> List[SimulatedAttack]:
- self.simulator_model, self.using_native_model = initialize_model(self.simulator_model)
+ self.simulator_model, self.using_native_model = initialize_model(
+ self.simulator_model
+ )
templates = dict()
simulated_attacks: List[SimulatedAttack] = []
@@ -177,12 +185,10 @@ class Bias(BaseVulnerability):
templates[type] = templates.get(type, [])
templates[type].append(
BiasTemplate.generate_baseline_attacks(
- type,
- attacks_per_vulnerability_type,
- self.purpose
+ type, attacks_per_vulnerability_type, self.purpose
)
)
-
+
for type in self.types:
for prompt in templates[type]:
if self.using_native_model:
@@ -201,23 +207,27 @@ class Bias(BaseVulnerability):
data = trimAndLoadJson(res)
local_attacks = [item["input"] for item in data["data"]]
- simulated_attacks.extend([
- SimulatedAttack(
- vulnerability=self.get_name(),
- vulnerability_type=type,
- input=local_attack,
- )
- for local_attack in local_attacks
- ])
-
+ simulated_attacks.extend(
+ [
+ SimulatedAttack(
+ vulnerability=self.get_name(),
+ vulnerability_type=type,
+ input=local_attack,
+ )
+ for local_attack in local_attacks
+ ]
+ )
+
return simulated_attacks
-
+
async def a_simulate_attacks(
self,
attacks_per_vulnerability_type: int = 1,
) -> List[SimulatedAttack]:
-
- self.simulator_model, self.using_native_model = initialize_model(self.simulator_model)
+
+ self.simulator_model, self.using_native_model = initialize_model(
+ self.simulator_model
+ )
templates = dict()
simulated_attacks: List[SimulatedAttack] = []
@@ -226,12 +236,10 @@ class Bias(BaseVulnerability):
templates[type] = templates.get(type, [])
templates[type].append(
BiasTemplate.generate_baseline_attacks(
- type,
- attacks_per_vulnerability_type,
- self.purpose
+ type, attacks_per_vulnerability_type, self.purpose
)
)
-
+
for type in self.types:
for prompt in templates[type]:
if self.using_native_model:
@@ -241,8 +249,10 @@ class Bias(BaseVulnerability):
local_attacks = [item.input for item in res.data]
else:
try:
- res: SyntheticDataList = await self.simulator_model.a_generate(
- prompt, schema=SyntheticDataList
+ res: SyntheticDataList = (
+ await self.simulator_model.a_generate(
+ prompt, schema=SyntheticDataList
+ )
)
local_attacks = [item.input for item in res.data]
except TypeError:
@@ -250,26 +260,28 @@ class Bias(BaseVulnerability):
data = trimAndLoadJson(res)
local_attacks = [item["input"] for item in data["data"]]
- simulated_attacks.extend([
- SimulatedAttack(
- vulnerability=self.get_name(),
- vulnerability_type=type,
- input=local_attack,
- )
- for local_attack in local_attacks
- ])
-
+ simulated_attacks.extend(
+ [
+ SimulatedAttack(
+ vulnerability=self.get_name(),
+ vulnerability_type=type,
+ input=local_attack,
+ )
+ for local_attack in local_attacks
+ ]
+ )
+
return simulated_attacks
-
+
def _get_metric(
- self,
- type: BiasType,
- ) -> BaseRedTeamingMetric:
+ self,
+ type: BiasType,
+ ) -> BaseRedTeamingMetric:
return BiasMetric(
purpose=self.purpose,
model=self.evaluation_model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/bola/bola.py b/deepteam/vulnerabilities/bola/bola.py
index 7949970a..070c8169 100644
--- a/deepteam/vulnerabilities/bola/bola.py
+++ b/deepteam/vulnerabilities/bola/bola.py
@@ -31,13 +31,13 @@ class BOLA(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: BOLAType,
- ):
+ self,
+ type: BOLAType,
+ ):
return BOLAMetric(
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/competition/competition.py b/deepteam/vulnerabilities/competition/competition.py
index a2bd265a..c8f545cb 100644
--- a/deepteam/vulnerabilities/competition/competition.py
+++ b/deepteam/vulnerabilities/competition/competition.py
@@ -37,14 +37,14 @@ class Competition(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: CompetitionType,
- ):
+ self,
+ type: CompetitionType,
+ ):
return CompetitorsMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/custom/custom.py b/deepteam/vulnerabilities/custom/custom.py
index 91d3d5d7..b2f83289 100644
--- a/deepteam/vulnerabilities/custom/custom.py
+++ b/deepteam/vulnerabilities/custom/custom.py
@@ -42,7 +42,7 @@ class CustomVulnerability(BaseVulnerability):
harm_category=self.criteria,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
super().__init__(self.types)
diff --git a/deepteam/vulnerabilities/debug_access/debug_access.py b/deepteam/vulnerabilities/debug_access/debug_access.py
index af7d96d7..a0dadeb3 100644
--- a/deepteam/vulnerabilities/debug_access/debug_access.py
+++ b/deepteam/vulnerabilities/debug_access/debug_access.py
@@ -33,13 +33,13 @@ class DebugAccess(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: DebugAccessType,
- ):
+ self,
+ type: DebugAccessType,
+ ):
return DebugAccessMetric(
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/graphic_content/graphic_content.py b/deepteam/vulnerabilities/graphic_content/graphic_content.py
index 27a8d7df..32d8eb59 100644
--- a/deepteam/vulnerabilities/graphic_content/graphic_content.py
+++ b/deepteam/vulnerabilities/graphic_content/graphic_content.py
@@ -33,14 +33,14 @@ class GraphicContent(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: GraphicContentType,
- ):
+ self,
+ type: GraphicContentType,
+ ):
return GraphicMetric(
graphic_category=self.graphic_category,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/illegal_activity/illegal_activity.py b/deepteam/vulnerabilities/illegal_activity/illegal_activity.py
index c52e20ce..a62dbb0c 100644
--- a/deepteam/vulnerabilities/illegal_activity/illegal_activity.py
+++ b/deepteam/vulnerabilities/illegal_activity/illegal_activity.py
@@ -39,14 +39,14 @@ class IllegalActivity(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: IllegalActivityType,
- ):
+ self,
+ type: IllegalActivityType,
+ ):
return IllegalMetric(
illegal_category=self.illegal_category,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/intellectual_property/intellectual_property.py b/deepteam/vulnerabilities/intellectual_property/intellectual_property.py
index 544c5489..802e52ef 100644
--- a/deepteam/vulnerabilities/intellectual_property/intellectual_property.py
+++ b/deepteam/vulnerabilities/intellectual_property/intellectual_property.py
@@ -40,14 +40,14 @@ class IntellectualProperty(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: IntellectualPropertyType,
- ):
+ self,
+ type: IntellectualPropertyType,
+ ):
return IntellectualPropertyMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/misinformation/misinformation.py b/deepteam/vulnerabilities/misinformation/misinformation.py
index 62d1aa27..9de9889e 100644
--- a/deepteam/vulnerabilities/misinformation/misinformation.py
+++ b/deepteam/vulnerabilities/misinformation/misinformation.py
@@ -34,14 +34,14 @@ class Misinformation(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: MisinformationType,
- ):
+ self,
+ type: MisinformationType,
+ ):
return MisinformationMetric(
misinformation_category=self.misinformation_category,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/personal_safety/personal_safety.py b/deepteam/vulnerabilities/personal_safety/personal_safety.py
index 1975478c..c5894283 100644
--- a/deepteam/vulnerabilities/personal_safety/personal_safety.py
+++ b/deepteam/vulnerabilities/personal_safety/personal_safety.py
@@ -37,14 +37,14 @@ class PersonalSafety(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: PersonalSafetyType,
- ):
+ self,
+ type: PersonalSafetyType,
+ ):
return SafetyMetric(
safety_category=self.safety_category,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/pii_leakage/pii_leakage.py b/deepteam/vulnerabilities/pii_leakage/pii_leakage.py
index 840fecd3..e77b5e33 100644
--- a/deepteam/vulnerabilities/pii_leakage/pii_leakage.py
+++ b/deepteam/vulnerabilities/pii_leakage/pii_leakage.py
@@ -34,16 +34,16 @@ class PIILeakage(BaseVulnerability):
self.async_mode = async_mode
self.verbose_mode = verbose_mode
super().__init__(types=enum_types)
-
+
def _get_metric(
- self,
- type: PIILeakageType,
- ):
+ self,
+ type: PIILeakageType,
+ ):
return PIIMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/prompt_leakage/prompt_leakage.py b/deepteam/vulnerabilities/prompt_leakage/prompt_leakage.py
index 2c1971e2..ed53fa90 100644
--- a/deepteam/vulnerabilities/prompt_leakage/prompt_leakage.py
+++ b/deepteam/vulnerabilities/prompt_leakage/prompt_leakage.py
@@ -36,14 +36,14 @@ class PromptLeakage(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: PromptLeakageType,
- ):
+ self,
+ type: PromptLeakageType,
+ ):
return PromptExtractionMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/rbac/rbac.py b/deepteam/vulnerabilities/rbac/rbac.py
index 4f830458..a09453e7 100644
--- a/deepteam/vulnerabilities/rbac/rbac.py
+++ b/deepteam/vulnerabilities/rbac/rbac.py
@@ -33,14 +33,14 @@ class RBAC(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: RBACType,
- ):
+ self,
+ type: RBACType,
+ ):
return RBACMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/shell_injection/shell_injection.py b/deepteam/vulnerabilities/shell_injection/shell_injection.py
index 5b4289ef..813fccc3 100644
--- a/deepteam/vulnerabilities/shell_injection/shell_injection.py
+++ b/deepteam/vulnerabilities/shell_injection/shell_injection.py
@@ -33,13 +33,13 @@ class ShellInjection(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: ShellInjectionType,
- ):
+ self,
+ type: ShellInjectionType,
+ ):
return ShellInjectionMetric(
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/sql_injection/sql_injection.py b/deepteam/vulnerabilities/sql_injection/sql_injection.py
index 38931c60..ec20c5b8 100644
--- a/deepteam/vulnerabilities/sql_injection/sql_injection.py
+++ b/deepteam/vulnerabilities/sql_injection/sql_injection.py
@@ -33,13 +33,13 @@ class SQLInjection(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: SQLInjectionType,
- ):
+ self,
+ type: SQLInjectionType,
+ ):
return SQLInjectionMetric(
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/ssrf/ssrf.py b/deepteam/vulnerabilities/ssrf/ssrf.py
index 9541c3de..fa8c766a 100644
--- a/deepteam/vulnerabilities/ssrf/ssrf.py
+++ b/deepteam/vulnerabilities/ssrf/ssrf.py
@@ -33,14 +33,14 @@ class SSRF(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: SSRFType,
- ):
+ self,
+ type: SSRFType,
+ ):
return SSRFMetric(
purpose=self.purpose,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/deepteam/vulnerabilities/toxicity/toxicity.py b/deepteam/vulnerabilities/toxicity/toxicity.py
index 29178674..f956c1e9 100644
--- a/deepteam/vulnerabilities/toxicity/toxicity.py
+++ b/deepteam/vulnerabilities/toxicity/toxicity.py
@@ -31,14 +31,14 @@ class Toxicity(BaseVulnerability):
super().__init__(types=enum_types)
def _get_metric(
- self,
- type: ToxicityType,
- ):
+ self,
+ type: ToxicityType,
+ ):
return ToxicityMetric(
toxicity_category=self.toxicity_category,
model=self.model,
async_mode=self.async_mode,
- verbose_mode=self.verbose_mode
+ verbose_mode=self.verbose_mode,
)
def get_name(self) -> str:
diff --git a/tests/test_core/test_red_teaming.py b/tests/test_core/test_red_teaming.py
index c8f9e1cb..60164cc5 100644
--- a/tests/test_core/test_red_teaming.py
+++ b/tests/test_core/test_red_teaming.py
@@ -9,12 +9,12 @@ async def model_callback(input: str) -> str:
def test_red_teaming():
- PURPOSE="purpose"
- TOXICITY="category"
- GRAPHIC="category"
- SAFETY="category"
- MISINFORMATION="category"
- ILLEGAL="category"
+ PURPOSE = "purpose"
+ TOXICITY = "category"
+ GRAPHIC = "category"
+ SAFETY = "category"
+ MISINFORMATION = "category"
+ ILLEGAL = "category"
custom_vulnerability = CustomVulnerability(
criteria="Criteria",
diff --git a/tests/test_core/test_vulnerabilities/test_all.py b/tests/test_core/test_vulnerabilities/test_all.py
index b0d3b0d8..be830967 100644
--- a/tests/test_core/test_vulnerabilities/test_all.py
+++ b/tests/test_core/test_vulnerabilities/test_all.py
@@ -8,12 +8,12 @@ async def model_callback(input: str) -> str:
def test_red_teaming():
- PURPOSE="purpose"
- TOXICITY="category"
- GRAPHIC="category"
- SAFETY="category"
- MISINFORMATION="category"
- ILLEGAL="category"
+ PURPOSE = "purpose"
+ TOXICITY = "category"
+ GRAPHIC = "category"
+ SAFETY = "category"
+ MISINFORMATION = "category"
+ ILLEGAL = "category"
custom_vulnerability = CustomVulnerability(
criteria="Criteria",
diff --git a/tests/test_core/test_vulnerabilities/test_bfla.py b/tests/test_core/test_vulnerabilities/test_bfla.py
index 290ee727..e55ca060 100644
--- a/tests/test_core/test_vulnerabilities/test_bfla.py
+++ b/tests/test_core/test_vulnerabilities/test_bfla.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.bfla import BFLAType
class TestBFLA:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_bfla_all_types(self):
types = [
@@ -17,7 +17,9 @@ class TestBFLA:
assert sorted(type.value for type in bfla.types) == sorted(types)
def test_bfla_all_types_default(self):
- bfla = BFLA(purpose=TestBFLA.PURPOSE, )
+ bfla = BFLA(
+ purpose=TestBFLA.PURPOSE,
+ )
assert sorted(type.value for type in bfla.types) == sorted(
type.value for type in BFLAType
)
diff --git a/tests/test_core/test_vulnerabilities/test_bias.py b/tests/test_core/test_vulnerabilities/test_bias.py
index ac4a678a..3f5e6e64 100644
--- a/tests/test_core/test_vulnerabilities/test_bias.py
+++ b/tests/test_core/test_vulnerabilities/test_bias.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.bias import BiasType
class TestBias:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_bias_all_types(self):
types = ["gender", "politics", "religion", "race"]
@@ -13,7 +13,9 @@ class TestBias:
assert sorted(type.value for type in bias.types) == sorted(types)
def test_bias_all_types_default(self):
- bias = Bias(purpose=TestBias.PURPOSE, )
+ bias = Bias(
+ purpose=TestBias.PURPOSE,
+ )
assert sorted(type.value for type in bias.types) == sorted(
type.value for type in BiasType
)
diff --git a/tests/test_core/test_vulnerabilities/test_competition.py b/tests/test_core/test_vulnerabilities/test_competition.py
index 4eb21182..c9eb7d1b 100644
--- a/tests/test_core/test_vulnerabilities/test_competition.py
+++ b/tests/test_core/test_vulnerabilities/test_competition.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.competition import CompetitionType
class TestCompetition:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_competition_all_types(self):
types = [
@@ -18,7 +18,9 @@ class TestCompetition:
assert sorted(type.value for type in competition.types) == sorted(types)
def test_competition_all_types_default(self):
- competition = Competition(purpose=TestCompetition.PURPOSE, )
+ competition = Competition(
+ purpose=TestCompetition.PURPOSE,
+ )
assert sorted(type.value for type in competition.types) == sorted(
type.value for type in CompetitionType
)
diff --git a/tests/test_core/test_vulnerabilities/test_excessive_agency.py b/tests/test_core/test_vulnerabilities/test_excessive_agency.py
index 50243d65..b61df40f 100644
--- a/tests/test_core/test_vulnerabilities/test_excessive_agency.py
+++ b/tests/test_core/test_vulnerabilities/test_excessive_agency.py
@@ -7,38 +7,48 @@ from deepteam.vulnerabilities.agentic.excessive_agency import (
class TestExcessiveAgency:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_excessive_agency_all_types(self):
types = ["functionality", "permissions", "autonomy"]
- excessive_agency = ExcessiveAgency(purpose=TestExcessiveAgency.PURPOSE, types=types)
+ excessive_agency = ExcessiveAgency(
+ purpose=TestExcessiveAgency.PURPOSE, types=types
+ )
assert sorted(type.value for type in excessive_agency.types) == sorted(
types
)
def test_excessive_agency_all_types_default(self):
- excessive_agency = ExcessiveAgency(purpose=TestExcessiveAgency.PURPOSE, )
+ excessive_agency = ExcessiveAgency(
+ purpose=TestExcessiveAgency.PURPOSE,
+ )
assert sorted(type.value for type in excessive_agency.types) == sorted(
type.value for type in ExcessiveAgencyType
)
def test_excessive_agency_functionality(self):
types = ["functionality"]
- excessive_agency = ExcessiveAgency(purpose=TestExcessiveAgency.PURPOSE, types=types)
+ excessive_agency = ExcessiveAgency(
+ purpose=TestExcessiveAgency.PURPOSE, types=types
+ )
assert sorted(type.value for type in excessive_agency.types) == sorted(
types
)
def test_excessive_agency_permissions(self):
types = ["permissions"]
- excessive_agency = ExcessiveAgency(purpose=TestExcessiveAgency.PURPOSE, types=types)
+ excessive_agency = ExcessiveAgency(
+ purpose=TestExcessiveAgency.PURPOSE, types=types
+ )
assert sorted(type.value for type in excessive_agency.types) == sorted(
types
)
def test_excessive_agency_autonomy(self):
types = ["autonomy"]
- excessive_agency = ExcessiveAgency(purpose=TestExcessiveAgency.PURPOSE, types=types)
+ excessive_agency = ExcessiveAgency(
+ purpose=TestExcessiveAgency.PURPOSE, types=types
+ )
assert sorted(type.value for type in excessive_agency.types) == sorted(
types
)
diff --git a/tests/test_core/test_vulnerabilities/test_goal_theft.py b/tests/test_core/test_vulnerabilities/test_goal_theft.py
index 2e0af11b..70015d8d 100644
--- a/tests/test_core/test_vulnerabilities/test_goal_theft.py
+++ b/tests/test_core/test_vulnerabilities/test_goal_theft.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.agentic.goal_theft import GoalTheftType
class TestGoalTheft:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_goal_theft_all_types(self):
types = [
@@ -17,7 +17,9 @@ class TestGoalTheft:
assert sorted(type.value for type in goal_theft.types) == sorted(types)
def test_goal_theft_all_types_default(self):
- goal_theft = GoalTheft(purpose=TestGoalTheft.PURPOSE, )
+ goal_theft = GoalTheft(
+ purpose=TestGoalTheft.PURPOSE,
+ )
assert sorted(type.value for type in goal_theft.types) == sorted(
type.value for type in GoalTheftType
)
diff --git a/tests/test_core/test_vulnerabilities/test_graphic_content.py b/tests/test_core/test_vulnerabilities/test_graphic_content.py
index db17aa53..9d6fbac2 100644
--- a/tests/test_core/test_vulnerabilities/test_graphic_content.py
+++ b/tests/test_core/test_vulnerabilities/test_graphic_content.py
@@ -5,38 +5,48 @@ from deepteam.vulnerabilities.graphic_content import GraphicContentType
class TestGraphicContent:
- GRAPHIC="category"
+ GRAPHIC = "category"
def test_graphic_content_all_types(self):
types = ["sexual content", "graphic content", "pornographic content"]
- graphic_content = GraphicContent(graphic_category=TestGraphicContent.GRAPHIC, types=types)
+ graphic_content = GraphicContent(
+ graphic_category=TestGraphicContent.GRAPHIC, types=types
+ )
assert sorted(type.value for type in graphic_content.types) == sorted(
types
)
def test_graphic_content_all_types_default(self):
- graphic_content = GraphicContent(graphic_category=TestGraphicContent.GRAPHIC, )
+ graphic_content = GraphicContent(
+ graphic_category=TestGraphicContent.GRAPHIC,
+ )
assert sorted(type.value for type in graphic_content.types) == sorted(
type.value for type in GraphicContentType
)
def test_graphic_content_sexual_content(self):
types = ["sexual content"]
- graphic_content = GraphicContent(graphic_category=TestGraphicContent.GRAPHIC, types=types)
+ graphic_content = GraphicContent(
+ graphic_category=TestGraphicContent.GRAPHIC, types=types
+ )
assert sorted(type.value for type in graphic_content.types) == sorted(
types
)
def test_graphic_content_graphic_content(self):
types = ["graphic content"]
- graphic_content = GraphicContent(graphic_category=TestGraphicContent.GRAPHIC, types=types)
+ graphic_content = GraphicContent(
+ graphic_category=TestGraphicContent.GRAPHIC, types=types
+ )
assert sorted(type.value for type in graphic_content.types) == sorted(
types
)
def test_graphic_content_pornographic_content(self):
types = ["pornographic content"]
- graphic_content = GraphicContent(graphic_category=TestGraphicContent.GRAPHIC, types=types)
+ graphic_content = GraphicContent(
+ graphic_category=TestGraphicContent.GRAPHIC, types=types
+ )
assert sorted(type.value for type in graphic_content.types) == sorted(
types
)
@@ -49,4 +59,6 @@ class TestGraphicContent:
"invalid",
]
with pytest.raises(ValueError):
- GraphicContent(graphic_category=TestGraphicContent.GRAPHIC, types=types)
+ GraphicContent(
+ graphic_category=TestGraphicContent.GRAPHIC, types=types
+ )
diff --git a/tests/test_core/test_vulnerabilities/test_illegal_activity.py b/tests/test_core/test_vulnerabilities/test_illegal_activity.py
index 5c78815e..a84b00ad 100644
--- a/tests/test_core/test_vulnerabilities/test_illegal_activity.py
+++ b/tests/test_core/test_vulnerabilities/test_illegal_activity.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.illegal_activity import IllegalActivityType
class TestIllegalActivity:
- ILLEGAL="category"
+ ILLEGAL = "category"
def test_illegal_activity_all_types(self):
types = [
@@ -17,62 +17,80 @@ class TestIllegalActivity:
"cybercrime",
"child exploitation",
]
- illegal_activity = IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, types=types)
+ illegal_activity = IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL, types=types
+ )
assert sorted(type.value for type in illegal_activity.types) == sorted(
types
)
def test_illegal_activity_all_types_default(self):
- illegal_activity = IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, )
+ illegal_activity = IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL,
+ )
assert sorted(type.value for type in illegal_activity.types) == sorted(
type.value for type in IllegalActivityType
)
def test_illegal_activity_weapons(self):
types = ["weapons"]
- illegal_activity = IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, types=types)
+ illegal_activity = IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL, types=types
+ )
assert sorted(type.value for type in illegal_activity.types) == sorted(
types
)
def test_illegal_activity_illegal_drugs(self):
types = ["illegal drugs"]
- illegal_activity = IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, types=types)
+ illegal_activity = IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL, types=types
+ )
assert sorted(type.value for type in illegal_activity.types) == sorted(
types
)
def test_illegal_activity_violent_crimes(self):
types = ["violent crimes"]
- illegal_activity = IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, types=types)
+ illegal_activity = IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL, types=types
+ )
assert sorted(type.value for type in illegal_activity.types) == sorted(
types
)
def test_illegal_activity_non_violent_crimes(self):
types = ["non violent crimes"]
- illegal_activity = IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, types=types)
+ illegal_activity = IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL, types=types
+ )
assert sorted(type.value for type in illegal_activity.types) == sorted(
types
)
def test_illegal_activity_sex_crimes(self):
types = ["sex crimes"]
- illegal_activity = IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, types=types)
+ illegal_activity = IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL, types=types
+ )
assert sorted(type.value for type in illegal_activity.types) == sorted(
types
)
def test_illegal_activity_cybercrime(self):
types = ["cybercrime"]
- illegal_activity = IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, types=types)
+ illegal_activity = IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL, types=types
+ )
assert sorted(type.value for type in illegal_activity.types) == sorted(
types
)
def test_illegal_activity_child_exploitation(self):
types = ["child exploitation"]
- illegal_activity = IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, types=types)
+ illegal_activity = IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL, types=types
+ )
assert sorted(type.value for type in illegal_activity.types) == sorted(
types
)
@@ -89,4 +107,6 @@ class TestIllegalActivity:
"invalid",
]
with pytest.raises(ValueError):
- IllegalActivity(illegal_category=TestIllegalActivity.ILLEGAL, types=types)
+ IllegalActivity(
+ illegal_category=TestIllegalActivity.ILLEGAL, types=types
+ )
diff --git a/tests/test_core/test_vulnerabilities/test_intellectual_property.py b/tests/test_core/test_vulnerabilities/test_intellectual_property.py
index 502029f3..0c8ee95a 100644
--- a/tests/test_core/test_vulnerabilities/test_intellectual_property.py
+++ b/tests/test_core/test_vulnerabilities/test_intellectual_property.py
@@ -7,7 +7,7 @@ from deepteam.vulnerabilities.intellectual_property import (
class TestIntellectualProperty:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_intellectual_property_all_types(self):
types = [
@@ -16,41 +16,53 @@ class TestIntellectualProperty:
"trademark infringement",
"patent disclosure",
]
- intellectual_property = IntellectualProperty(purpose=TestIntellectualProperty.PURPOSE, types=types)
+ intellectual_property = IntellectualProperty(
+ purpose=TestIntellectualProperty.PURPOSE, types=types
+ )
assert sorted(
type.value for type in intellectual_property.types
) == sorted(types)
def test_intellectual_property_all_types_default(self):
- intellectual_property = IntellectualProperty(purpose=TestIntellectualProperty.PURPOSE, )
+ intellectual_property = IntellectualProperty(
+ purpose=TestIntellectualProperty.PURPOSE,
+ )
assert sorted(
type.value for type in intellectual_property.types
) == sorted(type.value for type in IntellectualPropertyType)
def test_intellectual_property_imitation(self):
types = ["imitation"]
- intellectual_property = IntellectualProperty(purpose=TestIntellectualProperty.PURPOSE, types=types)
+ intellectual_property = IntellectualProperty(
+ purpose=TestIntellectualProperty.PURPOSE, types=types
+ )
assert sorted(
type.value for type in intellectual_property.types
) == sorted(types)
def test_intellectual_property_copyright_violations(self):
types = ["copyright violations"]
- intellectual_property = IntellectualProperty(purpose=TestIntellectualProperty.PURPOSE, types=types)
+ intellectual_property = IntellectualProperty(
+ purpose=TestIntellectualProperty.PURPOSE, types=types
+ )
assert sorted(
type.value for type in intellectual_property.types
) == sorted(types)
def test_intellectual_property_trademark_infringement(self):
types = ["trademark infringement"]
- intellectual_property = IntellectualProperty(purpose=TestIntellectualProperty.PURPOSE, types=types)
+ intellectual_property = IntellectualProperty(
+ purpose=TestIntellectualProperty.PURPOSE, types=types
+ )
assert sorted(
type.value for type in intellectual_property.types
) == sorted(types)
def test_intellectual_property_patent_disclosure(self):
types = ["patent disclosure"]
- intellectual_property = IntellectualProperty(purpose=TestIntellectualProperty.PURPOSE, types=types)
+ intellectual_property = IntellectualProperty(
+ purpose=TestIntellectualProperty.PURPOSE, types=types
+ )
assert sorted(
type.value for type in intellectual_property.types
) == sorted(types)
@@ -64,4 +76,6 @@ class TestIntellectualProperty:
"invalid",
]
with pytest.raises(ValueError):
- IntellectualProperty(purpose=TestIntellectualProperty.PURPOSE, types=types)
+ IntellectualProperty(
+ purpose=TestIntellectualProperty.PURPOSE, types=types
+ )
diff --git a/tests/test_core/test_vulnerabilities/test_misinformation.py b/tests/test_core/test_vulnerabilities/test_misinformation.py
index 523c92fb..b99a5063 100644
--- a/tests/test_core/test_vulnerabilities/test_misinformation.py
+++ b/tests/test_core/test_vulnerabilities/test_misinformation.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.misinformation import MisinformationType
class TestMisinformation:
- MISINFORMATION="category"
+ MISINFORMATION = "category"
def test_misinformation_all_types(self):
types = [
@@ -13,34 +13,48 @@ class TestMisinformation:
"unsupported claims",
"expertize misrepresentation",
]
- misinformation = Misinformation(misinformation_category=TestMisinformation.MISINFORMATION, types=types)
+ misinformation = Misinformation(
+ misinformation_category=TestMisinformation.MISINFORMATION,
+ types=types,
+ )
assert sorted(type.value for type in misinformation.types) == sorted(
types
)
def test_misinformation_all_types_default(self):
- misinformation = Misinformation(misinformation_category=TestMisinformation.MISINFORMATION, )
+ misinformation = Misinformation(
+ misinformation_category=TestMisinformation.MISINFORMATION,
+ )
assert sorted(type.value for type in misinformation.types) == sorted(
type.value for type in MisinformationType
)
def test_misinformation_factual_errors(self):
types = ["factual errors"]
- misinformation = Misinformation(misinformation_category=TestMisinformation.MISINFORMATION, types=types)
+ misinformation = Misinformation(
+ misinformation_category=TestMisinformation.MISINFORMATION,
+ types=types,
+ )
assert sorted(type.value for type in misinformation.types) == sorted(
types
)
def test_misinformation_unsupported_claims(self):
types = ["unsupported claims"]
- misinformation = Misinformation(misinformation_category=TestMisinformation.MISINFORMATION, types=types)
+ misinformation = Misinformation(
+ misinformation_category=TestMisinformation.MISINFORMATION,
+ types=types,
+ )
assert sorted(type.value for type in misinformation.types) == sorted(
types
)
def test_misinformation_expertize_misrepresentation(self):
types = ["expertize misrepresentation"]
- misinformation = Misinformation(misinformation_category=TestMisinformation.MISINFORMATION, types=types)
+ misinformation = Misinformation(
+ misinformation_category=TestMisinformation.MISINFORMATION,
+ types=types,
+ )
assert sorted(type.value for type in misinformation.types) == sorted(
types
)
@@ -53,4 +67,7 @@ class TestMisinformation:
"invalid",
]
with pytest.raises(ValueError):
- Misinformation(misinformation_category=TestMisinformation.MISINFORMATION, types=types)
+ Misinformation(
+ misinformation_category=TestMisinformation.MISINFORMATION,
+ types=types,
+ )
diff --git a/tests/test_core/test_vulnerabilities/test_personal_safety.py b/tests/test_core/test_vulnerabilities/test_personal_safety.py
index b2dbcbcf..cde293d2 100644
--- a/tests/test_core/test_vulnerabilities/test_personal_safety.py
+++ b/tests/test_core/test_vulnerabilities/test_personal_safety.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.personal_safety import PersonalSafetyType
class TestPersonalSafety:
- SAFETY="category"
+ SAFETY = "category"
def test_personal_safety_all_types(self):
types = [
@@ -15,48 +15,62 @@ class TestPersonalSafety:
"dangerous challenges",
"stalking",
]
- personal_safety = PersonalSafety(safety_category=TestPersonalSafety.SAFETY, types=types)
+ personal_safety = PersonalSafety(
+ safety_category=TestPersonalSafety.SAFETY, types=types
+ )
assert sorted(type.value for type in personal_safety.types) == sorted(
types
)
def test_personal_safety_all_types_default(self):
- personal_safety = PersonalSafety(safety_category=TestPersonalSafety.SAFETY, )
+ personal_safety = PersonalSafety(
+ safety_category=TestPersonalSafety.SAFETY,
+ )
assert sorted(type.value for type in personal_safety.types) == sorted(
type.value for type in PersonalSafetyType
)
def test_personal_safety_bullying(self):
types = ["bullying"]
- personal_safety = PersonalSafety(safety_category=TestPersonalSafety.SAFETY, types=types)
+ personal_safety = PersonalSafety(
+ safety_category=TestPersonalSafety.SAFETY, types=types
+ )
assert sorted(type.value for type in personal_safety.types) == sorted(
types
)
def test_personal_safety_self_harm(self):
types = ["self-harm"]
- personal_safety = PersonalSafety(safety_category=TestPersonalSafety.SAFETY, types=types)
+ personal_safety = PersonalSafety(
+ safety_category=TestPersonalSafety.SAFETY, types=types
+ )
assert sorted(type.value for type in personal_safety.types) == sorted(
types
)
def test_personal_safety_unsafe_practices(self):
types = ["unsafe practices"]
- personal_safety = PersonalSafety(safety_category=TestPersonalSafety.SAFETY, types=types)
+ personal_safety = PersonalSafety(
+ safety_category=TestPersonalSafety.SAFETY, types=types
+ )
assert sorted(type.value for type in personal_safety.types) == sorted(
types
)
def test_personal_safety_dangerous_challenges(self):
types = ["dangerous challenges"]
- personal_safety = PersonalSafety(safety_category=TestPersonalSafety.SAFETY, types=types)
+ personal_safety = PersonalSafety(
+ safety_category=TestPersonalSafety.SAFETY, types=types
+ )
assert sorted(type.value for type in personal_safety.types) == sorted(
types
)
def test_personal_safety_stalking(self):
types = ["stalking"]
- personal_safety = PersonalSafety(safety_category=TestPersonalSafety.SAFETY, types=types)
+ personal_safety = PersonalSafety(
+ safety_category=TestPersonalSafety.SAFETY, types=types
+ )
assert sorted(type.value for type in personal_safety.types) == sorted(
types
)
@@ -71,4 +85,6 @@ class TestPersonalSafety:
"invalid",
]
with pytest.raises(ValueError):
- PersonalSafety(safety_category=TestPersonalSafety.SAFETY, types=types)
+ PersonalSafety(
+ safety_category=TestPersonalSafety.SAFETY, types=types
+ )
diff --git a/tests/test_core/test_vulnerabilities/test_pii_leakage.py b/tests/test_core/test_vulnerabilities/test_pii_leakage.py
index c160afea..8552845e 100644
--- a/tests/test_core/test_vulnerabilities/test_pii_leakage.py
+++ b/tests/test_core/test_vulnerabilities/test_pii_leakage.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.pii_leakage import PIILeakageType
class TestPIILeakage:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_pii_leakage_all_types(self):
types = [
@@ -18,7 +18,9 @@ class TestPIILeakage:
assert sorted(type.value for type in pii_leakage.types) == sorted(types)
def test_pii_leakage_all_types_default(self):
- pii_leakage = PIILeakage(purpose=TestPIILeakage.PURPOSE, )
+ pii_leakage = PIILeakage(
+ purpose=TestPIILeakage.PURPOSE,
+ )
assert sorted(type.value for type in pii_leakage.types) == sorted(
type.value for type in PIILeakageType
)
diff --git a/tests/test_core/test_vulnerabilities/test_prompt_leakage.py b/tests/test_core/test_vulnerabilities/test_prompt_leakage.py
index bdbec163..4d930a32 100644
--- a/tests/test_core/test_vulnerabilities/test_prompt_leakage.py
+++ b/tests/test_core/test_vulnerabilities/test_prompt_leakage.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.prompt_leakage import PromptLeakageType
class TestPromptLeakage:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_prompt_leakage_all_types(self):
types = [
@@ -14,41 +14,53 @@ class TestPromptLeakage:
"guard exposure",
"permissions and roles",
]
- prompt_leakage = PromptLeakage(purpose=TestPromptLeakage.PURPOSE, types=types)
+ prompt_leakage = PromptLeakage(
+ purpose=TestPromptLeakage.PURPOSE, types=types
+ )
assert sorted(type.value for type in prompt_leakage.types) == sorted(
types
)
def test_prompt_leakage_all_types_default(self):
- prompt_leakage = PromptLeakage(purpose=TestPromptLeakage.PURPOSE, )
+ prompt_leakage = PromptLeakage(
+ purpose=TestPromptLeakage.PURPOSE,
+ )
assert sorted(type.value for type in prompt_leakage.types) == sorted(
type.value for type in PromptLeakageType
)
def test_prompt_leakage_secrets_and_credentials(self):
types = ["secrets and credentials"]
- prompt_leakage = PromptLeakage(purpose=TestPromptLeakage.PURPOSE, types=types)
+ prompt_leakage = PromptLeakage(
+ purpose=TestPromptLeakage.PURPOSE, types=types
+ )
assert sorted(type.value for type in prompt_leakage.types) == sorted(
types
)
def test_prompt_leakage_instructions(self):
types = ["instructions"]
- prompt_leakage = PromptLeakage(purpose=TestPromptLeakage.PURPOSE, types=types)
+ prompt_leakage = PromptLeakage(
+ purpose=TestPromptLeakage.PURPOSE, types=types
+ )
assert sorted(type.value for type in prompt_leakage.types) == sorted(
types
)
def test_prompt_leakage_guard_exposure(self):
types = ["guard exposure"]
- prompt_leakage = PromptLeakage(purpose=TestPromptLeakage.PURPOSE, types=types)
+ prompt_leakage = PromptLeakage(
+ purpose=TestPromptLeakage.PURPOSE, types=types
+ )
assert sorted(type.value for type in prompt_leakage.types) == sorted(
types
)
def test_prompt_leakage_permissions_and_roles(self):
types = ["permissions and roles"]
- prompt_leakage = PromptLeakage(purpose=TestPromptLeakage.PURPOSE, types=types)
+ prompt_leakage = PromptLeakage(
+ purpose=TestPromptLeakage.PURPOSE, types=types
+ )
assert sorted(type.value for type in prompt_leakage.types) == sorted(
types
)
diff --git a/tests/test_core/test_vulnerabilities/test_rbac.py b/tests/test_core/test_vulnerabilities/test_rbac.py
index a4919393..8ea1935c 100644
--- a/tests/test_core/test_vulnerabilities/test_rbac.py
+++ b/tests/test_core/test_vulnerabilities/test_rbac.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.rbac import RBACType
class TestRBAC:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_rbac_all_types(self):
types = [
@@ -17,7 +17,9 @@ class TestRBAC:
assert sorted(type.value for type in rbac.types) == sorted(types)
def test_rbac_all_types_default(self):
- rbac = RBAC(purpose=TestRBAC.PURPOSE, )
+ rbac = RBAC(
+ purpose=TestRBAC.PURPOSE,
+ )
assert sorted(type.value for type in rbac.types) == sorted(
type.value for type in RBACType
)
diff --git a/tests/test_core/test_vulnerabilities/test_recursive_hijacking.py b/tests/test_core/test_vulnerabilities/test_recursive_hijacking.py
index 91752a9a..01941c96 100644
--- a/tests/test_core/test_vulnerabilities/test_recursive_hijacking.py
+++ b/tests/test_core/test_vulnerabilities/test_recursive_hijacking.py
@@ -7,7 +7,7 @@ from deepteam.vulnerabilities.agentic.recursive_hijacking import (
class TestRecursiveHijacking:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_recursive_hijacking_all_types(self):
types = [
@@ -15,34 +15,44 @@ class TestRecursiveHijacking:
"recursive_objective_chaining",
"goal_propagation_attacks",
]
- recursive_hijacking = RecursiveHijacking(purpose=TestRecursiveHijacking.PURPOSE, types=types)
+ recursive_hijacking = RecursiveHijacking(
+ purpose=TestRecursiveHijacking.PURPOSE, types=types
+ )
assert sorted(
type.value for type in recursive_hijacking.types
) == sorted(types)
def test_recursive_hijacking_all_types_default(self):
- recursive_hijacking = RecursiveHijacking(purpose=TestRecursiveHijacking.PURPOSE, )
+ recursive_hijacking = RecursiveHijacking(
+ purpose=TestRecursiveHijacking.PURPOSE,
+ )
assert sorted(
type.value for type in recursive_hijacking.types
) == sorted(type.value for type in RecursiveHijackingType)
def test_recursive_hijacking_self_modifying_goals(self):
types = ["self_modifying_goals"]
- recursive_hijacking = RecursiveHijacking(purpose=TestRecursiveHijacking.PURPOSE, types=types)
+ recursive_hijacking = RecursiveHijacking(
+ purpose=TestRecursiveHijacking.PURPOSE, types=types
+ )
assert sorted(
type.value for type in recursive_hijacking.types
) == sorted(types)
def test_recursive_hijacking_recursive_objective_chaining(self):
types = ["recursive_objective_chaining"]
- recursive_hijacking = RecursiveHijacking(purpose=TestRecursiveHijacking.PURPOSE, types=types)
+ recursive_hijacking = RecursiveHijacking(
+ purpose=TestRecursiveHijacking.PURPOSE, types=types
+ )
assert sorted(
type.value for type in recursive_hijacking.types
) == sorted(types)
def test_recursive_hijacking_goal_propagation_attacks(self):
types = ["goal_propagation_attacks"]
- recursive_hijacking = RecursiveHijacking(purpose=TestRecursiveHijacking.PURPOSE, types=types)
+ recursive_hijacking = RecursiveHijacking(
+ purpose=TestRecursiveHijacking.PURPOSE, types=types
+ )
assert sorted(
type.value for type in recursive_hijacking.types
) == sorted(types)
@@ -55,4 +65,6 @@ class TestRecursiveHijacking:
"invalid",
]
with pytest.raises(ValueError):
- RecursiveHijacking(purpose=TestRecursiveHijacking.PURPOSE, types=types)
+ RecursiveHijacking(
+ purpose=TestRecursiveHijacking.PURPOSE, types=types
+ )
diff --git a/tests/test_core/test_vulnerabilities/test_robustness.py b/tests/test_core/test_vulnerabilities/test_robustness.py
index 26378382..37161071 100644
--- a/tests/test_core/test_vulnerabilities/test_robustness.py
+++ b/tests/test_core/test_vulnerabilities/test_robustness.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.agentic.robustness import RobustnessType
class TestRobustness:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_robustness_all_types(self):
types = ["input overreliance", "hijacking"]
@@ -13,7 +13,9 @@ class TestRobustness:
assert sorted(type.value for type in robustness.types) == sorted(types)
def test_robustness_all_types_default(self):
- robustness = Robustness(purpose=TestRobustness.PURPOSE, )
+ robustness = Robustness(
+ purpose=TestRobustness.PURPOSE,
+ )
assert sorted(type.value for type in robustness.types) == sorted(
type.value for type in RobustnessType
)
diff --git a/tests/test_core/test_vulnerabilities/test_ssrf.py b/tests/test_core/test_vulnerabilities/test_ssrf.py
index f810a262..00aa0d06 100644
--- a/tests/test_core/test_vulnerabilities/test_ssrf.py
+++ b/tests/test_core/test_vulnerabilities/test_ssrf.py
@@ -5,7 +5,7 @@ from deepteam.vulnerabilities.ssrf import SSRFType
class TestSSRF:
- PURPOSE="purpose"
+ PURPOSE = "purpose"
def test_ssrf_all_types(self):
types = [
@@ -17,7 +17,9 @@ class TestSSRF:
assert sorted(type.value for type in ssrf.types) == sorted(types)
def test_ssrf_all_types_default(self):
- ssrf = SSRF(purpose=TestSSRF.PURPOSE, )
+ ssrf = SSRF(
+ purpose=TestSSRF.PURPOSE,
+ )
assert sorted(type.value for type in ssrf.types) == sorted(
type.value for type in SSRFType
)
diff --git a/tests/test_core/test_vulnerabilities/test_toxicity.py b/tests/test_core/test_vulnerabilities/test_toxicity.py
index 874afb5e..5266dd7c 100644
--- a/tests/test_core/test_vulnerabilities/test_toxicity.py
+++ b/tests/test_core/test_vulnerabilities/test_toxicity.py
@@ -5,37 +5,49 @@ from deepteam.vulnerabilities.toxicity import ToxicityType
class TestToxicity:
- TOXICITY="category"
+ TOXICITY = "category"
def test_toxicity_all_types(self):
types = ["profanity", "insults", "threats", "mockery"]
- toxicity = Toxicity(toxicity_category=TestToxicity.TOXICITY, types=types)
+ toxicity = Toxicity(
+ toxicity_category=TestToxicity.TOXICITY, types=types
+ )
assert sorted(type.value for type in toxicity.types) == sorted(types)
def test_toxicity_all_types_default(self):
- toxicity = Toxicity(toxicity_category=TestToxicity.TOXICITY, )
+ toxicity = Toxicity(
+ toxicity_category=TestToxicity.TOXICITY,
+ )
assert sorted(type.value for type in toxicity.types) == sorted(
type.value for type in ToxicityType
)
def test_toxicity_profanity(self):
types = ["profanity"]
- toxicity = Toxicity(toxicity_category=TestToxicity.TOXICITY, types=types)
+ toxicity = Toxicity(
+ toxicity_category=TestToxicity.TOXICITY, types=types
+ )
assert sorted(type.value for type in toxicity.types) == sorted(types)
def test_toxicity_insults(self):
types = ["insults"]
- toxicity = Toxicity(toxicity_category=TestToxicity.TOXICITY, types=types)
+ toxicity = Toxicity(
+ toxicity_category=TestToxicity.TOXICITY, types=types
+ )
assert sorted(type.value for type in toxicity.types) == sorted(types)
def test_toxicity_threats(self):
types = ["threats"]
- toxicity = Toxicity(toxicity_category=TestToxicity.TOXICITY, types=types)
+ toxicity = Toxicity(
+ toxicity_category=TestToxicity.TOXICITY, types=types
+ )
assert sorted(type.value for type in toxicity.types) == sorted(types)
def test_toxicity_mockery(self):
types = ["mockery"]
- toxicity = Toxicity(toxicity_category=TestToxicity.TOXICITY, types=types)
+ toxicity = Toxicity(
+ toxicity_category=TestToxicity.TOXICITY, types=types
+ )
assert sorted(type.value for type in toxicity.types) == sorted(types)
def test_toxicity_all_types_invalid(self):