
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
Pull properly-casted documents from a CouchDB/CouchBase database, directly from CouchRest queries. Uses CouchRest::Model as a modelling framework.
(depends on couchrest
and couchrest_model
gems)
$ gem install couchrest_casted
Bundler users can add this line to their Gemfile:
gem 'couchrest_casted'
The following is a simple example of using a CouchDB view to load documents of different CouchRest::Model classes, casted automatically:
require 'rubygems'
require 'couchrest_casted'
# connect to the CouchDB server
cr = CouchRest.new('http://localhost:5984')
DB = cr.database('casted_test')
# create the database
DB.recreate!
# define a couple of similar document models
class Service < CouchRest::Model::Base
use_database DB
property :name
end
class Person < CouchRest::Model::Base
use_database DB
property :name
end
# create some documents (services and users)
['Socialiting', 'Window Washing',
'Keynoting', 'Table Architecture'].each do |name|
Service.new(:name => name).save!
end
['Zark Muckerberg', 'Gill Bates',
'Jeve Stobs', 'Ellarry Lison'].each do |name|
Person.new(:name => name).save!
end
# a simple view that splits the 'name' field
# into words and emits one row per word
DB.save_doc({
"_id" => "_design/generic",
:views => {
:by_word => {
:map => <<-JS
function(doc) {
if (doc.name && doc.name.length > 0) {
var words = doc.name.split(/\\W/);
words.forEach(function(word){
if (word.length > 0) emit(word, 1);
});
}
}
JS
} } })
# query the generic view
rows = DB.casted_view('generic/by_word')['rows']
# each returned document should be casted as the
# correct CouchRest::Model class
rows.each do |row|
doc = row['doc']
key = row['key']
value = row['value']
puts [doc.id, doc.class.to_s, doc.name, key, value].join(', ')
end
Bugs, suggestions, and such can be posted to https://github.com/m104/couchrest_casted/issues.
FAQs
Unknown package
We found that couchrest_casted 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.