Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
capistrano-stopwatch
Advanced tools
Capistrano::Stopwatch
is a gem to measure the execution time of each Capistrano tasks. Capistrano::Stopwatch
requires Capistrano v3 or above.
Add this line to your application's Gemfile:
gem 'capistrano-stopwatch'
And then execute:
$ bundle
Or install it yourself as:
$ gem install capistrano-stopwatch
Takes four simple steps to run Capistrano::Stopwatch
on your environment.
Capistrano::Stopwatch
in Capfile# Capfile
require 'capistrano-stopwatch'
Right now, you need to manually specify tasks you want to measure execution time. All you need to do is just call measure_duration
method in config/deploy.rb
and hand it name of tasks.
# config/deploy.rb
['deploy:starting', 'deploy:updating'].each do |n|
measure_duration(n)
end
Specify when to run stopwatch:finish
task and execute finish_stopwatch
lambda function. Usually, it is safe to run stopwatch:finish
after the very last task in your Capistrano deploy flow.
# config/deploy.rb
after 'test:stop', 'stopwatch:finish'
Override finish_stopwatch
and specify how to handle the output, which is a hash of task name and execution time. By default, finish_stopwatch
simply prints the output to stdout.
# config/deploy.rb
set :finish_stopwatch, lambda { |durations|
File.open("durations.json", "w") {|f| f.puts(durations.to_json) }
}
# Capfile
require 'capistrano-stopwatch'
# config/deploy.rb
require 'json'
set :finish_stopwatch, lambda { |durations|
File.open("durations.json", "w") {|f| f.puts(durations.to_json) }
puts durations
}
namespace :example do
task :first do
run_locally do
info 'Running first task'
sleep 1
end
end
task :second do
run_locally do
info 'Running second task'
sleep 2
end
end
task :third do
run_locally do
info 'Running third task'
sleep 3
end
end
end
['example:first', 'example:second', 'example:third'].each do |task|
measure_duration(task)
end
after 'example:third', 'stopwatch:finish'
$ bundle ex cap development example:first example:second example:third
00:00 example:first
Running first task
00:01 example:second
Running second task
00:03 example:third
Running third task
00:06 stopwatch:finish
Finishing stopwatch
{"example:first"=>1.001629, "example:second"=>2.002746, "example:third"=>3.004129}
$ cat durations.json
{"example:first":1.001246,"example:second":2.004474,"example:third":3.00379}
AWS CloudWatch Logs Insights might be another good option to gether information about task execution time, even though you need to set how to parse Capistrano logs.
Bug reports and pull requests are welcome on GitHub at https://github.com/shuheiktgw/capistrano-stopwatch. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Capistrano::Stopwatch project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that capistrano-stopwatch 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.