fix names

This commit is contained in:
Changzhi Li
2025-04-07 09:22:26 +00:00
parent 5a96c2d4d0
commit 075bd524a9
2 changed files with 6 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ from pydantic import BaseModel, Field
from utils.request import post_slce_api
from tools import Tool, ABCTool, tools
from urllib.parse import urlparse
@tools.register
class CreateHttpApplication(BaseModel, ABCTool):
domain: str = Field(default="",description="application domain, if empty, match all domain")

View File

@@ -1,9 +1,9 @@
from pydantic import BaseModel, Field
from utils.request import get_slce_api
from tools import Tool, ABCTool, tools
from urllib.parse import urlparse
@tools.register
class CreateHttpApplication(BaseModel, ABCTool):
class GetAttackEvents(BaseModel, ABCTool):
ip: str = Field(default="", description="the attacker's client IP address")
size: int = Field(default=10, min=1, max=100, description="the number of results to return")
start: str = Field(default="", description="start time, millisecond timestamp")
@@ -12,13 +12,9 @@ class CreateHttpApplication(BaseModel, ABCTool):
@classmethod
async def run(self, arguments:dict) -> str:
try:
req = CreateHttpApplication.model_validate(arguments)
parsed_upstream = urlparse(req.upstream)
if parsed_upstream.scheme not in ["https", "http"]:
return "invalid upstream scheme"
if parsed_upstream.hostname == "":
return "invalid upstream host"
req = GetAttackEvents.model_validate(arguments)
if req.size < 1 or req.size > 100:
return "size must be between 1 and 100"
except Exception as e:
return str(e)