
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
This gem provides two new minitest assertions, assert_mail
and
refute_mail
for easily testing whether a specific email has been
sent by your application.
Add this line to your application's Gemfile:
gem 'mail_assertions'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mail_assertions
You need to include the module MailAssertions
in
ActiveSupport::TestCase
.
Also, you almost certainly want to empty the deliveries list between every test (otherwise it's hard to know which emails came from this test).
Therefore, in your test_helper.rb
:
class ActiveSupport::TestCase
include MailAssertions
def setup
ActionMailer::Base.deliveries.clear
end
end
assert_mail(conditions, &block)
Conditions is a hash of attributes on the message object and the value you're looking for.
# Fails unless there was exactly email sent with the subject
# Hello World
assert_mail subject: 'Hello World'
You can also specify several conditions, in which case all must apply for the email to match:
# Fails unless there was exactly one email with the subject Hello World
# sent to hello@example.com.
assert_mail subject: 'Hello World', to: ['hello@example.com']
Optionally, the values may be regular expressions in which case the email's value will need to match it
# Fails unless there was exactly one email with a subject starting
# with an A
assert_mail subject: /^A/
The optional block is invoked with the matching mail
assert_mail subject: 'Hello World' do |mail|
# Further assertions about the email here
end
As a convenience, if the block accepts two arguments, the second
will be the HTML body of the email (mail.html_part.body.to_s
)
assert_mail subject: 'Hello World' do |mail, html|
# Further assertions about the email or its html here
end
refute_mail(conditions)
Works similarly to assert_mail
but fails unless no emails matching
the conditions have been sent.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/hult/mail_assertions.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that mail_assertions 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.