refactor(backend): validate numeric IDs and use url.Values for upstream URLs #2
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: shekhar/windows-iso-downloader#2
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "improve-backend-url-encoding"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
product_idandsku_idwith HTTP 400 before any upstream request is made, preventing parameter injection into Microsoft API query stringsfmt.SprintfURL construction withurl.Values.Set+.Encode()acrosshandleSkuInfo,handleProxy, andsetupSessionTest plan
product_id=abc→ 400product_id must be a numeric valueproduct_id=2618%26profile=injected→ 400 (injection blocked)product_id→ 400product_id query parameter is requiredsku_id=notanumber→ 400sku_id must be a numeric valueproduct_id=2618(valid) → 200 OK from MicrosoftSummary by CodeRabbit
Bug Fixes
Refactor
📝 Walkthrough
Walkthrough
Single file update to
backend/main.gothat refactors URL query construction across three handlers to usenet/urlencoding instead of manualfmt.Sprintfstrings, adds numeric validation for product ID and SKU ID parameters, and updates a related comment.Changes
Query Construction and Input Validation
backend/main.gonet/urland refactors three outbound Microsoft requests to build query strings viaurl.Valuesinstead of manual formatting: session/org queries, mdt.js parameters, and fingerprint response parameters.backend/main.goproduct_idis numeric before processing, then replaces thegetskuinformationbyproducteditionquery assembly withurl.Values-based encoding.backend/main.goproduct_idandsku_idas numeric values, returning JSON 400 errors on invalid input. Refactors warmup request andGetProductDownloadLinksBySkurequest URLs to useurl.Values. Updates comment onSetEscapeHTML(false).Estimated Code Review Effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
improve-backend-url-encodingComment
@coderabbitai helpto get the list of available commands and usage tips.Deploying msdl-frontend with
Cloudflare Pages
37f947cView logs
🧹 Nitpick comments (1)
🤖 Prompt for all review comments with AI agents
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
ab568493-41d9-447b-bc3b-b592061e7dd8📥 Commits
Reviewing files that changed from the base of the PR and between
10ad222ddeand37f947cb32.📒 Files selected for processing (1)
backend/main.go