
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
rspec-radar
monkey patches rspec-mocks
to prevent the stubbing of methods that don't exist. If you try and stub a method that doesn't exist, an UndefinedMethodError
will be raised.
Step 1. Add the gem to your gemfile.
# Gemfile
gem 'rspec-radar'
Step 2. In the spec_helper.rb
file, require 'rspec/radar'
# spec_helper.rb
require 'rspec/radar'
Now if you call stub
or should_receive
on a class or variable, it will check to see if the method exists and raise an exception if it doesn't.
rspec-radar
monkey patches rspec-mocks
and will raise an excpetion if you stub a method that doesn't exist. Spefically it alters the method visibility
in the class MethodDouble
.
I want to be able to prevent the stubbing of nonexistent methods when using rspec. Currently there is no way to do this with rspec-mocks. There is a popular mocking alternative called rspec-fire; however, rspec-fire isn't what I am after. rspec-fire introduces a different stubbing syntax and doesn't guard against a stub on an instance variable.
I'm more that happy to accept pull-requests. Also, I'm more than happy to receive crticism/suggestions for a better way to make this work.
git clone https://github.com/wusher/rspec-radar.git
bundle install
bundle exec rake spec
The following are features in want to add. (not in any spefic order)
stub(Avocado, fake_method: "boom") # raises undefined method error
)any_instance
( i.e. Avocado.any_instance.stub(:fake_method) # raises undefined method error)
stub!
so it will skip the existance check`FAQs
Unknown package
We found that rspec-radar 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
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.