Module: Metasploit::Framework::Version

Defined in:
lib/metasploit/framework/version.rb

Constant Summary collapse

VERSION =
"6.2.7"
PRERELEASE =
'dev'
HASH =
get_hash

Class Method Summary collapse

Class Method Details

.get_hashString

Determines the git hash for this source tree

Returns:

  • (String)

    the git hash for this source tree


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/metasploit/framework/version.rb', line 10

def self.get_hash
  @@git_hash ||= begin
    root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
    version_yml = File.join(root, 'version.yml')
    hash = ''

    if File.exist?(version_yml)
      version_info = YAML.load_file(version_yml)
      hash = '-' + version_info['build_framework_rev']
    else
      # determine if git is installed
      null = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL' : '/dev/null'
      git_installed = system("git --version > #{null} 2>&1")

      # get the hash of the HEAD commit
      if git_installed && File.exist?(File.join(root, '.git'))
        hash = '-' + `git rev-parse --short HEAD`
      end
    end
    hash.strip
  end
end