Skip to content

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

NIST update

A-Vamshi0e3b10286eac
diff --git a/deepteam/frameworks/nist/nist.py b/deepteam/frameworks/nist/nist.py
index 39cf36d1..1a7ed7e9 100644
--- a/deepteam/frameworks/nist/nist.py
+++ b/deepteam/frameworks/nist/nist.py
@@ -2,7 +2,7 @@ from typing import List, Literal
from deepteam.frameworks import AISafetyFramework
from deepteam.vulnerabilities import BaseVulnerability
from deepteam.attacks import BaseAttack
-from deepteam.frameworks.nist.risk_categories import NIST_MAPPING
+from deepteam.frameworks.nist.risk_categories import NIST_CATEGORIES
class NIST(AISafetyFramework):
@@ -25,9 +25,10 @@ class NIST(AISafetyFramework):
) -> List[BaseVulnerability]:
vulnerabilities: List[BaseVulnerability] = []
for category in categories:
- risk_category = NIST_MAPPING.get(category)
- new_vulnerabilities = risk_category.vulnerabilities
- vulnerabilities.extend(new_vulnerabilities)
+ for risk_category in NIST_CATEGORIES:
+ if category == risk_category.name:
+ new_vulnerabilities = risk_category.vulnerabilities
+ vulnerabilities.extend(new_vulnerabilities)
return vulnerabilities
def _get_attacks_by_categories(
@@ -35,9 +36,10 @@ class NIST(AISafetyFramework):
) -> List[BaseAttack]:
attacks: List[BaseAttack] = []
for category in categories:
- risk_category = NIST_MAPPING.get(category)
- new_attacks = risk_category.attacks
- attacks.extend(new_attacks)
+ for risk_category in NIST_CATEGORIES:
+ if category == risk_category.name:
+ new_attacks = risk_category.attacks
+ attacks.extend(new_attacks)
return attacks
def get_name(self):
diff --git a/deepteam/frameworks/nist/risk_categories.py b/deepteam/frameworks/nist/risk_categories.py
index ca3907af..45b04812 100644
--- a/deepteam/frameworks/nist/risk_categories.py
+++ b/deepteam/frameworks/nist/risk_categories.py
@@ -42,8 +42,8 @@ from deepteam.attacks.multi_turn import (
BadLikertJudge,
)
-NIST_MAPPING = {
- "measure_1": RiskCategory(
+NIST_CATEGORIES = [
+ RiskCategory(
name="measure_1",
attacks=[
Roleplay(
@@ -79,7 +79,7 @@ NIST_MAPPING = {
),
],
),
- "measure_2": RiskCategory(
+ RiskCategory(
name="measure_2",
attacks=[
PromptInjection(weight=3),
@@ -202,7 +202,7 @@ NIST_MAPPING = {
),
],
),
- "measure_3": RiskCategory(
+ RiskCategory(
name="measure_3",
attacks=[
PromptProbing(weight=3),
@@ -239,7 +239,7 @@ NIST_MAPPING = {
),
],
),
- "measure_4": RiskCategory(
+ RiskCategory(
name="measure_4",
attacks=[
BadLikertJudge(weight=2),
@@ -262,4 +262,4 @@ NIST_MAPPING = {
),
],
),
-}
+]