Class: WpItem

Inherits:
Object
  • Object
show all
Extended by:
Findable
Includes:
Existable, Infos, Output, Versionable, Vulnerable
Defined in:
lib/common/models/wp_item.rb,
lib/common/models/wp_item/infos.rb,
lib/common/models/wp_item/output.rb,
lib/common/models/wp_item/findable.rb,
lib/common/models/wp_item/existable.rb,
lib/common/models/wp_item/vulnerable.rb,
lib/common/models/wp_item/versionable.rb

Direct Known Subclasses

WpPlugin, WpTheme, WpTimthumb, WpUser, WpVersion

Defined Under Namespace

Modules: Existable, Findable, Infos, Output, Versionable, Vulnerable

Instance Attribute Summary (collapse)

Attributes included from Vulnerable

#vulns_file, #vulns_xpath

Instance Method Summary (collapse)

Methods included from Output

#output

Methods included from Infos

#changelog_url, #error_log_url, #has_changelog?, #has_directory_listing?, #has_error_log?, #has_readme?, #readme_url, #url_is_200?

Methods included from Existable

#exists?, #exists_from_response?

Methods included from Vulnerable

#vulnerabilities

Methods included from Versionable

#to_s, #version

Constructor Details

- (WpItem) initialize(target_base_uri, options = {})

Parameters:

  • target_base_uri (URI)
  • options (Hash) (defaults to: {})

    See allowed_option



32
33
34
35
36
37
38
39
# File 'lib/common/models/wp_item.rb', line 32

def initialize(target_base_uri, options = {})

  options[:wp_content_dir] ||= 'wp-content'
  options[:wp_plugins_dir] ||= options[:wp_content_dir] + '/plugins'

  set_options(options)
  forge_uri(target_base_uri)
end

Instance Attribute Details

- (Object) found_from

Returns the value of attribute found_from



4
5
6
# File 'lib/common/models/wp_item/findable.rb', line 4

def found_from
  @found_from
end

- (Object) name

Returns the value of attribute name



20
21
22
# File 'lib/common/models/wp_item.rb', line 20

def name
  @name
end

- (Object) path

Returns the value of attribute path



19
20
21
# File 'lib/common/models/wp_item.rb', line 19

def path
  @path
end

- (Object) version=(value) (writeonly)

Sets the attribute version

Parameters:

  • value

    the value to set the attribute version to.



4
5
6
# File 'lib/common/models/wp_item/versionable.rb', line 4

def version=(value)
  @version = value
end

- (Object) wp_content_dir

Returns the value of attribute wp_content_dir



20
21
22
# File 'lib/common/models/wp_item.rb', line 20

def wp_content_dir
  @wp_content_dir
end

- (Object) wp_plugins_dir

Returns the value of attribute wp_plugins_dir



20
21
22
# File 'lib/common/models/wp_item.rb', line 20

def wp_plugins_dir
  @wp_plugins_dir
end

Instance Method Details

- (Object) <=>(other)

Parameters:



89
90
91
# File 'lib/common/models/wp_item.rb', line 89

def <=>(other)
  name <=> other.name
end

- (Object) ==(other)

Parameters:



94
95
96
# File 'lib/common/models/wp_item.rb', line 94

def ==(other)
  name === other.name
end

- (Object) ===(other)

Parameters:



99
100
101
# File 'lib/common/models/wp_item.rb', line 99

def ===(other)
  self == other && version === other.version
end

- (Array) allowed_options

Make it private ?

Returns:



24
25
26
# File 'lib/common/models/wp_item.rb', line 24

def allowed_options
  [:name, :wp_content_dir, :wp_plugins_dir, :path, :version, :vulns_file]
end

- (void) forge_uri(target_base_uri)

This method returns an undefined value.

Parameters:

  • target_base_uri (URI)


62
63
64
# File 'lib/common/models/wp_item.rb', line 62

def forge_uri(target_base_uri)
  @uri = target_base_uri
end

- (void) set_options(options) (private)

This method returns an undefined value.

Parameters:

  • options (Hash)


44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/common/models/wp_item.rb', line 44

def set_options(options)
  allowed_options.each do |allowed_option|
    if options.has_key?(allowed_option)
      method = :#{allowed_option}="

      if self.respond_to?(method)
        self.send(method, options[allowed_option])
      else
        raise "#{self.class} does not respond to #{method}"
      end
    end
  end
end

- (URI) uri

The uri to the WpItem, with the path if present

Returns:

  • (URI)

    The uri to the WpItem, with the path if present



67
68
69
# File 'lib/common/models/wp_item.rb', line 67

def uri
  path ? @uri.merge(path) : @uri
end

- (String) url

The url to the WpItem

Returns:

  • (String)

    The url to the WpItem



72
# File 'lib/common/models/wp_item.rb', line 72

def url; uri.to_s end