11import json
22from types import NoneType
3- from typing import Optional , Union , Annotated
3+ from typing import Annotated , Optional , Union
44
5- from ..models import *
6- from ..base_model import Page , Service
5+ from httpx import Auth
76from pydantic import BaseModel , Field
87from pydantic .fields import FieldInfo
9- from httpx import Auth
8+
9+ from ..base_model import Page , Service
1010from ..http_client import HttpClient
11+ from ..models import *
12+
1113
1214class Cves (Service ):
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.95.1" )
15-
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+
1622 def get_cves (
1723 self ,
1824 query : Optional [str ] = None ,
1925 sort_by : Optional [GetCVEsSortBy ] = GetCVEsSortBy ("rule_release_date" ),
2026 sort_order : Optional [GetCVEsSortOrder ] = GetCVEsSortOrder ("desc" ),
2127 page : int = 1 ,
2228 size : int = 50 ,
23- )-> GetCVEsResponsePage :
29+ ) -> GetCVEsResponsePage :
2430 endpoint_url = "/cves"
2531 loc = locals ()
2632 headers = {}
2733 params = json .loads (
28- CvesGetCvesQueryParameters (** loc ).model_dump_json (
29- exclude_none = True
30- )
34+ CvesGetCvesQueryParameters (** loc ).model_dump_json (exclude_none = True )
3135 )
3236 path_params = {}
33-
37+
3438 response = self .http_client .get (
3539 url = endpoint_url , path_params = path_params , params = params , headers = headers
3640 )
37-
41+
3842 return GetCVEsResponsePage (_client = self , ** response .json ())
39-
43+
4044 def get_cve (
4145 self ,
4246 cve_id : str ,
43- )-> GetCVEResponse :
47+ ) -> GetCVEResponse :
4448 endpoint_url = "/cves/{cve_id}"
4549 loc = locals ()
4650 headers = {}
4751 params = {}
4852 path_params = json .loads (
49- CvesGetCvePathParameters (** loc ).model_dump_json (
50- exclude_none = True
51- )
53+ CvesGetCvePathParameters (** loc ).model_dump_json (exclude_none = True )
5254 )
53-
55+
5456 response = self .http_client .get (
5557 url = endpoint_url , path_params = path_params , params = params , headers = headers
5658 )
57-
59+
5860 return GetCVEResponse (** response .json ())
59-
61+
6062 def download_cve_ips (
6163 self ,
6264 cve_id : str ,
63- )-> str :
65+ ) -> str :
6466 endpoint_url = "/cves/{cve_id}/ips-download"
6567 loc = locals ()
6668 headers = {}
6769 params = {}
6870 path_params = json .loads (
69- CvesDownloadCveIpsPathParameters (** loc ).model_dump_json (
70- exclude_none = True
71- )
71+ CvesDownloadCveIpsPathParameters (** loc ).model_dump_json (exclude_none = True )
7272 )
73-
73+
7474 response = self .http_client .get (
7575 url = endpoint_url , path_params = path_params , params = params , headers = headers
7676 )
77-
77+
7878 return response .text
79-
79+
8080 def get_cve_ips_details (
8181 self ,
8282 cve_id : str ,
8383 since : Optional [str ] = "14d" ,
8484 page : int = 1 ,
8585 size : int = 50 ,
86- )-> GetCVEIPsResponsePage :
86+ ) -> GetCVEIPsResponsePage :
8787 endpoint_url = "/cves/{cve_id}/ips-details"
8888 loc = locals ()
8989 headers = {}
@@ -93,23 +93,21 @@ def get_cve_ips_details(
9393 )
9494 )
9595 path_params = json .loads (
96- CvesGetCveIpsDetailsPathParameters (** loc ).model_dump_json (
97- exclude_none = True
98- )
96+ CvesGetCveIpsDetailsPathParameters (** loc ).model_dump_json (exclude_none = True )
9997 )
100-
98+
10199 response = self .http_client .get (
102100 url = endpoint_url , path_params = path_params , params = params , headers = headers
103101 )
104-
102+
105103 return GetCVEIPsResponsePage (_client = self , ** response .json ())
106-
104+
107105 def get_cve_subscribed_integrations (
108106 self ,
109107 cve_id : str ,
110108 page : int = 1 ,
111109 size : int = 50 ,
112- )-> GetCVESubscribedIntegrationsResponsePage :
110+ ) -> GetCVESubscribedIntegrationsResponsePage :
113111 endpoint_url = "/cves/{cve_id}/integrations"
114112 loc = locals ()
115113 headers = {}
@@ -123,13 +121,13 @@ def get_cve_subscribed_integrations(
123121 exclude_none = True
124122 )
125123 )
126-
124+
127125 response = self .http_client .get (
128126 url = endpoint_url , path_params = path_params , params = params , headers = headers
129127 )
130-
128+
131129 return GetCVESubscribedIntegrationsResponsePage (_client = self , ** response .json ())
132-
130+
133131 def subscribe_integration_to_cve (
134132 self ,
135133 request : SubscribeCVEIntegrationRequest ,
@@ -144,18 +142,22 @@ def subscribe_integration_to_cve(
144142 exclude_none = True
145143 )
146144 )
147-
148- payload = json . loads (
149- request .model_dump_json (
150- exclude_none = True
151- )
152- ) if "request" in loc else None
145+
146+ payload = (
147+ json . loads ( request .model_dump_json (exclude_none = True ))
148+ if "request" in loc
149+ else None
150+ )
153151 response = self .http_client .post (
154- url = endpoint_url , path_params = path_params , params = params , headers = headers , json = payload
152+ url = endpoint_url ,
153+ path_params = path_params ,
154+ params = params ,
155+ headers = headers ,
156+ json = payload ,
155157 )
156-
158+
157159 return None
158-
160+
159161 def unsubscribe_integration_from_cve (
160162 self ,
161163 cve_id : str ,
@@ -170,35 +172,30 @@ def unsubscribe_integration_from_cve(
170172 exclude_none = True
171173 )
172174 )
173-
175+
174176 response = self .http_client .delete (
175177 url = endpoint_url , path_params = path_params , params = params , headers = headers
176178 )
177-
179+
178180 return None
179-
181+
180182 def get_cve_timeline (
181183 self ,
182184 cve_id : str ,
183185 since_days : SinceOptions ,
184- )-> list [TimelineItem ]:
186+ ) -> list [TimelineItem ]:
185187 endpoint_url = "/cves/{cve_id}/timeline"
186188 loc = locals ()
187189 headers = {}
188190 params = json .loads (
189- CvesGetCveTimelineQueryParameters (** loc ).model_dump_json (
190- exclude_none = True
191- )
191+ CvesGetCveTimelineQueryParameters (** loc ).model_dump_json (exclude_none = True )
192192 )
193193 path_params = json .loads (
194- CvesGetCveTimelinePathParameters (** loc ).model_dump_json (
195- exclude_none = True
196- )
194+ CvesGetCveTimelinePathParameters (** loc ).model_dump_json (exclude_none = True )
197195 )
198-
196+
199197 response = self .http_client .get (
200198 url = endpoint_url , path_params = path_params , params = params , headers = headers
201199 )
202-
200+
203201 return [TimelineItem (** item ) for item in response .json ()]
204-
0 commit comments