Class: Tigre::Url
- Inherits:
-
Object
- Object
- Tigre::Url
- Extended by:
- AnalysisComponents, CommonGetters, CommonParams, TagComponents
- Defined in:
- lib/tigre-client/url.rb
Class Method Summary collapse
-
.add_tags(sha256, tags) ⇒ Object
required sha256 => String tags => String => I.E ‘foo’ tags => String (comma seperated) => I.E ‘foo,bar,baz’ tags => Array => [‘foo’, ‘bar’, ‘baz’].
-
.daterange(options = {}) ⇒ Object
DEPRECATED => use Tigre::Url.index(options).
-
.domains(domain, options = {}) ⇒ Object
required params domain => String optional params options => Hash :after => Ruby DateTime object OR Integer (epoch time) :before => Ruby DateTime object OR Integer (epoch time) :page => Integer, :default => 0 :per => Integer, :default => 50.
-
.get(hash) ⇒ Object
required params sha256 => String ** DEPRECATED ** => use get(:digest => ‘sha256’, :value => ‘your-sha256’) hash => Hash :digest => String, The digest type :value => String, The digest value.
-
.get_md5(md5) ⇒ Object
DEPRECATED => use Tigre::Url.get(:digest => ‘md5’, :value => ‘your-md5’).
-
.post(url, options = {}) ⇒ Object
required params url => String options => Hash :source_name => String optional params options => Hash :shareable => Boolean, :default => false :tags => String => I.E ‘foo’ :tags => String (comma seperated) => I.E ‘foo,bar,baz’ :tags => Array => [‘foo’, ‘bar’, ‘baz’].
-
.post_many(urls = []) ⇒ Object
required params urls => Array of hashes => url, :source => source, :shareable => shareable.
-
.update(sha256, params_hash) ⇒ Object
required sha256 => String params_hash => Hash.
Methods included from CommonParams
before_after, before_after_page_per, common_params, get_klass, get_logic_param, package_array_list, page_per
Methods included from CommonGetters
count, exploit_feed, index, latest_analyses, latest_analysis
Methods included from TagComponents
not_tagged, not_tagged_with, remove_tags, tagged_count, tagged_with
Methods included from AnalysisComponents
Class Method Details
.add_tags(sha256, tags) ⇒ Object
required
sha256 => String
tags => String => I.E 'foo'
tags => String (comma seperated) => I.E 'foo,bar,baz'
tags => Array => ['foo', 'bar', 'baz']
64 65 66 67 68 69 70 71 72 |
# File 'lib/tigre-client/url.rb', line 64 def self.(sha256, ) if sha256 == '' || == '' raise ArguementError, "Missing tags parameter" end update_data = {"tag_list" => package_array_list()} Tigre.put_connection("/urls/#{sha256}/add_tags", update_data) end |
.daterange(options = {}) ⇒ Object
DEPRECATED => use Tigre::Url.index(options)
required params
options => Hash
:after => Ruby DateTime object OR Integer (epoch time)
:before => Ruby DateTime object OR Integer (epoch time)
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/tigre-client/url.rb', line 110 def self.daterange(={}) # if options.nil? || (options[:after].nil? && options[:before].nil?) # raise ArguementError, "Missing proper parameters (:start_date or :end_date required)" # end Tigre.logger.warn "** DEPRECATED ** Use Tigre::Url.index(options) " if Tigre.logger self.index() # common_params(options) # # Tigre.get_connection("/urls/daterange?after=#{@after}&before=#{@before}&page=#{@page}&per=#{@per}") end |
.domains(domain, options = {}) ⇒ Object
required params
domain => String
optional params
options => Hash
:after => Ruby DateTime object OR Integer (epoch time)
:before => Ruby DateTime object OR Integer (epoch time)
:page => Integer, :default => 0
:per => Integer, :default => 50
130 131 132 133 134 135 |
# File 'lib/tigre-client/url.rb', line 130 def self.domains(domain, ={}) raise ArguementError, "Missing domain parameter" if domain == '' common_params() Tigre.get_connection("/urls/domains?domain=#{domain}&#{before_after_page_per}") end |
.get(hash) ⇒ Object
required params
sha256 => String ** DEPRECATED ** => use get(:digest => 'sha256', :value => 'your-sha256')
hash => Hash
:digest => String, The digest type
:value => String, The digest value
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/tigre-client/url.rb', line 79 def self.get(hash) if hash.is_a?(String) Tigre.logger.warn "** DEPRECATED PARAMETER ** Use get(:digest => 'sha256', :value => 'your-sha256')" if Tigre.logger hash = {:digest => 'sha256', :value => hash} end unless hash[:digest] && hash[:value] raise 'Missing parameter :digest or :value' end Tigre.get_connection("/urls/#{hash[:digest]}/value/#{hash[:value]}") end |
.get_md5(md5) ⇒ Object
DEPRECATED => use Tigre::Url.get(:digest => ‘md5’, :value => ‘your-md5’)
required params
md5 => String
97 98 99 100 101 |
# File 'lib/tigre-client/url.rb', line 97 def self.get_md5(md5) raise ArguementError, "Missing md5 parameter" if md5 == '' Tigre.logger.warn "** DEPRECATED ** Use Tigre::Url.get(:digest => 'md5', :value => 'your-md5')" if Tigre.logger self.get(:digest => 'md5', :value => md5) end |
.post(url, options = {}) ⇒ Object
required params
url => String
=> Hash
:source_name => String
optional params
options => Hash
:shareable => Boolean, :default => false
:tags => String => I.E 'foo'
:tags => String (comma seperated) => I.E 'foo,bar,baz'
:tags => Array => ['foo', 'bar', 'baz']
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tigre-client/url.rb', line 19 def self.post(url, ={}) raise "Missing url parameter" if url == '' raise "Missing source_name parameter" unless [:source_name] # prepare post data post_data = { "url[original_url]" => url, "url[source_name]" => [:source_name], "url[shareable]" => [:shareable], } post_data["url[tags]"] = package_array_list([:tags]) if [:tags] Tigre.post_connection('/urls', post_data) end |
.post_many(urls = []) ⇒ Object
required params
urls => Array of hashes {:original_url => url, :source => source, :shareable => shareable}
37 38 39 40 41 42 43 44 45 |
# File 'lib/tigre-client/url.rb', line 37 def self.post_many(urls=[]) raise "Missing URLS parameter" if urls == [] raise 'Too many!! Limit urls to 100 plesae!' if urls.size > 100 Tigre.logger.warn "im in yer logger" if Tigre.logger post_data = {:urls => urls} Tigre.post_connection('/urls/batch', post_data) end |
.update(sha256, params_hash) ⇒ Object
required
sha256 => String
params_hash => Hash
50 51 52 53 54 55 56 57 |
# File 'lib/tigre-client/url.rb', line 50 def self.update(sha256, params_hash) if sha256 == '' || params_hash.empty? raise "Missing url parameter or params_hash is empty" end update_data = params_hash.map { |k, v| {"url[#{k.to_s}]" => v.to_s} } Tigre.put_connection("/urls/#{sha256}", update_data ) end |