11from pydantic import BaseModel , Field
22from utils .request import get_slce_api
33from tools import Tool , ABCTool , tools
4- from urllib . parse import urlparse
4+
55@tools .register
6- class CreateHttpApplication (BaseModel , ABCTool ):
6+ class GetAttackEvents (BaseModel , ABCTool ):
77 ip : str = Field (default = "" , description = "the attacker's client IP address" )
88 size : int = Field (default = 10 , min = 1 , max = 100 , description = "the number of results to return" )
99 start : str = Field (default = "" , description = "start time, millisecond timestamp" )
@@ -12,13 +12,9 @@ class CreateHttpApplication(BaseModel, ABCTool):
1212 @classmethod
1313 async def run (self , arguments :dict ) -> str :
1414 try :
15- req = CreateHttpApplication .model_validate (arguments )
16- parsed_upstream = urlparse (req .upstream )
17- if parsed_upstream .scheme not in ["https" , "http" ]:
18- return "invalid upstream scheme"
19-
20- if parsed_upstream .hostname == "" :
21- return "invalid upstream host"
15+ req = GetAttackEvents .model_validate (arguments )
16+ if req .size < 1 or req .size > 100 :
17+ return "size must be between 1 and 100"
2218 except Exception as e :
2319 return str (e )
2420
0 commit comments