Skip to content

Commit 8008e2a

Browse files
nitescucgithub-actions[bot]
authored andcommitted
Update python SDK 1.92.0
1 parent 625a058 commit 8008e2a

File tree

12 files changed

+132
-32
lines changed

12 files changed

+132
-32
lines changed

crowdsec_tracker_api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class Server(Enum):
4242
'GetCVEResponse',
4343
'GetCVESubscribedIntegrationsResponsePage',
4444
'GetCVEsResponsePage',
45+
'GetCVEsSortBy',
46+
'GetCVEsSortOrder',
4547
'History',
4648
'IPItem',
4749
'IntegrationResponse',
0 Bytes
Binary file not shown.
51 Bytes
Binary file not shown.

crowdsec_tracker_api/http_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(self, base_url: str, auth: httpx.Auth, aws_region="eu-west-1") -> N
4949
self.aws_region = aws_region
5050
self.base_url = base_url
5151
self.auth = auth
52-
self.client = httpx.Client()
52+
self.client = httpx.Client(headers={"Accept-Encoding": "gzip"})
5353
self.timeout = 30
5454

5555
def _replace_path_params(self, url: str, path_params: dict):

crowdsec_tracker_api/models.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: <stdin>
3-
# timestamp: 2025-12-15T11:06:13+00:00
3+
# timestamp: 2025-12-17T10:47:38+00:00
44

55
from __future__ import annotations
66

@@ -311,6 +311,18 @@ class GetCVEsResponsePage(BaseModelSdk):
311311
links: Links
312312

313313

314+
class GetCVEsSortBy(StrEnum):
315+
RULE_RELEASE_DATE = 'rule_release_date'
316+
TRENDING = 'trending'
317+
NB_IPS = 'nb_ips'
318+
NAME = 'name'
319+
320+
321+
class GetCVEsSortOrder(StrEnum):
322+
ASC = 'asc'
323+
DESC = 'desc'
324+
325+
314326
class History(BaseModelSdk):
315327
first_seen: Annotated[
316328
datetime, Field(description='First seen timestamp', title='First Seen')
@@ -493,6 +505,13 @@ class CvesGetCvesQueryParameters(BaseModelSdk):
493505
query: Annotated[
494506
Optional[str], Field(description='Search query for CVEs', title='Query')
495507
] = None
508+
sort_by: Annotated[
509+
Optional[GetCVEsSortBy], Field(description='Field to sort by', title='Sort By')
510+
] = 'rule_release_date'
511+
sort_order: Annotated[
512+
Optional[GetCVEsSortOrder],
513+
Field(description='Sort order: ascending or descending', title='Sort Order'),
514+
] = 'desc'
496515
page: Annotated[
497516
Optional[int], Field(description='Page number', ge=1, title='Page')
498517
] = 1
@@ -505,25 +524,29 @@ class CvesGetCvePathParameters(BaseModelSdk):
505524
cve_id: Annotated[str, Field(title='Cve Id')]
506525

507526

527+
class CvesDownloadCveIpsPathParameters(BaseModelSdk):
528+
cve_id: Annotated[str, Field(title='Cve Id')]
529+
530+
508531
class Since(RootModelSdk[str]):
509532
root: Annotated[
510533
str,
511534
Field(
512-
description='Filter IPs seen since this date, format duration (e.g., 7d, 24h)',
535+
description='Filter IPs seen since this date, format duration (e.g., 7d, 24h), default to 14d',
513536
pattern='^\\d+[hd]$',
514537
title='Since',
515538
),
516539
]
517540

518541

519-
class CvesGetCveIpsQueryParameters(BaseModelSdk):
542+
class CvesGetCveIpsDetailsQueryParameters(BaseModelSdk):
520543
since: Annotated[
521544
Optional[Since],
522545
Field(
523-
description='Filter IPs seen since this date, format duration (e.g., 7d, 24h)',
546+
description='Filter IPs seen since this date, format duration (e.g., 7d, 24h), default to 14d',
524547
title='Since',
525548
),
526-
] = None
549+
] = Since('14d')
527550
page: Annotated[
528551
Optional[int], Field(description='Page number', ge=1, title='Page')
529552
] = 1
@@ -532,7 +555,7 @@ class CvesGetCveIpsQueryParameters(BaseModelSdk):
532555
] = 50
533556

534557

535-
class CvesGetCveIpsPathParameters(BaseModelSdk):
558+
class CvesGetCveIpsDetailsPathParameters(BaseModelSdk):
536559
cve_id: Annotated[str, Field(title='Cve Id')]
537560

538561

Binary file not shown.

crowdsec_tracker_api/services/cves.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def __init__(self, auth: Auth, base_url: str = "https://admin.api.crowdsec.net/v
1616
def get_cves(
1717
self,
1818
query: Optional[str] = None,
19+
sort_by: Optional[GetCVEsSortBy] = GetCVEsSortBy("rule_release_date"),
20+
sort_order: Optional[GetCVEsSortOrder] = GetCVEsSortOrder("desc"),
1921
page: int = 1,
2022
size: int = 50,
2123
)-> GetCVEsResponsePage:
@@ -55,23 +57,43 @@ def get_cve(
5557

5658
return GetCVEResponse(**response.json())
5759

58-
def get_cve_ips(
60+
def download_cve_ips(
5961
self,
6062
cve_id: str,
61-
since: Optional[str] = None,
63+
)-> str:
64+
endpoint_url = "/cves/{cve_id}/ips-download"
65+
loc = locals()
66+
headers = {}
67+
params = {}
68+
path_params = json.loads(
69+
CvesDownloadCveIpsPathParameters(**loc).model_dump_json(
70+
exclude_none=True
71+
)
72+
)
73+
74+
response = self.http_client.get(
75+
url=endpoint_url, path_params=path_params, params=params, headers=headers
76+
)
77+
78+
return response.text
79+
80+
def get_cve_ips_details(
81+
self,
82+
cve_id: str,
83+
since: Optional[str] = "14d",
6284
page: int = 1,
6385
size: int = 50,
6486
)-> GetCVEIPsResponsePage:
65-
endpoint_url = "/cves/{cve_id}/ips"
87+
endpoint_url = "/cves/{cve_id}/ips-details"
6688
loc = locals()
6789
headers = {}
6890
params = json.loads(
69-
CvesGetCveIpsQueryParameters(**loc).model_dump_json(
91+
CvesGetCveIpsDetailsQueryParameters(**loc).model_dump_json(
7092
exclude_none=True
7193
)
7294
)
7395
path_params = json.loads(
74-
CvesGetCveIpsPathParameters(**loc).model_dump_json(
96+
CvesGetCveIpsDetailsPathParameters(**loc).model_dump_json(
7597
exclude_none=True
7698
)
7799
)

doc/Cves.md

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
| ------ | ----------- |
66
| [get_cves](#get_cves) | Get a paginated list of CVEs that CrowdSec is tracking |
77
| [get_cve](#get_cve) | Get information about a specific CVE ID |
8-
| [get_cve_ips](#get_cve_ips) | Get information about IPs exploiting a specific CVE ID |
8+
| [download_cve_ips](#download_cve_ips) | Download the list of IPs exploiting a specific CVE ID in raw format |
9+
| [get_cve_ips_details](#get_cve_ips_details) | Get detailed information about IPs exploiting a specific CVE ID |
910
| [get_cve_subscribed_integrations](#get_cve_subscribed_integrations) | Get the list of integrations subscribed to a specific CVE ID |
1011
| [subscribe_integration_to_cve](#subscribe_integration_to_cve) | Subscribe an integration to receive threats related to a specific CVE ID |
1112
| [unsubscribe_integration_from_cve](#unsubscribe_integration_from_cve) | Unsubscribe an integration from receiving threats related to a specific CVE ID |
@@ -19,6 +20,8 @@
1920
| Parameter | Type | Description | Required | Default |
2021
| --------- | ---- | ----------- | -------- | ------- |
2122
| query | Optional[str] | Search query for CVEs | False | None |
23+
| sort_by | Optional[GetCVEsSortBy] | Field to sort by | False | GetCVEsSortBy("rule_release_date") |
24+
| sort_order | Optional[GetCVEsSortOrder] | Sort order: ascending or descending | False | GetCVEsSortOrder("desc") |
2225
| page | int | Page number | False | 1 |
2326
| size | int | Page size | False | 50 |
2427
### Returns:
@@ -40,6 +43,8 @@ client = Cves(auth=auth)
4043
try:
4144
response = client.get_cves(
4245
query=None,
46+
sort_by=rule_release_date,
47+
sort_order=desc,
4348
page=1,
4449
size=50,
4550
)
@@ -85,16 +90,52 @@ except HTTPStatusError as e:
8590
```
8691

8792

88-
## **get_cve_ips**
89-
### Get information about IPs exploiting a specific CVE ID
90-
- Endpoint: `/cves/{cve_id}/ips`
93+
## **download_cve_ips**
94+
### Download the list of IPs exploiting a specific CVE ID in raw format
95+
- Endpoint: `/cves/{cve_id}/ips-download`
9196
- Method: `GET`
9297

9398
### Parameters:
9499
| Parameter | Type | Description | Required | Default |
95100
| --------- | ---- | ----------- | -------- | ------- |
96101
| cve_id | str | | True | |
97-
| since | Optional[str] | Filter IPs seen since this date, format duration (e.g., 7d, 24h) | False | None |
102+
### Returns:
103+
[str](./Models.md#str)
104+
### Errors:
105+
| Code | Description |
106+
| ---- | ----------- |
107+
| 404 | CVE Not Found |
108+
| 422 | Validation Error |
109+
### Usage
110+
111+
```python
112+
from crowdsec_tracker_api import (
113+
Cves,
114+
ApiKeyAuth,
115+
)
116+
from httpx import HTTPStatusError
117+
auth = ApiKeyAuth(api_key='your_api_key')
118+
client = Cves(auth=auth)
119+
try:
120+
response = client.download_cve_ips(
121+
cve_id='cve_id',
122+
)
123+
print(response)
124+
except HTTPStatusError as e:
125+
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
126+
```
127+
128+
129+
## **get_cve_ips_details**
130+
### Get detailed information about IPs exploiting a specific CVE ID
131+
- Endpoint: `/cves/{cve_id}/ips-details`
132+
- Method: `GET`
133+
134+
### Parameters:
135+
| Parameter | Type | Description | Required | Default |
136+
| --------- | ---- | ----------- | -------- | ------- |
137+
| cve_id | str | | True | |
138+
| since | Optional[str] | Filter IPs seen since this date, format duration (e.g., 7d, 24h), default to 14d | False | "14d" |
98139
| page | int | Page number | False | 1 |
99140
| size | int | Page size | False | 50 |
100141
### Returns:
@@ -115,9 +156,9 @@ from httpx import HTTPStatusError
115156
auth = ApiKeyAuth(api_key='your_api_key')
116157
client = Cves(auth=auth)
117158
try:
118-
response = client.get_cve_ips(
159+
response = client.get_cve_ips_details(
119160
cve_id='cve_id',
120-
since=None,
161+
since=14d,
121162
page=1,
122163
size=50,
123164
)

doc/Models.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ name, entity_type, output_format
4848
|----------|------|-------------|---------|
4949
| name | str | Name of the integration ||
5050
| description | str | Description of the integration ||
51-
| entity_type | str | None ||
52-
| output_format | str | None ||
51+
| entity_type | IntegrationType | None ||
52+
| output_format | OutputFormat | None ||
5353

5454
# **IntegrationCreateResponse**
5555
## Required:
@@ -63,8 +63,8 @@ id, name, organization_id, created_at, updated_at, entity_type, output_format, b
6363
| description | str | Description of the integration ||
6464
| created_at | str | Time the integration was created ||
6565
| updated_at | str | Last time the integration was updated ||
66-
| entity_type | str | None ||
67-
| output_format | str | None ||
66+
| entity_type | IntegrationType | None ||
67+
| output_format | OutputFormat | None ||
6868
| last_pull | Optional[str] | Last time the integration pulled blocklists ||
6969
| blocklists | list[BlocklistSubscription] | Blocklists that are subscribed by the integration ||
7070
| cves | list[CVESubscription] | CVEs that are subscribed by the integration ||
@@ -85,8 +85,8 @@ id, name, organization_id, created_at, updated_at, entity_type, output_format, b
8585
| description | str | Description of the integration ||
8686
| created_at | str | Time the integration was created ||
8787
| updated_at | str | Last time the integration was updated ||
88-
| entity_type | str | None ||
89-
| output_format | str | None ||
88+
| entity_type | IntegrationType | None ||
89+
| output_format | OutputFormat | None ||
9090
| last_pull | Optional[str] | Last time the integration pulled blocklists ||
9191
| blocklists | list[BlocklistSubscription] | Blocklists that are subscribed by the integration ||
9292
| cves | list[CVESubscription] | CVEs that are subscribed by the integration ||
@@ -117,7 +117,7 @@ FIREWALL_INTEGRATION, REMEDIATION_COMPONENT_INTEGRATION
117117
|----------|------|-------------|---------|
118118
| name | str | New name ||
119119
| description | str | New description ||
120-
| output_format | str | None ||
120+
| output_format | OutputFormat | None ||
121121
| regenerate_credentials | bool | Regenerate credentials for the integration ||
122122

123123
# **IntegrationUpdateResponse**
@@ -132,8 +132,8 @@ id, name, organization_id, created_at, updated_at, entity_type, output_format, b
132132
| description | str | Description of the integration ||
133133
| created_at | str | Time the integration was created ||
134134
| updated_at | str | Last time the integration was updated ||
135-
| entity_type | str | None ||
136-
| output_format | str | None ||
135+
| entity_type | IntegrationType | None ||
136+
| output_format | OutputFormat | None ||
137137
| last_pull | Optional[str] | Last time the integration pulled blocklists ||
138138
| blocklists | list[BlocklistSubscription] | Blocklists that are subscribed by the integration ||
139139
| cves | list[CVESubscription] | CVEs that are subscribed by the integration ||
@@ -342,6 +342,14 @@ items, total, page, size, pages, links
342342
| pages | int | None ||
343343
| links | Links | None ||
344344

345+
# **GetCVEsSortBy**
346+
## Enum:
347+
RULE_RELEASE_DATE, TRENDING, NB_IPS, NAME
348+
349+
# **GetCVEsSortOrder**
350+
## Enum:
351+
ASC, DESC
352+
345353
# **History**
346354
## Required:
347355
first_seen, last_seen, full_age, days_age
@@ -392,15 +400,15 @@ organization_id, entity_type, name, output_format
392400
| tags | list[str] | None ||
393401
| organization_id | str | None ||
394402
| created_at | str | Time the integration was created ||
395-
| entity_type | str | None ||
403+
| entity_type | EntityType | None ||
396404
| id | str | ID of the integration ||
397405
| blocklists | list[BlocklistSubscription] | None ||
398406
| allowlists | list[AllowlistSubscription] | None ||
399407
| cves | list[CVEsubscription] | None ||
400408
| name | str | Name of the integration ||
401409
| updated_at | str | Last time the integration was updated ||
402410
| description | Optional[str] | Description of the integration ||
403-
| output_format | str | None ||
411+
| output_format | OutputFormat | None ||
404412
| last_pull | Optional[str] | Last time the integration pulled blocklists ||
405413

406414
# **Location**

doc/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ You can find a Quickstart about this SDK, following this [documentation](https:/
7979

8080
[GetCVEsResponsePage](./Models.md#getcvesresponsepage)
8181

82+
[GetCVEsSortBy](./Models.md#getcvessortby)
83+
84+
[GetCVEsSortOrder](./Models.md#getcvessortorder)
85+
8286
[History](./Models.md#history)
8387

8488
[IPItem](./Models.md#ipitem)

0 commit comments

Comments
 (0)