Skip to content

Commit 95e6599

Browse files
committed
Merge branch 'staging/electro-release' of github.com:rapid7/metasploit-framework into staging/electro-release
2 parents c457285 + d696b5f commit 95e6599

File tree

8 files changed

+67
-23
lines changed

8 files changed

+67
-23
lines changed

lib/metasploit/framework/api.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Metasploit
2+
module Framework
3+
module API
4+
5+
end
6+
end
7+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Metasploit
2+
module Framework
3+
module API
4+
# @note This is a like. The API version is not semantically version and it's version has actually never changed
5+
# even though API changes have occured. DO NOT base compatibility on this version.
6+
module Version
7+
MAJOR = 1
8+
MINOR = 0
9+
PATCH = 0
10+
end
11+
12+
VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::PATCH}"
13+
GEM_VERSION = Gem::Version.new(VERSION)
14+
end
15+
end
16+
end

lib/metasploit/framework/core.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Metasploit
2+
module Framework
3+
module Core
4+
5+
end
6+
end
7+
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'metasploit/framework/version'
2+
3+
module Metasploit
4+
module Framework
5+
# @note This is a lie. The core libraries are not semantically versioned. This is currently just linked to the
6+
# Metasploit::Framework::Version, which is also not semantically versioned.
7+
module Core
8+
module Version
9+
MAJOR = Metasploit::Framework::Version::MAJOR
10+
MINOR = Metasploit::Framework::Version::MINOR
11+
PATCH = Metasploit::Framework::Version::PATCH
12+
PRERELEASE = Metasploit::Framework::Version::PRERELEASE
13+
end
14+
15+
VERSION = Metasploit::Framework::VERSION
16+
GEM_VERSION = Gem::Version.new(Metasploit::Framework::GEM_VERSION)
17+
end
18+
end
19+
end

lib/msf/core/framework.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ class Framework
4242
# EICAR canary
4343
EICARCorrupted = ::Msf::Util::EXE.is_eicar_corrupted?
4444

45-
# API Version
46-
APIMajor = 1
47-
APIMinor = 0
48-
49-
# Base/API Version
50-
VersionCore = Major + (Minor / 10.0)
51-
VersionAPI = APIMajor + (APIMinor / 10.0)
52-
5345
#
5446
# Mixin meant to be included into all classes that can have instances that
5547
# should be tied to the framework, such as modules.

lib/msf/core/modules/namespace.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
require 'metasploit/framework/api/version'
2+
require 'metasploit/framework/core/version'
3+
14
# Concern for behavior that all namespace modules that wrap Msf::Modules must support like version checking and
25
# grabbing the version specific-Metasploit* class.
36
module Msf::Modules::Namespace
@@ -54,11 +57,11 @@ def metasploit_class!(module_path, module_reference_name)
5457
def version_compatible!(module_path, module_reference_name)
5558
if const_defined?(:RequiredVersions)
5659
required_versions = const_get(:RequiredVersions)
57-
minimum_core_version = required_versions[0]
58-
minimum_api_version = required_versions[1]
60+
minimum_core_version = Gem::Version.new(required_versions[0].to_s)
61+
minimum_api_version = Gem::Version.new(required_versions[1].to_s)
5962

60-
if (minimum_core_version > ::Msf::Framework::VersionCore or
61-
minimum_api_version > ::Msf::Framework::VersionAPI)
63+
if (minimum_core_version > Metasploit::Framework::Core::GEM_VERSION ||
64+
minimum_api_version > Metasploit::Framework::API::GEM_VERSION)
6265
raise Msf::Modules::VersionCompatibilityError.new(
6366
:module_path => module_path,
6467
:module_reference_name => module_reference_name,

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def cmd_banner(*args)
408408
avdwarn = nil
409409

410410
banner_trailers = {
411-
:version => "%yelmetasploit v#{Msf::Framework::Version} [core:#{Msf::Framework::VersionCore} api:#{Msf::Framework::VersionAPI}]%clr",
411+
:version => "%yelmetasploit v#{Msf::Framework::Version} [core:#{Metasploit::Framework::Core::GEM_VERSION} api:#{Metasploit::Framework::API::GEM_VERSION}]%clr",
412412
:exp_aux_pos => "#{framework.stats.num_exploits} exploits - #{framework.stats.num_auxiliary} auxiliary - #{framework.stats.num_post} post",
413413
:pay_enc_nop => "#{framework.stats.num_payloads} payloads - #{framework.stats.num_encoders} encoders - #{framework.stats.num_nops} nops",
414414
:free_trial => "Free Metasploit Pro trial: http://r-7.co/trymsp",

spec/lib/msf/core/modules/namespace_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,17 @@
209209
end
210210

211211
context 'with minimum Core version' do
212-
it 'should be <= Msf::Framework::VersionCore' do
213-
minimum_core_version.should <= Msf::Framework::VersionCore
212+
it 'is <= Metasploit::Framework::Core::GEM_VERSION when converted to Gem::Version' do
213+
expect(Gem::Version.new(minimum_core_version.to_s)).to be <= Metasploit::Framework::Core::GEM_VERSION
214214
end
215215

216216
context 'without minimum API version' do
217217
let(:minimum_api_version) do
218218
2
219219
end
220220

221-
it 'should be > Msf::Framework::VersionAPI' do
222-
minimum_api_version.should > Msf::Framework::VersionAPI
221+
it 'is > Metasploit::Framework::API::GEM_VERSION when converted to Gem::Version' do
222+
expect(Gem::Version.new(minimum_api_version.to_s)).to be > Metasploit::Framework::API::GEM_VERSION
223223
end
224224

225225
it_should_behave_like 'Msf::Modules::VersionCompatibilityError'
@@ -239,25 +239,25 @@
239239
5
240240
end
241241

242-
it 'should be > Msf::Framework::VersionCore' do
243-
minimum_core_version.should > Msf::Framework::VersionCore
242+
it 'is > Metasploit::Framework::Core::GEM_VERSION when converted to Gem::Version' do
243+
expect(Gem::Version.new(minimum_core_version.to_s)).to be > Metasploit::Framework::Core::GEM_VERSION
244244
end
245245

246246
context 'without minimum API version' do
247247
let(:minimum_api_version) do
248248
2
249249
end
250250

251-
it 'should be > Msf::Framework::VersionAPI' do
252-
minimum_api_version.should > Msf::Framework::VersionAPI
251+
it 'is > Metasploit::Framework::API::GEM_VERSION when converted to Gem::Version' do
252+
expect(Gem::Version.new(minimum_api_version.to_s)).to be > Metasploit::Framework::API::GEM_VERSION
253253
end
254254

255255
it_should_behave_like 'Msf::Modules::VersionCompatibilityError'
256256
end
257257

258258
context 'with minimum API version' do
259-
it 'should be <= Msf::Framework::VersionAPI' do
260-
minimum_api_version <= Msf::Framework::VersionAPI
259+
it 'is <= Metasploit::Framework::API::GEM_VERSION when converted to Gem::Version' do
260+
expect(Gem::Version.new(minimum_api_version.to_s)).to be <= Metasploit::Framework::API::GEM_VERSION
261261
end
262262

263263
it_should_behave_like 'Msf::Modules::VersionCompatibilityError'

0 commit comments

Comments
 (0)