Skip to content

Commit 0e34c7f

Browse files
justin808claude
andcommitted
Replace shell-dependent backtick call with secure Open3 invocation
- Replace `node --version 2>/dev/null` with Open3.capture3('node', '--version') - Add proper error handling for non-zero exit status - Use stdout with stderr fallback for version string extraction - Eliminates shell injection vulnerabilities from shell redirection - Maintains same functionality while improving security 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d3a4ba2 commit 0e34c7f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/react_on_rails/system_checker.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
require 'open3'
4+
35
module ReactOnRails
46
# SystemChecker provides validation methods for React on Rails setup
57
# Used by install generator and doctor rake task
@@ -56,8 +58,14 @@ def check_node_installation
5658
end
5759

5860
def check_node_version
59-
node_version = `node --version 2>/dev/null`.strip
60-
return if node_version.empty?
61+
stdout, stderr, status = Open3.capture3('node', '--version')
62+
63+
# Use stdout if available, fallback to stderr if stdout is empty
64+
node_version = stdout.strip
65+
node_version = stderr.strip if node_version.empty?
66+
67+
# Return early if node is not found (non-zero status) or no output
68+
return if !status.success? || node_version.empty?
6169

6270
# Extract major version number (e.g., "v18.17.0" -> 18)
6371
major_version = node_version[/v(\d+)/, 1]&.to_i

0 commit comments

Comments
 (0)