Skip to content

bundle.Import: skip dot entries, use filepath.Abs for destDir containment check#345

Merged
intel352 merged 2 commits intoalert-autofix-65from
copilot/sub-pr-344
Mar 16, 2026
Merged

bundle.Import: skip dot entries, use filepath.Abs for destDir containment check#345
intel352 merged 2 commits intoalert-autofix-65from
copilot/sub-pr-344

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

Two correctness issues in the path-traversal hardening added to bundle.Import:

  • Dot entry rejection broke valid tarballs: tar -czf bundle.tar.gz . emits a top-level . directory entry. The previous fix returned an error on clean == "." — now it continues (skips) instead.
  • Containment check unreliable with relative destDir: filepath.Clean(destDir) does not produce an absolute path when destDir is relative (e.g. .), so the strings.HasPrefix check against joined paths could incorrectly reject valid entries. Replaced with filepath.Abs(destDir).

Changes

  • bundle/import.go

    • clean == "."continue instead of returning an error
    • filepath.Clean(destDir)filepath.Abs(destDir) (with error handling) so the containment prefix check operates on true absolute paths
  • bundle/bundle_test.go

    • TestImportDotDirectoryEntry: tarballs with a . entry succeed
    • TestImportRelativeDestDir: relative destDir resolves correctly; returned workflowPath is absolute

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI changed the title [WIP] [65] Potential fix for uncontrolled data path expression bundle.Import: skip dot entries, use filepath.Abs for destDir containment check Mar 16, 2026
Copilot AI requested a review from intel352 March 16, 2026 18:40
@intel352 intel352 marked this pull request as ready for review March 16, 2026 18:40
@intel352 intel352 merged commit 17134de into alert-autofix-65 Mar 16, 2026
@intel352 intel352 deleted the copilot/sub-pr-344 branch March 16, 2026 18:40
intel352 added a commit that referenced this pull request Mar 16, 2026
…in path expression (#344)

* Potential fix for code scanning alert no. 65: Uncontrolled data used in path expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* bundle.Import: skip dot entries, use filepath.Abs for destDir containment check (#345)

* Initial plan

* Fix bundle.Import: skip dot entries, use filepath.Abs for destDir

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
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.

2 participants