Skip to content
Merged
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
1 change: 0 additions & 1 deletion ddtrace/appsec/_iast/taint_sinks/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def _rel_path(file_name: str) -> str:
# If the path contains site-packages anywhere, return 'site-packages/<rest>'
# Normalize separators to forward slashes for consistency
if (idx := file_name_norm.find("/site-packages/")) != -1:
print(f"file_name_norm({idx}): {file_name_norm}")
return file_name_norm[idx:]
return ""

Expand Down
7 changes: 3 additions & 4 deletions tests/appsec/integrations/fastapi_tests/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import time
from urllib.parse import parse_qs
from urllib.parse import urlparse

from fastapi import FastAPI
from fastapi import Form
Expand Down Expand Up @@ -107,17 +108,15 @@

@app.post("/iast/ssrf/test_secure", response_class=PlainTextResponse)
async def view_iast_ssrf_secure(url: str = Form(...)):
from urllib.parse import urlparse

# Validate the URL and enforce whitelist
allowed_domains = ["example.com", "api.example.com", "www.datadoghq.com", "localhost"]
if type(url) == bytes:
if isinstance(url, bytes):
url = url.decode("utf-8")
parsed_url = urlparse(url)
if parsed_url.hostname not in allowed_domains:
return PlainTextResponse("Forbidden", status_code=403)
try:
requests.get(parsed_url.geturl())
requests.get(url)
except Exception:
pass

Expand Down
Loading