diff --git a/lib/common/models/wp_version.rb b/lib/common/models/wp_version.rb index ca88db7d..65bde522 100755 --- a/lib/common/models/wp_version.rb +++ b/lib/common/models/wp_version.rb @@ -10,23 +10,9 @@ class WpVersion < WpItem include WpVersion::Vulnerable include WpVersion::Output - @@version_xml = WP_VERSIONS_FILE - # The version number attr_accessor :number def allowed_options; super << :number << :found_from end - def self.version_xml - @@version_xml - end - - def self.version_xml=(xml) - if File.exists?(xml) - @@version_xml = xml - else - raise "The file #{xml} does not exist" - end - end - end diff --git a/lib/common/models/wp_version/findable.rb b/lib/common/models/wp_version/findable.rb index eb9b884f..7853d37f 100755 --- a/lib/common/models/wp_version/findable.rb +++ b/lib/common/models/wp_version/findable.rb @@ -1,7 +1,21 @@ # encoding: UTF-8 class WpVersion < WpItem + module Findable + @@version_xml = WP_VERSIONS_FILE + + def version_xml + @@version_xml + end + + def version_xml=(xml) + if File.exists?(xml) + @@version_xml = xml + else + raise "The file #{xml} does not exist" + end + end # Find the version of the wp_target blog # returns a WpVersion object or nil @@ -16,6 +30,7 @@ class WpVersion < WpItem # Returns the first match of in the body of the url def scan_url(target_uri, pattern, path = nil) + return nil url = path ? target_uri.merge(path).to_s : target_uri.to_s response = Browser.instance.get_and_follow_location(url) diff --git a/spec/lib/common/models/wp_version_spec.rb b/spec/lib/common/models/wp_version_spec.rb new file mode 100644 index 00000000..96fb3666 --- /dev/null +++ b/spec/lib/common/models/wp_version_spec.rb @@ -0,0 +1,16 @@ +# encoding: UTF-8 + +require 'spec_helper' + +describe WpVersion do + subject(:wp_version) { WpVersion.new(uri, options) } + let(:uri) { URI.parse('http://example.com') } + let(:options) { {} } + + describe '#allowed_options' do + [:number, :found_from].each do |sym| + its(:allowed_options) { should include sym } + end + end + +end