Harden ATA package name filtering#63368
Merged
jakebailey merged 2 commits intomicrosoft:mainfrom Apr 7, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Tightens the typings installer’s package-name validation to a strict allowlist before constructing npm install command strings (shell-enabled), and updates diagnostics + baselines accordingly.
Changes:
- Replace URI-encoding-based package name validation with an explicit
^[\w.-]+$allowlist (plus existing leading./_checks and scoped-name splitting). - Introduce
NameContainsInvalidCharacters(with an enum alias to preserve the oldNameContainsNonURISafeCharactersname) and update the rendered failure message. - Update unit tests and tsserver baseline logs to match the new validation result/message.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/jsTyping/jsTyping.ts |
Implements the new allowlist validation, adds/aliases enum member, updates rendered error text. |
src/testRunner/unittests/tsserver/typingsInstaller.ts |
Updates/extends validation tests to expect the new enum result. |
tests/baselines/reference/tsserver/typingsInstaller/should-not-initialize-invaalid-package-names.js |
Baseline update for new error message text. |
tests/baselines/reference/tsserver/typingsInstaller/should-handle-node-core-modules.js |
Baseline update for new error message text. |
tests/baselines/reference/tsserver/typingsInstaller/malformed-packagejson.js |
Baseline update for new error message text. |
RyanCavanaugh
approved these changes
Apr 7, 2026
Member
Author
|
@typescript-bot cherry-pick this to release-6.0 |
Collaborator
typescript-bot
pushed a commit
that referenced
this pull request
Apr 7, 2026
Collaborator
|
Hey, @jakebailey! I've created #63372 for you. |
jakebailey
added a commit
that referenced
this pull request
Apr 7, 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 URI-based validation is what
npmdoes internally, but we should be stricter about what we allow down to npm as we usechild_processwith the shell enabled to avoid reimplementingwhich. Instead, just only allow[\w.-]+.This prevents the odd scenario where someone manages to query ATA on via a broken specifier. The old URI-based validation allowing something through would maximally cause the ATA request to fail and the feature to not work, nothing further.