
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
SafeShell lets you execute shell commands and get the resulting output, but without the security problems of Ruby's backtick operator.
Install gem:
gem install safe_shell
Use gem:
require 'safe_shell'
SafeShell.execute("echo", "Hello, world!")
SafeShell sets the $? operator to the process status, in the same manner as the backtick operator.
# Send stdout and stderr to files:
SafeShell.execute("echo", "Hello, world!", :stdout => "output.txt", :stderr => "error.txt")
# Send additional environment variables:
SafeShell.execute("echo", "Hello, world!", :env => { 'name' => 'john', 'foo' => 'bar' })
# Return true if the command exits with a zero status:
SafeShell.execute?("echo", "Hello, world!")
# Raise an exception if the command exits with a non-zero status:
SafeShell.execute!("echo", "Hello, world!")
If you use backticks to process a file supplied by a user, a carefully crafted filename could allow execution of an arbitrary command:
file = ";blah"
`echo #{file}`
sh: blah: command not found
=> "\n"
SafeShell solves this.
SafeShell.execute("echo", file)
=> ";blah\n"
Tested with Ruby 2.0.0 or newer, but it should be happy on pretty much any Ruby version. Maybe not so much on Windows.
bundle exec rake
In use on at least one big site, so should be pretty solid. There's not much to it, so I'm not expecting there'll be many releases.
Copyright (c) 2010 - 2015 Envato, Ian Leitch, & Pete Yandell. See LICENSE for details.
FAQs
Unknown package
We found that safe_shell demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.