Skip to content

Fix incomplete URL substring sanitization in extract_pdf.py (CodeQL #12)#17

Merged
ArmandXiao merged 2 commits into
mainfrom
copilot/fix-code-scanning-alert-12
Jul 22, 2026
Merged

Fix incomplete URL substring sanitization in extract_pdf.py (CodeQL #12)#17
ArmandXiao merged 2 commits into
mainfrom
copilot/fix-code-scanning-alert-12

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

"github.io" in url is trivially bypassed — http://evil.com/github.io passes the check. CodeQL flags this as py/incomplete-url-substring-sanitization.

Changes

  • extract_pdf.py: Replace raw substring check with urlparse-based hostname validation
    • Import urlparse from urllib.parse
    • Extract hostname and verify it equals "github.io" or ends with ".github.io"
# Before (bypassable)
if "github.io" in url or is_project_line or ...:

# After (safe)
parsed_host = urlparse(url).hostname or ""
is_github_io = parsed_host == "github.io" or parsed_host.endswith(".github.io")
if is_github_io or is_project_line or ...:

@huangyangyu
huangyangyu marked this pull request as ready for review July 20, 2026 16:39
Copilot AI changed the title [WIP] Fix code scanning alert #12 Fix incomplete URL substring sanitization in extract_pdf.py (CodeQL #12) Jul 20, 2026
Copilot AI requested a review from huangyangyu July 20, 2026 16:39
@ArmandXiao
ArmandXiao merged commit f0294d5 into main Jul 22, 2026
4 checks passed
@ArmandXiao
ArmandXiao deleted the copilot/fix-code-scanning-alert-12 branch July 22, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants