diff --git a/lib/common/models/wp_item/infos.rb b/lib/common/models/wp_item/infos.rb index 1724b695..df9b92b2 100644 --- a/lib/common/models/wp_item/infos.rb +++ b/lib/common/models/wp_item/infos.rb @@ -10,6 +10,11 @@ class WpItem !readme_url.nil? end + # @return [ Boolean ] + def outdated?(installed_version, latest_version) + installed_version < latest_version + end + # @return [ String,nil ] The url to the readme file, nil if not found def readme_url # See https://github.com/wpscanteam/wpscan/pull/737#issuecomment-66375445 diff --git a/lib/common/models/wp_item/output.rb b/lib/common/models/wp_item/output.rb index 4d749017..b6cccd8e 100644 --- a/lib/common/models/wp_item/output.rb +++ b/lib/common/models/wp_item/output.rb @@ -7,12 +7,13 @@ class WpItem def output(verbose = false) puts puts info("Name: #{self}") #this will also output the version number if detected - puts " | Latest version: #{latest_version}" if latest_version + puts " | Latest version: #{latest_version} (up to date)" if latest_version && !outdated?(version, latest_version) puts " | Last updated: #{last_updated}" if last_updated puts " | Location: #{url}" - #puts " | WordPress: #{wordpress_url}" if wordpress_org_item? puts " | Readme: #{readme_url}" if has_readme? puts " | Changelog: #{changelog_url}" if has_changelog? + puts warning("The version is out of date, the latest version is #{latest_version}") if latest_version && outdated?(version, latest_version) + puts warning("Directory listing is enabled: #{url}") if has_directory_listing? puts warning("An error_log file has been found: #{error_log_url}") if has_error_log? diff --git a/spec/shared_examples/wp_item_infos.rb b/spec/shared_examples/wp_item_infos.rb index 1be9d8b0..4bf56269 100644 --- a/spec/shared_examples/wp_item_infos.rb +++ b/spec/shared_examples/wp_item_infos.rb @@ -53,6 +53,22 @@ shared_examples 'WpItem::Infos' do end end + describe '#outdated?' do + it 'returns true if outdated' do + latest_version = '1.0' + installed_version = '0.1' + + expect(subject.outdated?(installed_version, latest_version)).to be true + end + + it 'returns false if not outdated' do + latest_version = '1.0' + installed_version = '1.0' + + expect(subject.outdated?(installed_version, latest_version)).to be false + end + end + describe '#has_changelog?' do after :each do stub_request(:get, subject.changelog_url).to_return(status: @status)