Repository navigation
[repo-assist] Prevent home directory deletion from malformed github/git source spec - #4389
Merged
dsyme merged 1 commit intoAug 29, 2026
Conversation
… spec (#4306) Root cause: DependenciesFileParser can parse a malformed remote source line (e.g. `github myorg/repo:main ~>` with a missing version after `~>`) such that the trailing token becomes the remote file's Name. ModuleResolver.computeFilePath then calls normalizePath on that name, which expands a leading '~' into an absolute path rooted at the user's home directory (via normalizeHomeDirectory). Because Path.Combine discards preceding segments once a later segment is rooted, the computed destination directory silently became the user's actual home directory instead of a paket-files subfolder. RemoteDownload.DownloadSourceFiles then calls Utils.CleanDir on that path, recursively deleting the user's home directory. Fix: computeFilePath now rejects any resolved relative-name path that turns out to be rooted/absolute, raising a clear parse error instead of silently computing a destination outside the paket-files tree. Co-authored-by: Copilot <[email protected]>
17 tasks
dsyme
marked this pull request as ready for review
August 29, 2026 09:35
This was referenced Oct 5, 2026
This was referenced Oct 14, 2026
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist, an automated AI assistant.
Closes #4306
Root cause
A malformed remote-source line in
paket.dependencies, such as:(a
~>version operator with no version following it) is parsed byDependenciesFileParsersuch that the trailing~>token ends up as the remote file'sNameinstead of a real file path.ModuleResolver.computeFilePaththen callsnormalizePathon that name.normalizePathcallsnormalizeHomeDirectory, which expands any string starting with~into an absolute path rooted at the user's home directory. BecausePath.Combinediscards all preceding segments once a later segment is rooted, the computed destination directory for the source file silently became the user's actual home directory instead of a subfolder underpaket-files.RemoteDownload.DownloadSourceFilesthen callsUtils.CleanDiron that path, which recursively deletes everything in it — i.e. the user's home directory.Fix
computeFilePathinsrc/Paket.Core/Dependencies/ModuleResolver.fsnow checks whether the normalized relative-name path is rooted/absolute after normalization, and raises a clearfailwithfparse error instead of silently computing a destination path outside the intendedpaket-filestree. This turns a silent data-loss bug into an explicit, safe error for malformed dependency specs.Trade-offs
~>as a file name. It's a minimal, surgical change that blocks the dangerous outcome for any malformed spec that could produce a rooted "name", not just this specific~>case.Test Status
dotnet build src/Paket.Core/Paket.Core.fsproj -c Release— succeeded (no new warnings/errors).dotnet test tests/Paket.Tests/Paket.Tests.fsproj --filter "FullyQualifiedName~ParserSpecs"— 155 passed, 0 failed onnet9.0. (net461 host could not run in this sandbox due to missingmono, an environment limitation unrelated to this change.)should not compute a file path outside paket-files for a malformed github source spec, verifying that agithub owner/repo:main ~>line parses withName = "~>"and that calling.FilePath(...)now throws instead of resolving to a rooted path.Add this agentic workflow to your repo
To install this agentic workflow, run