metasploit_data_models 4.1.3 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.github/workflows/verify.yml +5 -9
- data/Gemfile +0 -2
- data/README.md +8 -0
- data/app/models/mdm/event.rb +2 -0
- data/app/models/mdm/exploit_attempt.rb +4 -0
- data/app/models/mdm/listener.rb +1 -0
- data/app/models/mdm/loot.rb +2 -0
- data/app/models/mdm/note.rb +3 -0
- data/app/models/mdm/session.rb +1 -0
- data/app/models/mdm/tag.rb +1 -0
- data/app/models/mdm/vuln.rb +3 -0
- data/app/models/mdm/vuln_attempt.rb +2 -0
- data/app/models/mdm/vuln_detail.rb +1 -0
- data/app/models/mdm/workspace.rb +1 -1
- data/app/models/metasploit_data_models/automatic_exploitation/match.rb +1 -0
- data/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list.rb +1 -1
- data/app/models/metasploit_data_models/module_run.rb +2 -0
- data/app/models/metasploit_data_models/search/visitor/relation.rb +1 -1
- data/db/migrate/20140905031549_add_detected_arch_to_host.rb +1 -1
- data/lib/metasploit_data_models/version.rb +1 -1
- data/metasploit_data_models.gemspec +3 -3
- data/spec/app/models/mdm/event_spec.rb +2 -2
- data/spec/app/models/mdm/listener_spec.rb +1 -1
- data/spec/app/models/mdm/loot_spec.rb +2 -2
- data/spec/app/models/mdm/note_spec.rb +3 -3
- data/spec/app/models/mdm/session_spec.rb +1 -1
- data/spec/app/models/mdm/tag_spec.rb +1 -1
- data/spec/app/models/mdm/vuln_spec.rb +3 -3
- data/spec/app/models/mdm/workspace_spec.rb +3 -3
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +8 -8
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +2 -2
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +6 -2
- data/spec/dummy/app/models/application_record.rb +2 -0
- data/spec/dummy/config/application.rb +5 -0
- data/spec/dummy/config/storage.yml +7 -0
- data/spec/dummy/db/structure.sql +3 -18
- data/spec/factories/mdm/sessions.rb +1 -0
- data/spec/factories/mdm/tags.rb +1 -0
- data/spec/factories/mdm/vuln_refs.rb +2 -0
- data/spec/factories/metasploit_data_models/automatic_exploitation/runs.rb +1 -0
- data/spec/factories/module_runs.rb +2 -2
- metadata +9 -9
- metadata.gz.sig +0 -0
- data/config/initializers/arel_helper.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8920b63a901c80e4019bd8cbd07283da3f33d22101bae7199e7cb0130ab6016c
|
4
|
+
data.tar.gz: 2fae60132df63f13b2c04f9e4b73b9ca92e6439f2685fe4d6aa4ece95231ef35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24997125ed56ff03a2ba8f2f76071278364cb8355a6a3b50424b8cfca6798d5a714f1b6d0674ed6886737f649e33aeb1a357284a7a3094517bb4fe57accfb8df
|
7
|
+
data.tar.gz: 54666b5b8a7028d2848e26b9f5e66cb1dad4bd5d3d7a6874ed2677c95a5a076491ad12664a015ce5eb9196256888679cd995d2fd805f7f1b37fd58a65cc74f1d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -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
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
|
data/app/models/mdm/event.rb
CHANGED
@@ -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
|
#
|
data/app/models/mdm/listener.rb
CHANGED
data/app/models/mdm/loot.rb
CHANGED
@@ -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
|
data/app/models/mdm/note.rb
CHANGED
@@ -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
|
data/app/models/mdm/session.rb
CHANGED
@@ -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
|
|
data/app/models/mdm/tag.rb
CHANGED
data/app/models/mdm/vuln.rb
CHANGED
@@ -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.
|
data/app/models/mdm/workspace.rb
CHANGED
@@ -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>#{
|
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 = "#{
|
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
|
@@ -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', '~>
|
37
|
-
s.add_runtime_dependency 'activesupport', '~>
|
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', '~>
|
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,7 +3,7 @@ RSpec.describe Mdm::Listener, 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(:task).class_name('Mdm::Task') }
|
6
|
+
it { is_expected.to belong_to(:task).optional.class_name('Mdm::Task') }
|
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 =>
|
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 =
|
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.
|
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.
|
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.
|
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.
|
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
|
-
|
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
|
@@ -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
|
|
data/spec/dummy/db/structure.sql
CHANGED
@@ -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
|
|
data/spec/factories/mdm/tags.rb
CHANGED
@@ -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
|
+
version: 5.0.3
|
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-
|
96
|
+
date: 2021-06-22 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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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
|