Class: Mihari::Analyzers::Urlscan
- Defined in:
- lib/mihari/analyzers/urlscan.rb
Constant Summary collapse
- SUPPORTED_DATA_TYPES =
%w[url domain ip].freeze
- SIZE =
1000
Constants included from Mixins::Retriable
Instance Attribute Summary collapse
- #api_key ⇒ String? readonly
Attributes inherited from Base
#ignore_old_artifacts, #ignore_threshold
Instance Method Summary collapse
- #artifacts ⇒ Object
-
#initialize(*args, **kwargs) ⇒ Urlscan
constructor
A new instance of Urlscan.
Methods inherited from Base
#description, inherited, #normalized_artifacts, #run, #run_emitter, #source, #tags, #title
Methods included from Mixins::Retriable
Methods included from Mixins::Database
Methods included from Mixins::Configurable
#configuration_values, #configured?
Methods included from Mixins::AutonomousSystem
Constructor Details
#initialize(*args, **kwargs) ⇒ Urlscan
Returns a new instance of Urlscan.
20 21 22 23 24 25 26 |
# File 'lib/mihari/analyzers/urlscan.rb', line 20 def initialize(*args, **kwargs) super raise InvalidInputError, "allowed_data_types should be any of url, domain and ip." unless valid_alllowed_data_types? @api_key = kwargs[:api_key] || Mihari.config.urlscan_api_key end |
Instance Attribute Details
#api_key ⇒ String? (readonly)
18 19 20 |
# File 'lib/mihari/analyzers/urlscan.rb', line 18 def api_key @api_key end |
Instance Method Details
#artifacts ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mihari/analyzers/urlscan.rb', line 28 def artifacts responses = search results = responses.map(&:results).flatten allowed_data_types.map do |type| results.filter_map do |result| page = result.page data = page.send(type.to_sym) data.nil? ? nil : Artifact.new(data: data, source: source, metadata: result) end end.flatten end |