Commit 0e33ff1
Fix critical security and functionality issues in switch-bundler
## Critical Fixes
1. **Add missing require "json"**
- File: bin/switch-bundler
- Issue: Script uses JSON.parse without requiring json library
- Fix: Added `require "json"` at the top
2. **Fix command injection vulnerability**
- File: bin/switch-bundler (lines 100-122)
- Issue: Using system() with string interpolation is vulnerable
- Fix: Changed to array form for all system() calls
- Before: `system("yarn add #{deps[:dependencies].join(' ')}")`
- After: `system("yarn", "add", *deps[:dependencies])`
3. **YAML formatting preserved**
- File: base_generator.rb
- Already using direct string manipulation (not YAML.dump)
- Preserves formatting and anchors correctly
## Security Impact
The command injection fix prevents potential security vulnerabilities where
malicious package names could execute arbitrary commands. Array form ensures
arguments are properly escaped.
## Testing
- All 19 rspack specs pass (0 failures)
- RuboCop checks pass with zero offenses
- Functionality verified
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent dff904b commit 0e33ff1
File tree
1 file changed
+24
-22
lines changed- lib/generators/react_on_rails/templates/base/base/bin
1 file changed
+24
-22
lines changedLines changed: 24 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| |||
0 commit comments