
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
Manage Elasticsearch indices using wither, close, open, delete, snapshot, and restore.
Most of the index actions can be performed by setting an expiry via cutoff days.
The gem may be used within a Rails app or in a Ruby script for cron jobs.
Note: this is inspired by Curator at https://github.com/elasticsearch/curator.git, but if you are an ophidiophobe, no worries, this is written in Ruby :-)
The following actions may be performed on Elasticsearch indices:
Add this line to your application's Gemfile:
gem 'elasticshelf'
And then execute:
$ bundle
Or install it yourself as:
$ gem install elasticshelf
Note: see the examples folder for more command line ruby scripts.
initial setup:
require 'elasticshelf'
es = Elasticshelf::Client.new(:host => '127.0.0.1:9200')
if required be sure to override these defaults:
es.indices_prefix = 'logstash-'
es.date_separator = '.'
Note: an asterisk '*' is appended to indices_prefix.
ensure the cutoff date is as desired:
es.cutoff_days = 30
es.cutoff_days_as_date_to_s
do a "dry run" to see what indices will be affected:
es.find_expired_indices
remove the bloom filter on any indices older than 30 days, but only if they are not closed already:
es.cutoff_days = 30
es.wither_indices
or wither a single index:
es.wither_index("index_name")
close any indices older than 60 days:
es.cutoff_days = 60
es.close_expired_indices
or close a single index:
es.close_index("index_name")
just in case one was closed by mistake
es.open_index("index_name")
delete any indices older than 60 days:
es.cutoff_days = 60
es.delete_expired_indices
or delete a single index:
es.delete_index("index_name")
Notes:
es.repo = 'name_of_the_snapshot_repository'
es.repo_location = '/var/elasticsearch_snapshots' ... or what was prepped by the sysadmin
es.snapshot_create_repository
Note: if es.repo is not set this gets information about all snapshot repositories.
es.snapshot_get_repository
es.repo = 'name_of_the_snapshot_repository'
es.snapshot_delete_repository
take a snapshot of all indices older than 22 days:
es.cutoff_days = 22
es.repo = 'name_of_the_snapshot_repository'
es.snapshot_expired_indices
Note: this snapshot is auto-named like "2014-04-02_15:07:55_utc_logstash-_cutoff_22_days", as there may be many indices within this snapshot. Override this as described below.
override snapshot auto-naming behavior:
es.snapshot_expired_indices_name = "more_desirable_name"
es.cutoff_days = 22
es.repo = 'name_of_the_snapshot_repository'
es.snapshot_expired_indices
es.indices = "index1" ... single
es.indices = "index1,index2" ... multiples
es.repo = 'name_of_the_snapshot_repository'
es.snapshot = 'name_of_the_snapshot'
es.snapshot_expired_indices
Note: if es.snapshot is not set this gets information about all snapshots, i.e. to see all snapshots do es.snapshot=nil.
es.snapshot_get
es.snapshot = 'name_of_the_snapshot'
es.snapshot_delete
es.repo = 'name_of_the_snapshot_repository'
es.snapshot = "name_of_the_snapshot"
- do one of these:
1. es.indices = "" # restores all indices in the snapshot
2. es.indices = "index1,index2" # restore multiple indices
3. es.indices = "index1" # restore a single index
- note: es.snapshot_get can be used to list indices in a snapshot
es.snapshot_restore
puts "errors=#{es.errors.inspect}"
puts "results=#{es.results.inspect}"
es.index_closed?("index_name")
es.get_elasticsearch_version
es.get_lucene_version
es.get_info
es.get_cluster_state("index_name")
es.get_index_state("index_name")
es.version ... of this gem
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that elasticshelf 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.