Skip to content
Open
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
9 changes: 6 additions & 3 deletions crowdsec_tracker_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ class Server(Enum):
'AllowlistSubscription',
'AttackDetail',
'Behavior',
'CVEEvent',
'CVEEventOutput',
'CVEResponseBase',
'CVEsubscription',
'CWE',
'Classification',
'Classifications',
'EntityType',
'ExploitationPhase',
'FingerprintEventOutput',
'FingerprintRuleResponse',
'FingerprintRuleSummary',
'FingerprintTimelineItem',
Expand All @@ -70,8 +71,8 @@ class Server(Enum):
'LookupImpactCVEItem',
'LookupImpactFingerprintItem',
'LookupImpactResponsePage',
'LookupListItem',
'LookupListResponsePage',
'LookupListItemWithStats',
'LookupListWithStatsResponsePage',
'MitreTechnique',
'Reference',
'ScoreBreakdown',
Expand All @@ -80,6 +81,8 @@ class Server(Enum):
'SubscribeCVEIntegrationRequest',
'SubscribeFingerprintIntegrationRequest',
'TimelineItem',
'TopProductItem',
'VendorStatsResponse',
'ApiKeyAuth',
'Server',
'Page'
Expand Down
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.
105 changes: 90 additions & 15 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: 2026-02-24T17:00:06+00:00
# timestamp: 2026-03-18T08:48:04+00:00

from __future__ import annotations

Expand Down Expand Up @@ -142,13 +142,12 @@ class Behavior(BaseModelSdk):
]


class CVEEvent(BaseModelSdk):
date: Annotated[datetime, Field(description='Date of the event', title='Date')]
description: Annotated[
str, Field(description='Description of the event', title='Description')
]
label: Annotated[str, Field(description='Label of the event', title='Label')]
name: Annotated[str, Field(description='Name of the event', title='Name')]
class CVEEventOutput(BaseModelSdk):
name: Annotated[str, Field(title='Name')]
date: Annotated[str, Field(title='Date')]
description: Annotated[str, Field(title='Description')]
label: Annotated[str, Field(title='Label')]
sorting_priority: Annotated[int, Field(title='Sorting Priority')]


class CvssScore(RootModelSdk[float]):
Expand Down Expand Up @@ -212,6 +211,13 @@ class ExploitationPhase(BaseModelSdk):
]


class FingerprintEventOutput(BaseModelSdk):
name: Annotated[str, Field(title='Name')]
date: Annotated[str, Field(title='Date')]
description: Annotated[str, Field(title='Description')]
label: Annotated[str, Field(title='Label')]


class FingerprintRuleResponse(BaseModelSdk):
id: Annotated[str, Field(description='Fingerprint rule identifier', title='Id')]
name: Annotated[str, Field(description='Fingerprint rule name', title='Name')]
Expand Down Expand Up @@ -290,7 +296,7 @@ class FingerprintRuleResponse(BaseModelSdk):
),
] = None
events: Annotated[
Optional[List[CVEEvent]],
Optional[List[FingerprintEventOutput]],
Field(
description='List of events related to the fingerprint rule', title='Events'
),
Expand Down Expand Up @@ -459,7 +465,7 @@ class GetCVEResponse(BaseModelSdk):
Field(description='List of CWEs associated with the CVE', title='Cwes'),
]
events: Annotated[
Optional[List[CVEEvent]],
Optional[List[CVEEventOutput]],
Field(description='List of events related to the CVE', title='Events'),
] = None

Expand Down Expand Up @@ -674,7 +680,7 @@ class LookupImpactCVEItem(BaseModelSdk):
Field(description='List of CWEs associated with the CVE', title='Cwes'),
]
events: Annotated[
Optional[List[CVEEvent]],
Optional[List[CVEEventOutput]],
Field(description='List of events related to the CVE', title='Events'),
] = None
type: Annotated[
Expand Down Expand Up @@ -760,7 +766,7 @@ class LookupImpactFingerprintItem(BaseModelSdk):
),
] = None
events: Annotated[
Optional[List[CVEEvent]],
Optional[List[FingerprintEventOutput]],
Field(
description='List of events related to the fingerprint rule', title='Events'
),
Expand All @@ -786,12 +792,31 @@ class LookupImpactResponsePage(BaseModelSdk):
links: Links


class LookupListItem(BaseModelSdk):
class LookupListItemWithStats(BaseModelSdk):
value: Annotated[str, Field(description='Lookup entry value', title='Value')]
nb_cves: Annotated[
Optional[int], Field(description='Number of CVEs', ge=0, title='Nb Cves')
] = 0
nb_fingerprints: Annotated[
Optional[int],
Field(description='Number of fingerprint rules', ge=0, title='Nb Fingerprints'),
] = 0
nb_ips_cves: Annotated[
Optional[int],
Field(description='Number of IPs across CVEs', ge=0, title='Nb Ips Cves'),
] = 0
nb_ips_fingerprints: Annotated[
Optional[int],
Field(
description='Number of IPs across fingerprint rules',
ge=0,
title='Nb Ips Fingerprints',
),
] = 0


class LookupListResponsePage(BaseModelSdk):
items: Annotated[List[LookupListItem], Field(title='Items')]
class LookupListWithStatsResponsePage(BaseModelSdk):
items: Annotated[List[LookupListItemWithStats], Field(title='Items')]
total: Annotated[int, Field(ge=0, title='Total')]
page: Annotated[int, Field(ge=1, title='Page')]
size: Annotated[int, Field(ge=1, title='Size')]
Expand Down Expand Up @@ -866,6 +891,52 @@ class TimelineItem(BaseModelSdk):
]


class TopProductItem(BaseModelSdk):
value: Annotated[str, Field(description='Product name', title='Value')]
nb_ips_cves: Annotated[
Optional[int],
Field(description='Number of IPs across CVEs', ge=0, title='Nb Ips Cves'),
] = 0
nb_ips_fingerprints: Annotated[
Optional[int],
Field(
description='Number of IPs across fingerprint rules',
ge=0,
title='Nb Ips Fingerprints',
),
] = 0


class VendorStatsResponse(BaseModelSdk):
value: Annotated[str, Field(description='Vendor name', title='Value')]
nb_cves: Annotated[
Optional[int], Field(description='Number of CVEs', ge=0, title='Nb Cves')
] = 0
nb_fingerprints: Annotated[
Optional[int],
Field(description='Number of fingerprint rules', ge=0, title='Nb Fingerprints'),
] = 0
nb_ips_cves: Annotated[
Optional[int],
Field(description='Number of IPs across CVEs', ge=0, title='Nb Ips Cves'),
] = 0
nb_ips_fingerprints: Annotated[
Optional[int],
Field(
description='Number of IPs across fingerprint rules',
ge=0,
title='Nb Ips Fingerprints',
),
] = 0
top_products: Annotated[
Optional[List[TopProductItem]],
Field(
description='Top products for this vendor sorted by total IPs descending',
title='Top Products',
),
] = None


class IntegrationsGetIntegrationsQueryParameters(BaseModelSdk):
tag: Annotated[
Optional[List[str]],
Expand Down Expand Up @@ -1063,6 +1134,10 @@ class VendorsGetVendorsQueryParameters(BaseModelSdk):
] = 50


class VendorsGetVendorStatsPathParameters(BaseModelSdk):
vendor: Annotated[str, Field(title='Vendor')]


class VendorsGetVendorImpactQueryParameters(BaseModelSdk):
sort_by: Annotated[
Optional[GetCVEsSortBy], Field(description='Field to sort by', title='Sort By')
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion 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, user_agent="crowdsec_tracker_api/1.108.1")
super().__init__(base_url=base_url, auth=auth, user_agent="crowdsec_tracker_api/1.116.0")

def get_cves(
self,
Expand Down
2 changes: 1 addition & 1 deletion crowdsec_tracker_api/services/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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

def get_fingerprint_rules(
self,
Expand Down
2 changes: 1 addition & 1 deletion 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, user_agent="crowdsec_tracker_api/1.108.1")
super().__init__(base_url=base_url, auth=auth, user_agent="crowdsec_tracker_api/1.116.0")

def get_integrations(
self,
Expand Down
6 changes: 3 additions & 3 deletions crowdsec_tracker_api/services/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

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

def get_products(
self,
query: Optional[str] = None,
page: int = 1,
size: int = 50,
)-> LookupListResponsePage:
)-> LookupListWithStatsResponsePage:
endpoint_url = "/products"
loc = locals()
headers = {}
Expand All @@ -33,7 +33,7 @@ def get_products(
url=endpoint_url, path_params=path_params, params=params, headers=headers
)

return LookupListResponsePage(_client=self, **response.json())
return LookupListWithStatsResponsePage(_client=self, **response.json())

def get_product_impact(
self,
Expand Down
6 changes: 3 additions & 3 deletions crowdsec_tracker_api/services/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

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

def get_tags(
self,
query: Optional[str] = None,
page: int = 1,
size: int = 50,
)-> LookupListResponsePage:
)-> LookupListWithStatsResponsePage:
endpoint_url = "/tags"
loc = locals()
headers = {}
Expand All @@ -33,7 +33,7 @@ def get_tags(
url=endpoint_url, path_params=path_params, params=params, headers=headers
)

return LookupListResponsePage(_client=self, **response.json())
return LookupListWithStatsResponsePage(_client=self, **response.json())

def get_tag_impact(
self,
Expand Down
26 changes: 23 additions & 3 deletions crowdsec_tracker_api/services/vendors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

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

def get_vendors(
self,
query: Optional[str] = None,
page: int = 1,
size: int = 50,
)-> LookupListResponsePage:
)-> LookupListWithStatsResponsePage:
endpoint_url = "/vendors"
loc = locals()
headers = {}
Expand All @@ -33,7 +33,27 @@ def get_vendors(
url=endpoint_url, path_params=path_params, params=params, headers=headers
)

return LookupListResponsePage(_client=self, **response.json())
return LookupListWithStatsResponsePage(_client=self, **response.json())

def get_vendor_stats(
self,
vendor: str,
)-> VendorStatsResponse:
endpoint_url = "/vendors/{vendor}/stats"
loc = locals()
headers = {}
params = {}
path_params = json.loads(
VendorsGetVendorStatsPathParameters(**loc).model_dump_json(
exclude_none=True
)
)

response = self.http_client.get(
url=endpoint_url, path_params=path_params, params=params, headers=headers
)

return VendorStatsResponse(**response.json())

def get_vendor_impact(
self,
Expand Down
Loading