Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide on a policy on how to handle URLs and clashing project names #1323

Open
elcritch opened this issue Dec 28, 2024 · 0 comments
Open

Decide on a policy on how to handle URLs and clashing project names #1323

elcritch opened this issue Dec 28, 2024 · 0 comments

Comments

@elcritch
Copy link
Contributor

Currently the way Nimble treats package names and URL's in requires list in Nimble files causes issue.

For example having packageA and github.com/foo/packagea in the nimble files for two dependencies in a project can potential result in non-deterministic behavior. One case would be to have two separate paths of the same module (--path:packagea_path --path:github_foo_packagea_path) passed to the compiler. Though I believe the SAT code currently avoids this. Alternatively a package will get chosen based on the insert order of the packages lists as they're generated, which seems to depend partly on the order of iteration of Nimble packages.

One really bad result of this indeterminate order could be a hijack a package name with a hostile package injected via another dependency which adds a trojan URL into it's nimble requirements. For example project bar could add requires "github.com/_bad_hacker/foo" which has a foo.nimble. When Nimble runs printPkgInfo on the package cache after an update then Nimble might choose github.com/_bad_hacker/foo instead of the official github.com/cooluser/foo because say it uses treeWalk or similar to parse package info. Note that I haven't tried this, and it's possible the code avoids this issue. It'd also depend on the end-users OS and other details as well.

Personally I think the way Elixir's mix package manager handles it is the best, but it requires specifying the package name as well as the URL in it's dependencies format for packages not in the official catalog. In Elixir that's done as a tuple {:other_package, "~> 2.0", git: "github.com/foo/packagea"}. Then if as an end-user I want to fork a library and use it I can do {:other_package, "~> 2.0", git: "github.com/user/packagea_fork", override: true}. However, Nimble requires doesn't support this and packages are already specified purely via URL.

A benefit about treating the URL or source as extra metadata in requires means the name conflict can be raised before running SAT or even cloning a repo/package since the name is already included. The user can then specify what they want to do. If it's a legitimate fork then the user can override the default name.

One solution for example would be to modify requires to allow requires (name: "foo > 0.2", git: "github.com/cooluser/foo", override: true). This also avoids the need for Nimble to do network requests to test is a requirement is a git or hg repo, etc.`. Just one thought.

IMHO, the randomness of URL handling is a pretty big issue to have in the 1.0 release. Especially as a fair number of widely used packages in the nimbleverse are reference via URLs.

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

No branches or pull requests

1 participant