From 8ab41013d17b03f8adf15da983b03cc98760d80a Mon Sep 17 00:00:00 2001 From: Tod Beardsley Date: Tue, 22 Nov 2011 18:08:27 -0600 Subject: [PATCH] Updating the version information to check the SVN metadata first. --- lib/msf/core/module.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/msf/core/module.rb b/lib/msf/core/module.rb index 463f557a01..13aa88e9ea 100644 --- a/lib/msf/core/module.rb +++ b/lib/msf/core/module.rb @@ -339,14 +339,28 @@ class Module end # - # Return the module's version information. + # Return the module's legacy version information. # - def version + def legacy_version module_info['Version'].split(/,/).map { |ver| ver.gsub(/\$Rev.s.on:\s+|\s+\$$/, '') }.join(',') end + # + # Calculate the version information using SVN's all-wcprops entries file. + # If it's not present (always get case for github checkouts), fall back to the + # old in-module method instead. TODO: Completely deprecate in-module versions. + # + def version + svn_all_wcprops = ::File.join(::File.split(self.file_path).first,".svn","all-wcprops") + return legacy_version unless ::File.readable?(svn_all_wcprops) + mod_pathname = refname + ".rb" + prop_info = ::File.readlines(svn_all_wcprops,"rb").select {|line| line =~ /#{mod_pathname}$/}.first + prop_version = prop_info.match(/!svn[\x5c\x2f]ver[\x5c\x2f]([0-9]+)/) + (prop_version and prop_version[1]) ? prop_version[1] : legacy_version + end + # # Returns the disclosure date, if known. #