Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Send notifications to Slack about Capistrano deployments.
Add this line to your application's Gemfile:
gem 'slackistrano'
Execute:
$ bundle
Require the library in your application's Capfile:
require 'slackistrano/capistrano'
You have two options to notify a channel in Slack when you deploy:
Configure your Slack's Incoming Webhook.
Add the following to config/deploy.rb
:
set :slackistrano, {
channel: '#your-channel',
webhook: 'your-incoming-webhook-url'
}
Configure your Slack's Slackbot (not Bot).
Add the following to config/deploy.rb
:
set :slackistrano, {
channel: '#your-channel',
team: 'your-team-name',
token: 'your-token'
}
By default Slackistrano will use a default icon and username. These, can be overriden if you are using the default messaging class (ie. have not specified your own).
Configure per instructions above.
Add the following to config/deploy.rb
:
set :slackistrano, {
...
username: 'Foobar the Deployer',
icon_emoji: ':thumbsup:', # takes precedence over icon_url
icon_url: 'https://avatars2.githubusercontent.com/u/16705?v=4&s=40',
...
}
Test your setup by running the following command. This will post each stage's message to Slack in turn.
$ cap production slack:deploy:test
Deploy your application like normal and you should see messages in the channel you specified.
If you wish to take control over when and what slackistrano hooks are fired, then you can use the option in deploy.rb
:
set :use_custom_slackistrano_hooks, true
This allows you to set custom hooks for all the slackistrano tasks:
'slack:deploy:starting'
'slack:deploy:updating'
'slack:deploy:reverting'
'slack:deploy:updated'
'slack:deploy:reverted'
'slack:deploy:failed'
You can customize the messaging posted to Slack by providing your own messaging class and overriding several methods. Here is one example:
if defined?(Slackistrano::Messaging)
module Slackistrano
class CustomMessaging < Messaging::Base
# Send failed message to #ops. Send all other messages to default channels.
# The #ops channel must exist prior.
def channels_for(action)
if action == :failed
"#ops"
else
super
end
end
# Suppress starting message.
def payload_for_starting
nil
end
# Suppress updating message.
def payload_for_updating
nil
end
# Suppress reverting message.
def payload_for_reverting
nil
end
# Fancy updated message.
# See https://api.slack.com/docs/message-attachments
def payload_for_updated
{
attachments: [{
color: 'good',
title: 'Integrations Application Deployed :boom::bangbang:',
fields: [{
title: 'Environment',
value: stage,
short: true
}, {
title: 'Branch',
value: branch,
short: true
}, {
title: 'Deployer',
value: deployer,
short: true
}, {
title: 'Time',
value: elapsed_time,
short: true
}],
fallback: super[:text]
}],
text: "<!here> Application Deployed!"
}
end
# Default reverted message. Alternatively simply do not redefine this
# method.
def payload_for_reverted
super
end
# Slightly tweaked failed message.
# See https://api.slack.com/docs/message-formatting
def payload_for_failed
payload = super
payload[:text] = "OMG :fire: #{payload[:text]}"
payload
end
# Override the deployer helper to pull the best name available (git, password file, env vars).
# See https://github.com/phallstrom/slackistrano/blob/master/lib/slackistrano/messaging/helpers.rb
def deployer
name = `git config user.name`.strip
name = nil if name.empty?
name ||= Etc.getpwnam(ENV['USER']).gecos || ENV['USER'] || ENV['USERNAME']
name
end
end
end
end
The output would look like this:
To set this up:
Add the above class to your app, for example lib/custom_messaging.rb
.
Require the library after the requiring of Slackistrano in your application's Capfile.
require_relative 'lib/custom_messaging'
Update the slackistrano
configuration in config/deploy.rb
and add the klass
option.
set :slackistrano, {
klass: Slackistrano::CustomMessaging,
channel: '#your-channel',
webhook: 'your-incoming-webhook-url'
}
If you come up with something that you think others would enjoy submit it as
an issue along with a screenshot of the output from cap production slack:deploy:test
and I'll add it to the Wiki.
You can disable deployment notifications to a specific stage by setting the :slackistrano
configuration variable to false
instead of actual settings.
set :slackistrano, false
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that slackistrano demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.