Module: CMSScanner::Finders::Finder::Enumerator
- Defined in:
- lib/cms_scanner/finders/finder/enumerator.rb
Overview
Module to provide an easy way to enumerate items such as plugins, themes etc
Instance Method Summary collapse
- #browser ⇒ CMSScanner::Browser
- #enumerate(opts = {}) {|Typhoeus::Response, String| ... } ⇒ Object
- #hydra ⇒ Typhoeus::Hydra
-
#progress_bar_title ⇒ String
Progress Bar title to use, allow instance using this module to display a custom title if needed.
- #request_params ⇒ Object
- #target_urls(_opts = {}) ⇒ Hash
Instance Method Details
#browser ⇒ CMSScanner::Browser
49 50 51 |
# File 'lib/cms_scanner/finders/finder/enumerator.rb', line 49 def browser @browser ||= NS::Browser.instance end |
#enumerate(opts = {}) {|Typhoeus::Response, String| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cms_scanner/finders/finder/enumerator.rb', line 11 def enumerate(opts = {}) targets = target_urls(opts) = (targets.size, ) if opts[:show_progression] targets.each do |url, id| request = browser.forge_request(url, request_params) request.on_complete do |res| .progress += 1 if opts[:show_progression] next if target.homepage_or_404?(res) next if opts[:exclude_content] && res.body.match(opts[:exclude_content]) yield res, id end hydra.queue(request) end hydra.run end |
#hydra ⇒ Typhoeus::Hydra
61 62 63 |
# File 'lib/cms_scanner/finders/finder/enumerator.rb', line 61 def hydra @hydra ||= browser.hydra end |
#progress_bar_title ⇒ String
Progress Bar title to use, allow instance using this module to display a custom title if needed
44 45 46 |
# File 'lib/cms_scanner/finders/finder/enumerator.rb', line 44 def ' ' # Used to create a left margin end |
#request_params ⇒ Object
53 54 55 56 57 58 |
# File 'lib/cms_scanner/finders/finder/enumerator.rb', line 53 def request_params # disabling the cache, as it causes a 'stack level too deep' exception # with a large number of requests :/ # See https://github.com/typhoeus/typhoeus/issues/408 { cache_ttl: 0 } end |
#target_urls(_opts = {}) ⇒ Hash
36 37 38 |
# File 'lib/cms_scanner/finders/finder/enumerator.rb', line 36 def target_urls(_opts = {}) fail NotImplementedError end |