fix: Enforce stricter validation rules for the plugin name. [INS-5310 & INS-5408 & INS-5333] - #8639
Conversation
1833d41 to
c224a46
Compare
| ); | ||
| } catch (err) { | ||
| // Log and rethrow any installation errors | ||
| console.error(`[plugins] Failed to install plugin ${pluginName}:`, err); |
Check notice
Code scanning / Semgrep OSS
Semgrep Finding: javascript.lang.security.audit.unsafe-formatstring.unsafe-formatstring
| try { | ||
| await rm(tmpDir, { recursive: true, force: true }); | ||
| } catch (error) { | ||
| console.warn(`[plugins] Failed to clean tmp dir ${tmpDir}:`, error); |
Check notice
Code scanning / Semgrep OSS
Semgrep Finding: javascript.lang.security.audit.unsafe-formatstring.unsafe-formatstring
| const pluginDir = getSafePluginDir(pluginName); | ||
|
|
||
| try { | ||
| const packagePath = path.resolve(pluginDir, 'package.json'); |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
|
|
||
| try { | ||
| const packagePath = path.resolve(pluginDir, 'package.json'); | ||
| const mainJsPath = path.resolve(pluginDir, 'main.js'); |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
| try { | ||
| const modulePath = path.join(p, filename); | ||
| const packageJSONPath = path.join(modulePath, 'package.json'); | ||
| const modulePath = path.resolve(p, filename); |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
| try { | ||
| const modulePath = path.join(p, filename); | ||
| const packageJSONPath = path.join(modulePath, 'package.json'); | ||
| const modulePath = path.resolve(p, filename); |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
| const modulePath = path.join(p, filename); | ||
| const packageJSONPath = path.join(modulePath, 'package.json'); | ||
| const modulePath = path.resolve(p, filename); | ||
| const packageJSONPath = path.resolve(modulePath, 'package.json'); |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
| if (p.indexOf(modulePath) === 0) { | ||
| delete global.require.cache[p]; | ||
| // Sanitize paths and check for known module patterns to prevent command injection | ||
| const safeModulePath = path.resolve(modulePath); |
Check warning
Code scanning / Semgrep OSS
Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
dd41f52 to
95a150b
Compare
@godfrzero I have changed it like this
|
786af2c to
dddded8
Compare
3babbe8 to
3aa067a
Compare
3aa067a to
8a4c8c3
Compare
…e path resolution for security
…luginDir and improving path handling
…additional utility functions
…gin installation logic
…n plugin settings
…n interactions tests
…roved plugin validation
…r and rename webUtils import
…moving unnecessary properties
…lugin reload logic
INS-5408 & INS-5333] (#8639) * feat: Add CreatePluginModal component for plugin creation * feat: Integrate CreatePluginModal for streamlined plugin creation * feat: Enhance plugin creation with path validation and error handling * feat: Add comprehensive validation tests for plugin name generation * feat: Improve path validation for plugin directory to prevent traversal attacks * feat: Add checks to prevent overwriting existing plugin files during creation * feat: Add plugin name validation and sanitization to prevent path traversal * fix: Correct import order in create-plugin-modal component * fix: Correct import order in plugins interactions test * feat: Enhance plugin name validation to prevent invalid formats and add test ID for button * test: Refactor plugin interactions tests for improved readability and maintainability * fix: Improve code readability by adding comments and removing unnecessary whitespace in create plugin directory function * fix: Correct import order in plugins interactions test * Imports * refactor: Improve import order and enhance code readability in CreatePluginModal component * test: Update plugin interactions tests to use soft assertions for improved error handling * fix: Remove version parameter from createPlugin function call in Root component * refactor: Enhance plugin name validation and remove version parameter from createPlugin function * refactor: Remove plugin name validation logic from CreatePluginModal component * refactor: Simplify destructuring and improve button class order in Plugins component * test: Update plugin name validation messages and add additional rejection cases * refactor: Enhance plugin name validation to prevent OS command injection and disallow path traversal * refactor: Simplify error handling in CreatePluginModal component * test: Add validation for plugin name restrictions including path traversal and length * refactor: Rename moduleName to pluginName in createPlugin function for clarity * refactor: Add path traversal validation in getSafePluginDir function * test: Add comprehensive validation for plugin name restrictions in smoke tests * feat: Implement comprehensive validation for plugin names and directory safety * fix: Adjust modal content height to auto for better responsiveness * Modify the plugins tab * feat: Enhance CreatePluginModal with accessibility attributes for plugin name input * refactor: Rename _traversePluginPath to traversePluginPath and enhance path resolution for security * refactor: Simplify plugin directory validation by extracting getSafePluginDir and improving path handling * Modify the install plugin functionality * Improvements * feat: Export containsOnlyDeprecationWarnings function for broader usage * refactor: Remove isDeprecatedDependencies tests to streamline install.js test suite * feat: Export utility functions for broader access in the plugin system * fix: Validate plugin metadata by checking for missing tarball URL * Improve plugin system by enhancing metadata validation and exporting additional utility functions * fix: Set modal content height to 100% for consistent display * refactor: Rename isInsomniaPlugin to getPluginInfo and streamline plugin installation logic * test: Add comprehensive tests for plugin installation and utility functions * delete: Remove obsolete test file for plugin installation * refactor: Update elevated access warning display and improve layout in plugin settings * feat: Add support for scoped package names in plugin installation functions * refactor: Improve layout and error handling in plugin settings component * feat: Add validation for plugin name input during installation * feat: Enhance plugin name validation to support scoped package names * test: Update error messages for invalid scoped package names in plugin interactions tests * feat: Pass allowScopedPackageNames parameter to getPluginInfo for improved plugin validation * feat: Add support for scoped package names in plugin validation regex * feat: Update installPlugin to accept allowScopedPackageNames parameter and rename webUtils import * feat: Update installPlugin handler to accept allowScopedPackageNames parameter * refactor: Simplify mock implementations in install-plugin tests by removing unnecessary properties * fix: Correct plugin name length validation to enforce a maximum of 214 characters * refactor: Simplify state management in Plugins component and update plugin reload logic



Enforce stricter validation rules for the plugin name.
Empty state - without plugins
With Installed plugin list
Initial View
Error exists
Closes: INS-5310, INS-5310