rspec tests
This commit is contained in:
@@ -16,8 +16,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#++
|
||||
|
||||
require "#{WPSCAN_LIB_DIR}/vulnerable"
|
||||
|
||||
class WpItem < Vulnerable
|
||||
attr_accessor :path, :url, :wp_content_dir, :name
|
||||
attr_accessor :path, :url, :wp_content_dir, :name, :vulns_xml, :vulns_xpath
|
||||
@version = nil
|
||||
|
||||
def initialize(options = {})
|
||||
@@ -25,6 +27,14 @@ class WpItem < Vulnerable
|
||||
@url = options[:url]
|
||||
@path = options[:path]
|
||||
@name = options[:name] || extract_name_from_url
|
||||
@vulns_xml = options[:vulns_xml]
|
||||
@vulns_xpath = options[:vulns_xpath]
|
||||
|
||||
raise("url not set") unless @url
|
||||
raise("path not set") unless @path
|
||||
raise("wp_content_dir not set") unless @wp_content_dir
|
||||
raise("name not set") unless @name
|
||||
raise("vulns_xml not set") unless @vulns_xml
|
||||
end
|
||||
|
||||
# Get the full url for this item
|
||||
|
||||
@@ -16,27 +16,11 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#++
|
||||
|
||||
require "#{WPSCAN_LIB_DIR}/vulnerable"
|
||||
|
||||
class WpPlugin < WpItem
|
||||
|
||||
attr_reader :name
|
||||
|
||||
def initialize(options = {})
|
||||
@url = options[:url]
|
||||
@path = options[:path]
|
||||
@wp_content_dir = options[:wp_content_dir]
|
||||
@vulns_xml = options[:vulns_xml] || DATA_DIR + '/plugin_vulns.xml'
|
||||
@vulns_xpath = "//plugin[@name='#@name']/vulnerability"
|
||||
@version = nil
|
||||
|
||||
raise("url not set") unless @url
|
||||
raise("path not set") unless @path
|
||||
raise("wp_content_dir not set") unless @wp_content_dir
|
||||
raise("name not set") unless @name
|
||||
raise("vulns_xml not set") unless @vulns_xml
|
||||
|
||||
super(:wp_content_dir => @wp_content_dir, :url => @url, :path => @path)
|
||||
options[:vulns_xml] = options[:vulns_xml] || DATA_DIR + '/plugin_vulns.xml'
|
||||
options[:vulns_xpath] = "//plugin[@name='#@name']/vulnerability"
|
||||
super(options)
|
||||
end
|
||||
|
||||
# Discover any error_log files created by WordPress
|
||||
|
||||
@@ -23,22 +23,11 @@ class WpTheme < WpItem
|
||||
attr_reader :name, :style_url, :version
|
||||
|
||||
def initialize(options = {})
|
||||
@url = options[:url]
|
||||
@path = options[:path]
|
||||
@wp_content_dir = options[:wp_content_dir]
|
||||
@vulns_xml = options[:vulns_xml] || DATA_DIR + '/wp_theme_vulns.xml'
|
||||
@vulns_xpath = "//theme[@name='#{@name}']/vulnerability"
|
||||
|
||||
@version = options[:version]
|
||||
@style_url = options[:style_url]
|
||||
|
||||
raise("url not set") unless @url
|
||||
raise("path not set") unless @path
|
||||
raise("wp_content_dir not set") unless @wp_content_dir
|
||||
raise("name not set") unless @name
|
||||
raise("vulns_xml not set") unless @vulns_xml
|
||||
|
||||
super(:wp_content_dir => @wp_content_dir, :url => @url, :path => @path)
|
||||
options[:vulns_xml] = options[:vulns_xml] || DATA_DIR + '/wp_theme_vulns.xml'
|
||||
options[:vulns_xpath] = "//theme[@name='#{@name}']/vulnerability"
|
||||
@version = options[:version]
|
||||
@style_url = options[:style_url]
|
||||
super(options)
|
||||
end
|
||||
|
||||
def version
|
||||
@@ -59,11 +48,6 @@ class WpTheme < WpItem
|
||||
nil
|
||||
end
|
||||
|
||||
def to_s
|
||||
version = version()
|
||||
"#{@name}#{' v' + version if version}"
|
||||
end
|
||||
|
||||
def ===(wp_theme)
|
||||
wp_theme.name === @name and wp_theme.version === @version
|
||||
end
|
||||
@@ -105,5 +89,4 @@ class WpTheme < WpItem
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user