metasploit_data_models 4.1.2 → 5.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +2 -1
  3. data.tar.gz.sig +1 -2
  4. data/.github/workflows/verify.yml +5 -9
  5. data/Gemfile +0 -2
  6. data/README.md +8 -0
  7. data/app/models/mdm/event.rb +2 -0
  8. data/app/models/mdm/exploit_attempt.rb +4 -0
  9. data/app/models/mdm/loot.rb +2 -0
  10. data/app/models/mdm/note.rb +3 -0
  11. data/app/models/mdm/session.rb +1 -0
  12. data/app/models/mdm/tag.rb +1 -0
  13. data/app/models/mdm/vuln.rb +3 -0
  14. data/app/models/mdm/vuln_attempt.rb +2 -0
  15. data/app/models/mdm/vuln_detail.rb +1 -0
  16. data/app/models/mdm/workspace.rb +1 -1
  17. data/app/models/metasploit_data_models/automatic_exploitation/match.rb +1 -0
  18. data/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list.rb +1 -1
  19. data/app/models/metasploit_data_models/module_run.rb +2 -0
  20. data/app/models/metasploit_data_models/search/visitor/relation.rb +1 -1
  21. data/db/migrate/20140905031549_add_detected_arch_to_host.rb +1 -1
  22. data/db/migrate/20190308134512_create_async_callbacks.rb +0 -1
  23. data/lib/metasploit_data_models/version.rb +1 -1
  24. data/metasploit_data_models.gemspec +3 -3
  25. data/spec/app/models/mdm/event_spec.rb +2 -2
  26. data/spec/app/models/mdm/loot_spec.rb +2 -2
  27. data/spec/app/models/mdm/note_spec.rb +3 -3
  28. data/spec/app/models/mdm/session_spec.rb +1 -1
  29. data/spec/app/models/mdm/tag_spec.rb +1 -1
  30. data/spec/app/models/mdm/vuln_spec.rb +3 -3
  31. data/spec/app/models/mdm/workspace_spec.rb +3 -3
  32. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +3 -3
  33. data/spec/app/models/metasploit_data_models/module_run_spec.rb +8 -8
  34. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +2 -2
  35. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +6 -2
  36. data/spec/dummy/app/models/application_record.rb +2 -0
  37. data/spec/dummy/config/application.rb +5 -0
  38. data/spec/dummy/config/storage.yml +7 -0
  39. data/spec/dummy/db/structure.sql +3 -18
  40. data/spec/factories/mdm/sessions.rb +1 -0
  41. data/spec/factories/mdm/tags.rb +1 -0
  42. data/spec/factories/mdm/vuln_refs.rb +2 -0
  43. data/spec/factories/metasploit_data_models/automatic_exploitation/runs.rb +1 -0
  44. data/spec/factories/module_runs.rb +2 -2
  45. metadata +9 -9
  46. metadata.gz.sig +0 -0
  47. data/config/initializers/arel_helper.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c4113ef1cf55d49c2bf1a1d381759fede35bf155c70769ffc27690c86202c59
4
- data.tar.gz: 12b492eff901a960ec9f2ae4223cfdef9e8f96705a21e826061c20b3ca4eddbf
3
+ metadata.gz: 232b057420ed2ce662db4ebc490d34ef13bbb0ac57e2e35e516f886b7dfb9e0b
4
+ data.tar.gz: 644cade6aa4791d599c6405d61581bba496a8ae07c6d0b1d69579fc2d2867fc2
5
5
  SHA512:
6
- metadata.gz: 7395cc9909026f5778cf27c3c2d67d4d768d5c25f151cff9b5f60529e3702331274f030943d8e8f529e4c57cd47f83c21e5867fc5e3c7c39a27b7735ca227c6c
7
- data.tar.gz: 3324390bc1f7e734ea14dfe68a8a47a762cbebc8e808564545a64fcdb4156e7f822c53d939387cf499fc35d3fb26ee95fc6e2b795d931002f2c906b39635d30c
6
+ metadata.gz: ee21837a8af1f62fdfdec43615eb5dba2d62edc5bbc521627d97cd59d69fd78b06b13f1c94ca693810871ec24e0f0401449176fc53ca0ec3ea65ccabefc31e68
7
+ data.tar.gz: 0b95c36f7521b2e2cd503df6ad05d49b355550f102eec2df2ac9df03d8ec150575770561e0cba34297ab649bc987219b4eed9059a8445056e3ac4ce57a0b88d9
checksums.yaml.gz.sig CHANGED
@@ -1 +1,2 @@
1
- �9�y�YӸ~١�|��n�%b,��5���~�vSe�FZ�ͽ�Ʉ?@C8�]^�x�'�_��0�R[�PA?}�Vjj���f���mo@ZL5`47�����/a�� &�\L�&������'��/�1N��=te�[1�G��[i9OE�e����T�M��������"�H�9fRn|��B����v��9�MN�0U֯��Ç�*^��-�anC9c�սly�O����uA�ɟ_r��|�N3�=�2�sy
1
+ ���M}�͝�ʊ�}��N�!�1
2
+ ��DO�6u�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
@@ -1,2 +1 @@
1
- Z�����)Tg^�ϛ��E��v��`Os����do����y���ۗ�4�\^[;�F��%��x"�ڕ�ƶ;�0����gYP ]�{�T��,��iAt Z{l /:ഛ-,�;y(Z2���\޸ԙ�� g����� ���?������d.B� "������-0I@P5�ȷ�����H
2
- �{z�T�{��i9�M�*\sT��2�.&���3~�l�j}�6q�.5d
1
+ �������!��;6�6�λ�����o� m<j���^j��.�n�̴qa7�K�<�����L9��$3���Z{i����&�l��*X�,�R8W���,�u{@gn���y7�t�y"��<�������p �zў;���O��ۈ�i�w�-ᤧ8�D��?��r8:�2�Y��=��Hn�V�sQL�'��a1��S[��z�ӓ��J�<���R&ؽ0�'����ݎ&�Niib3zK�����csQC
@@ -30,7 +30,10 @@ jobs:
30
30
  fail-fast: true
31
31
  matrix:
32
32
  ruby:
33
+ - 2.5
34
+ - 2.6
33
35
  - 2.7
36
+ - 3.0
34
37
 
35
38
  env:
36
39
  RAILS_ENV: test
@@ -49,19 +52,12 @@ jobs:
49
52
 
50
53
  - name: Setup bundler
51
54
  run: |
52
- gem install bundler
53
-
54
- - uses: actions/cache@v2
55
- with:
56
- path: vendor/bundle
57
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
58
- restore-keys: |
59
- ${{ runner.os }}-gems-
55
+ gem install bundler:2.1.4
60
56
 
61
57
  - name: Bundle install
62
58
  run: |
63
59
  bundle config path vendor/bundle
64
- bundle install --jobs 4 --retry 3
60
+ bundle _2.1.4_ install --jobs 4 --retry 3
65
61
 
66
62
  - name: Test
67
63
  run: |
data/Gemfile CHANGED
@@ -27,8 +27,6 @@ group :development, :test do
27
27
  # bound to 0.20 for Activerecord 4.2.8 deprecation warnings:
28
28
  # https://github.com/ged/ruby-pg/commit/c90ac644e861857ae75638eb6954b1cb49617090
29
29
  gem 'pg'
30
-
31
- gem 'pry'
32
30
  end
33
31
 
34
32
  group :test do
data/README.md CHANGED
@@ -41,6 +41,14 @@ different `on_load` name, which is just the class name converted to an underscor
41
41
 
42
42
  require 'metasploit_data_models/engine'
43
43
 
44
+ `ArelHelper` classes must also be included in your applications `app/models/application_record.rb` class:
45
+
46
+ class ApplicationRecord < ActiveRecord::Base
47
+ self.abstract_class = true
48
+ include ArelHelpers::ArelTable
49
+ include ArelHelpers::JoinAssociation
50
+ end
51
+
44
52
  ### Metasploit Framework
45
53
 
46
54
  In Metasploit Framework, `MetasploitDataModels::Engine` is loaded, but the data models are only if the user wants to use
@@ -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
@@ -12,7 +12,7 @@ class MetasploitDataModels::IPAddress::V4::Segment::Nmap::List < Metasploit::Mod
12
12
  # Either an individual {MetasploitDataModels::IPAddress::V4::Segment::Single segment number} or a
13
13
  # {MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range segment range}.
14
14
  RANGE_OR_NUMBER_REGEXP = %r{
15
- (?<range>#{parent::Range.regexp})
15
+ (?<range>#{module_parent::Range.regexp})
16
16
  |
17
17
  # range first because it contains a segment and if the range isn't first only the first part of the range will
18
18
  # match.
@@ -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
 
@@ -67,7 +67,7 @@ class MetasploitDataModels::Search::Visitor::Relation < Metasploit::Model::Base
67
67
  # @return [Hash{Symbol => Class}]
68
68
  def self.visitor_class_by_relation_method
69
69
  @relation_method_by_visitor_class ||= RELATION_METHODS.each_with_object({}) { |relation_method, relation_method_by_visitor_class|
70
- visitor_class_name = "#{parent.name}::#{relation_method.to_s.camelize}"
70
+ visitor_class_name = "#{module_parent.name}::#{relation_method.to_s.camelize}"
71
71
  visitor_class = visitor_class_name.constantize
72
72
 
73
73
  relation_method_by_visitor_class[relation_method] = visitor_class
@@ -1,5 +1,5 @@
1
1
  class AddDetectedArchToHost < ActiveRecord::Migration[4.2]
2
2
  def change
3
- add_column :hosts, :detected_arch, :string, { :null => true }
3
+ add_column :hosts, :detected_arch, :string, :null => true
4
4
  end
5
5
  end
@@ -8,7 +8,6 @@ class CreateAsyncCallbacks < ActiveRecord::Migration[4.2]
8
8
  t.string :target_port
9
9
 
10
10
  t.timestamps null: false
11
- t.uuid null: false
12
11
  end
13
12
  end
14
13
  end
@@ -1,6 +1,6 @@
1
1
  module MetasploitDataModels
2
2
  # VERSION is managed by GemRelease
3
- VERSION = '4.1.2'
3
+ VERSION = '5.0.2'
4
4
 
5
5
  # @return [String]
6
6
  #
@@ -33,11 +33,11 @@ Gem::Specification.new do |s|
33
33
  s.add_development_dependency 'pry'
34
34
 
35
35
 
36
- s.add_runtime_dependency 'activerecord', '~>5.2.2'
37
- s.add_runtime_dependency 'activesupport', '~>5.2.2'
36
+ s.add_runtime_dependency 'activerecord', '~>6.0'
37
+ s.add_runtime_dependency 'activesupport', '~>6.0'
38
38
  s.add_runtime_dependency 'metasploit-concern'
39
39
  s.add_runtime_dependency 'metasploit-model', '>=3.1'
40
- s.add_runtime_dependency 'railties', '~>5.2.2'
40
+ s.add_runtime_dependency 'railties', '~>6.0'
41
41
  s.add_runtime_dependency 'webrick'
42
42
 
43
43
  # os fingerprinting
@@ -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) }
@@ -233,7 +233,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Single, type: :mode
233
233
  end
234
234
 
235
235
  context '#to_s' do
236
- subject(:to_s) {
236
+ subject(:call_to_s) {
237
237
  single.to_s
238
238
  }
239
239
 
@@ -256,7 +256,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Single, type: :mode
256
256
  it 'delegates to #value' do
257
257
  expect(value).to receive(:to_s)
258
258
 
259
- to_s
259
+ call_to_s
260
260
  end
261
261
  end
262
262
 
@@ -321,4 +321,4 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Single, type: :mode
321
321
  end
322
322
  end
323
323
  end
324
- end
324
+ end
@@ -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 }
@@ -39,7 +39,7 @@ RSpec.describe MetasploitDataModels::Search::Operation::Range, type: :model do
39
39
 
40
40
  context '#ordered' do
41
41
  let(:error) {
42
- I18n.translate!('metasploit.model.errors.models.metasploit_data_models/search/operation/range.attributes.value.order', error_attributes)
42
+ I18n.translate!('metasploit.model.errors.models.metasploit_data_models/search/operation/range.attributes.value.order', **error_attributes)
43
43
  }
44
44
 
45
45
  context 'with Range' do
@@ -230,4 +230,4 @@ RSpec.describe MetasploitDataModels::Search::Operation::Range, type: :model do
230
230
  end
231
231
  end
232
232
  end
233
- end
233
+ end
@@ -28,7 +28,11 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Attribute, type: :model do
28
28
  end
29
29
 
30
30
  it "should be #{node_class}#attribute" do
31
- expect(name).to eq(node.attribute)
31
+ if node.attribute.instance_of? Symbol
32
+ expect(name.to_s).to eq(node.attribute.to_s)
33
+ else
34
+ expect(name).to eq(node.attribute)
35
+ end
32
36
  end
33
37
  end
34
38
 
@@ -93,4 +97,4 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Attribute, type: :model do
93
97
  }
94
98
  end
95
99
  end
96
- end
100
+ end
@@ -1,3 +1,5 @@
1
1
  class ApplicationRecord < ActiveRecord::Base
2
2
  self.abstract_class = true
3
+ include ArelHelpers::ArelTable
4
+ include ArelHelpers::JoinAssociation
3
5
  end
@@ -51,11 +51,16 @@ 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
 
57
60
  # Version of your assets, change this if you want to expire all your assets
58
61
  config.assets.version = '1.0'
62
+
63
+ config.autoloader = :zeitwerk
59
64
  end
60
65
  end
61
66
 
@@ -0,0 +1,7 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
@@ -5,27 +5,12 @@ SET client_encoding = 'UTF8';
5
5
  SET standard_conforming_strings = on;
6
6
  SELECT pg_catalog.set_config('search_path', '', false);
7
7
  SET check_function_bodies = false;
8
+ SET xmloption = content;
8
9
  SET client_min_messages = warning;
9
10
  SET row_security = off;
10
11
 
11
- --
12
- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
13
- --
14
-
15
- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
16
-
17
-
18
- --
19
- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
20
- --
21
-
22
- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
23
-
24
-
25
12
  SET default_tablespace = '';
26
13
 
27
- SET default_with_oids = false;
28
-
29
14
  --
30
15
  -- Name: api_keys; Type: TABLE; Schema: public; Owner: -
31
16
  --
@@ -64,8 +49,8 @@ ALTER SEQUENCE public.api_keys_id_seq OWNED BY public.api_keys.id;
64
49
  CREATE TABLE public.ar_internal_metadata (
65
50
  key character varying NOT NULL,
66
51
  value character varying,
67
- created_at timestamp without time zone NOT NULL,
68
- updated_at timestamp without time zone NOT NULL
52
+ created_at timestamp(6) without time zone NOT NULL,
53
+ updated_at timestamp(6) without time zone NOT NULL
69
54
  );
70
55
 
71
56
 
@@ -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: 4.1.2
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-02-18 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
@@ -185,28 +185,28 @@ dependencies:
185
185
  requirements:
186
186
  - - "~>"
187
187
  - !ruby/object:Gem::Version
188
- version: 5.2.2
188
+ version: '6.0'
189
189
  type: :runtime
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
193
193
  - - "~>"
194
194
  - !ruby/object:Gem::Version
195
- version: 5.2.2
195
+ version: '6.0'
196
196
  - !ruby/object:Gem::Dependency
197
197
  name: activesupport
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - "~>"
201
201
  - !ruby/object:Gem::Version
202
- version: 5.2.2
202
+ version: '6.0'
203
203
  type: :runtime
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements:
207
207
  - - "~>"
208
208
  - !ruby/object:Gem::Version
209
- version: 5.2.2
209
+ version: '6.0'
210
210
  - !ruby/object:Gem::Dependency
211
211
  name: metasploit-concern
212
212
  requirement: !ruby/object:Gem::Requirement
@@ -241,14 +241,14 @@ dependencies:
241
241
  requirements:
242
242
  - - "~>"
243
243
  - !ruby/object:Gem::Version
244
- version: 5.2.2
244
+ version: '6.0'
245
245
  type: :runtime
246
246
  prerelease: false
247
247
  version_requirements: !ruby/object:Gem::Requirement
248
248
  requirements:
249
249
  - - "~>"
250
250
  - !ruby/object:Gem::Version
251
- version: 5.2.2
251
+ version: '6.0'
252
252
  - !ruby/object:Gem::Dependency
253
253
  name: webrick
254
254
  requirement: !ruby/object:Gem::Requirement
@@ -416,7 +416,6 @@ files:
416
416
  - app/models/metasploit_data_models/search/visitor/method.rb
417
417
  - app/models/metasploit_data_models/search/visitor/relation.rb
418
418
  - app/models/metasploit_data_models/search/visitor/where.rb
419
- - config/initializers/arel_helper.rb
420
419
  - config/initializers/ipaddr.rb
421
420
  - config/locales/en.yml
422
421
  - console_db.yml
@@ -685,6 +684,7 @@ files:
685
684
  - spec/dummy/config/initializers/wrap_parameters.rb
686
685
  - spec/dummy/config/locales/en.yml
687
686
  - spec/dummy/config/routes.rb
687
+ - spec/dummy/config/storage.yml
688
688
  - spec/dummy/db/structure.sql
689
689
  - spec/dummy/db/structure.sql.from_rails_3
690
690
  - spec/dummy/lib/assets/.gitkeep
metadata.gz.sig CHANGED
Binary file
@@ -1,5 +0,0 @@
1
- # Including arel-helpers in all active record models.
2
- # https://github.com/camertron/arel-helpers
3
-
4
- ApplicationRecord.send(:include, ArelHelpers::ArelTable)
5
- ApplicationRecord.send(:include, ArelHelpers::JoinAssociation)