CheckmarxPythonSDK 1.8.9__py3-none-any.whl → 1.9.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CheckmarxPythonSDK/CxOne/__init__.py +14 -3
- CheckmarxPythonSDK/CxOne/aiRemediationAPI.py +128 -0
- CheckmarxPythonSDK/CxOne/aiTriageAPI.py +195 -0
- CheckmarxPythonSDK/CxOne/dto/AiRemediationDetails.py +24 -0
- CheckmarxPythonSDK/CxOne/dto/AiRemediationRequest.py +24 -0
- CheckmarxPythonSDK/CxOne/dto/AiRemediationResponse.py +32 -0
- CheckmarxPythonSDK/CxOne/dto/AiTriageInsight.py +32 -0
- CheckmarxPythonSDK/CxOne/dto/AiTriageRequest.py +23 -0
- CheckmarxPythonSDK/CxOne/dto/AiTriageResponse.py +34 -0
- CheckmarxPythonSDK/CxOne/dto/AiTriageResult.py +70 -0
- CheckmarxPythonSDK/CxOne/dto/AutoPr.py +21 -0
- CheckmarxPythonSDK/CxOne/dto/ConfidenceScore.py +14 -0
- CheckmarxPythonSDK/CxOne/dto/ExploitabilityAnalysis.py +16 -0
- CheckmarxPythonSDK/CxOne/dto/FileChange.py +18 -0
- CheckmarxPythonSDK/CxOne/dto/ReachabilityAnalysis.py +16 -0
- CheckmarxPythonSDK/CxOne/dto/ReasoningTrace.py +25 -0
- CheckmarxPythonSDK/CxOne/dto/RemediationAnalysis.py +18 -0
- CheckmarxPythonSDK/CxOne/dto/RemediationBucket.py +23 -0
- CheckmarxPythonSDK/CxOne/dto/RemediationData.py +37 -0
- CheckmarxPythonSDK/CxOne/dto/RemediationInsight.py +25 -0
- CheckmarxPythonSDK/CxOne/dto/RemediationResult.py +26 -0
- CheckmarxPythonSDK/CxOne/dto/RepositoryInfo.py +33 -0
- CheckmarxPythonSDK/CxOne/dto/Risk.py +66 -0
- CheckmarxPythonSDK/CxOne/dto/RiskCounter.py +27 -0
- CheckmarxPythonSDK/CxOne/dto/RiskWithAiInsights.py +81 -0
- CheckmarxPythonSDK/CxOne/dto/RisksAggregateResponse.py +25 -0
- CheckmarxPythonSDK/CxOne/dto/RisksAiInsightsResponse.py +32 -0
- CheckmarxPythonSDK/CxOne/dto/RisksMetaData.py +28 -0
- CheckmarxPythonSDK/CxOne/dto/RisksResponse.py +31 -0
- CheckmarxPythonSDK/CxOne/dto/TestCreation.py +27 -0
- CheckmarxPythonSDK/CxOne/dto/TestFile.py +22 -0
- CheckmarxPythonSDK/CxOne/dto/TriageAnalysis.py +23 -0
- CheckmarxPythonSDK/CxOne/dto/TriageBucket.py +23 -0
- CheckmarxPythonSDK/CxOne/dto/VerificationStep.py +27 -0
- CheckmarxPythonSDK/CxOne/dto/VulnerabilityMetadata.py +16 -0
- CheckmarxPythonSDK/CxOne/dto/__init__.py +32 -13
- CheckmarxPythonSDK/CxOne/riskOrchestrationAPI.py +523 -0
- CheckmarxPythonSDK/CxOne/scannersResultsAPI.py +10 -0
- CheckmarxPythonSDK/CxPortalSoapApiSDK/CxPortalWebService.py +2 -1
- CheckmarxPythonSDK/__version__.py +1 -1
- CheckmarxPythonSDK/api_client.py +0 -17
- {checkmarxpythonsdk-1.8.9.dist-info → checkmarxpythonsdk-1.9.0.dist-info}/METADATA +3 -1
- {checkmarxpythonsdk-1.8.9.dist-info → checkmarxpythonsdk-1.9.0.dist-info}/RECORD +46 -17
- {checkmarxpythonsdk-1.8.9.dist-info → checkmarxpythonsdk-1.9.0.dist-info}/WHEEL +1 -1
- CheckmarxPythonSDK/CxOne/aiTriageAndRemediationAPI.py +0 -294
- CheckmarxPythonSDK/CxOne/dto/AiTrProcessResult.py +0 -40
- CheckmarxPythonSDK/CxOne/dto/AiTrProcessStatusResponse.py +0 -33
- CheckmarxPythonSDK/CxOne/dto/AiTriageTriggerRequest.py +0 -17
- CheckmarxPythonSDK/CxOne/dto/AiTriageTriggerResponse.py +0 -23
- CheckmarxPythonSDK/CxOne/dto/AiTriageVulnerability.py +0 -25
- {checkmarxpythonsdk-1.8.9.dist-info → checkmarxpythonsdk-1.9.0.dist-info}/licenses/LICENSE +0 -0
- {checkmarxpythonsdk-1.8.9.dist-info → checkmarxpythonsdk-1.9.0.dist-info}/top_level.txt +0 -0
|
@@ -46,11 +46,22 @@ from .aiAssetsAPI import (
|
|
|
46
46
|
get_asset_risks,
|
|
47
47
|
)
|
|
48
48
|
|
|
49
|
-
from .
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
from .aiTriageAPI import (
|
|
50
|
+
AiTriageAPI,
|
|
51
|
+
get_ai_triage_status,
|
|
52
52
|
trigger_ai_triage,
|
|
53
|
+
retrieve_ai_triage_results,
|
|
54
|
+
)
|
|
55
|
+
from .aiRemediationAPI import (
|
|
56
|
+
AiRemediationAPI,
|
|
53
57
|
trigger_ai_remediation,
|
|
58
|
+
retrieve_ai_remediation_details,
|
|
59
|
+
)
|
|
60
|
+
from .riskOrchestrationAPI import (
|
|
61
|
+
RiskOrchestrationAPI,
|
|
62
|
+
get_risks,
|
|
63
|
+
get_risks_aggregate,
|
|
64
|
+
get_risks_ai_insights,
|
|
54
65
|
)
|
|
55
66
|
|
|
56
67
|
from .accessManagementAPI import (
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from CheckmarxPythonSDK.api_client import ApiClient
|
|
2
|
+
from CheckmarxPythonSDK.CxOne.config import construct_configuration
|
|
3
|
+
from .dto import (
|
|
4
|
+
AiRemediationRequest,
|
|
5
|
+
AiRemediationResponse,
|
|
6
|
+
AiRemediationDetails,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AiRemediationAPI(object):
|
|
11
|
+
"""API client for the AI Remediation REST API.
|
|
12
|
+
|
|
13
|
+
Submits requests to generate AI-powered remediation for vulnerabilities
|
|
14
|
+
within a scan and retrieves remediation details. AI Remediation first runs
|
|
15
|
+
AI Triage and then, when applicable, opens a pull request with the
|
|
16
|
+
suggested remediation. For manual projects, the remediation workflow
|
|
17
|
+
updates the RO table without opening a pull request. Currently supported
|
|
18
|
+
for SAST and SCA scanners only.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, api_client: ApiClient = None):
|
|
22
|
+
if api_client is None:
|
|
23
|
+
configuration = construct_configuration()
|
|
24
|
+
api_client = ApiClient(configuration=configuration)
|
|
25
|
+
self.api_client = api_client
|
|
26
|
+
self.base_url = (
|
|
27
|
+
f"{self.api_client.configuration.server_base_url}/api/remediation"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
def trigger_ai_remediation(
|
|
31
|
+
self, remediation_request: AiRemediationRequest
|
|
32
|
+
) -> AiRemediationResponse:
|
|
33
|
+
"""Submit a request to generate AI-powered remediation for one or more
|
|
34
|
+
vulnerabilities within a scan.
|
|
35
|
+
|
|
36
|
+
The request is processed asynchronously. A successful request returns
|
|
37
|
+
202 Accepted. Use retrieve_ai_remediation_details to poll for results.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
remediation_request (AiRemediationRequest): Request body containing
|
|
41
|
+
the scan ID and one or more scanner buckets (scannerType +
|
|
42
|
+
resultIDs). Result IDs are obtained from the alternateId field
|
|
43
|
+
returned by GET /api/results. URL-encoding the IDs is highly
|
|
44
|
+
recommended. At least one bucket is required.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
AiRemediationResponse: Response containing status ('accepted'),
|
|
48
|
+
published flag, existingState, and remediationJobId.
|
|
49
|
+
"""
|
|
50
|
+
url = f"{self.base_url}/remediate"
|
|
51
|
+
response = self.api_client.call_api(
|
|
52
|
+
method="POST",
|
|
53
|
+
url=url,
|
|
54
|
+
headers={"Accept": "application/json"},
|
|
55
|
+
json=remediation_request.to_dict(),
|
|
56
|
+
)
|
|
57
|
+
return AiRemediationResponse.from_dict(response.json())
|
|
58
|
+
|
|
59
|
+
def retrieve_ai_remediation_details(
|
|
60
|
+
self, scan_id: str, result_id: str
|
|
61
|
+
) -> AiRemediationDetails:
|
|
62
|
+
"""Retrieve AI Remediation details for a specific vulnerability within
|
|
63
|
+
a scan.
|
|
64
|
+
|
|
65
|
+
If remediation is still in progress or has failed, the response
|
|
66
|
+
contains the current job status. Otherwise, the completed remediation
|
|
67
|
+
details are returned.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
scan_id (str): Unique identifier of the scan.
|
|
71
|
+
result_id (str): Use the alternateId returned by GET /api/results.
|
|
72
|
+
URL-encoding is highly recommended.
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
AiRemediationDetails: Scan ID and per-result remediation details
|
|
76
|
+
including auto-PR status, code diffs, analysis, and generated
|
|
77
|
+
tests.
|
|
78
|
+
"""
|
|
79
|
+
url = f"{self.base_url}/remediation-details/{scan_id}/{result_id}"
|
|
80
|
+
response = self.api_client.call_api(
|
|
81
|
+
method="GET",
|
|
82
|
+
url=url,
|
|
83
|
+
headers={"Accept": "application/json"},
|
|
84
|
+
)
|
|
85
|
+
return AiRemediationDetails.from_dict(response.json())
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def trigger_ai_remediation(
|
|
89
|
+
remediation_request: AiRemediationRequest,
|
|
90
|
+
) -> AiRemediationResponse:
|
|
91
|
+
"""Submit a request to generate AI-powered remediation for one or more
|
|
92
|
+
vulnerabilities within a scan.
|
|
93
|
+
|
|
94
|
+
The request is processed asynchronously. A successful request returns
|
|
95
|
+
202 Accepted. Use retrieve_ai_remediation_details to poll for results.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
remediation_request (AiRemediationRequest): Request body containing the
|
|
99
|
+
scan ID and one or more scanner buckets (scannerType + resultIDs).
|
|
100
|
+
Result IDs are obtained from the alternateId field returned by
|
|
101
|
+
GET /api/results. URL-encoding the IDs is highly recommended. At
|
|
102
|
+
least one bucket is required.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
AiRemediationResponse: Response containing status ('accepted'),
|
|
106
|
+
published flag, existingState, and remediationJobId.
|
|
107
|
+
"""
|
|
108
|
+
return AiRemediationAPI().trigger_ai_remediation(remediation_request)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def retrieve_ai_remediation_details(scan_id: str, result_id: str) -> AiRemediationDetails:
|
|
112
|
+
"""Retrieve AI Remediation details for a specific vulnerability within a
|
|
113
|
+
scan.
|
|
114
|
+
|
|
115
|
+
If remediation is still in progress or has failed, the response contains
|
|
116
|
+
the current job status. Otherwise, the completed remediation details are
|
|
117
|
+
returned.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
scan_id (str): Unique identifier of the scan.
|
|
121
|
+
result_id (str): Use the alternateId returned by GET /api/results.
|
|
122
|
+
URL-encoding is highly recommended.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
AiRemediationDetails: Scan ID and per-result remediation details
|
|
126
|
+
including auto-PR status, code diffs, analysis, and generated tests.
|
|
127
|
+
"""
|
|
128
|
+
return AiRemediationAPI().retrieve_ai_remediation_details(scan_id, result_id)
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from CheckmarxPythonSDK.api_client import ApiClient
|
|
4
|
+
from CheckmarxPythonSDK.CxOne.config import construct_configuration
|
|
5
|
+
from .dto import (
|
|
6
|
+
AiTriageRequest,
|
|
7
|
+
AiTriageResponse,
|
|
8
|
+
AiTriageResult,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AiTriageAPI(object):
|
|
13
|
+
"""API client for the AI Triage REST API.
|
|
14
|
+
|
|
15
|
+
Submits requests to triage vulnerabilities within a scan and retrieves
|
|
16
|
+
triage results. AI Triage updates the vulnerability risk state and records
|
|
17
|
+
a changelog with a comment. Currently supported for SAST and SCA scanners.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, api_client: ApiClient = None):
|
|
21
|
+
if api_client is None:
|
|
22
|
+
configuration = construct_configuration()
|
|
23
|
+
api_client = ApiClient(configuration=configuration)
|
|
24
|
+
self.api_client = api_client
|
|
25
|
+
self.base_url = (
|
|
26
|
+
f"{self.api_client.configuration.server_base_url}/api/ai-triage"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
def trigger_ai_triage(
|
|
30
|
+
self, triage_request: AiTriageRequest
|
|
31
|
+
) -> AiTriageResponse:
|
|
32
|
+
"""Submit a request to triage vulnerabilities within a scan.
|
|
33
|
+
|
|
34
|
+
The request is processed asynchronously. A successful request returns
|
|
35
|
+
202 Accepted. Use retrieve_ai_triage_results to poll for results.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
triage_request (AiTriageRequest): Request body containing the scan
|
|
39
|
+
ID and one or more scanner buckets (scannerType + resultIDs).
|
|
40
|
+
Result IDs are obtained from the alternateId field returned by
|
|
41
|
+
GET /api/results. URL-encoding the IDs is highly recommended.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
AiTriageResponse: Response containing scanID, status ('accepted'),
|
|
45
|
+
triageID, published flag, and existingTriageState.
|
|
46
|
+
"""
|
|
47
|
+
url = f"{self.base_url}/triage"
|
|
48
|
+
response = self.api_client.call_api(
|
|
49
|
+
method="POST",
|
|
50
|
+
url=url,
|
|
51
|
+
headers={"Accept": "application/json"},
|
|
52
|
+
json=triage_request.to_dict(),
|
|
53
|
+
)
|
|
54
|
+
return AiTriageResponse.from_dict(response.json())
|
|
55
|
+
|
|
56
|
+
def get_ai_triage_status(
|
|
57
|
+
self, engine: str, group_id: int, project_id: str
|
|
58
|
+
) -> AiTriageResult:
|
|
59
|
+
"""Poll the SSE gateway for real-time AI Triage status updates.
|
|
60
|
+
|
|
61
|
+
Connects to the Server-Sent Events endpoint and blocks until the
|
|
62
|
+
stream closes, then returns the last triage status event received.
|
|
63
|
+
Heartbeat frames (`:heartbeat`) are ignored.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
engine (str): Scanner engine type, e.g. "sast".
|
|
67
|
+
group_id (int): Vulnerability group identifier (the similarityId
|
|
68
|
+
of the SAST result).
|
|
69
|
+
project_id (str): Unique identifier of the project.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
AiTriageResult: The last triage status event from the SSE stream,
|
|
73
|
+
or an empty AiTriageResult if the stream contained only heartbeats.
|
|
74
|
+
"""
|
|
75
|
+
url = (
|
|
76
|
+
f"{self.api_client.configuration.server_base_url}"
|
|
77
|
+
"/api/ssegateway/triage-status"
|
|
78
|
+
)
|
|
79
|
+
params = {
|
|
80
|
+
"engine": engine,
|
|
81
|
+
"groupId": group_id,
|
|
82
|
+
"projectId": project_id,
|
|
83
|
+
}
|
|
84
|
+
response = self.api_client.call_api(
|
|
85
|
+
method="GET",
|
|
86
|
+
url=url,
|
|
87
|
+
params=params,
|
|
88
|
+
headers={"Accept": "text/event-stream"},
|
|
89
|
+
)
|
|
90
|
+
last_event = {}
|
|
91
|
+
for line in response.text.splitlines():
|
|
92
|
+
line = line.strip()
|
|
93
|
+
if line.startswith("data:"):
|
|
94
|
+
payload = line[len("data:"):].strip()
|
|
95
|
+
try:
|
|
96
|
+
last_event = json.loads(payload)
|
|
97
|
+
except json.JSONDecodeError:
|
|
98
|
+
pass
|
|
99
|
+
return AiTriageResult.from_dict(last_event)
|
|
100
|
+
|
|
101
|
+
def retrieve_ai_triage_results(
|
|
102
|
+
self, project_id: str, group_id: str
|
|
103
|
+
) -> AiTriageResult:
|
|
104
|
+
"""Retrieve AI Triage results for a vulnerability group within a project.
|
|
105
|
+
|
|
106
|
+
Returns the full triage analysis if triage has completed, or the
|
|
107
|
+
current job status if still in progress. If the triage operation
|
|
108
|
+
failed, returns a failed job status.
|
|
109
|
+
|
|
110
|
+
The recommended way to obtain group_id is to call GET /api/risks for
|
|
111
|
+
the specified project and use the groupId field of the corresponding
|
|
112
|
+
risk object. If group_id contains reserved URL characters (e.g. #),
|
|
113
|
+
URL-encode the value before passing it (replace # with %23).
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
project_id (str): Unique identifier of the project.
|
|
117
|
+
group_id (str): Identifier of the vulnerability group. URL-encode
|
|
118
|
+
if the value contains reserved characters.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
AiTriageResult: Triage verdict, summary, confidence score,
|
|
122
|
+
reachability, exploitability, and supporting analysis details.
|
|
123
|
+
"""
|
|
124
|
+
url = f"{self.base_url}/triage/{project_id}/{group_id}"
|
|
125
|
+
response = self.api_client.call_api(
|
|
126
|
+
method="GET",
|
|
127
|
+
url=url,
|
|
128
|
+
headers={"Accept": "application/json"},
|
|
129
|
+
)
|
|
130
|
+
return AiTriageResult.from_dict(response.json())
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def get_ai_triage_status(
|
|
134
|
+
engine: str, group_id: int, project_id: str
|
|
135
|
+
) -> AiTriageResult:
|
|
136
|
+
"""Poll the SSE gateway for real-time AI Triage status updates.
|
|
137
|
+
|
|
138
|
+
Connects to the Server-Sent Events endpoint and blocks until the stream
|
|
139
|
+
closes, then returns the last triage status event received. Heartbeat
|
|
140
|
+
frames (`:heartbeat`) are ignored.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
engine (str): Scanner engine type, e.g. "sast".
|
|
144
|
+
group_id (int): Vulnerability group identifier (the similarityId of
|
|
145
|
+
the SAST result).
|
|
146
|
+
project_id (str): Unique identifier of the project.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
AiTriageResult: The last triage status event from the SSE stream, or
|
|
150
|
+
an empty AiTriageResult if the stream contained only heartbeats.
|
|
151
|
+
"""
|
|
152
|
+
return AiTriageAPI().get_ai_triage_status(engine, group_id, project_id)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def trigger_ai_triage(triage_request: AiTriageRequest) -> AiTriageResponse:
|
|
156
|
+
"""Submit a request to triage vulnerabilities within a scan.
|
|
157
|
+
|
|
158
|
+
The request is processed asynchronously. A successful request returns
|
|
159
|
+
202 Accepted. Use retrieve_ai_triage_results to poll for results.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
triage_request (AiTriageRequest): Request body containing the scan ID
|
|
163
|
+
and one or more scanner buckets (scannerType + resultIDs). Result
|
|
164
|
+
IDs are obtained from the alternateId field returned by
|
|
165
|
+
GET /api/results. URL-encoding the IDs is highly recommended.
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
AiTriageResponse: Response containing scanID, status ('accepted'),
|
|
169
|
+
triageID, published flag, and existingTriageState.
|
|
170
|
+
"""
|
|
171
|
+
return AiTriageAPI().trigger_ai_triage(triage_request)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def retrieve_ai_triage_results(project_id: str, group_id: str) -> AiTriageResult:
|
|
175
|
+
"""Retrieve AI Triage results for a vulnerability group within a project.
|
|
176
|
+
|
|
177
|
+
Returns the full triage analysis if triage has completed, or the current
|
|
178
|
+
job status if still in progress. If the triage operation failed, returns
|
|
179
|
+
a failed job status.
|
|
180
|
+
|
|
181
|
+
The recommended way to obtain group_id is to call GET /api/risks for the
|
|
182
|
+
specified project and use the groupId field of the corresponding risk
|
|
183
|
+
object. If group_id contains reserved URL characters (e.g. #), URL-encode
|
|
184
|
+
the value before passing it (replace # with %23).
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
project_id (str): Unique identifier of the project.
|
|
188
|
+
group_id (str): Identifier of the vulnerability group. URL-encode if
|
|
189
|
+
the value contains reserved characters.
|
|
190
|
+
|
|
191
|
+
Returns:
|
|
192
|
+
AiTriageResult: Triage verdict, summary, confidence score,
|
|
193
|
+
reachability, exploitability, and supporting analysis details.
|
|
194
|
+
"""
|
|
195
|
+
return AiTriageAPI().retrieve_ai_triage_results(project_id, group_id)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from .RemediationResult import RemediationResult
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class AiRemediationDetails:
|
|
9
|
+
"""Response from GET /api/remediation/remediation-details/{scan_id}/{result_id}.
|
|
10
|
+
|
|
11
|
+
Contains the remediation details for one or more vulnerability results in
|
|
12
|
+
a scan. If remediation is still in progress or has failed, the results
|
|
13
|
+
reflect the current job status.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
scanID: str = None
|
|
17
|
+
results: List[RemediationResult] = field(default_factory=list)
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def from_dict(cls, item: dict) -> "AiRemediationDetails":
|
|
21
|
+
return cls(
|
|
22
|
+
scanID=item.get("scanID"),
|
|
23
|
+
results=[RemediationResult.from_dict(r) for r in item.get("results", [])],
|
|
24
|
+
)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from .RemediationBucket import RemediationBucket
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class AiRemediationRequest:
|
|
9
|
+
"""Request body for POST /api/remediation/remediate.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
scanID (str): Scan identifier.
|
|
13
|
+
buckets (List[RemediationBucket]): One or more scanner-specific result
|
|
14
|
+
groups to remediate. Minimum 1 item required.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
scanID: str
|
|
18
|
+
buckets: List[RemediationBucket] = field(default_factory=list)
|
|
19
|
+
|
|
20
|
+
def to_dict(self) -> dict:
|
|
21
|
+
return {
|
|
22
|
+
"scanID": self.scanID,
|
|
23
|
+
"buckets": [b.to_dict() for b in self.buckets],
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class AiRemediationResponse:
|
|
7
|
+
"""Response from POST /api/remediation/remediate (202 Accepted).
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
status (str): Always 'accepted' when the request is successfully
|
|
11
|
+
accepted for processing.
|
|
12
|
+
published (bool): True if a new remediation job was submitted; False if
|
|
13
|
+
an identical request already exists and no duplicate was created.
|
|
14
|
+
existingState (str or None): Current state of the existing remediation
|
|
15
|
+
job when published is False; otherwise None.
|
|
16
|
+
remediationJobId (str): Unique identifier assigned to the remediation
|
|
17
|
+
operation.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
status: str = "accepted"
|
|
21
|
+
published: bool = True
|
|
22
|
+
existingState: Optional[str] = None
|
|
23
|
+
remediationJobId: str = None
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def from_dict(cls, item: dict) -> "AiRemediationResponse":
|
|
27
|
+
return cls(
|
|
28
|
+
status=item.get("status", "accepted"),
|
|
29
|
+
published=item.get("published", True),
|
|
30
|
+
existingState=item.get("existingState"),
|
|
31
|
+
remediationJobId=item.get("remediationJobId"),
|
|
32
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class AiTriageInsight:
|
|
7
|
+
"""AI triage summary embedded in a risk from GET /api/risks/ai-insights.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
triageStatus (str): VULNERABLE, PROPOSED_NOT_EXPLOITABLE, etc.
|
|
11
|
+
exploitability (str): UNKNOWN, EXPLOITABLE, NOT_EXPLOITABLE,
|
|
12
|
+
UNDETERMINED.
|
|
13
|
+
reachability (str): UNKNOWN, REACHABLE, NOT_REACHABLE, UNDETERMINED.
|
|
14
|
+
fixability (str): UNKNOWN, FIXABLE, NOT_FIXABLE.
|
|
15
|
+
completedAt (str): RFC3339 datetime when triage completed.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
triageStatus: Optional[str] = None
|
|
19
|
+
exploitability: Optional[str] = None
|
|
20
|
+
reachability: Optional[str] = None
|
|
21
|
+
fixability: Optional[str] = None
|
|
22
|
+
completedAt: Optional[str] = None
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def from_dict(cls, item: dict) -> "AiTriageInsight":
|
|
26
|
+
return cls(
|
|
27
|
+
triageStatus=item.get("triageStatus"),
|
|
28
|
+
exploitability=item.get("exploitability"),
|
|
29
|
+
reachability=item.get("reachability"),
|
|
30
|
+
fixability=item.get("fixability"),
|
|
31
|
+
completedAt=item.get("completedAt"),
|
|
32
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from .TriageBucket import TriageBucket
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class AiTriageRequest:
|
|
9
|
+
"""Request body for POST /api/ai-triage/triage.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
scanID (str): Scan identifier.
|
|
13
|
+
buckets (List[TriageBucket]): Scanner-specific result groups to triage.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
scanID: str
|
|
17
|
+
buckets: List[TriageBucket] = field(default_factory=list)
|
|
18
|
+
|
|
19
|
+
def to_dict(self) -> dict:
|
|
20
|
+
return {
|
|
21
|
+
"scanID": self.scanID,
|
|
22
|
+
"buckets": [b.to_dict() for b in self.buckets],
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class AiTriageResponse:
|
|
7
|
+
"""Response from POST /api/ai-triage/triage (202 Accepted).
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
scanID (str): Scan identifier.
|
|
11
|
+
status (str): Always 'accepted' when the request is successfully
|
|
12
|
+
accepted for processing.
|
|
13
|
+
triageID (str): Unique identifier assigned to the triage operation.
|
|
14
|
+
published (bool): True if a new triage job was submitted; False if an
|
|
15
|
+
identical request already exists and no duplicate was created.
|
|
16
|
+
existingTriageState (str or None): Current state of the existing triage
|
|
17
|
+
job when published is False; otherwise None.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
scanID: str = None
|
|
21
|
+
status: str = None
|
|
22
|
+
triageID: str = None
|
|
23
|
+
published: bool = True
|
|
24
|
+
existingTriageState: Optional[str] = None
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def from_dict(cls, item: dict) -> "AiTriageResponse":
|
|
28
|
+
return cls(
|
|
29
|
+
scanID=item.get("scanID"),
|
|
30
|
+
status=item.get("status"),
|
|
31
|
+
triageID=item.get("triageID"),
|
|
32
|
+
published=item.get("published", True),
|
|
33
|
+
existingTriageState=item.get("existingTriageState"),
|
|
34
|
+
)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from .TriageAnalysis import TriageAnalysis
|
|
5
|
+
from .VulnerabilityMetadata import VulnerabilityMetadata
|
|
6
|
+
from .ReasoningTrace import ReasoningTrace
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class AiTriageResult:
|
|
11
|
+
"""Response from GET /api/ai-triage/triage/{project_id}/{group_id}.
|
|
12
|
+
|
|
13
|
+
triageStatus allowed values:
|
|
14
|
+
NOT_TRIAGED, IN_PROGRESS, FAILED, VULNERABLE,
|
|
15
|
+
PROPOSED_NOT_EXPLOITABLE, UNCERTAIN, RISK_ACCEPTED
|
|
16
|
+
reachabilityStatus allowed values:
|
|
17
|
+
UNSPECIFIED, REACHABLE, NOT_REACHABLE, UNCERTAIN
|
|
18
|
+
exploitabilityStatus allowed values:
|
|
19
|
+
UNSPECIFIED, EXPLOITABLE, NOT_EXPLOITABLE, UNCERTAIN
|
|
20
|
+
attackabilityStatus allowed values:
|
|
21
|
+
UNSPECIFIED, ATTACKABLE, NOT_ATTACKABLE
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
resultID: str = None
|
|
25
|
+
scanner: str = None
|
|
26
|
+
triageStatus: str = None
|
|
27
|
+
reachabilityStatus: str = None
|
|
28
|
+
exploitabilityStatus: str = None
|
|
29
|
+
attackabilityStatus: str = None
|
|
30
|
+
summary: str = None
|
|
31
|
+
triagedAt: str = None
|
|
32
|
+
analysis: Optional[TriageAnalysis] = None
|
|
33
|
+
metadata: Optional[VulnerabilityMetadata] = None
|
|
34
|
+
reasoningTrace: Optional[ReasoningTrace] = None
|
|
35
|
+
mockOrigin: bool = False
|
|
36
|
+
groupId: Optional[str] = None
|
|
37
|
+
projectId: Optional[str] = None
|
|
38
|
+
sourceProjectId: Optional[str] = None
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def from_dict(cls, item: dict) -> "AiTriageResult":
|
|
42
|
+
return cls(
|
|
43
|
+
resultID=item.get("resultID"),
|
|
44
|
+
scanner=item.get("scanner"),
|
|
45
|
+
triageStatus=item.get("triageStatus"),
|
|
46
|
+
reachabilityStatus=item.get("reachabilityStatus"),
|
|
47
|
+
exploitabilityStatus=item.get("exploitabilityStatus"),
|
|
48
|
+
attackabilityStatus=item.get("attackabilityStatus"),
|
|
49
|
+
summary=item.get("summary"),
|
|
50
|
+
triagedAt=item.get("triagedAt"),
|
|
51
|
+
analysis=(
|
|
52
|
+
TriageAnalysis.from_dict(item["analysis"])
|
|
53
|
+
if item.get("analysis")
|
|
54
|
+
else None
|
|
55
|
+
),
|
|
56
|
+
metadata=(
|
|
57
|
+
VulnerabilityMetadata.from_dict(item["metadata"])
|
|
58
|
+
if item.get("metadata")
|
|
59
|
+
else None
|
|
60
|
+
),
|
|
61
|
+
reasoningTrace=(
|
|
62
|
+
ReasoningTrace.from_dict(item["reasoningTrace"])
|
|
63
|
+
if item.get("reasoningTrace")
|
|
64
|
+
else None
|
|
65
|
+
),
|
|
66
|
+
mockOrigin=item.get("mockOrigin", False),
|
|
67
|
+
groupId=item.get("groupId"),
|
|
68
|
+
projectId=item.get("projectId"),
|
|
69
|
+
sourceProjectId=item.get("sourceProjectId"),
|
|
70
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class AutoPr:
|
|
7
|
+
"""Information about the automatic pull request operation."""
|
|
8
|
+
|
|
9
|
+
status: str = None
|
|
10
|
+
url: Optional[str] = None
|
|
11
|
+
error_msg: str = None
|
|
12
|
+
file_url: str = None
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def from_dict(cls, item: dict) -> "AutoPr":
|
|
16
|
+
return cls(
|
|
17
|
+
status=item.get("status"),
|
|
18
|
+
url=item.get("url"),
|
|
19
|
+
error_msg=item.get("error_msg"),
|
|
20
|
+
file_url=item.get("file_url"),
|
|
21
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class ConfidenceScore:
|
|
6
|
+
score: int = 0
|
|
7
|
+
explanation: str = ""
|
|
8
|
+
|
|
9
|
+
@classmethod
|
|
10
|
+
def from_dict(cls, item: dict) -> "ConfidenceScore":
|
|
11
|
+
return cls(
|
|
12
|
+
score=item.get("score", 0),
|
|
13
|
+
explanation=item.get("explanation", ""),
|
|
14
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class ExploitabilityAnalysis:
|
|
6
|
+
"""Allowed status values: UNSPECIFIED, EXPLOITABLE, NOT_EXPLOITABLE, UNCERTAIN."""
|
|
7
|
+
|
|
8
|
+
status: str = "UNSPECIFIED"
|
|
9
|
+
reasoning: str = ""
|
|
10
|
+
|
|
11
|
+
@classmethod
|
|
12
|
+
def from_dict(cls, item: dict) -> "ExploitabilityAnalysis":
|
|
13
|
+
return cls(
|
|
14
|
+
status=item.get("status", "UNSPECIFIED"),
|
|
15
|
+
reasoning=item.get("reasoning", ""),
|
|
16
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class FileChange:
|
|
6
|
+
"""A source code change generated by the remediation."""
|
|
7
|
+
|
|
8
|
+
file_path: str = None
|
|
9
|
+
analysis: str = None
|
|
10
|
+
diff: str = None
|
|
11
|
+
|
|
12
|
+
@classmethod
|
|
13
|
+
def from_dict(cls, item: dict) -> "FileChange":
|
|
14
|
+
return cls(
|
|
15
|
+
file_path=item.get("file_path"),
|
|
16
|
+
analysis=item.get("analysis"),
|
|
17
|
+
diff=item.get("diff"),
|
|
18
|
+
)
|