Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A concise, fast ElasticSearch Ruby client designed to reflect the actual elastic search API as closely as possible. Elastic search's API is complex, and mostly documented on the Elastic Search Guide. This client tries to stay out of your way more than others making advanced techniques easier to implement, and making debugging Elastic Search's sometimes cryptic errors easier. Stretcher is currently in production use by Pose, Get Satisfaction, Reverb, and many others.
Add this line to your application's Gemfile:
gem 'stretcher'
Stretcher Strives to provide adequate documentation for all methods. Many methods not described in the 'Getting Started' section can be found in the full rdocs.
# First Create a server
server = Stretcher::Server.new('http://localhost:9200')
# Delete an index (in case you already have this one)
server.index(:foo).delete rescue nil
# Create an index
server.index(:foo).create(mappings: {tweet: {properties: {text: {type: 'string'}}}})
# Add some documents
30.times {|t| server.index(:foo).type(:tweet).put(t, {text: "Hello #{t}"}) }
# Retrieve a document
server.index(:foo).type(:tweet).get(3)
# => #<Hashie::Mash text="Hello 3">
# Perform a search (Returns a Stretcher::SearchResults instance)
res = server.index(:foo).search(size: 12, query: {match_all: {}})
res.class # Stretcher::SearchResults
res.total # => 30
res.documents # => [#<Hashie::Mash _id="4" text="Hello 4">, ...]
res.facets # => nil
res.raw # => #<Hashie::Mash ...> Raw JSON from the search
res.raw_plain # => #<Hash ...> Non-Hashie Raw JSON from the search (fastest)
# use an alias
alias = server.index(:foo).alias(:my_alias)
alias.create({ filter: { term: { user_id: 1 } } })
alias.index_context.search({ query: { match_all: {} } })
# or get some cluster health information
server.cluster.health # Hashie::Mash
# A nested block syntax is also supported.
# with_server takes the same args as #new, but is amenable to blocks
Stretcher::Server.with_server('http://localhost:9200') {|srv|
srv.index(:foo) {|idx|
idx.type(:tweet) {|t| {exists: t.exists?, mapping: t.get_mapping} }
}
}
# => {:exists=>true, :mapping=>#<Hashie::Mash tweet=...>}
# Within a single index
server.index(:foo).msearch([{query: {match_all: {}}}])
# => Returns an array of Stretcher::SearchResults
# Across multiple indexes
server.msearch([{index: :foo}, {query: {match_all: {}}}])
# => Returns an array of Stretcher::SearchResults
docs = [{"_type" => "tweet", "_id" => 91011, "text" => "Bulked"}]
server.index(:foo).bulk_index(docs)
Implements the ElasticSearch Percolate API
# Register a new percolate query
server.index(:foo).register_percolator_query(query_name, query_hash)
# Check a document against an index, returns an array of query matches
server.index(:foo).type(:foo1).percolate(doc)
# Delete a percolate query
server.index(:foo).delete_percolator_query(query_name)
Pass in the :log_level
parameter to set logging verbosity. cURL statements are surfaced at the :debug
log level. For instance:
Stretcher::Server.new('http://localhost:9200', :log_level => :debug)
You can also pass any Logger style object with the :logger
option. For instance:
Stretcher::Server.new('http://localhost:9200', :logger => Rails.logger)
Stretcher is a low level-client, but it was built as a part of a full suite of Rails integration tools. While not yet open-sourced, you can read our detailed blog post: integrating Stretcher with Rails.
Running the specs requires an operational Elastic Search server on http://localhost:9200. The test suite is not to be trusted, don't count on your indexes staying around!
Specs may be run with rake spec
Email or tweet @andrewvc if you'd like to be added to this list!
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that stretcher 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.