Skip to content
Open
Changes from all 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
13 changes: 10 additions & 3 deletions src/defectdojo/findings_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,22 +170,26 @@ async def add_finding_note(finding_id: int, note: str) -> Dict[str, Any]:
return {"status": "success", "data": result}


async def create_finding(title: str, test_id: int, severity: str, description: str,
async def create_finding(title: str, test_id: int, severity: str, description: str, found_by: list,
cwe: Optional[int] = None, cvssv3: Optional[str] = None,
mitigation: Optional[str] = None, impact: Optional[str] = None,
steps_to_reproduce: Optional[str] = None) -> Dict[str, Any]:
steps_to_reproduce: Optional[str] = None,
numerical_severity: Optional[str] = "S2"
) -> Dict[str, Any]:
"""Create a new finding.

Args:
title: Title of the finding
test_id: ID of the test to associate the finding with
severity: Severity level (Critical, High, Medium, Low, Info)
description: Description of the finding
found_by: Required ID of the origin test of the finding
cwe: Optional CWE identifier
cvssv3: Optional CVSS v3 score string
mitigation: Optional mitigation steps
impact: Optional impact description
steps_to_reproduce: Optional steps to reproduce
numerical_severity: Optional numerical representation of the severity (default: S2)

Returns:
Dictionary with status and data/error
Expand All @@ -206,10 +210,11 @@ async def create_finding(title: str, test_id: int, severity: str, description: s
"test": test_id,
"severity": api_severity,
"description": description,
"found_by": found_by,
# Set defaults expected by API if not provided explicitly by user?
# e.g., "active": True, "verified": False? Check API docs.
"active": True,
"verified": False,
"verified": False
}

# Add optional fields if provided
Expand All @@ -223,6 +228,8 @@ async def create_finding(title: str, test_id: int, severity: str, description: s
data["impact"] = impact
if steps_to_reproduce:
data["steps_to_reproduce"] = steps_to_reproduce
if numerical_severity:
data["numerical_severity"] = numerical_severity

client = get_client()
result = await client.create_finding(data)
Expand Down