Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 3 additions & 67 deletions src/giskard_hub/data/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,72 +21,6 @@ class ScanCategory(BaseData):
owasp_id: Optional[str] = field(default=None)


SCAN_CATEGORIES = [
ScanCategory(
id="gsk:threat-type='prompt-injection'",
title="Prompt Injection",
description="Attempts to manipulate model behavior through crafted inputs",
owasp_id="OWASP LLM01",
),
ScanCategory(
id="gsk:threat-type='data-privacy-exfiltration'",
title="Data Privacy & Exfiltration",
description="Unauthorized exposure of sensitive or private information",
owasp_id="OWASP LLM05",
),
ScanCategory(
id="gsk:threat-type='harmful-content-generation'",
title="Harmful Content Generation",
description="Generation of harmful, offensive, or inappropriate content",
),
ScanCategory(
id="gsk:threat-type='excessive-agency'",
title="Excessive Agency",
description="Model given too much autonomy or permissions beyond intended scope",
owasp_id="OWASP LLM06",
),
ScanCategory(
id="gsk:threat-type='internal-information-exposure'",
title="Internal Information Exposure",
description="Exposure of internal system information or model architecture",
owasp_id="OWASP LLM01-07",
),
ScanCategory(
id="gsk:threat-type='training-data-extraction'",
title="Training Data Extraction",
description="Attempts to extract training data from the model",
owasp_id="OWASP LLM02",
),
ScanCategory(
id="gsk:threat-type='denial-of-service'",
title="Denial of Service",
description="Resource exhaustion attacks against the model or system",
owasp_id="OWASP LLM10",
),
ScanCategory(
id="gsk:threat-type='hallucination'",
title="Hallucination / Misinformation",
description="Generation of false or misleading information presented as fact",
owasp_id="OWASP LLM08",
),
ScanCategory(
id="gsk:threat-type='misguidance-and-unauthorized-advice'",
title="Misguidance & Unauthorized Advice",
description="Providing inappropriate guidance or advice outside intended scope",
),
ScanCategory(
id="gsk:threat-type='legal-and-financial-risk'",
title="Legal & Financial Risk",
description="Responses that could create legal or financial liability",
),
ScanCategory(
id="gsk:threat-type='brand-damaging-and-reputation'",
title="Brand Damaging & Reputation",
description="Responses that could damage brand reputation or public trust",
),
]


class ScanGrade(str, Enum):
A = "A"
B = "B"
Expand Down Expand Up @@ -279,7 +213,9 @@ def print_metrics(self):
title=f"Scan Result [bold cyan]{self.id}[/bold cyan]",
)

category_map = {cat.id: cat.title for cat in SCAN_CATEGORIES}
category_map = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we cache this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

cat.id: cat.title for cat in self._client.scans.list_categories()
}
probe_results = self.results
probe_data = []

Expand Down
6 changes: 2 additions & 4 deletions src/giskard_hub/resources/scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from ..data._base import NOT_GIVEN, filter_not_given
from ..data.scan import (
SCAN_CATEGORIES,
ProbeAttempt,
ProbeResult,
ScanCategory,
Expand All @@ -22,7 +21,8 @@ def list_categories(self) -> List[ScanCategory]:
-------
List[ScanCategory]: A list of `ScanCategory` objects representing all available scan categories.
"""
return SCAN_CATEGORIES
data = self._client.get(f"{_SCAN_BASE_URL}/categories")
return [ScanCategory.from_dict(item) for item in data["items"]]

def create(
self,
Expand All @@ -47,8 +47,6 @@ def create(
ScanResult
The created scan result.
"""
if not tags or len(tags) == 0:
tags = [category.id for category in self.list_categories()]

data = filter_not_given(
{
Expand Down