Skip to content

Commit e4926a6

Browse files
he2ssgithub-actions[bot]
authored andcommitted
Update python SDK 1.102.2
1 parent 562a7bf commit e4926a6

File tree

12 files changed

+152
-120
lines changed

12 files changed

+152
-120
lines changed

crowdsec_tracker_api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Server(Enum):
4141
'GetCVEIPsResponsePage',
4242
'GetCVEResponse',
4343
'GetCVESubscribedIntegrationsResponsePage',
44+
'GetCVEsFilterBy',
4445
'GetCVEsResponsePage',
4546
'GetCVEsSortBy',
4647
'GetCVEsSortOrder',
2 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.

crowdsec_tracker_api/models.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: <stdin>
3-
# timestamp: 2026-01-06T15:34:27+00:00
3+
# timestamp: 2026-01-29T15:05:21+00:00
44

55
from __future__ import annotations
66

@@ -161,6 +161,15 @@ class CVEResponseBase(BaseModelSdk):
161161
title='Crowdsec Score',
162162
),
163163
]
164+
opportunity_score: Annotated[
165+
Optional[int],
166+
Field(
167+
description="Opportunity score indicating if it's an opportunistic(0) or targeted(5) attack (between 0-5)",
168+
ge=0,
169+
le=5,
170+
title='Opportunity Score',
171+
),
172+
] = 0
164173
first_seen: Annotated[
165174
Optional[datetime], Field(description='First seen date', title='First Seen')
166175
] = None
@@ -251,6 +260,15 @@ class GetCVEResponse(BaseModelSdk):
251260
title='Crowdsec Score',
252261
),
253262
]
263+
opportunity_score: Annotated[
264+
Optional[int],
265+
Field(
266+
description="Opportunity score indicating if it's an opportunistic(0) or targeted(5) attack (between 0-5)",
267+
ge=0,
268+
le=5,
269+
title='Opportunity Score',
270+
),
271+
] = 0
254272
first_seen: Annotated[
255273
Optional[datetime], Field(description='First seen date', title='First Seen')
256274
] = None
@@ -302,6 +320,10 @@ class GetCVEResponse(BaseModelSdk):
302320
] = None
303321

304322

323+
class GetCVEsFilterBy(StrEnum):
324+
IS_PUBLIC = 'is_public'
325+
326+
305327
class GetCVEsResponsePage(BaseModelSdk):
306328
items: Annotated[List[CVEResponseBase], Field(title='Items')]
307329
total: Annotated[int, Field(ge=0, title='Total')]
@@ -538,6 +560,10 @@ class CvesGetCvesQueryParameters(BaseModelSdk):
538560
Optional[GetCVEsSortOrder],
539561
Field(description='Sort order: ascending or descending', title='Sort Order'),
540562
] = 'desc'
563+
filters: Annotated[
564+
Optional[List[GetCVEsFilterBy]],
565+
Field(description='Filters to apply on the CVE list', title='Filters'),
566+
] = None
541567
page: Annotated[
542568
Optional[int], Field(description='Page number', ge=1, title='Page')
543569
] = 1
Binary file not shown.
Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,90 @@
11
import json
22
from types import NoneType
3-
from typing import Annotated, Optional, Union
3+
from typing import Optional, Union, Annotated
44

5-
from httpx import Auth
5+
from ..models import *
6+
from ..base_model import Page, Service
67
from pydantic import BaseModel, Field
78
from pydantic.fields import FieldInfo
8-
9-
from ..base_model import Page, Service
9+
from httpx import Auth
1010
from ..http_client import HttpClient
11-
from ..models import *
12-
1311

1412
class Cves(Service):
15-
def __init__(
16-
self, auth: Auth, base_url: str = "https://admin.api.crowdsec.net/v1"
17-
) -> None:
18-
super().__init__(
19-
base_url=base_url, auth=auth, user_agent="crowdsec_tracker_api/1.95.2"
20-
)
21-
13+
def __init__(self, auth: Auth, base_url: str = "https://admin.api.crowdsec.net/v1") -> None:
14+
super().__init__(base_url=base_url, auth=auth, user_agent="crowdsec_tracker_api/1.102.2")
15+
2216
def get_cves(
2317
self,
2418
query: Optional[str] = None,
2519
sort_by: Optional[GetCVEsSortBy] = GetCVEsSortBy("rule_release_date"),
2620
sort_order: Optional[GetCVEsSortOrder] = GetCVEsSortOrder("desc"),
21+
filters: Optional[list[GetCVEsFilterBy]] = None,
2722
page: int = 1,
2823
size: int = 50,
29-
) -> GetCVEsResponsePage:
24+
)-> GetCVEsResponsePage:
3025
endpoint_url = "/cves"
3126
loc = locals()
3227
headers = {}
3328
params = json.loads(
34-
CvesGetCvesQueryParameters(**loc).model_dump_json(exclude_none=True)
29+
CvesGetCvesQueryParameters(**loc).model_dump_json(
30+
exclude_none=True
31+
)
3532
)
3633
path_params = {}
37-
34+
3835
response = self.http_client.get(
3936
url=endpoint_url, path_params=path_params, params=params, headers=headers
4037
)
41-
38+
4239
return GetCVEsResponsePage(_client=self, **response.json())
43-
40+
4441
def get_cve(
4542
self,
4643
cve_id: str,
47-
) -> GetCVEResponse:
44+
)-> GetCVEResponse:
4845
endpoint_url = "/cves/{cve_id}"
4946
loc = locals()
5047
headers = {}
5148
params = {}
5249
path_params = json.loads(
53-
CvesGetCvePathParameters(**loc).model_dump_json(exclude_none=True)
50+
CvesGetCvePathParameters(**loc).model_dump_json(
51+
exclude_none=True
52+
)
5453
)
55-
54+
5655
response = self.http_client.get(
5756
url=endpoint_url, path_params=path_params, params=params, headers=headers
5857
)
59-
58+
6059
return GetCVEResponse(**response.json())
61-
60+
6261
def download_cve_ips(
6362
self,
6463
cve_id: str,
65-
) -> str:
64+
)-> str:
6665
endpoint_url = "/cves/{cve_id}/ips-download"
6766
loc = locals()
6867
headers = {}
6968
params = {}
7069
path_params = json.loads(
71-
CvesDownloadCveIpsPathParameters(**loc).model_dump_json(exclude_none=True)
70+
CvesDownloadCveIpsPathParameters(**loc).model_dump_json(
71+
exclude_none=True
72+
)
7273
)
73-
74+
7475
response = self.http_client.get(
7576
url=endpoint_url, path_params=path_params, params=params, headers=headers
7677
)
77-
78+
7879
return response.text
79-
80+
8081
def get_cve_ips_details(
8182
self,
8283
cve_id: str,
8384
since: Optional[str] = "14d",
8485
page: int = 1,
8586
size: int = 50,
86-
) -> GetCVEIPsResponsePage:
87+
)-> GetCVEIPsResponsePage:
8788
endpoint_url = "/cves/{cve_id}/ips-details"
8889
loc = locals()
8990
headers = {}
@@ -93,21 +94,23 @@ def get_cve_ips_details(
9394
)
9495
)
9596
path_params = json.loads(
96-
CvesGetCveIpsDetailsPathParameters(**loc).model_dump_json(exclude_none=True)
97+
CvesGetCveIpsDetailsPathParameters(**loc).model_dump_json(
98+
exclude_none=True
99+
)
97100
)
98-
101+
99102
response = self.http_client.get(
100103
url=endpoint_url, path_params=path_params, params=params, headers=headers
101104
)
102-
105+
103106
return GetCVEIPsResponsePage(_client=self, **response.json())
104-
107+
105108
def get_cve_subscribed_integrations(
106109
self,
107110
cve_id: str,
108111
page: int = 1,
109112
size: int = 50,
110-
) -> GetCVESubscribedIntegrationsResponsePage:
113+
)-> GetCVESubscribedIntegrationsResponsePage:
111114
endpoint_url = "/cves/{cve_id}/integrations"
112115
loc = locals()
113116
headers = {}
@@ -121,13 +124,13 @@ def get_cve_subscribed_integrations(
121124
exclude_none=True
122125
)
123126
)
124-
127+
125128
response = self.http_client.get(
126129
url=endpoint_url, path_params=path_params, params=params, headers=headers
127130
)
128-
131+
129132
return GetCVESubscribedIntegrationsResponsePage(_client=self, **response.json())
130-
133+
131134
def subscribe_integration_to_cve(
132135
self,
133136
request: SubscribeCVEIntegrationRequest,
@@ -142,22 +145,18 @@ def subscribe_integration_to_cve(
142145
exclude_none=True
143146
)
144147
)
145-
146-
payload = (
147-
json.loads(request.model_dump_json(exclude_none=True))
148-
if "request" in loc
149-
else None
150-
)
148+
149+
payload = json.loads(
150+
request.model_dump_json(
151+
exclude_none=True
152+
)
153+
) if "request" in loc else None
151154
response = self.http_client.post(
152-
url=endpoint_url,
153-
path_params=path_params,
154-
params=params,
155-
headers=headers,
156-
json=payload,
155+
url=endpoint_url, path_params=path_params, params=params, headers=headers, json=payload
157156
)
158-
157+
159158
return None
160-
159+
161160
def unsubscribe_integration_from_cve(
162161
self,
163162
cve_id: str,
@@ -172,30 +171,35 @@ def unsubscribe_integration_from_cve(
172171
exclude_none=True
173172
)
174173
)
175-
174+
176175
response = self.http_client.delete(
177176
url=endpoint_url, path_params=path_params, params=params, headers=headers
178177
)
179-
178+
180179
return None
181-
180+
182181
def get_cve_timeline(
183182
self,
184183
cve_id: str,
185184
since_days: SinceOptions,
186-
) -> list[TimelineItem]:
185+
)-> list[TimelineItem]:
187186
endpoint_url = "/cves/{cve_id}/timeline"
188187
loc = locals()
189188
headers = {}
190189
params = json.loads(
191-
CvesGetCveTimelineQueryParameters(**loc).model_dump_json(exclude_none=True)
190+
CvesGetCveTimelineQueryParameters(**loc).model_dump_json(
191+
exclude_none=True
192+
)
192193
)
193194
path_params = json.loads(
194-
CvesGetCveTimelinePathParameters(**loc).model_dump_json(exclude_none=True)
195+
CvesGetCveTimelinePathParameters(**loc).model_dump_json(
196+
exclude_none=True
197+
)
195198
)
196-
199+
197200
response = self.http_client.get(
198201
url=endpoint_url, path_params=path_params, params=params, headers=headers
199202
)
200-
203+
201204
return [TimelineItem(**item) for item in response.json()]
205+

0 commit comments

Comments
 (0)