
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Add this line to your application's Gemfile:
gem 'script_executor'
And then execute:
bundle
Or install it yourself as:
gem install script_executor
# Create executor
executor = ScriptExecutor.new
executor.execute "ls"
server_info = {
:remote => true,
:domain => "some_host",
:user => "some_user",
:password => "some_password"
}
executor.execute server_info.merge(:script => "ls -al")
executor.execute server_info.merge({:sudo => true, :script => "/etc/init.d/tomcat stop"})
executor.execute server_info.merge(:sudo => true) do
%Q(
/etc/init.d/tomcat stop
/etc/init.d/tomcat start
)
end
server_info.merge(:capture_output => true, :suppress_output => true)
result = executor.execute server_info.merge(:script => "whoami")
puts result # ENV['USER']
server_info.merge(:simulate => true)
executor.execute server_info.merge(:script => "whoami") # generate commands without actual execution
You can keep scripts that needs to be executed embedded into your code (as in examples above), move them into separate file or keep them in same file behind "END" Ruby directive. The latter gives you the ability to keep command and code together thus simplifying access to code.
For example, if you want to create script with 2 commands (command1, command2), you can use "scripts" and "evaluate_script_body" methods:
require 'script_locator'
include ScriptLocator
scripts = scripts(__FILE__) # [command1, command2]
name = "john"
result = evaluate_script_body(scripts[:command1][:code], binding)
puts result # john
__END__
[command1]
echo "<%= name %>"
[command2]
echo "test2"
# base.conf.json
{
"node": {
"domain": "22.22.22.22", // remote host, see "config.vm.synced_folder"
"port": "22", // default ssh port
"user": "vagrant", // vagrant user name
"password": "vagrant", // vagrant user password
"home": "/home/vagrant",
"remote": true
},
"project": {
"home": "#{node.home}/acceptance_demo",
"ruby_version": "2.2.3",
"gemset": "acceptance_demo"
}
}
# script.sh
[echo]
echo "Hello world!"
[ubuntu_update]
sudo apt-get update
# install.thor
class MyProvision < Thor
@provision = BaseProvision.new self, 'base.conf.json', ['script.sh']
@provision.create_thor_methods(self)
desc "local_command", "local_command"
def local_command
invoke :echo
invoke :ubuntu_update
end
end
my_provision = MyProvision.new
thor my_provision:echo
thor my_provision:ubuntu_update
thor my_provision:local_command
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that script_executor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.