From 3d7b8592ea2362e46cdd3d51da9278e3e742a251 Mon Sep 17 00:00:00 2001 From: Francesco Marano Date: Wed, 3 Jun 2015 15:32:34 +0200 Subject: [PATCH 1/5] Defined function to get last db update and removed redundant code --- lib/common/common_helper.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/common/common_helper.rb b/lib/common/common_helper.rb index f20e7665..0330c21b 100644 --- a/lib/common/common_helper.rb +++ b/lib/common/common_helper.rb @@ -79,10 +79,17 @@ def missing_db_file? false end +def last_update + date = nil + if File.exists?(LAST_UPDATE_FILE) + content = File.read(LAST_UPDATE_FILE) + date = Time.parse(content) rescue nil + end + return date +end + def update_required? - return true unless File.exist?(LAST_UPDATE_FILE) - content = File.read(LAST_UPDATE_FILE) - date = Time.parse(content) rescue Time.parse("2000-01-01") + date = last_update() or Time.parse('2000-01-01') return date < 5.days.ago end From 9c5196dfec374f277ae3a61656caf8d52cf58d6f Mon Sep 17 00:00:00 2001 From: Francesco Marano Date: Wed, 3 Jun 2015 15:33:14 +0200 Subject: [PATCH 2/5] Added last db update to --version option (see #815) --- wpscan.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wpscan.rb b/wpscan.rb index 78fc15c5..69fca753 100755 --- a/wpscan.rb +++ b/wpscan.rb @@ -36,6 +36,8 @@ def main if wpscan_options.version puts "Current version: #{WPSCAN_VERSION}" + date = last_update() + puts "Last db update: #{date.strftime('%Y-%m-%d')}" unless date.nil? exit(0) end From b6bf306042ebf32e2135843b817dc3b07a300d4d Mon Sep 17 00:00:00 2001 From: Francesco Marano Date: Wed, 3 Jun 2015 15:43:58 +0200 Subject: [PATCH 3/5] Removed unnecessary 'return' and '()' --- lib/common/common_helper.rb | 6 +++--- wpscan.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/common/common_helper.rb b/lib/common/common_helper.rb index 0330c21b..03c5f7dd 100644 --- a/lib/common/common_helper.rb +++ b/lib/common/common_helper.rb @@ -85,12 +85,12 @@ def last_update content = File.read(LAST_UPDATE_FILE) date = Time.parse(content) rescue nil end - return date + date end def update_required? - date = last_update() or Time.parse('2000-01-01') - return date < 5.days.ago + date = last_update or Time.parse('2000-01-01') + date < 5.days.ago end # Define colors diff --git a/wpscan.rb b/wpscan.rb index 69fca753..b2128676 100755 --- a/wpscan.rb +++ b/wpscan.rb @@ -36,7 +36,7 @@ def main if wpscan_options.version puts "Current version: #{WPSCAN_VERSION}" - date = last_update() + date = last_update puts "Last db update: #{date.strftime('%Y-%m-%d')}" unless date.nil? exit(0) end From ae5bae98993120bf8fb1f8aea11c1c014dd93081 Mon Sep 17 00:00:00 2001 From: Francesco Marano Date: Wed, 3 Jun 2015 15:52:33 +0200 Subject: [PATCH 4/5] Capitalised 'Last db update' in 'Last DB update' --- wpscan.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpscan.rb b/wpscan.rb index b2128676..d5fd6294 100755 --- a/wpscan.rb +++ b/wpscan.rb @@ -37,7 +37,7 @@ def main if wpscan_options.version puts "Current version: #{WPSCAN_VERSION}" date = last_update - puts "Last db update: #{date.strftime('%Y-%m-%d')}" unless date.nil? + puts "Last DB update: #{date.strftime('%Y-%m-%d')}" unless date.nil? exit(0) end From 6c8172c7cf1e1c581e1e19a8ed84d95bcfeaa7eb Mon Sep 17 00:00:00 2001 From: Francesco Marano Date: Wed, 3 Jun 2015 16:03:01 +0200 Subject: [PATCH 5/5] Removed `Time.parse('2000-01-01')` expedient --- lib/common/common_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/common_helper.rb b/lib/common/common_helper.rb index 03c5f7dd..3027d695 100644 --- a/lib/common/common_helper.rb +++ b/lib/common/common_helper.rb @@ -89,8 +89,8 @@ def last_update end def update_required? - date = last_update or Time.parse('2000-01-01') - date < 5.days.ago + date = last_update + (true if date.nil?) or (date < 5.days.ago) end # Define colors