We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f9dce3f + 9213b64 commit 431bf84Copy full SHA for 431bf84
agentic_security/http_spec.py
@@ -1,6 +1,7 @@
1
import base64
2
from enum import Enum
3
4
+from urllib.parse import urlparse
5
import httpx
6
from pydantic import BaseModel
7
@@ -159,6 +160,12 @@ def parse_http_spec(http_spec: str) -> LLMSpec:
159
160
# Extract the method and URL from the first line
161
method, url = lines[0].split(" ")[0:2]
162
163
+ # Check url validity
164
+ valid_url= urlparse(url)
165
+ # if missing the correct formatting ://, urlparse.netloc will be empty
166
+ if valid_url.scheme not in ("http", "https") or not valid_url.netloc:
167
+ raise InvalidHTTPSpecError(f"Invalid URL: {url}. Ensure it starts with 'http://' or 'https://'")
168
+
169
# Initialize headers and body
170
headers = {}
171
body = ""
0 commit comments