mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 12:31:54 +00:00
fix(ui): resolve grouped Jira pipeline failures
This commit is contained in:
@@ -487,37 +487,36 @@ def send_findings_to_jira(
|
||||
|
||||
num_tickets_created = 0
|
||||
error_messages = []
|
||||
failed_finding_ids = []
|
||||
for finding_id in finding_ids:
|
||||
with rls_transaction(tenant_id):
|
||||
finding_instance = (
|
||||
Finding.all_objects.select_related("scan__provider")
|
||||
.prefetch_related("resources")
|
||||
.get(id=finding_id)
|
||||
)
|
||||
|
||||
# Extract resource information
|
||||
resource = (
|
||||
finding_instance.resources.first()
|
||||
if finding_instance.resources.exists()
|
||||
else None
|
||||
)
|
||||
resource_uid = resource.uid if resource else ""
|
||||
resource_name = resource.name if resource else ""
|
||||
resource_tags = {}
|
||||
if resource and hasattr(resource, "tags"):
|
||||
resource_tags = resource.get_tags(tenant_id)
|
||||
|
||||
# Get region
|
||||
region = resource.region if resource and resource.region else ""
|
||||
|
||||
# Extract remediation information from check_metadata
|
||||
check_metadata = finding_instance.check_metadata
|
||||
remediation = check_metadata.get("remediation", {})
|
||||
recommendation = remediation.get("recommendation", {})
|
||||
remediation_code = remediation.get("code", {})
|
||||
|
||||
try:
|
||||
finding_instance = (
|
||||
Finding.all_objects.select_related("scan__provider")
|
||||
.prefetch_related("resources")
|
||||
.get(id=finding_id)
|
||||
)
|
||||
|
||||
# Extract resource information
|
||||
resource = (
|
||||
finding_instance.resources.first()
|
||||
if finding_instance.resources.exists()
|
||||
else None
|
||||
)
|
||||
resource_uid = resource.uid if resource else ""
|
||||
resource_name = resource.name if resource else ""
|
||||
resource_tags = {}
|
||||
if resource and hasattr(resource, "tags"):
|
||||
resource_tags = resource.get_tags(tenant_id)
|
||||
|
||||
# Get region
|
||||
region = resource.region if resource and resource.region else ""
|
||||
|
||||
# Extract remediation information from check_metadata
|
||||
check_metadata = finding_instance.check_metadata
|
||||
remediation = check_metadata.get("remediation", {})
|
||||
recommendation = remediation.get("recommendation", {})
|
||||
remediation_code = remediation.get("code", {})
|
||||
|
||||
# Send the individual finding to Jira
|
||||
result = jira_integration.send_finding(
|
||||
check_id=finding_instance.check_id,
|
||||
@@ -547,21 +546,18 @@ def send_findings_to_jira(
|
||||
"Failed to send finding %s to Jira: %s", finding_id, error_message
|
||||
)
|
||||
error_messages.append(error_message)
|
||||
failed_finding_ids.append(finding_id)
|
||||
continue
|
||||
except Exception:
|
||||
logger.exception("Failed to send finding %s to Jira", finding_id)
|
||||
error_messages.append(JIRA_GENERIC_SEND_ERROR)
|
||||
failed_finding_ids.append(finding_id)
|
||||
continue
|
||||
|
||||
if result:
|
||||
num_tickets_created += 1
|
||||
else:
|
||||
error_message = JIRA_GENERIC_SEND_ERROR
|
||||
logger.error(error_message)
|
||||
error_messages.append(error_message)
|
||||
failed_finding_ids.append(finding_id)
|
||||
if result:
|
||||
num_tickets_created += 1
|
||||
else:
|
||||
error_message = JIRA_GENERIC_SEND_ERROR
|
||||
logger.error(error_message)
|
||||
error_messages.append(error_message)
|
||||
|
||||
result = {
|
||||
"created_count": num_tickets_created,
|
||||
@@ -569,6 +565,5 @@ def send_findings_to_jira(
|
||||
}
|
||||
if error_messages:
|
||||
result["error"] = "; ".join(dict.fromkeys(error_messages))
|
||||
result["failed_finding_ids"] = failed_finding_ids
|
||||
|
||||
return result
|
||||
|
||||
@@ -1837,7 +1837,6 @@ class TestJiraIntegration:
|
||||
assert result == {
|
||||
"created_count": 2,
|
||||
"failed_count": 1,
|
||||
"failed_finding_ids": ["finding-2"],
|
||||
"error": "Failed to create Jira issue.",
|
||||
}
|
||||
|
||||
@@ -1904,7 +1903,6 @@ class TestJiraIntegration:
|
||||
assert result == {
|
||||
"created_count": 0,
|
||||
"failed_count": 1,
|
||||
"failed_finding_ids": ["finding-1"],
|
||||
"error": error_message,
|
||||
}
|
||||
mock_logger.exception.assert_called_with(
|
||||
@@ -1973,7 +1971,6 @@ class TestJiraIntegration:
|
||||
assert result == {
|
||||
"created_count": 0,
|
||||
"failed_count": 1,
|
||||
"failed_finding_ids": ["finding-1"],
|
||||
"error": error_message,
|
||||
}
|
||||
mock_logger.exception.assert_called_with(
|
||||
@@ -2038,7 +2035,6 @@ class TestJiraIntegration:
|
||||
assert result == {
|
||||
"created_count": 0,
|
||||
"failed_count": 1,
|
||||
"failed_finding_ids": ["finding-1"],
|
||||
"error": "Failed to create Jira issue.",
|
||||
}
|
||||
assert "secret-value" not in result["error"]
|
||||
|
||||
Reference in New Issue
Block a user