Class: WpItems

Inherits:
Array show all
Extended by:
Detectable
Includes:
Output
Defined in:
lib/common/collections/wp_items.rb,
lib/common/collections/wp_items/output.rb,
lib/common/collections/wp_items/detectable.rb

Direct Known Subclasses

WpPlugins, WpThemes, WpTimthumbs, WpUsers

Defined Under Namespace

Modules: Detectable, Output

Instance Attribute Summary (collapse)

Attributes included from Detectable

#item_xpath, #vulns_file

Instance Method Summary (collapse)

Methods included from Detectable

aggressive_detection, item_options, passive_detection, progress_bar, request_params, targets_items, targets_items_from_file, vulnerable_targets_items

Methods included from Output

#output

Methods inherited from Array

#_grep_

Constructor Details

- (WpItems) initialize(wp_target = nil)

A new instance of WpItems

Parameters:

  • wp_target (WpTarget) (defaults to: nil)


13
14
15
# File 'lib/common/collections/wp_items.rb', line 13

def initialize(wp_target = nil)
  self.wp_target = wp_target
end

Instance Attribute Details

- (Object) wp_target

Returns the value of attribute wp_target



10
11
12
# File 'lib/common/collections/wp_items.rb', line 10

def wp_target
  @wp_target
end

Instance Method Details

- (self) +(other)

Parameters:

Returns:

  • (self)


64
65
66
67
# File 'lib/common/collections/wp_items.rb', line 64

def +(other)
  other.each { |item| self << item }
  self
end

- (void) add(*args)

This method returns an undefined value.

Parameters:

  • argv (String, )


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/common/collections/wp_items.rb', line 20

def add(*args)
  index = 0

  until args[index].nil?
    arg = args[index]

    if arg.is_a?(String)
      if (next_arg = args[index + 1]).is_a?(Hash)
        item = create_item(arg, next_arg)
        index += 1
      else
        item = create_item(arg)
      end
    elsif arg.is_a?(Item)
      item = arg
    else
      raise 'Invalid arguments'
    end

    self << item
    index += 1
  end
end

- (WpItem) create_item(name, attrs = {})

Parameters:

  • name (String)
  • attrs (Hash) (defaults to: {})

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/common/collections/wp_items.rb', line 48

def create_item(name, attrs = {})
  raise 'wp_target must be set' unless wp_target

  item_class.new(
    wp_target.uri,
    attrs.merge(
      name: name,
      wp_content_dir: wp_target.wp_content_dir,
      wp_plugins_dir: wp_target.wp_plugins_dir
    ) { |key, oldval, newval| oldval }
  )
end

- (Class) item_class (protected)

Returns:

  • (Class)


71
72
73
# File 'lib/common/collections/wp_items.rb', line 71

def item_class
  Object.const_get(self.class.to_s.gsub(/.$/, ''))
end