metasploit_data_models 5.0.1 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b3d6afb4043f6da94c943b5fbc781ae3181d50720a85dc148faaafb90342e9d
4
- data.tar.gz: 42b7980d65c39dfafca53117d550d3bd408e845e051637b9dc2581f580c86f96
3
+ metadata.gz: 232b057420ed2ce662db4ebc490d34ef13bbb0ac57e2e35e516f886b7dfb9e0b
4
+ data.tar.gz: 644cade6aa4791d599c6405d61581bba496a8ae07c6d0b1d69579fc2d2867fc2
5
5
  SHA512:
6
- metadata.gz: 8e868aaf68a281bfed3c28ce4bc262fdc8e33ed02ca90beb49c1136e94f78ab0c671e76d6c81d3110592b344ef463d5dc0686c3d110ff8abe3b1aed91a07e33a
7
- data.tar.gz: 74ba74b84a2daadc73546e4b604e6c9cac36a3b1370e757848096c76f2580dc79d4d573c48833c904606fcd15535da27fb6d6a8e60fd83abd070b4bb3ba38c56
6
+ metadata.gz: ee21837a8af1f62fdfdec43615eb5dba2d62edc5bbc521627d97cd59d69fd78b06b13f1c94ca693810871ec24e0f0401449176fc53ca0ec3ea65ccabefc31e68
7
+ data.tar.gz: 0b95c36f7521b2e2cd503df6ad05d49b355550f102eec2df2ac9df03d8ec150575770561e0cba34297ab649bc987219b4eed9059a8445056e3ac4ce57a0b88d9
checksums.yaml.gz.sig CHANGED
@@ -1,5 +1,2 @@
1
- s��K�ZU%���
2
- Vg\?ui��hׄ�=���Ь���*PcjVO��dt,"��y[C��&�Åkt���+b3�~��Thq�:eXJ<V�p�$w�� QBe�I=��]r��1*�p�þ��*�ň�S&
3
- )�x��s�u,��畼Z׾p�;�C���k�ﺥ�q@?���DB�"Z�A�`�>`�;
4
- ���,����P=6y�n �I�`�w��
5
- K�D�έ��\���('�J�E�g���ț�s�1w�Nt
1
+ ���M}�͝�ʊ�}��N�!�1
2
+ ��DO6u�7)X�c����o��w���Nd�U� �C�n��2���B�����V ��>�p���Z���}&+ -�q5&��b�sBP����~f�Q �hA).S���$ڄ9k��b���@�|ک��{��s!s��
data.tar.gz.sig CHANGED
Binary file
@@ -11,12 +11,14 @@ class Mdm::Event < ApplicationRecord
11
11
  # @return [nil] if event did not occur on a host.
12
12
  belongs_to :host,
13
13
  class_name: 'Mdm::Host',
14
+ optional: true,
14
15
  inverse_of: :events
15
16
 
16
17
  # {Mdm::Workspace} in which this event occured. If {#host} is present, then this will match
17
18
  # {Mdm::Host#workspace `host.workspace`}.
18
19
  belongs_to :workspace,
19
20
  class_name: 'Mdm::Workspace',
21
+ optional: true,
20
22
  inverse_of: :events
21
23
 
22
24
  #
@@ -18,6 +18,7 @@ class Mdm::ExploitAttempt < ApplicationRecord
18
18
  # @return [Mdm::Loot, nil]
19
19
  belongs_to :loot,
20
20
  class_name: 'Mdm::Loot',
21
+ optional: true,
21
22
  inverse_of: :exploit_attempt
22
23
 
23
24
  # The service being exploited on {#host}.
@@ -25,6 +26,7 @@ class Mdm::ExploitAttempt < ApplicationRecord
25
26
  # @return [Mdm::Service, nil]
26
27
  belongs_to :service,
27
28
  class_name: 'Mdm::Service',
29
+ optional: true,
28
30
  inverse_of: :exploit_attempts
29
31
 
30
32
  # The session that was established when this attempt was successful.
@@ -33,6 +35,7 @@ class Mdm::ExploitAttempt < ApplicationRecord
33
35
  # @return [nil] if session was not established.
34
36
  belongs_to :session,
35
37
  class_name: 'Mdm::Session',
38
+ optional: true,
36
39
  inverse_of: :exploit_attempt
37
40
 
38
41
  # The vulnerability that was attempted to be exploited.
@@ -40,6 +43,7 @@ class Mdm::ExploitAttempt < ApplicationRecord
40
43
  # @return [Mdm::Vuln, nil]
41
44
  belongs_to :vuln,
42
45
  class_name: 'Mdm::Vuln',
46
+ optional: true,
43
47
  inverse_of: :exploit_attempts
44
48
 
45
49
  #
@@ -40,6 +40,7 @@ class Mdm::Loot < ApplicationRecord
40
40
  belongs_to :module_run,
41
41
  class_name: 'MetasploitDataModels::ModuleRun',
42
42
  foreign_key: :module_run_id,
43
+ optional: true, # allow for manually stored loot?
43
44
  inverse_of: :loots
44
45
 
45
46
  # @!attribute [rw] service
@@ -48,6 +49,7 @@ class Mdm::Loot < ApplicationRecord
48
49
  # @return [Mdm::Service]
49
50
  belongs_to :service,
50
51
  class_name: 'Mdm::Service',
52
+ optional: true,
51
53
  inverse_of: :loots
52
54
 
53
55
  # @!attribute vuln_attempt
@@ -13,6 +13,7 @@ class Mdm::Note < ApplicationRecord
13
13
  belongs_to :host,
14
14
  class_name: 'Mdm::Host',
15
15
  counter_cache: :note_count,
16
+ optional: true,
16
17
  inverse_of: :notes
17
18
 
18
19
  # @!attribute [rw] service
@@ -22,6 +23,7 @@ class Mdm::Note < ApplicationRecord
22
23
  # @return [nil] if not is attached to an {Mdm::Host}.
23
24
  belongs_to :service,
24
25
  class_name: 'Mdm::Service',
26
+ optional: true,
25
27
  inverse_of: :notes
26
28
 
27
29
  # @!attribute [rw] vuln
@@ -31,6 +33,7 @@ class Mdm::Note < ApplicationRecord
31
33
  # @return [nil] if not is attached to an {Mdm::Host}.
32
34
  belongs_to :vuln,
33
35
  class_name: 'Mdm::Vuln',
36
+ optional: true,
34
37
  inverse_of: :notes
35
38
 
36
39
  # @!attribute [rw] workspace
@@ -47,6 +47,7 @@ class Mdm::Session < ApplicationRecord
47
47
  # @return [MetasploitDataModels::ModuleRun]
48
48
  belongs_to :originating_module_run,
49
49
  class_name: 'MetasploitDataModels::ModuleRun',
50
+ optional: true, # no code currently generates a module_run
50
51
  foreign_key: :module_run_id,
51
52
  inverse_of: :spawned_session
52
53
 
@@ -15,6 +15,7 @@ class Mdm::Tag < ApplicationRecord
15
15
  # User that created this tag.
16
16
  belongs_to :user,
17
17
  class_name: 'Mdm::User',
18
+ optional: true, # no tags have ever actually had user set.
18
19
  inverse_of: :tags
19
20
 
20
21
  #
@@ -20,6 +20,7 @@ class Mdm::Vuln < ApplicationRecord
20
20
  belongs_to :host,
21
21
  class_name: 'Mdm::Host',
22
22
  counter_cache: :vuln_count,
23
+ optional: true,
23
24
  inverse_of: :vulns
24
25
 
25
26
  # @!attribute [rw] matches
@@ -36,6 +37,7 @@ class Mdm::Vuln < ApplicationRecord
36
37
  # @return [Mdm::Service]
37
38
  belongs_to :service,
38
39
  class_name: 'Mdm::Service',
40
+ optional: true,
39
41
  inverse_of: :vulns
40
42
 
41
43
  # @!attribute [rw] origin
@@ -44,6 +46,7 @@ class Mdm::Vuln < ApplicationRecord
44
46
  #
45
47
  # @return [ActiveRecord::Relation<origin>]
46
48
  belongs_to :origin,
49
+ optional: true,
47
50
  polymorphic: true
48
51
 
49
52
  # @!attribute [rw] vuln_attempts
@@ -11,6 +11,7 @@ class Mdm::VulnAttempt < ApplicationRecord
11
11
  # @return [nil] if {#exploited} is `false`.
12
12
  belongs_to :loot,
13
13
  class_name: 'Mdm::Loot',
14
+ optional: true,
14
15
  inverse_of: :vuln_attempt
15
16
 
16
17
  # The session opened by this attempt.
@@ -19,6 +20,7 @@ class Mdm::VulnAttempt < ApplicationRecord
19
20
  # @return [nil] if {#exploited} is `false`.
20
21
  belongs_to :session,
21
22
  class_name: 'Mdm::Session',
23
+ optional: true,
22
24
  inverse_of: :vuln_attempt
23
25
 
24
26
  # The {Mdm::Vuln vulnerability} that this attempt was exploiting.
@@ -67,6 +67,7 @@ class Mdm::VulnDetail < ApplicationRecord
67
67
  belongs_to :nexpose_console,
68
68
  class_name: 'Mdm::NexposeConsole',
69
69
  foreign_key: :nx_console_id,
70
+ optional: true,
70
71
  inverse_of: :vuln_details
71
72
 
72
73
  # @!attribute nx_added
@@ -36,7 +36,7 @@ class Mdm::Workspace < ApplicationRecord
36
36
 
37
37
  # User that owns this workspace and has full permissions within this workspace even if they are not an
38
38
  # {Mdm::User#admin administrator}.
39
- belongs_to :owner, :class_name => 'Mdm::User', :foreign_key => 'owner_id'
39
+ belongs_to :owner, :class_name => 'Mdm::User', :foreign_key => 'owner_id', optional: true
40
40
 
41
41
  # Tasks run inside this workspace.
42
42
  has_many :tasks,
@@ -17,6 +17,7 @@ class MetasploitDataModels::AutomaticExploitation::Match < ApplicationRecord
17
17
  # The {MatchSet} this match is part of
18
18
  belongs_to :match_set,
19
19
  class_name: 'MetasploitDataModels::AutomaticExploitation::MatchSet',
20
+ optional: true,
20
21
  inverse_of: :matches
21
22
 
22
23
  # The Metasploit Module that this match connects to
@@ -109,6 +109,7 @@ class MetasploitDataModels::ModuleRun < ApplicationRecord
109
109
  belongs_to :target_session,
110
110
  class_name: 'Mdm::Session',
111
111
  foreign_key: :session_id,
112
+ optional: true,
112
113
  inverse_of: :target_module_runs
113
114
 
114
115
 
@@ -130,6 +131,7 @@ class MetasploitDataModels::ModuleRun < ApplicationRecord
130
131
  belongs_to :user,
131
132
  class_name: 'Mdm::User',
132
133
  foreign_key: 'user_id',
134
+ optional: true,
133
135
  inverse_of: :module_runs
134
136
 
135
137
 
@@ -1,6 +1,6 @@
1
1
  module MetasploitDataModels
2
2
  # VERSION is managed by GemRelease
3
- VERSION = '5.0.1'
3
+ VERSION = '5.0.2'
4
4
 
5
5
  # @return [String]
6
6
  #
@@ -2,8 +2,8 @@ RSpec.describe Mdm::Event, type: :model do
2
2
  it_should_behave_like 'Metasploit::Concern.run'
3
3
 
4
4
  context 'associations' do
5
- it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
6
- it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
5
+ it { is_expected.to belong_to(:host).optional.class_name('Mdm::Host') }
6
+ it { is_expected.to belong_to(:workspace).optional.class_name('Mdm::Workspace') }
7
7
  end
8
8
 
9
9
  context 'database' do
@@ -3,9 +3,9 @@ RSpec.describe Mdm::Loot, type: :model do
3
3
 
4
4
  context 'associations' do
5
5
  it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
6
- it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
6
+ it { is_expected.to belong_to(:service).optional.class_name('Mdm::Service') }
7
7
  it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
8
- it { is_expected.to belong_to(:module_run).class_name('MetasploitDataModels::ModuleRun') }
8
+ it { is_expected.to belong_to(:module_run).optional.class_name('MetasploitDataModels::ModuleRun') }
9
9
  end
10
10
 
11
11
  context 'database' do
@@ -41,9 +41,9 @@ RSpec.describe Mdm::Note, type: :model do
41
41
 
42
42
  context 'associations' do
43
43
  it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
44
- it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
45
- it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
46
- it { is_expected.to belong_to(:vuln).class_name('Mdm::Vuln') }
44
+ it { is_expected.to belong_to(:host).optional.class_name('Mdm::Host') }
45
+ it { is_expected.to belong_to(:service).optional.class_name('Mdm::Service') }
46
+ it { is_expected.to belong_to(:vuln).optional.class_name('Mdm::Vuln') }
47
47
  end
48
48
 
49
49
  context 'scopes' do
@@ -45,7 +45,7 @@ RSpec.describe Mdm::Session, type: :model do
45
45
  context 'associations' do
46
46
  it { is_expected.to have_many(:events).class_name('Mdm::SessionEvent').dependent(:delete_all) }
47
47
  it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
48
- it { is_expected.to belong_to(:originating_module_run).class_name('MetasploitDataModels::ModuleRun') }
48
+ it { is_expected.to belong_to(:originating_module_run).optional.class_name('MetasploitDataModels::ModuleRun') }
49
49
  it { is_expected.to have_many(:routes).class_name('Mdm::Route').dependent(:delete_all) }
50
50
  it { is_expected.to have_many(:target_module_runs).class_name('MetasploitDataModels::ModuleRun') }
51
51
  it { is_expected.to have_many(:tasks).class_name('Mdm::Task').through(:task_sessions)}
@@ -6,7 +6,7 @@ RSpec.describe Mdm::Tag, type: :model do
6
6
  context 'associations' do
7
7
  it { is_expected.to have_many(:hosts_tags).class_name('Mdm::HostTag') }
8
8
  it { is_expected.to have_many(:hosts).class_name('Mdm::Host').through(:hosts_tags) }
9
- it { is_expected.to belong_to(:user).class_name('Mdm::User') }
9
+ it { is_expected.to belong_to(:user).optional.class_name('Mdm::User') }
10
10
  end
11
11
 
12
12
  context 'database' do
@@ -31,9 +31,9 @@ RSpec.describe Mdm::Vuln, type: :model do
31
31
 
32
32
 
33
33
  context 'associations' do
34
- it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
35
- it { is_expected.to belong_to(:origin) }
36
- it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
34
+ it { is_expected.to belong_to(:host).optional.class_name('Mdm::Host') }
35
+ it { is_expected.to belong_to(:origin).optional }
36
+ it { is_expected.to belong_to(:service).optional.class_name('Mdm::Service') }
37
37
  it { is_expected.to have_many(:module_refs).class_name('Mdm::Module::Ref').through(:refs) }
38
38
  it { is_expected.to have_many(:module_runs).class_name('MetasploitDataModels::ModuleRun') }
39
39
  it { is_expected.to have_many(:refs).class_name('Mdm::Ref').through(:vulns_refs) }
@@ -46,7 +46,7 @@ RSpec.describe Mdm::Workspace, type: :model do
46
46
  it { is_expected.to have_many(:listeners).class_name('Mdm::Listener').dependent(:destroy) }
47
47
  it { is_expected.to have_many(:loots).class_name('Mdm::Loot').through(:hosts) }
48
48
  it { is_expected.to have_many(:notes).class_name('Mdm::Note') }
49
- it { is_expected.to belong_to(:owner).class_name('Mdm::User').with_foreign_key('owner_id') }
49
+ it { is_expected.to belong_to(:owner).optional.class_name('Mdm::User').with_foreign_key('owner_id') }
50
50
  it { is_expected.to have_many(:services).class_name('Mdm::Service').through(:hosts).with_foreign_key('service_id') }
51
51
  it { is_expected.to have_many(:sessions).class_name('Mdm::Session').through(:hosts) }
52
52
  it { is_expected.to have_many(:tasks).class_name('Mdm::Task').dependent(:destroy).order('created_at DESC') }
@@ -185,7 +185,7 @@ RSpec.describe Mdm::Workspace, type: :model do
185
185
  before(:example) do
186
186
  FactoryBot.create(
187
187
  :mdm_workspace,
188
- :name => default
188
+ :name => Mdm::Workspace::DEFAULT
189
189
  )
190
190
  end
191
191
 
@@ -220,7 +220,7 @@ RSpec.describe Mdm::Workspace, type: :model do
220
220
 
221
221
  context 'with DEFAULT name' do
222
222
  before(:example) do
223
- workspace.name = default
223
+ workspace.name = Mdm::Workspace::DEFAULT
224
224
  end
225
225
 
226
226
  it { is_expected.to eq(true) }
@@ -18,10 +18,10 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
18
18
  end
19
19
 
20
20
  context "associations" do
21
- it { is_expected.to belong_to(:user).class_name('Mdm::User') }
22
- it { is_expected.to belong_to(:user).inverse_of(:module_runs) }
23
- it { is_expected.to belong_to(:target_session).class_name('Mdm::Session') }
24
- it { is_expected.to belong_to(:target_session).inverse_of(:target_module_runs) }
21
+ it { is_expected.to belong_to(:user).optional.class_name('Mdm::User') }
22
+ it { is_expected.to belong_to(:user).optional.inverse_of(:module_runs) }
23
+ it { is_expected.to belong_to(:target_session).optional.class_name('Mdm::Session') }
24
+ it { is_expected.to belong_to(:target_session).optional.inverse_of(:target_module_runs) }
25
25
  it { is_expected.to belong_to(:trackable) }
26
26
  it { is_expected.to belong_to(:module_detail).class_name('Mdm::Module::Detail') }
27
27
  it { is_expected.to belong_to(:module_detail).inverse_of(:module_runs) }
@@ -40,7 +40,7 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
40
40
  context "when the module is an exploit" do
41
41
  context "and that exploit IS NOT local" do
42
42
  before(:example) do
43
- module_run.module_fullname = 'exploit/windows/mah-crazy-exploit'
43
+ module_run.module_detail = FactoryBot.create(:mdm_module_detail, fullname: 'exploit/windows/mah-crazy-exploit')
44
44
  end
45
45
 
46
46
  it { is_expected.to_not be_valid }
@@ -48,7 +48,7 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
48
48
 
49
49
  context "and that exploit IS local" do
50
50
  before(:example) do
51
- module_run.module_fullname = 'exploit/windows/local/mah-crazy-exploit'
51
+ module_run.module_detail = FactoryBot.create(:mdm_module_detail, fullname: 'exploit/windows/local/mah-crazy-exploit')
52
52
  end
53
53
 
54
54
  it { is_expected.to be_valid }
@@ -65,7 +65,7 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
65
65
 
66
66
  context "and it IS NOT a login scanner" do
67
67
  before(:example) do
68
- module_run.module_fullname = 'post/multi/gather/steal-minecraft-maps'
68
+ module_run.module_detail = FactoryBot.create(:mdm_module_detail, fullname: 'post/multi/gather/steal-minecraft-maps')
69
69
  end
70
70
 
71
71
  it { is_expected.to_not be_valid }
@@ -73,7 +73,7 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
73
73
 
74
74
  context "and it IS a login scanner" do
75
75
  before(:example) do
76
- module_run.module_fullname = 'auxiliary/scanner/ssh/ssh_login'
76
+ module_run.module_detail = FactoryBot.create(:mdm_module_detail, fullname: 'auxiliary/scanner/ssh/ssh_login')
77
77
  end
78
78
 
79
79
  it { is_expected.to be_valid }
@@ -51,6 +51,9 @@ module Dummy
51
51
  # like if you have constraints or database-specific column types
52
52
  config.active_record.schema_format = :sql
53
53
 
54
+ # 5.x change to belongs_to
55
+ config.active_record.belongs_to_required_by_default = true
56
+
54
57
  # Enable the asset pipeline
55
58
  config.assets.enabled = false
56
59
 
@@ -4,6 +4,7 @@ FactoryBot.define do
4
4
  # Associations
5
5
  #
6
6
  association :host, :factory => :mdm_host
7
+ association :originating_module_run, :factory => :metasploit_data_models_module_run
7
8
 
8
9
  #
9
10
  # Attributes
@@ -1,5 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :mdm_tag, :class => Mdm::Tag do
3
+ association :user, factory: :mdm_user
3
4
  desc { generate :mdm_tag_desc }
4
5
  name { generate :mdm_tag_name }
5
6
  end
@@ -1,4 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :mdm_vuln_ref, :class => Mdm::VulnRef do
3
+ association :ref, factory: :mdm_ref
4
+ association :vuln, factory: :mdm_vuln
3
5
  end
4
6
  end
@@ -2,5 +2,6 @@ FactoryBot.define do
2
2
  factory :automatic_exploitation_run, :class => MetasploitDataModels::AutomaticExploitation::Run do
3
3
  association :workspace, factory: :mdm_workspace
4
4
  association :user, factory: :mdm_user
5
+ association :match_set, factory: :automatic_exploitation_match_set
5
6
  end
6
7
  end
@@ -4,6 +4,8 @@ FactoryBot.define do
4
4
  factory :metasploit_data_models_module_run, class: MetasploitDataModels::ModuleRun do
5
5
 
6
6
  association :user, factory: :mdm_user
7
+ association :module_detail, factory: :mdm_module_detail
8
+ association :trackable, factory: :mdm_host
7
9
 
8
10
  trait :failed do
9
11
  status { MetasploitDataModels::ModuleRun::FAIL }
@@ -18,13 +20,11 @@ FactoryBot.define do
18
20
  end
19
21
 
20
22
  attempted_at { Time.now }
21
- session_id { 1 }
22
23
  port { generate :port }
23
24
  proto { "tcp" }
24
25
  fail_detail { generate :module_run_fail_detail }
25
26
  status { MetasploitDataModels::ModuleRun::SUCCEED }
26
27
  username { "joefoo" }
27
- module_fullname { generate :module_run_module_fullname }
28
28
  end
29
29
 
30
30
  sequence :module_run_module_fullname do |n|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasploit_data_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
@@ -93,7 +93,7 @@ cert_chain:
93
93
  EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
94
94
  9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
95
95
  -----END CERTIFICATE-----
96
- date: 2021-05-11 00:00:00.000000000 Z
96
+ date: 2021-06-07 00:00:00.000000000 Z
97
97
  dependencies:
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: metasploit-yard
metadata.gz.sig CHANGED
Binary file