Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified crowdsec_tracker_api/__pycache__/base_model.cpython-311.pyc
Binary file not shown.
Binary file modified crowdsec_tracker_api/__pycache__/http_client.cpython-311.pyc
Binary file not shown.
6 changes: 4 additions & 2 deletions crowdsec_tracker_api/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class Page(BaseModelSdk, Generic[T]):


class Service:
def __init__(self, base_url: str, auth: Auth) -> None:
self.http_client = HttpClient(base_url=base_url, auth=auth)
def __init__(self, base_url: str, auth: Auth, user_agent: str = None) -> None:
self.http_client = HttpClient(
base_url=base_url, auth=auth, user_agent=user_agent
)

def next_page(self, page: BaseModelSdk) -> Optional[BaseModelSdk]:
if not hasattr(page, "links") or not page.links:
Expand Down
13 changes: 11 additions & 2 deletions crowdsec_tracker_api/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,20 @@ def auth_flow(self, request):


class HttpClient:
def __init__(self, base_url: str, auth: httpx.Auth, aws_region="eu-west-1") -> None:
def __init__(
self,
base_url: str,
auth: httpx.Auth,
user_agent: str = None,
aws_region="eu-west-1",
) -> None:
self.aws_region = aws_region
self.base_url = base_url
self.auth = auth
self.client = httpx.Client(headers={"Accept-Encoding": "gzip"})
headers = {"Accept-Encoding": "gzip"}
if user_agent:
headers["User-Agent"] = user_agent
self.client = httpx.Client(headers=headers)
self.timeout = 30

def _replace_path_params(self, url: str, path_params: dict):
Expand Down
34 changes: 11 additions & 23 deletions crowdsec_tracker_api/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: <stdin>
# timestamp: 2025-12-17T10:47:38+00:00
# timestamp: 2025-12-29T14:24:53+00:00

from __future__ import annotations

Expand Down Expand Up @@ -546,7 +546,7 @@ class CvesGetCveIpsDetailsQueryParameters(BaseModelSdk):
description='Filter IPs seen since this date, format duration (e.g., 7d, 24h), default to 14d',
title='Since',
),
] = Since('14d')
] = '14d'
page: Annotated[
Optional[int], Field(description='Page number', ge=1, title='Page')
] = 1
Expand Down Expand Up @@ -662,13 +662,9 @@ class IntegrationCreateResponse(BaseModelSdk):
title='Endpoint',
),
]
stats: Annotated[
Optional[Stats],
Field(
default_factory=lambda: Stats.model_validate({'count': 0}),
description='Stats of the integration',
),
]
stats: Annotated[Optional[Stats], Field(description='Stats of the integration')] = {
'count': 0
}
tags: Annotated[
Optional[List[str]],
Field(description='Tags associated with the integration', title='Tags'),
Expand Down Expand Up @@ -736,13 +732,9 @@ class IntegrationGetResponse(BaseModelSdk):
title='Endpoint',
),
]
stats: Annotated[
Optional[Stats],
Field(
default_factory=lambda: Stats.model_validate({'count': 0}),
description='Stats of the integration',
),
]
stats: Annotated[Optional[Stats], Field(description='Stats of the integration')] = {
'count': 0
}
tags: Annotated[
Optional[List[str]],
Field(description='Tags associated with the integration', title='Tags'),
Expand Down Expand Up @@ -835,13 +827,9 @@ class IntegrationUpdateResponse(BaseModelSdk):
title='Endpoint',
),
]
stats: Annotated[
Optional[Stats],
Field(
default_factory=lambda: Stats.model_validate({'count': 0}),
description='Stats of the integration',
),
]
stats: Annotated[Optional[Stats], Field(description='Stats of the integration')] = {
'count': 0
}
tags: Annotated[
Optional[List[str]],
Field(description='Tags associated with the integration', title='Tags'),
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions crowdsec_tracker_api/services/cves.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class Cves(Service):
def __init__(self, auth: Auth, base_url: str = "https://admin.api.crowdsec.net/v1") -> None:
super().__init__(base_url=base_url, auth=auth)
super().__init__(base_url=base_url, auth=auth, user_agent="crowdsec_tracker_api/1.94.2")

def get_cves(
self,
Expand All @@ -21,7 +21,7 @@ def get_cves(
page: int = 1,
size: int = 50,
)-> GetCVEsResponsePage:
endpoint_url = "/cves/"
endpoint_url = "/cves"
loc = locals()
headers = {}
params = json.loads(
Expand Down
6 changes: 3 additions & 3 deletions crowdsec_tracker_api/services/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class Integrations(Service):
def __init__(self, auth: Auth, base_url: str = "https://admin.api.crowdsec.net/v1") -> None:
super().__init__(base_url=base_url, auth=auth)
super().__init__(base_url=base_url, auth=auth, user_agent="crowdsec_tracker_api/1.94.2")

def get_integrations(
self,
Expand Down Expand Up @@ -124,7 +124,7 @@ def get_integration_content(
integration_id: str,
page: int = 1,
page_size: Optional[int] = None,
):
)-> str:
endpoint_url = "/integrations/{integration_id}/content"
loc = locals()
headers = {}
Expand All @@ -143,7 +143,7 @@ def get_integration_content(
url=endpoint_url, path_params=path_params, params=params, headers=headers
)

return None
return response.text

def get_integration_content_stream(
self,
Expand Down
2 changes: 1 addition & 1 deletion doc/Cves.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## **get_cves**
### Get a paginated list of CVEs that CrowdSec is tracking
- Endpoint: `/cves/`
- Endpoint: `/cves`
- Method: `GET`

### Parameters:
Expand Down
3 changes: 3 additions & 0 deletions doc/Integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,13 @@ except HTTPStatusError as e:
| integration_id | str | | True | |
| page | int | Page number to return | False | 1 |
| page_size | Optional[int] | Maximum number of items to return, 0 means no limit (default), should be greater than 10000 | False | None |
### Returns:
[str](./Models.md#str)
### Errors:
| Code | Description |
| ---- | ----------- |
| 404 | Integration not found |
| 204 | Integration has no subscribed blocklists or no content available |
| 422 | Validation Error |
### Usage

Expand Down
14 changes: 7 additions & 7 deletions doc/Models.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ loc, msg, type
## Properties
| Property | Type | Description | Example |
|----------|------|-------------|---------|
| vendor | str | Vendor of the affected component ||
| product | str | Product name of the affected component ||
| vendor | Optional[str] | Vendor of the affected component ||
| product | Optional[str] | Product name of the affected component ||

# **AllowlistSubscription**
## Required:
Expand Down Expand Up @@ -368,28 +368,28 @@ ip
| Property | Type | Description | Example |
|----------|------|-------------|---------|
| ip | str | IP address ||
| reputation | str | Reputation of the IP ||
| reputation | Optional[str] | Reputation of the IP ||
| ip_range | Optional[str] | IP range ||
| ip_range_score | Optional[int] | IP range score ||
| ip_range_24 | Optional[str] | IP range /24 ||
| ip_range_24_reputation | Optional[str] | IP range /24 reputation ||
| ip_range_24_score | Optional[int] | IP range /24 score ||
| as_name | Optional[str] | AS name ||
| as_num | Optional[int] | AS number ||
| background_noise_score | int | Background noise score ||
| background_noise_score | Optional[int] | Background noise score ||
| background_noise | Optional[str] | Background noise level ||
| confidence | Optional[str] | Confidence level ||
| location | Optional[Location] | IP location information ||
| reverse_dns | Optional[str] | Reverse DNS ||
| behaviors | list[Behavior] | List of behaviors ||
| references | list[Reference] | List of references ||
| history | History | None ||
| classifications | Classifications | None ||
| history | Optional[History] | Historical data ||
| classifications | Optional[Classifications] | Classification data ||
| mitre_techniques | list[MitreTechnique] | MITRE techniques ||
| cves | list[str] | List of CVEs ||
| attack_details | list[AttackDetail] | Attack details ||
| target_countries | Target Countries | Target countries ||
| scores | Scores | None ||
| scores | Optional[Scores] | Scoring information ||

# **IntegrationResponse**
## Required:
Expand Down
2 changes: 1 addition & 1 deletion let-openapi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "crowdsec_tracker_api"
version = "1.92.0"
version = "1.94.2"
license = { text = "MIT" }
authors = [
{ name="crowdsec", email="[email protected]" }
Expand Down