feat(jira): support issue labels

This commit is contained in:
pedrooot
2025-08-28 15:34:15 +02:00
parent 08660026d2
commit 199efd290d
2 changed files with 10 additions and 1 deletions
+5
View File
@@ -67,6 +67,7 @@ class Jira:
- test_connection: Test the connection to Jira and return a Connection object
- get_projects: Get the projects from Jira
- get_available_issue_types: Get the available issue types for a project
- get_available_issue_labels: Get the available labels for a project
- send_findings: Send the findings to Jira and create an issue
Raises:
@@ -1346,6 +1347,7 @@ class Jira:
findings: list[Finding] = None,
project_key: str = None,
issue_type: str = None,
issue_labels: list[str] = None,
):
"""
Send the findings to Jira
@@ -1354,6 +1356,7 @@ class Jira:
- findings: The findings to send
- project_key: The project key
- issue_type: The issue type
- issue_labels: The issue labels
Raises:
- JiraRefreshTokenError: Failed to refresh the access token
@@ -1434,6 +1437,8 @@ class Jira:
"issuetype": {"name": issue_type},
}
}
if issue_labels:
payload["fields"]["labels"] = issue_labels
response = requests.post(
f"https://api.atlassian.com/ex/jira/{self.cloud_id}/rest/api/3/issue",
+5 -1
View File
@@ -606,7 +606,10 @@ class TestJiraIntegration:
self.jira_integration.cloud_id = "valid_cloud_id"
self.jira_integration.send_findings(
findings=[finding], project_key="TEST-1", issue_type="Bug"
findings=[finding],
project_key="TEST-1",
issue_type="Bug",
issue_labels=["scan-mocked", "whatever"],
)
mock_post.assert_called_once()
@@ -629,6 +632,7 @@ class TestJiraIntegration:
assert payload["fields"]["summary"] == "[Prowler] HIGH - CHECK-1 - resource-1"
assert payload["fields"]["issuetype"]["name"] == "Bug"
assert payload["fields"]["description"]["type"] == "doc"
assert payload["fields"]["labels"] == ["scan-mocked", "whatever"]
description_content = payload["fields"]["description"]["content"]