Better version output #862
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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?
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user