Module: Metasploit::Framework::Version

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

Constant Summary collapse

VERSION =
"6.4.14"
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



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

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
      # Fallback to using Git version detection if version_yml not present
      changed_files = %w[git rev-parse --short HEAD]
      begin
        # stderr may contain Git warnings that we can ignore
        output, _stderr, status = ::Open3.capture3(*changed_files, chdir: root)
        hash = "-#{output}" if status.success?
      rescue => e
        elog(e) if defined?(elog)
      end
    end
    hash.strip
  end
end