Use base filename when saving Orbit signed-URL installer downloads - #52121
Conversation
1877b44 to
33953f0
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. Walkthrough
Merge Risk: ⚪ Minimal · up to The change keeps server-supplied installer downloads within the configured directory by using only the base filename and handling degenerate names safely. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the vulnerability, the code fix, the test coverage, the related issue, and the platform scope. It omits or leaves incomplete several template items, including manual QA, timeout and retry review, release compatibility, and auto-update verification. These omissions are not critical to understanding this focused change. Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Warning
- Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.
Pull request overview
Updates the client-side installer download handling to ensure server-influenced filenames cannot affect the destination directory, particularly for Orbit signed-URL downloads where SkipMediaType is used.
Changes:
- Apply
filepath.Baseto theDestFilefallback used whenSkipMediaTypeis set, and re-guard invalid basename edge cases. - Add tests covering
SkipMediaType+DestFilehandling (including Windows backslash-separated input behavior). - Expand Windows Go test workflow triggers and coverage to include
client/**.go.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| client/base_client.go | Sanitizes fallback filename selection for signed-URL downloads by basing DestFile and re-checking invalid names. |
| client/base_client_test.go | Adds regression tests ensuring SkipMediaType downloads stay within DestPath (including Windows path separator cases). |
| .github/workflows/test-go-windows.yml | Ensures Windows CI runs when client code changes and includes ./client/... in the test matrix. |
| changes/16722-orbit-installer-filename | Release note entry (content excluded from review by policy). |
Files excluded by content exclusion policy (1)
- changes/16722-orbit-installer-filename
Suppressed comments (1)
client/base_client.go:255
filepath.Basecan still return an absolute root path (e.g. "/" on Unix, "\" on Windows, and potentially a drive root/volume-ish value), which would causefilepath.Join(f.DestPath, filename)to ignoreDestPathand write outside the intended download directory. Sincefilenameis ultimately server-influenced (via Content-Disposition orDestFilewhenSkipMediaTypeis true), it should also be rejected if it is absolute or contains a volume name.
if filename == "" || filename == "." || filename == ".." {
filename = uuid.NewString()
}
f.DestFilePath = filepath.Join(f.DestPath, filename)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #52121 +/- ##
==========================================
- Coverage 69.79% 68.70% -1.09%
==========================================
Files 4072 3843 -229
Lines 265453 261605 -3848
Branches 14237 12306 -1931
==========================================
- Hits 185285 179748 -5537
- Misses 63979 65655 +1676
- Partials 16189 16202 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@sharon-fdm @lucasmrod This seemed like a straightforward change so I opened a PR. Then I realized I couldn't validate locally because I don't have a local environment with cloudfront configured. Do you think the tests are sufficient to merge, given it will go through normal QA? |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
lucasmrod
left a comment
There was a problem hiding this comment.
LGTM!
(I moved the changes file to orbit/changes/).
Setting milestone of the issue to fleetd-v1.62.0.
There was a problem hiding this comment.
This should be moved to orbit/changes/.
Related issue: Resolves fleetdm/confidential#16722
FileResponse.Handle(client/base_client.go) only reduced the filename to its base nameinside the Content-Disposition (
!SkipMediaType) branch. On the Orbit signed-URL installerdownload path,
SkipMediaTypeis set and the server-supplied installer name comes in throughDestFile, which was then joined into the destination path as-is. This makes the downloaddestination depend on the exact server-supplied string rather than always staying inside the
configured download directory.
This applies
filepath.Baseto theDestFilefallback as well, so only the base name is used,and re-guards the degenerate
""/"."/".."cases beforefilepath.Join.Checklist for submitter
changes/.SELECT *is avoided, SQL injection is prevented, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.Testing
fleetd/orbit/Fleet Desktop
runtime.GOOSis used as needed to isolate changes (N/A —filepath.Basetreats/and\as separators on both platforms)Summary by CodeRabbit
Bug Fixes
Tests