Skip to content

Conversation

@sdn4z
Copy link
Collaborator

@sdn4z sdn4z commented Oct 30, 2025

This PR makes a difference between normal packages and packages with a namespace. For the latter, the behaviour has been extended so that we check only in the namespace for a typo, and if there's a possible one, we require the package to be identical to the legit one.

For example:

  • trusted package -> @aws/sdk
  • not a typo -> @awz/zdk (namespace could be a typo, but package name does not match trusted one)
  • typo -> @awz/sdk (namespace could be a typo, package name matches trusted one)

This will help reduce the number of false positives and assumes that if someone is impersonating a package, they'll mimic the namespace but keep the package identical.

refs #97

@sdn4z
Copy link
Collaborator Author

sdn4z commented Oct 30, 2025

/lgtm review

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦉 lgtm Review

Score: Needs a Lot of Work 🚨

🔍 Summary

This PR introduces a solid architectural refactoring, using a TrustedPackagesProtocol to support different package ecosystems like PyPI and npm. This makes the system more extensible.

However, there are three critical correctness bugs that must be fixed before merging:

  1. The TrustedNpmPackageManager.__contains__ method is implemented incorrectly and will fail for namespaced packages.
  2. The top_npm_reference.py file is missing an import re, which will cause a runtime NameError.
  3. Invalid npm package names are silently ignored, which is inconsistent with the PyPI implementation and could hide issues in the trusted source data.

I've also included suggestions to improve performance in NormalizedPackages and to add unit tests for the new npm-specific logic. Given the critical issues, the PR needs significant work.

More information
  • Id: e2d96ad3e5a840a7b8f7c79a0755a0e6
  • Model: gemini-2.5-pro
  • Created at: 2025-10-30T11:16:19.720185+00:00
Usage summary
  • Request count: 2
  • Request tokens: 83,337
  • Response tokens: 19,093
  • Total tokens: 102,430

See the 📚 lgtm-ai repository for more information about lgtm.

@github-actions github-actions bot added feature and removed feature labels Oct 30, 2025
@github-actions github-actions bot added feature and removed feature labels Oct 30, 2025
@github-actions github-actions bot added feature and removed feature labels Oct 30, 2025
@sdn4z sdn4z marked this pull request as ready for review October 30, 2025 11:41
@sdn4z sdn4z requested a review from scastlara as a code owner October 30, 2025 11:41
@github-actions github-actions bot added feature and removed feature labels Oct 30, 2025
@sdn4z sdn4z changed the title feat: treat namespaces as a special case when checking typos feat: treat namespaces as a special case when checking for typos Oct 31, 2025
Copy link
Collaborator

@scastlara scastlara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@sdn4z sdn4z enabled auto-merge (squash) November 3, 2025 08:27
@github-actions github-actions bot added feature and removed feature labels Nov 3, 2025
@sdn4z sdn4z merged commit de2376c into elementsinteractive:main Nov 3, 2025
12 checks passed
@sdn4z sdn4z deleted the ns branch November 3, 2025 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants