Skip to content

Commit 159bc67

Browse files
SckyzOclaude
andcommitted
security: fix incomplete URL sanitization in tests
Replace unsafe substring check with proper URL parsing in test_url_validation to prevent incomplete URL sanitization. Changes: - Import urllib.parse.urlparse - Parse URL and validate scheme and netloc separately - Ensure hostname is exactly "github.com", not substring This prevents malicious URLs like: - https://evil.com/github.com/malicious - https://github.com.evil.com/ - https://attacker.com?redirect=github.com Fixes CodeQL HIGH severity alert: Incomplete URL substring sanitization. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 4244f4b commit 159bc67

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_artifact_schemas.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
from datetime import datetime
8+
from urllib.parse import urlparse
89

910
import pytest
1011

@@ -397,8 +398,9 @@ def test_url_validation(self):
397398
]
398399

399400
for url in valid_urls:
400-
assert url.startswith("https://")
401-
assert "github.com" in url
401+
parsed = urlparse(url)
402+
assert parsed.scheme == "https"
403+
assert parsed.netloc == "github.com"
402404

403405
def test_sha256_format(self):
404406
"""SHA256 checksums must be valid hex strings."""

0 commit comments

Comments
 (0)