binalyze-air-sdk 1.0.2__py3-none-any.whl → 1.0.3__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.
- binalyze_air/__init__.py +77 -77
- binalyze_air/apis/__init__.py +67 -27
- binalyze_air/apis/acquisitions.py +107 -0
- binalyze_air/apis/api_tokens.py +49 -0
- binalyze_air/apis/assets.py +161 -0
- binalyze_air/apis/audit_logs.py +26 -0
- binalyze_air/apis/{authentication.py → auth.py} +29 -27
- binalyze_air/apis/auto_asset_tags.py +79 -75
- binalyze_air/apis/backup.py +177 -0
- binalyze_air/apis/baseline.py +46 -0
- binalyze_air/apis/cases.py +225 -0
- binalyze_air/apis/cloud_forensics.py +116 -0
- binalyze_air/apis/event_subscription.py +96 -96
- binalyze_air/apis/evidence.py +249 -53
- binalyze_air/apis/interact.py +153 -36
- binalyze_air/apis/investigation_hub.py +234 -0
- binalyze_air/apis/license.py +104 -0
- binalyze_air/apis/logger.py +83 -0
- binalyze_air/apis/multipart_upload.py +201 -0
- binalyze_air/apis/notifications.py +115 -0
- binalyze_air/apis/organizations.py +267 -0
- binalyze_air/apis/params.py +44 -39
- binalyze_air/apis/policies.py +186 -0
- binalyze_air/apis/preset_filters.py +79 -0
- binalyze_air/apis/recent_activities.py +71 -0
- binalyze_air/apis/relay_server.py +104 -0
- binalyze_air/apis/settings.py +395 -27
- binalyze_air/apis/tasks.py +80 -0
- binalyze_air/apis/triage.py +197 -0
- binalyze_air/apis/user_management.py +183 -74
- binalyze_air/apis/webhook_executions.py +50 -0
- binalyze_air/apis/webhooks.py +322 -230
- binalyze_air/base.py +207 -133
- binalyze_air/client.py +217 -1337
- binalyze_air/commands/__init__.py +175 -145
- binalyze_air/commands/acquisitions.py +661 -387
- binalyze_air/commands/api_tokens.py +55 -0
- binalyze_air/commands/assets.py +324 -362
- binalyze_air/commands/{authentication.py → auth.py} +36 -36
- binalyze_air/commands/auto_asset_tags.py +230 -230
- binalyze_air/commands/backup.py +47 -0
- binalyze_air/commands/baseline.py +32 -396
- binalyze_air/commands/cases.py +609 -602
- binalyze_air/commands/cloud_forensics.py +88 -0
- binalyze_air/commands/event_subscription.py +101 -101
- binalyze_air/commands/evidences.py +918 -988
- binalyze_air/commands/interact.py +172 -58
- binalyze_air/commands/investigation_hub.py +315 -0
- binalyze_air/commands/license.py +183 -0
- binalyze_air/commands/logger.py +126 -0
- binalyze_air/commands/multipart_upload.py +363 -0
- binalyze_air/commands/notifications.py +45 -0
- binalyze_air/commands/organizations.py +200 -221
- binalyze_air/commands/policies.py +175 -203
- binalyze_air/commands/preset_filters.py +55 -0
- binalyze_air/commands/recent_activities.py +32 -0
- binalyze_air/commands/relay_server.py +144 -0
- binalyze_air/commands/settings.py +431 -29
- binalyze_air/commands/tasks.py +95 -56
- binalyze_air/commands/triage.py +224 -360
- binalyze_air/commands/user_management.py +351 -126
- binalyze_air/commands/webhook_executions.py +77 -0
- binalyze_air/config.py +244 -244
- binalyze_air/exceptions.py +49 -49
- binalyze_air/http_client.py +426 -305
- binalyze_air/models/__init__.py +287 -285
- binalyze_air/models/acquisitions.py +365 -250
- binalyze_air/models/api_tokens.py +73 -0
- binalyze_air/models/assets.py +438 -438
- binalyze_air/models/audit.py +247 -272
- binalyze_air/models/audit_logs.py +14 -0
- binalyze_air/models/{authentication.py → auth.py} +69 -69
- binalyze_air/models/auto_asset_tags.py +227 -116
- binalyze_air/models/backup.py +138 -0
- binalyze_air/models/baseline.py +231 -231
- binalyze_air/models/cases.py +275 -275
- binalyze_air/models/cloud_forensics.py +145 -0
- binalyze_air/models/event_subscription.py +170 -171
- binalyze_air/models/evidence.py +65 -65
- binalyze_air/models/evidences.py +367 -348
- binalyze_air/models/interact.py +266 -135
- binalyze_air/models/investigation_hub.py +265 -0
- binalyze_air/models/license.py +150 -0
- binalyze_air/models/logger.py +83 -0
- binalyze_air/models/multipart_upload.py +352 -0
- binalyze_air/models/notifications.py +138 -0
- binalyze_air/models/organizations.py +293 -293
- binalyze_air/models/params.py +153 -127
- binalyze_air/models/policies.py +260 -249
- binalyze_air/models/preset_filters.py +79 -0
- binalyze_air/models/recent_activities.py +70 -0
- binalyze_air/models/relay_server.py +121 -0
- binalyze_air/models/settings.py +538 -84
- binalyze_air/models/tasks.py +215 -149
- binalyze_air/models/triage.py +141 -142
- binalyze_air/models/user_management.py +200 -97
- binalyze_air/models/webhook_executions.py +33 -0
- binalyze_air/queries/__init__.py +121 -133
- binalyze_air/queries/acquisitions.py +155 -155
- binalyze_air/queries/api_tokens.py +46 -0
- binalyze_air/queries/assets.py +186 -105
- binalyze_air/queries/audit.py +400 -416
- binalyze_air/queries/{authentication.py → auth.py} +55 -55
- binalyze_air/queries/auto_asset_tags.py +59 -59
- binalyze_air/queries/backup.py +66 -0
- binalyze_air/queries/baseline.py +21 -185
- binalyze_air/queries/cases.py +292 -292
- binalyze_air/queries/cloud_forensics.py +137 -0
- binalyze_air/queries/event_subscription.py +54 -54
- binalyze_air/queries/evidence.py +139 -139
- binalyze_air/queries/evidences.py +279 -279
- binalyze_air/queries/interact.py +140 -28
- binalyze_air/queries/investigation_hub.py +329 -0
- binalyze_air/queries/license.py +85 -0
- binalyze_air/queries/logger.py +58 -0
- binalyze_air/queries/multipart_upload.py +180 -0
- binalyze_air/queries/notifications.py +71 -0
- binalyze_air/queries/organizations.py +222 -222
- binalyze_air/queries/params.py +154 -115
- binalyze_air/queries/policies.py +149 -149
- binalyze_air/queries/preset_filters.py +60 -0
- binalyze_air/queries/recent_activities.py +44 -0
- binalyze_air/queries/relay_server.py +42 -0
- binalyze_air/queries/settings.py +533 -20
- binalyze_air/queries/tasks.py +125 -81
- binalyze_air/queries/triage.py +230 -230
- binalyze_air/queries/user_management.py +193 -83
- binalyze_air/queries/webhook_executions.py +39 -0
- binalyze_air_sdk-1.0.3.dist-info/METADATA +752 -0
- binalyze_air_sdk-1.0.3.dist-info/RECORD +132 -0
- {binalyze_air_sdk-1.0.2.dist-info → binalyze_air_sdk-1.0.3.dist-info}/WHEEL +1 -1
- binalyze_air/apis/endpoints.py +0 -22
- binalyze_air/apis/evidences.py +0 -216
- binalyze_air/apis/users.py +0 -68
- binalyze_air/commands/users.py +0 -101
- binalyze_air/models/endpoints.py +0 -76
- binalyze_air/models/users.py +0 -82
- binalyze_air/queries/endpoints.py +0 -25
- binalyze_air/queries/users.py +0 -69
- binalyze_air_sdk-1.0.2.dist-info/METADATA +0 -706
- binalyze_air_sdk-1.0.2.dist-info/RECORD +0 -82
- {binalyze_air_sdk-1.0.2.dist-info → binalyze_air_sdk-1.0.3.dist-info}/top_level.txt +0 -0
@@ -1,280 +1,280 @@
|
|
1
|
-
"""
|
2
|
-
Evidences/Repositories-related queries for the Binalyze AIR SDK.
|
3
|
-
"""
|
4
|
-
|
5
|
-
from typing import List, Optional
|
6
|
-
|
7
|
-
from ..base import Query
|
8
|
-
from ..models.evidences import (
|
9
|
-
EvidenceRepository, AmazonS3Repository, AzureStorageRepository,
|
10
|
-
FTPSRepository, SFTPRepository, SMBRepository, RepositoryFilter
|
11
|
-
)
|
12
|
-
from ..http_client import HTTPClient
|
13
|
-
|
14
|
-
|
15
|
-
class ListRepositoriesQuery(Query[List[EvidenceRepository]]):
|
16
|
-
"""Query to list evidence repositories."""
|
17
|
-
|
18
|
-
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None, organization_ids: Optional[List[int]] = None):
|
19
|
-
self.http_client = http_client
|
20
|
-
self.filter_params = filter_params
|
21
|
-
self.organization_ids = organization_ids or [0]
|
22
|
-
|
23
|
-
def execute(self) -> List[EvidenceRepository]:
|
24
|
-
"""Execute the list repositories query."""
|
25
|
-
params = {}
|
26
|
-
if self.filter_params:
|
27
|
-
params = self.filter_params.to_params()
|
28
|
-
else:
|
29
|
-
# Add required organization IDs filter if no filter provided
|
30
|
-
params["filter[organizationIds]"] = ",".join(map(str, self.organization_ids))
|
31
|
-
|
32
|
-
# Ensure consistent sorting to match API defaults
|
33
|
-
if "sortBy" not in params:
|
34
|
-
params["sortBy"] = "createdAt"
|
35
|
-
if "sortType" not in params:
|
36
|
-
params["sortType"] = "ASC"
|
37
|
-
|
38
|
-
response = self.http_client.get("evidences/repositories", params=params)
|
39
|
-
|
40
|
-
if response.get("success"):
|
41
|
-
repositories_data = response.get("result", {}).get("entities", [])
|
42
|
-
|
43
|
-
# Use Pydantic parsing with proper field aliasing
|
44
|
-
repositories = []
|
45
|
-
for repo_data in repositories_data:
|
46
|
-
repositories.append(EvidenceRepository.model_validate(repo_data))
|
47
|
-
|
48
|
-
return repositories
|
49
|
-
|
50
|
-
return []
|
51
|
-
|
52
|
-
|
53
|
-
class GetRepositoryQuery(Query[EvidenceRepository]):
|
54
|
-
"""Query to get evidence repository by ID."""
|
55
|
-
|
56
|
-
def __init__(self, http_client: HTTPClient, repository_id: str):
|
57
|
-
self.http_client = http_client
|
58
|
-
self.repository_id = repository_id
|
59
|
-
|
60
|
-
def execute(self) -> EvidenceRepository:
|
61
|
-
"""Execute the get repository query."""
|
62
|
-
response = self.http_client.get(f"evidences/repositories/{self.repository_id}")
|
63
|
-
|
64
|
-
if response.get("success"):
|
65
|
-
repository_data = response.get("result", {})
|
66
|
-
|
67
|
-
# Use Pydantic parsing with proper field aliasing
|
68
|
-
return EvidenceRepository.model_validate(repository_data)
|
69
|
-
|
70
|
-
raise Exception(f"Evidence repository not found: {self.repository_id}")
|
71
|
-
|
72
|
-
|
73
|
-
# Amazon S3 Repository Queries
|
74
|
-
|
75
|
-
class ListAmazonS3RepositoriesQuery(Query[List[AmazonS3Repository]]):
|
76
|
-
"""Query to list Amazon S3 repositories."""
|
77
|
-
|
78
|
-
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
79
|
-
self.http_client = http_client
|
80
|
-
self.filter_params = filter_params
|
81
|
-
|
82
|
-
def execute(self) -> List[AmazonS3Repository]:
|
83
|
-
"""Execute the list Amazon S3 repositories query."""
|
84
|
-
params = {}
|
85
|
-
if self.filter_params:
|
86
|
-
params = self.filter_params.model_dump(exclude_none=True)
|
87
|
-
|
88
|
-
response = self.http_client.get("evidences/repositories/amazon-s3", params=params)
|
89
|
-
|
90
|
-
if response.get("success"):
|
91
|
-
repositories_data = response.get("result", {}).get("entities", [])
|
92
|
-
return [AmazonS3Repository(**repo) for repo in repositories_data]
|
93
|
-
|
94
|
-
return []
|
95
|
-
|
96
|
-
|
97
|
-
class GetAmazonS3RepositoryQuery(Query[AmazonS3Repository]):
|
98
|
-
"""Query to get Amazon S3 repository by ID."""
|
99
|
-
|
100
|
-
def __init__(self, http_client: HTTPClient, repository_id: str):
|
101
|
-
self.http_client = http_client
|
102
|
-
self.repository_id = repository_id
|
103
|
-
|
104
|
-
def execute(self) -> AmazonS3Repository:
|
105
|
-
"""Execute the get Amazon S3 repository query."""
|
106
|
-
response = self.http_client.get(f"evidences/repositories/amazon-s3/{self.repository_id}")
|
107
|
-
|
108
|
-
if response.get("success"):
|
109
|
-
repository_data = response.get("result", {})
|
110
|
-
return AmazonS3Repository(**repository_data)
|
111
|
-
|
112
|
-
raise Exception(f"Amazon S3 repository not found: {self.repository_id}")
|
113
|
-
|
114
|
-
|
115
|
-
# Azure Storage Repository Queries
|
116
|
-
|
117
|
-
class ListAzureStorageRepositoriesQuery(Query[List[AzureStorageRepository]]):
|
118
|
-
"""Query to list Azure Storage repositories."""
|
119
|
-
|
120
|
-
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
121
|
-
self.http_client = http_client
|
122
|
-
self.filter_params = filter_params
|
123
|
-
|
124
|
-
def execute(self) -> List[AzureStorageRepository]:
|
125
|
-
"""Execute the list Azure Storage repositories query."""
|
126
|
-
params = {}
|
127
|
-
if self.filter_params:
|
128
|
-
params = self.filter_params.model_dump(exclude_none=True)
|
129
|
-
|
130
|
-
response = self.http_client.get("evidences/repositories/azure-storage", params=params)
|
131
|
-
|
132
|
-
if response.get("success"):
|
133
|
-
repositories_data = response.get("result", {}).get("entities", [])
|
134
|
-
return [AzureStorageRepository(**repo) for repo in repositories_data]
|
135
|
-
|
136
|
-
return []
|
137
|
-
|
138
|
-
|
139
|
-
class GetAzureStorageRepositoryQuery(Query[AzureStorageRepository]):
|
140
|
-
"""Query to get Azure Storage repository by ID."""
|
141
|
-
|
142
|
-
def __init__(self, http_client: HTTPClient, repository_id: str):
|
143
|
-
self.http_client = http_client
|
144
|
-
self.repository_id = repository_id
|
145
|
-
|
146
|
-
def execute(self) -> AzureStorageRepository:
|
147
|
-
"""Execute the get Azure Storage repository query."""
|
148
|
-
response = self.http_client.get(f"evidences/repositories/azure-storage/{self.repository_id}")
|
149
|
-
|
150
|
-
if response.get("success"):
|
151
|
-
repository_data = response.get("result", {})
|
152
|
-
return AzureStorageRepository(**repository_data)
|
153
|
-
|
154
|
-
raise Exception(f"Azure Storage repository not found: {self.repository_id}")
|
155
|
-
|
156
|
-
|
157
|
-
# FTPS Repository Queries
|
158
|
-
|
159
|
-
class ListFTPSRepositoriesQuery(Query[List[FTPSRepository]]):
|
160
|
-
"""Query to list FTPS repositories."""
|
161
|
-
|
162
|
-
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
163
|
-
self.http_client = http_client
|
164
|
-
self.filter_params = filter_params
|
165
|
-
|
166
|
-
def execute(self) -> List[FTPSRepository]:
|
167
|
-
"""Execute the list FTPS repositories query."""
|
168
|
-
params = {}
|
169
|
-
if self.filter_params:
|
170
|
-
params = self.filter_params.model_dump(exclude_none=True)
|
171
|
-
|
172
|
-
response = self.http_client.get("evidences/repositories/ftps", params=params)
|
173
|
-
|
174
|
-
if response.get("success"):
|
175
|
-
repositories_data = response.get("result", {}).get("entities", [])
|
176
|
-
return [FTPSRepository(**repo) for repo in repositories_data]
|
177
|
-
|
178
|
-
return []
|
179
|
-
|
180
|
-
|
181
|
-
class GetFTPSRepositoryQuery(Query[FTPSRepository]):
|
182
|
-
"""Query to get FTPS repository by ID."""
|
183
|
-
|
184
|
-
def __init__(self, http_client: HTTPClient, repository_id: str):
|
185
|
-
self.http_client = http_client
|
186
|
-
self.repository_id = repository_id
|
187
|
-
|
188
|
-
def execute(self) -> FTPSRepository:
|
189
|
-
"""Execute the get FTPS repository query."""
|
190
|
-
response = self.http_client.get(f"evidences/repositories/ftps/{self.repository_id}")
|
191
|
-
|
192
|
-
if response.get("success"):
|
193
|
-
repository_data = response.get("result", {})
|
194
|
-
return FTPSRepository(**repository_data)
|
195
|
-
|
196
|
-
raise Exception(f"FTPS repository not found: {self.repository_id}")
|
197
|
-
|
198
|
-
|
199
|
-
# SFTP Repository Queries
|
200
|
-
|
201
|
-
class ListSFTPRepositoriesQuery(Query[List[SFTPRepository]]):
|
202
|
-
"""Query to list SFTP repositories."""
|
203
|
-
|
204
|
-
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
205
|
-
self.http_client = http_client
|
206
|
-
self.filter_params = filter_params
|
207
|
-
|
208
|
-
def execute(self) -> List[SFTPRepository]:
|
209
|
-
"""Execute the list SFTP repositories query."""
|
210
|
-
params = {}
|
211
|
-
if self.filter_params:
|
212
|
-
params = self.filter_params.model_dump(exclude_none=True)
|
213
|
-
|
214
|
-
response = self.http_client.get("evidences/repositories/sftp", params=params)
|
215
|
-
|
216
|
-
if response.get("success"):
|
217
|
-
repositories_data = response.get("result", {}).get("entities", [])
|
218
|
-
return [SFTPRepository(**repo) for repo in repositories_data]
|
219
|
-
|
220
|
-
return []
|
221
|
-
|
222
|
-
|
223
|
-
class GetSFTPRepositoryQuery(Query[SFTPRepository]):
|
224
|
-
"""Query to get SFTP repository by ID."""
|
225
|
-
|
226
|
-
def __init__(self, http_client: HTTPClient, repository_id: str):
|
227
|
-
self.http_client = http_client
|
228
|
-
self.repository_id = repository_id
|
229
|
-
|
230
|
-
def execute(self) -> SFTPRepository:
|
231
|
-
"""Execute the get SFTP repository query."""
|
232
|
-
response = self.http_client.get(f"evidences/repositories/sftp/{self.repository_id}")
|
233
|
-
|
234
|
-
if response.get("success"):
|
235
|
-
repository_data = response.get("result", {})
|
236
|
-
return SFTPRepository(**repository_data)
|
237
|
-
|
238
|
-
raise Exception(f"SFTP repository not found: {self.repository_id}")
|
239
|
-
|
240
|
-
|
241
|
-
# SMB Repository Queries
|
242
|
-
|
243
|
-
class ListSMBRepositoriesQuery(Query[List[SMBRepository]]):
|
244
|
-
"""Query to list SMB repositories."""
|
245
|
-
|
246
|
-
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
247
|
-
self.http_client = http_client
|
248
|
-
self.filter_params = filter_params
|
249
|
-
|
250
|
-
def execute(self) -> List[SMBRepository]:
|
251
|
-
"""Execute the list SMB repositories query."""
|
252
|
-
params = {}
|
253
|
-
if self.filter_params:
|
254
|
-
params = self.filter_params.model_dump(exclude_none=True)
|
255
|
-
|
256
|
-
response = self.http_client.get("evidences/repositories/smb", params=params)
|
257
|
-
|
258
|
-
if response.get("success"):
|
259
|
-
repositories_data = response.get("result", {}).get("entities", [])
|
260
|
-
return [SMBRepository(**repo) for repo in repositories_data]
|
261
|
-
|
262
|
-
return []
|
263
|
-
|
264
|
-
|
265
|
-
class GetSMBRepositoryQuery(Query[SMBRepository]):
|
266
|
-
"""Query to get SMB repository by ID."""
|
267
|
-
|
268
|
-
def __init__(self, http_client: HTTPClient, repository_id: str):
|
269
|
-
self.http_client = http_client
|
270
|
-
self.repository_id = repository_id
|
271
|
-
|
272
|
-
def execute(self) -> SMBRepository:
|
273
|
-
"""Execute the get SMB repository query."""
|
274
|
-
response = self.http_client.get(f"evidences/repositories/smb/{self.repository_id}")
|
275
|
-
|
276
|
-
if response.get("success"):
|
277
|
-
repository_data = response.get("result", {})
|
278
|
-
return SMBRepository(**repository_data)
|
279
|
-
|
1
|
+
"""
|
2
|
+
Evidences/Repositories-related queries for the Binalyze AIR SDK.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from typing import List, Optional
|
6
|
+
|
7
|
+
from ..base import Query
|
8
|
+
from ..models.evidences import (
|
9
|
+
EvidenceRepository, AmazonS3Repository, AzureStorageRepository,
|
10
|
+
FTPSRepository, SFTPRepository, SMBRepository, RepositoryFilter
|
11
|
+
)
|
12
|
+
from ..http_client import HTTPClient
|
13
|
+
|
14
|
+
|
15
|
+
class ListRepositoriesQuery(Query[List[EvidenceRepository]]):
|
16
|
+
"""Query to list evidence repositories."""
|
17
|
+
|
18
|
+
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None, organization_ids: Optional[List[int]] = None):
|
19
|
+
self.http_client = http_client
|
20
|
+
self.filter_params = filter_params
|
21
|
+
self.organization_ids = organization_ids or [0]
|
22
|
+
|
23
|
+
def execute(self) -> List[EvidenceRepository]:
|
24
|
+
"""Execute the list repositories query."""
|
25
|
+
params = {}
|
26
|
+
if self.filter_params:
|
27
|
+
params = self.filter_params.to_params()
|
28
|
+
else:
|
29
|
+
# Add required organization IDs filter if no filter provided
|
30
|
+
params["filter[organizationIds]"] = ",".join(map(str, self.organization_ids))
|
31
|
+
|
32
|
+
# Ensure consistent sorting to match API defaults
|
33
|
+
if "sortBy" not in params:
|
34
|
+
params["sortBy"] = "createdAt"
|
35
|
+
if "sortType" not in params:
|
36
|
+
params["sortType"] = "ASC"
|
37
|
+
|
38
|
+
response = self.http_client.get("evidences/repositories", params=params)
|
39
|
+
|
40
|
+
if response.get("success"):
|
41
|
+
repositories_data = response.get("result", {}).get("entities", [])
|
42
|
+
|
43
|
+
# Use Pydantic parsing with proper field aliasing
|
44
|
+
repositories = []
|
45
|
+
for repo_data in repositories_data:
|
46
|
+
repositories.append(EvidenceRepository.model_validate(repo_data))
|
47
|
+
|
48
|
+
return repositories
|
49
|
+
|
50
|
+
return []
|
51
|
+
|
52
|
+
|
53
|
+
class GetRepositoryQuery(Query[EvidenceRepository]):
|
54
|
+
"""Query to get evidence repository by ID."""
|
55
|
+
|
56
|
+
def __init__(self, http_client: HTTPClient, repository_id: str):
|
57
|
+
self.http_client = http_client
|
58
|
+
self.repository_id = repository_id
|
59
|
+
|
60
|
+
def execute(self) -> EvidenceRepository:
|
61
|
+
"""Execute the get repository query."""
|
62
|
+
response = self.http_client.get(f"evidences/repositories/{self.repository_id}")
|
63
|
+
|
64
|
+
if response.get("success"):
|
65
|
+
repository_data = response.get("result", {})
|
66
|
+
|
67
|
+
# Use Pydantic parsing with proper field aliasing
|
68
|
+
return EvidenceRepository.model_validate(repository_data)
|
69
|
+
|
70
|
+
raise Exception(f"Evidence repository not found: {self.repository_id}")
|
71
|
+
|
72
|
+
|
73
|
+
# Amazon S3 Repository Queries
|
74
|
+
|
75
|
+
class ListAmazonS3RepositoriesQuery(Query[List[AmazonS3Repository]]):
|
76
|
+
"""Query to list Amazon S3 repositories."""
|
77
|
+
|
78
|
+
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
79
|
+
self.http_client = http_client
|
80
|
+
self.filter_params = filter_params
|
81
|
+
|
82
|
+
def execute(self) -> List[AmazonS3Repository]:
|
83
|
+
"""Execute the list Amazon S3 repositories query."""
|
84
|
+
params = {}
|
85
|
+
if self.filter_params:
|
86
|
+
params = self.filter_params.model_dump(exclude_none=True)
|
87
|
+
|
88
|
+
response = self.http_client.get("evidences/repositories/amazon-s3", params=params)
|
89
|
+
|
90
|
+
if response.get("success"):
|
91
|
+
repositories_data = response.get("result", {}).get("entities", [])
|
92
|
+
return [AmazonS3Repository(**repo) for repo in repositories_data]
|
93
|
+
|
94
|
+
return []
|
95
|
+
|
96
|
+
|
97
|
+
class GetAmazonS3RepositoryQuery(Query[AmazonS3Repository]):
|
98
|
+
"""Query to get Amazon S3 repository by ID."""
|
99
|
+
|
100
|
+
def __init__(self, http_client: HTTPClient, repository_id: str):
|
101
|
+
self.http_client = http_client
|
102
|
+
self.repository_id = repository_id
|
103
|
+
|
104
|
+
def execute(self) -> AmazonS3Repository:
|
105
|
+
"""Execute the get Amazon S3 repository query."""
|
106
|
+
response = self.http_client.get(f"evidences/repositories/amazon-s3/{self.repository_id}")
|
107
|
+
|
108
|
+
if response.get("success"):
|
109
|
+
repository_data = response.get("result", {})
|
110
|
+
return AmazonS3Repository(**repository_data)
|
111
|
+
|
112
|
+
raise Exception(f"Amazon S3 repository not found: {self.repository_id}")
|
113
|
+
|
114
|
+
|
115
|
+
# Azure Storage Repository Queries
|
116
|
+
|
117
|
+
class ListAzureStorageRepositoriesQuery(Query[List[AzureStorageRepository]]):
|
118
|
+
"""Query to list Azure Storage repositories."""
|
119
|
+
|
120
|
+
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
121
|
+
self.http_client = http_client
|
122
|
+
self.filter_params = filter_params
|
123
|
+
|
124
|
+
def execute(self) -> List[AzureStorageRepository]:
|
125
|
+
"""Execute the list Azure Storage repositories query."""
|
126
|
+
params = {}
|
127
|
+
if self.filter_params:
|
128
|
+
params = self.filter_params.model_dump(exclude_none=True)
|
129
|
+
|
130
|
+
response = self.http_client.get("evidences/repositories/azure-storage", params=params)
|
131
|
+
|
132
|
+
if response.get("success"):
|
133
|
+
repositories_data = response.get("result", {}).get("entities", [])
|
134
|
+
return [AzureStorageRepository(**repo) for repo in repositories_data]
|
135
|
+
|
136
|
+
return []
|
137
|
+
|
138
|
+
|
139
|
+
class GetAzureStorageRepositoryQuery(Query[AzureStorageRepository]):
|
140
|
+
"""Query to get Azure Storage repository by ID."""
|
141
|
+
|
142
|
+
def __init__(self, http_client: HTTPClient, repository_id: str):
|
143
|
+
self.http_client = http_client
|
144
|
+
self.repository_id = repository_id
|
145
|
+
|
146
|
+
def execute(self) -> AzureStorageRepository:
|
147
|
+
"""Execute the get Azure Storage repository query."""
|
148
|
+
response = self.http_client.get(f"evidences/repositories/azure-storage/{self.repository_id}")
|
149
|
+
|
150
|
+
if response.get("success"):
|
151
|
+
repository_data = response.get("result", {})
|
152
|
+
return AzureStorageRepository(**repository_data)
|
153
|
+
|
154
|
+
raise Exception(f"Azure Storage repository not found: {self.repository_id}")
|
155
|
+
|
156
|
+
|
157
|
+
# FTPS Repository Queries
|
158
|
+
|
159
|
+
class ListFTPSRepositoriesQuery(Query[List[FTPSRepository]]):
|
160
|
+
"""Query to list FTPS repositories."""
|
161
|
+
|
162
|
+
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
163
|
+
self.http_client = http_client
|
164
|
+
self.filter_params = filter_params
|
165
|
+
|
166
|
+
def execute(self) -> List[FTPSRepository]:
|
167
|
+
"""Execute the list FTPS repositories query."""
|
168
|
+
params = {}
|
169
|
+
if self.filter_params:
|
170
|
+
params = self.filter_params.model_dump(exclude_none=True)
|
171
|
+
|
172
|
+
response = self.http_client.get("evidences/repositories/ftps", params=params)
|
173
|
+
|
174
|
+
if response.get("success"):
|
175
|
+
repositories_data = response.get("result", {}).get("entities", [])
|
176
|
+
return [FTPSRepository(**repo) for repo in repositories_data]
|
177
|
+
|
178
|
+
return []
|
179
|
+
|
180
|
+
|
181
|
+
class GetFTPSRepositoryQuery(Query[FTPSRepository]):
|
182
|
+
"""Query to get FTPS repository by ID."""
|
183
|
+
|
184
|
+
def __init__(self, http_client: HTTPClient, repository_id: str):
|
185
|
+
self.http_client = http_client
|
186
|
+
self.repository_id = repository_id
|
187
|
+
|
188
|
+
def execute(self) -> FTPSRepository:
|
189
|
+
"""Execute the get FTPS repository query."""
|
190
|
+
response = self.http_client.get(f"evidences/repositories/ftps/{self.repository_id}")
|
191
|
+
|
192
|
+
if response.get("success"):
|
193
|
+
repository_data = response.get("result", {})
|
194
|
+
return FTPSRepository(**repository_data)
|
195
|
+
|
196
|
+
raise Exception(f"FTPS repository not found: {self.repository_id}")
|
197
|
+
|
198
|
+
|
199
|
+
# SFTP Repository Queries
|
200
|
+
|
201
|
+
class ListSFTPRepositoriesQuery(Query[List[SFTPRepository]]):
|
202
|
+
"""Query to list SFTP repositories."""
|
203
|
+
|
204
|
+
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
205
|
+
self.http_client = http_client
|
206
|
+
self.filter_params = filter_params
|
207
|
+
|
208
|
+
def execute(self) -> List[SFTPRepository]:
|
209
|
+
"""Execute the list SFTP repositories query."""
|
210
|
+
params = {}
|
211
|
+
if self.filter_params:
|
212
|
+
params = self.filter_params.model_dump(exclude_none=True)
|
213
|
+
|
214
|
+
response = self.http_client.get("evidences/repositories/sftp", params=params)
|
215
|
+
|
216
|
+
if response.get("success"):
|
217
|
+
repositories_data = response.get("result", {}).get("entities", [])
|
218
|
+
return [SFTPRepository(**repo) for repo in repositories_data]
|
219
|
+
|
220
|
+
return []
|
221
|
+
|
222
|
+
|
223
|
+
class GetSFTPRepositoryQuery(Query[SFTPRepository]):
|
224
|
+
"""Query to get SFTP repository by ID."""
|
225
|
+
|
226
|
+
def __init__(self, http_client: HTTPClient, repository_id: str):
|
227
|
+
self.http_client = http_client
|
228
|
+
self.repository_id = repository_id
|
229
|
+
|
230
|
+
def execute(self) -> SFTPRepository:
|
231
|
+
"""Execute the get SFTP repository query."""
|
232
|
+
response = self.http_client.get(f"evidences/repositories/sftp/{self.repository_id}")
|
233
|
+
|
234
|
+
if response.get("success"):
|
235
|
+
repository_data = response.get("result", {})
|
236
|
+
return SFTPRepository(**repository_data)
|
237
|
+
|
238
|
+
raise Exception(f"SFTP repository not found: {self.repository_id}")
|
239
|
+
|
240
|
+
|
241
|
+
# SMB Repository Queries
|
242
|
+
|
243
|
+
class ListSMBRepositoriesQuery(Query[List[SMBRepository]]):
|
244
|
+
"""Query to list SMB repositories."""
|
245
|
+
|
246
|
+
def __init__(self, http_client: HTTPClient, filter_params: Optional[RepositoryFilter] = None):
|
247
|
+
self.http_client = http_client
|
248
|
+
self.filter_params = filter_params
|
249
|
+
|
250
|
+
def execute(self) -> List[SMBRepository]:
|
251
|
+
"""Execute the list SMB repositories query."""
|
252
|
+
params = {}
|
253
|
+
if self.filter_params:
|
254
|
+
params = self.filter_params.model_dump(exclude_none=True)
|
255
|
+
|
256
|
+
response = self.http_client.get("evidences/repositories/smb", params=params)
|
257
|
+
|
258
|
+
if response.get("success"):
|
259
|
+
repositories_data = response.get("result", {}).get("entities", [])
|
260
|
+
return [SMBRepository(**repo) for repo in repositories_data]
|
261
|
+
|
262
|
+
return []
|
263
|
+
|
264
|
+
|
265
|
+
class GetSMBRepositoryQuery(Query[SMBRepository]):
|
266
|
+
"""Query to get SMB repository by ID."""
|
267
|
+
|
268
|
+
def __init__(self, http_client: HTTPClient, repository_id: str):
|
269
|
+
self.http_client = http_client
|
270
|
+
self.repository_id = repository_id
|
271
|
+
|
272
|
+
def execute(self) -> SMBRepository:
|
273
|
+
"""Execute the get SMB repository query."""
|
274
|
+
response = self.http_client.get(f"evidences/repositories/smb/{self.repository_id}")
|
275
|
+
|
276
|
+
if response.get("success"):
|
277
|
+
repository_data = response.get("result", {})
|
278
|
+
return SMBRepository(**repository_data)
|
279
|
+
|
280
280
|
raise Exception(f"SMB repository not found: {self.repository_id}")
|