get_issue
Retrieve specific vulnerability details and patch information by issue ID to analyze security findings and remediation options.
Instructions
Get a specific vulnerability issue by its ID, including patch information if available.
Args:
issue_id (str): The ID of the issue to retrieve
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issue_id | Yes |
Implementation Reference
- The core handler function for the 'get_issue' tool. Decorated with @mcp.tool() for automatic registration in the MCP server. Retrieves issue details from the ZeroPath API using the 'issues/get' endpoint and formats the response using process_issue_response.@mcp.tool() def get_issue(issue_id): """ Get a specific vulnerability issue by its ID, including patch information if available. Args: issue_id (str): The ID of the issue to retrieve """ if not issue_id: return "Error: Issue ID is required" response, error = make_api_request("issues/get", {"issueId": issue_id}) if error: return error if response.status_code == 200: raw_response = response.json() if not raw_response: return "Error: Empty response received from API" return process_issue_response(raw_response) elif response.status_code == 401: return "Error: Unauthorized - check API credentials" elif response.status_code == 400: return f"Error: Bad request - {response.text}" else: return f"Error: API returned status {response.status_code}: {response.text}"
- Supporting helper function that transforms the raw API response for an issue into a formatted, readable string output. Extracts and displays key details such as ID, status, severity, vulnerable code, and any available patch information including git diff.def process_issue_response(issue): """ Process a single issue response into a readable format, focusing on the issue details and patch. """ if not issue: return "Error: Empty issue data" if "error" in issue and issue["error"]: return f"Error: {issue['error']}" # Check if we have a valid issue (must have an id at minimum) if not issue.get('id'): return "Error: Invalid issue data received - missing ID" # Get patch information if available patch = issue.get("patch") or issue.get("vulnerabilityPatch") result = "Issue Details:\n" result += f"ID: {issue.get('id', 'N/A')}\n" result += f"Status: {issue.get('status', 'N/A')}\n" result += f"Title: {issue.get('generatedTitle', 'N/A')}\n" result += f"Description: {issue.get('generatedDescription', 'N/A')}\n" result += f"Language: {issue.get('language', 'N/A')}\n" result += f"Vulnerability Class: {issue.get('vulnClass', 'N/A')}\n" if issue.get("cwes"): result += f"CWEs: {', '.join(issue.get('cwes', []))}\n" result += f"Severity: {issue.get('severity', 'N/A')}\n" result += f"Affected File: {issue.get('affectedFile', 'N/A')}\n" if issue.get("startLine") and issue.get("endLine"): result += f"Location: Lines {issue.get('startLine')} to {issue.get('endLine')}\n" result += f"Validation Status: {issue.get('validated', 'N/A')}\n" result += f"Unpatchable: {issue.get('unpatchable', False)}\n" result += f"Triage Phase: {issue.get('triagePhase', 'N/A')}\n" # Add code segment if available if issue.get("sastCodeSegment"): result += "\nVulnerable Code Segment:\n" result += f"```\n{issue.get('sastCodeSegment')}\n```\n" # Add patch information if available if patch and not issue.get("unpatchable", False): result += "\n========== PATCH INFORMATION ==========\n" result += f"PR Link: {patch.get('prLink', 'N/A')}\n" result += f"PR Title: {patch.get('prTitle', 'N/A')}\n" result += f"PR Description: {patch.get('prDescription', 'N/A')}\n" result += f"PR Status: {patch.get('pullRequestStatus', 'N/A')}\n" result += f"Validation Status: {patch.get('validated', 'N/A')}\n" result += f"Created At: {patch.get('createdAt', 'N/A')}\n" result += f"Updated At: {patch.get('updatedAt', 'N/A')}\n" # Add git diff if available if patch.get("gitDiff"): result += "\n========== PATCH ID & GIT DIFF ==========\n" result += f"PATCH ID: {patch.get('id', 'N/A')}\n" result += "========================================\n" result += "Git Diff:\n" result += f"```diff\n{patch.get('gitDiff')}\n```\n" return result
- General helper function used by get_issue to make authenticated POST requests to the ZeroPath API endpoints.def make_api_request(endpoint, payload=None, include_org=True): """Make authenticated API request to ZeroPath.""" if not token_id or not token_secret: return None, "Error: Zeropath API credentials not found in environment variables" headers = { "X-ZeroPath-API-Token-Id": token_id, "X-ZeroPath-API-Token-Secret": token_secret, "Content-Type": "application/json" } if payload is None: payload = {} if include_org and org_id: payload["organizationId"] = org_id try: response = requests.post( f"{API_BASE_URL}/{endpoint}", headers=headers, json=payload ) return response, None except Exception as e: return None, f"Error: {str(e)}"