CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/metasploit/framework/version.rb
Views: 1904
1
require 'rbconfig'
2
require 'yaml'
3
require 'open3'
4
5
module Metasploit
6
module Framework
7
module Version
8
# Determines the git hash for this source tree
9
#
10
# @return [String] the git hash for this source tree
11
def self.get_hash
12
@@git_hash ||= begin
13
root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
14
version_yml = File.join(root, 'version.yml')
15
hash = ''
16
17
if File.exist?(version_yml)
18
version_info = YAML.load_file(version_yml)
19
hash = '-' + version_info['build_framework_rev']
20
else
21
# Fallback to using Git version detection if version_yml not present
22
changed_files = %w[git rev-parse --short HEAD]
23
begin
24
# stderr may contain Git warnings that we can ignore
25
output, _stderr, status = ::Open3.capture3(*changed_files, chdir: root)
26
hash = "-#{output}" if status.success?
27
rescue => e
28
elog(e) if defined?(elog)
29
end
30
end
31
hash.strip
32
end
33
end
34
35
VERSION = "6.4.28"
36
MAJOR, MINOR, PATCH = VERSION.split('.').map { |x| x.to_i }
37
PRERELEASE = 'dev'
38
HASH = get_hash
39
end
40
41
VERSION = "#{Version::VERSION}-#{Version::PRERELEASE}#{Version::HASH}"
42
GEM_VERSION = "#{Version::VERSION}"
43
end
44
end
45
46