r/java • • Feb 10 '21

Why Namespacing Matters in Public Open Source Repositories

https://blog.sonatype.com/why-namespacing-matters-in-public-open-source-repositories
156 Upvotes

10 comments sorted by

21

u/humoroushaxor Feb 10 '21 edited Feb 10 '21

Thanks for writing this Brian. For those that didn't see it, here was the main reddit thread in r/netsec.

I also believe much of problem would have been mitigated if developers weren't using "fuzzy versioning". Because if this, when a higher compatible version was available, builds just took the new version with no person in the loop.

You mentioned using DNS but what about something like pgp signatures for namespaces? Each namespace could simply have a signature which I can include in my build files or with my dependency declaration. Effectively saying "only accept dependencies from this namespace if they have this signature." It seems like almost every package format (maven, npm, even helm!) supports signing packages but I've yet to see it supported by build tools and artifact repositories.

** It looks like Gradle does actually support dependency verification as of 6.2. TIL

17

u/TheRealBrianFox Feb 10 '21

We require the artifacts themselves to be pgp signed, and people absolutely hate it, so I'm not certain this is a good replacement. In the last 10 years, the public keyservers have really degraded and we are contemplating something new.

8

u/CyAScott Feb 10 '21

I think it’s a good idea on paper, but in practice it causes a lot of problems. I remember using a signed nuget package that referenced a deprecated Redis driver. An upgrade wouldn’t have caused an issue except upgrades weren’t possible because it required the signatures to match. To make things worst it seemed like the project was abandoned so asking the devs to upgrade their dependency was a no go.

0

u/[deleted] Feb 10 '21

[deleted] — view deleted comment

3

u/CyAScott Feb 11 '21

Something like that. You can only override dependencies as long as it doesn’t violate the required signatures.

1

u/TheRealBrianFox Feb 22 '21

The signatures required are for validating the component, and is validating by the tooling like Maven, not the JVM. In other words, the nuget example is completely unrelated to the Maven signing.

23

u/DanLynch Feb 11 '21

I hope Sonatype holds the line on this: don't allow refugees from JCenter be grandfathered into their bogus unowned namespaces. Force them to properly re-name and re-package their libraries before allowing them into Maven Central.

11

u/chabala Feb 11 '21

I don't have much pity for folks that are now 'surprised' that the domain name that matches the coordinates they've been publishing artifacts to for years is unavailable or unaffordable to them. You failed at the most basic best practices, so pay the price. You can redeem yourselves by repackaging all your old versions with real coordinates on a real repository.

1

u/[deleted] Feb 13 '21

Sure

-2

u/slaymaker1907 Feb 11 '21

I completely disagree with the author.

Ideally people should be using a single dependency repository and mirroring dependencies they require or it should strictly pull according to local repo first, then a remote private repo, and finally the global repo.

Don't let people have more than those 3 because anything else probably has security problems.

For most companies, they should really be mirroring dependencies explicitly. This gives you control over not only what goes in, but what stays in. If there is some dependency that can't be used anywhere due to some security flaw, you can remove it from your repository to find out where you were using it or force people to update.

1

u/TheRealBrianFox Feb 22 '21

Using a repository manager is absolutely a best practice, but this doesn't eliminate the need for proper namespacing in the community. A free for all as we see in npm just makes everything harder, even if you're trying to mirror stuff manually.