
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
Brings the API of Ruby's Array#sample to Mongoid collections
Add this line to your application's Gemfile:
gem 'mongoid-sample'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mongoid-sample
And require:
require 'mongoid/sample'
require 'mongoid/sample'
class MyModel
include Mongoid::Document
field :name
end
puts MyModel.sample.inspect # => nil
5.times { MyModel.create(name: 'Foo') }
puts MyModel.sample.inspect # => #<MyModel _id: 57954c1002182308d7000000, name: "Foo">
require 'mongoid/sample'
class MyModel
include Mongoid::Document
field :name
end
puts MyModel.sample(3).inspect # => []
5.times { MyModel.create(name: 'Foo') }
puts MyModel.sample(3).inspect # => [#<MyModel _id: 57954c6f02182308d7000008, name: "Foo">, #<MyModel _id: 57954c6f02182308d700000a, name: "Foo">, #<MyModel _id: 57954c6f02182308d7000009, name: "Foo">]
require 'mongoid/sample'
class MyModel
include Mongoid::Document
field :name
end
puts MyModel.where(name: 'Foo').sample(3).inspect # => []
5.times { MyModel.create(name: 'Foo') }
5.times { MyModel.create(name: 'Bar') }
puts MyModel.sample(3).inspect # => [#<MyModel _id: 57954c6f02182308d7000007, name: "Foo">, #<MyModel _id: 57954c6f02182308d7000008, name: "Foo">, #<MyModel _id: 57954ca702182308d700000e, name: "Bar">]
puts MyModel.where(name: 'Foo').sample(3).inspect # => [#<MyModel _id: 57954c6f02182308d7000008, name: "Foo">, #<MyModel _id: 57954c6f02182308d7000009, name: "Foo">, #<MyModel _id: 57954c6f02182308d7000006, name: "Foo">]
FAQs
Unknown package
We found that mongoid-sample 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.