metasploit_data_models 2.0.17 → 3.0.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.travis.yml +1 -1
- data/Gemfile +3 -8
- data/lib/mdm/host/operating_system_normalization.rb +2 -1
- data/lib/metasploit_data_models/engine.rb +7 -7
- data/lib/metasploit_data_models/version.rb +1 -1
- data/metasploit_data_models.gemspec +3 -1
- data/spec/app/models/mdm/client_spec.rb +3 -3
- data/spec/app/models/mdm/cred_spec.rb +34 -34
- data/spec/app/models/mdm/event_spec.rb +9 -9
- data/spec/app/models/mdm/exploit_attempt_spec.rb +5 -5
- data/spec/app/models/mdm/exploited_host_spec.rb +3 -3
- data/spec/app/models/mdm/host_detail_spec.rb +4 -4
- data/spec/app/models/mdm/host_spec.rb +47 -47
- data/spec/app/models/mdm/host_tag_spec.rb +5 -5
- data/spec/app/models/mdm/listener_spec.rb +12 -12
- data/spec/app/models/mdm/loot_spec.rb +8 -8
- data/spec/app/models/mdm/module/action_spec.rb +2 -2
- data/spec/app/models/mdm/module/arch_spec.rb +2 -2
- data/spec/app/models/mdm/module/author_spec.rb +3 -3
- data/spec/app/models/mdm/module/detail_spec.rb +71 -71
- data/spec/app/models/mdm/module/mixin_spec.rb +2 -2
- data/spec/app/models/mdm/module/platform_spec.rb +2 -2
- data/spec/app/models/mdm/module/ref_spec.rb +5 -5
- data/spec/app/models/mdm/module/target_spec.rb +2 -2
- data/spec/app/models/mdm/nexpose_console_spec.rb +15 -15
- data/spec/app/models/mdm/note_spec.rb +11 -11
- data/spec/app/models/mdm/ref_spec.rb +6 -6
- data/spec/app/models/mdm/route_spec.rb +3 -3
- data/spec/app/models/mdm/service_spec.rb +20 -20
- data/spec/app/models/mdm/session_event_spec.rb +3 -3
- data/spec/app/models/mdm/session_spec.rb +14 -14
- data/spec/app/models/mdm/tag_spec.rb +12 -12
- data/spec/app/models/mdm/task_cred_spec.rb +6 -6
- data/spec/app/models/mdm/task_host_spec.rb +6 -6
- data/spec/app/models/mdm/task_service_spec.rb +6 -6
- data/spec/app/models/mdm/task_session_spec.rb +6 -6
- data/spec/app/models/mdm/task_spec.rb +3 -3
- data/spec/app/models/mdm/user_spec.rb +3 -3
- data/spec/app/models/mdm/vuln_attempt_spec.rb +4 -4
- data/spec/app/models/mdm/vuln_detail_spec.rb +3 -3
- data/spec/app/models/mdm/vuln_ref_spec.rb +4 -4
- data/spec/app/models/mdm/vuln_spec.rb +20 -20
- data/spec/app/models/mdm/web_form_spec.rb +3 -3
- data/spec/app/models/mdm/web_page_spec.rb +4 -4
- data/spec/app/models/mdm/web_site_spec.rb +15 -15
- data/spec/app/models/mdm/web_vuln_spec.rb +4 -4
- data/spec/app/models/mdm/workspace_spec.rb +25 -25
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +4 -4
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +2 -2
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +3 -3
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +5 -5
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +3 -3
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +4 -8
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +12 -12
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +16 -16
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +3 -3
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/structure.sql +2 -2
- data/spec/factories/mdm/addresses.rb +2 -2
- data/spec/factories/mdm/clients.rb +2 -2
- data/spec/factories/mdm/creds.rb +2 -2
- data/spec/factories/mdm/events.rb +3 -3
- data/spec/factories/mdm/exploit_attempts.rb +2 -2
- data/spec/factories/mdm/exploited_hosts.rb +1 -1
- data/spec/factories/mdm/fingerprints/nessus_fingerprints.rb +2 -2
- data/spec/factories/mdm/fingerprints/nexpose_fingerprints.rb +2 -2
- data/spec/factories/mdm/fingerprints/nmap_fingerprints.rb +2 -2
- data/spec/factories/mdm/fingerprints/retina_fingerprints.rb +2 -2
- data/spec/factories/mdm/fingerprints/session_fingerprints.rb +2 -2
- data/spec/factories/mdm/host_details.rb +2 -2
- data/spec/factories/mdm/host_tags.rb +2 -2
- data/spec/factories/mdm/hosts.rb +2 -2
- data/spec/factories/mdm/listeners.rb +2 -2
- data/spec/factories/mdm/loots.rb +2 -2
- data/spec/factories/mdm/module/actions.rb +2 -2
- data/spec/factories/mdm/module/archs.rb +2 -2
- data/spec/factories/mdm/module/authors.rb +2 -2
- data/spec/factories/mdm/module/details.rb +1 -1
- data/spec/factories/mdm/module/mixins.rb +2 -2
- data/spec/factories/mdm/module/platforms.rb +2 -2
- data/spec/factories/mdm/module/refs.rb +2 -2
- data/spec/factories/mdm/module/targets.rb +2 -2
- data/spec/factories/mdm/nexpose_consoles.rb +2 -2
- data/spec/factories/mdm/notes.rb +2 -2
- data/spec/factories/mdm/refs.rb +2 -2
- data/spec/factories/mdm/routes.rb +2 -2
- data/spec/factories/mdm/services.rb +3 -3
- data/spec/factories/mdm/session_events.rb +1 -1
- data/spec/factories/mdm/sessions.rb +2 -2
- data/spec/factories/mdm/tags.rb +2 -2
- data/spec/factories/mdm/task.rb +2 -2
- data/spec/factories/mdm/task_creds.rb +2 -2
- data/spec/factories/mdm/task_hosts.rb +2 -2
- data/spec/factories/mdm/task_services.rb +2 -2
- data/spec/factories/mdm/task_sessions.rb +2 -2
- data/spec/factories/mdm/users.rb +2 -2
- data/spec/factories/mdm/vuln_attempts.rb +2 -2
- data/spec/factories/mdm/vuln_details.rb +2 -2
- data/spec/factories/mdm/vuln_refs.rb +2 -2
- data/spec/factories/mdm/vulns.rb +2 -2
- data/spec/factories/mdm/web_forms.rb +1 -1
- data/spec/factories/mdm/web_pages.rb +2 -2
- data/spec/factories/mdm/web_sites.rb +2 -2
- data/spec/factories/mdm/web_vulns.rb +2 -2
- data/spec/factories/mdm/workspaces.rb +2 -2
- data/spec/factories/metasploit_data_models/automatic_exploitation/match_results.rb +1 -1
- data/spec/factories/metasploit_data_models/automatic_exploitation/match_sets.rb +2 -2
- data/spec/factories/metasploit_data_models/automatic_exploitation/matches.rb +1 -1
- data/spec/factories/metasploit_data_models/automatic_exploitation/runs.rb +1 -1
- data/spec/factories/module_runs.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +7 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 03b4a325dada926f12b72a8e49fec3c93072210f
|
|
4
|
+
data.tar.gz: 077bff5e070fc282f664c4ccbbbc553f4eb4ff6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 121c9cf293efe9c2fff5ae2db10c5a1559b43e6dbeda0e36260db53cac5fb7555869c8d6a9c4ebcab9bcf0bc7f4b1c69fbcdb90a352fe0a4ed3fe4341d569409
|
|
7
|
+
data.tar.gz: 0ff5b5cd7990f6f1df049f70cd80533f586d0fd3cd487dfc538bd5052430a4395c7fe7d2e04976f2cd5cd2a6e57203a04f707df605e6efc6ac9a98418f23092b
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -15,19 +15,14 @@ group :development, :test do
|
|
|
15
15
|
# Upload coverage reports to coveralls.io
|
|
16
16
|
gem 'coveralls', require: false
|
|
17
17
|
# supplies factories for producing model instance for specs
|
|
18
|
-
# Version 4.1.0 or newer is needed to support generate calls without the '
|
|
19
|
-
gem '
|
|
18
|
+
# Version 4.1.0 or newer is needed to support generate calls without the 'FactoryBot.' in factory definitions syntax.
|
|
19
|
+
gem 'factory_bot'
|
|
20
20
|
# auto-load factories from spec/factories
|
|
21
|
-
gem '
|
|
22
|
-
|
|
21
|
+
gem 'factory_bot_rails'
|
|
23
22
|
|
|
24
23
|
gem 'rails', '~>4.2.6'
|
|
25
24
|
# Used to create fake data
|
|
26
25
|
gem "faker"
|
|
27
|
-
|
|
28
|
-
# bound to 0.20 for Activerecord 4.2.8 deprecation warnings:
|
|
29
|
-
# https://github.com/ged/ruby-pg/commit/c90ac644e861857ae75638eb6954b1cb49617090
|
|
30
|
-
gem 'pg', "0.20.0"
|
|
31
26
|
end
|
|
32
27
|
|
|
33
28
|
group :test do
|
|
@@ -493,7 +493,8 @@ module Mdm::Host::OperatingSystemNormalization
|
|
|
493
493
|
i.each_char do |j|
|
|
494
494
|
begin
|
|
495
495
|
pstr << j.downcase.encode("UTF-8")
|
|
496
|
-
rescue Encoding::UndefinedConversionError
|
|
496
|
+
rescue Encoding::UndefinedConversionError
|
|
497
|
+
# rescue Encoding::UndefinedConversionError => e
|
|
497
498
|
# this works in Framework, but causes a Travis CI error
|
|
498
499
|
# elog("Found incompatible (non-ANSI) character in guess_purpose_from_match")
|
|
499
500
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
require 'rails'
|
|
2
2
|
|
|
3
3
|
# `Rails::Engine` that exposes MetasploitDataModel's `ActiveRecord::Base` subclasses and automatically loads its
|
|
4
|
-
# `
|
|
4
|
+
# `FactoryBot` factories, sequences, and traits.
|
|
5
5
|
class MetasploitDataModels::Engine < Rails::Engine
|
|
6
6
|
# @see http://viget.com/extend/rails-engine-testing-with-rspec-capybara-and-factorygirl
|
|
7
7
|
config.generators do |g|
|
|
8
8
|
g.assets false
|
|
9
|
-
g.fixture_replacement :
|
|
9
|
+
g.fixture_replacement :factory_bot, :dir => 'spec/factories'
|
|
10
10
|
g.helper false
|
|
11
11
|
g.test_framework :rspec, :fixture => false
|
|
12
12
|
end
|
|
@@ -20,13 +20,13 @@ class MetasploitDataModels::Engine < Rails::Engine
|
|
|
20
20
|
path.skip_load_path!
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
initializer 'metasploit_data_models.prepend_factory_path', :after => '
|
|
24
|
-
if defined?
|
|
25
|
-
relative_definition_file_path = config.generators.options[:
|
|
23
|
+
initializer 'metasploit_data_models.prepend_factory_path', :after => 'factory_bot.set_factory_paths' do
|
|
24
|
+
if defined? FactoryBot
|
|
25
|
+
relative_definition_file_path = config.generators.options[:factory_bot][:dir]
|
|
26
26
|
definition_file_path = root.join(relative_definition_file_path)
|
|
27
27
|
|
|
28
28
|
# unshift so that Pro can modify mdm factories
|
|
29
|
-
|
|
29
|
+
FactoryBot.definition_file_paths.unshift definition_file_path
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
|
-
end
|
|
32
|
+
end
|
|
@@ -71,7 +71,9 @@ Gem::Specification.new do |s|
|
|
|
71
71
|
# markdown formatting for yard
|
|
72
72
|
s.add_development_dependency 'redcarpet'
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
# bound to 0.20 for Activerecord 4.2.8 deprecation warnings:
|
|
75
|
+
# https://github.com/ged/ruby-pg/commit/c90ac644e861857ae75638eb6954b1cb49617090
|
|
76
|
+
s.add_runtime_dependency 'pg', "0.20.0"
|
|
75
77
|
|
|
76
78
|
s.platform = Gem::Platform::RUBY
|
|
77
79
|
end
|
|
@@ -8,7 +8,7 @@ RSpec.describe Mdm::Client, type: :model do
|
|
|
8
8
|
|
|
9
9
|
context '#destroy' do
|
|
10
10
|
it 'should successfully destroy the object' do
|
|
11
|
-
client =
|
|
11
|
+
client = FactoryBot.create(:mdm_client, :ua_string => 'user-agent')
|
|
12
12
|
expect {
|
|
13
13
|
client.destroy
|
|
14
14
|
}.to_not raise_error
|
|
@@ -20,7 +20,7 @@ RSpec.describe Mdm::Client, type: :model do
|
|
|
20
20
|
|
|
21
21
|
context 'factory' do
|
|
22
22
|
it 'should be valid' do
|
|
23
|
-
client =
|
|
23
|
+
client = FactoryBot.build(:mdm_client)
|
|
24
24
|
expect(client).to be_valid
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -40,4 +40,4 @@ RSpec.describe Mdm::Client, type: :model do
|
|
|
40
40
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
end
|
|
43
|
+
end
|
|
@@ -27,8 +27,8 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
27
27
|
|
|
28
28
|
context '#destroy' do
|
|
29
29
|
it 'should successfully destroy the object and all dependent objects' do
|
|
30
|
-
cred =
|
|
31
|
-
task_cred =
|
|
30
|
+
cred = FactoryBot.create(:mdm_cred)
|
|
31
|
+
task_cred = FactoryBot.create(:mdm_task_cred, :cred => cred)
|
|
32
32
|
expect {
|
|
33
33
|
cred.destroy
|
|
34
34
|
}.to_not raise_error
|
|
@@ -44,19 +44,19 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
44
44
|
context 'callbacks' do
|
|
45
45
|
context 'after_create' do
|
|
46
46
|
it 'should increment cred_count on the host' do
|
|
47
|
-
host =
|
|
48
|
-
svc =
|
|
47
|
+
host = FactoryBot.create(:mdm_host)
|
|
48
|
+
svc = FactoryBot.create(:mdm_service, :host => host)
|
|
49
49
|
expect {
|
|
50
|
-
|
|
50
|
+
FactoryBot.create(:mdm_cred, :service => svc)
|
|
51
51
|
}.to change{ Mdm::Host.find(host.id).cred_count}.by(1)
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
context 'after_destroy' do
|
|
56
56
|
it 'should decrement cred_count on the host' do
|
|
57
|
-
host =
|
|
58
|
-
svc =
|
|
59
|
-
cred =
|
|
57
|
+
host = FactoryBot.create(:mdm_host)
|
|
58
|
+
svc = FactoryBot.create(:mdm_service, :host => host)
|
|
59
|
+
cred =FactoryBot.create(:mdm_cred, :service => svc)
|
|
60
60
|
expect {
|
|
61
61
|
cred.destroy
|
|
62
62
|
}.to change{ Mdm::Host.find(host.id).cred_count}.by(-1)
|
|
@@ -84,28 +84,28 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
84
84
|
|
|
85
85
|
context 'methods' do
|
|
86
86
|
let(:host) {
|
|
87
|
-
|
|
87
|
+
FactoryBot.create(
|
|
88
88
|
:mdm_host,
|
|
89
89
|
workspace: workspace
|
|
90
90
|
)
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
let(:other_service) {
|
|
94
|
-
|
|
94
|
+
FactoryBot.create(
|
|
95
95
|
:mdm_service,
|
|
96
96
|
host: host
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
let(:service) {
|
|
101
|
-
|
|
101
|
+
FactoryBot.create(
|
|
102
102
|
:mdm_service,
|
|
103
103
|
host: host
|
|
104
104
|
)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
let(:ssh_key) {
|
|
108
|
-
|
|
108
|
+
FactoryBot.create(
|
|
109
109
|
:mdm_cred,
|
|
110
110
|
pass: '/path/to/keyfile',
|
|
111
111
|
proof: "KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a",
|
|
@@ -116,7 +116,7 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
let(:ssh_pubkey) {
|
|
119
|
-
|
|
119
|
+
FactoryBot.create(
|
|
120
120
|
:mdm_cred,
|
|
121
121
|
pass: '/path/to/keyfile',
|
|
122
122
|
proof: "KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a",
|
|
@@ -127,49 +127,49 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
let(:workspace) {
|
|
130
|
-
|
|
130
|
+
FactoryBot.create(:mdm_workspace)
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
context '#ptype_human' do
|
|
134
134
|
it "should return 'read/write password' for 'password_rw'" do
|
|
135
|
-
cred =
|
|
135
|
+
cred = FactoryBot.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_rw')
|
|
136
136
|
expect(cred.ptype_human).to eq('read/write password')
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
it "should return 'read-only password' for 'password_ro'" do
|
|
140
|
-
cred =
|
|
140
|
+
cred = FactoryBot.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_ro')
|
|
141
141
|
expect(cred.ptype_human).to eq('read-only password')
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
it "should return 'SMB Hash' for 'smb_hash'" do
|
|
145
|
-
cred =
|
|
145
|
+
cred = FactoryBot.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'smb_hash')
|
|
146
146
|
expect(cred.ptype_human).to eq('SMB hash')
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
it "should return 'SSH private key' for 'ssh_key'" do
|
|
150
|
-
cred =
|
|
150
|
+
cred = FactoryBot.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'ssh_key')
|
|
151
151
|
expect(cred.ptype_human).to eq('SSH private key')
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
it "should return 'SSH public key' for 'ssh_pubkey'" do
|
|
155
|
-
cred =
|
|
155
|
+
cred = FactoryBot.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'ssh_pubkey')
|
|
156
156
|
expect(cred.ptype_human).to eq('SSH public key')
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
context '#ssh_key_id' do
|
|
161
161
|
it 'should return nil if not an ssh_key' do
|
|
162
|
-
cred =
|
|
162
|
+
cred = FactoryBot.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_rw')
|
|
163
163
|
expect(cred.ssh_key_id).to eq(nil)
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
it 'should return nil if proof does not contain the key id' do
|
|
167
|
-
cred =
|
|
167
|
+
cred = FactoryBot.build(:mdm_cred, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_key', :proof => "no key here")
|
|
168
168
|
expect(cred.ssh_key_id).to eq(nil)
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
it 'should return the key id for an ssh_key' do
|
|
172
|
-
cred =
|
|
172
|
+
cred = FactoryBot.build(:mdm_cred, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_key', :proof => "KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a")
|
|
173
173
|
expect(cred.ssh_key_id).to eq('57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a')
|
|
174
174
|
end
|
|
175
175
|
|
|
@@ -177,7 +177,7 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
177
177
|
|
|
178
178
|
context '#ssh_key_matches?' do
|
|
179
179
|
it 'should return true if the ssh_keys match' do
|
|
180
|
-
other_ssh_key =
|
|
180
|
+
other_ssh_key = FactoryBot.create(
|
|
181
181
|
:mdm_cred,
|
|
182
182
|
pass: '/path/to/keyfile',
|
|
183
183
|
proof: 'KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a',
|
|
@@ -194,7 +194,7 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
it 'should return false if the ptypes do not match' do
|
|
197
|
-
different_ptype =
|
|
197
|
+
different_ptype = FactoryBot.create(
|
|
198
198
|
:mdm_cred,
|
|
199
199
|
pass: '/path/to/keyfile',
|
|
200
200
|
proof: 'KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a',
|
|
@@ -207,7 +207,7 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
207
207
|
end
|
|
208
208
|
|
|
209
209
|
it 'should return false if the key ids do not match' do
|
|
210
|
-
different_proof =
|
|
210
|
+
different_proof = FactoryBot.create(
|
|
211
211
|
:mdm_cred,
|
|
212
212
|
pass: '/path/to/keyfile',
|
|
213
213
|
proof: 'KEY=66:d4:22:6e:88:d6:74:A1:44:3e:d6:d5:AA:89:73:8b',
|
|
@@ -220,15 +220,15 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
220
220
|
end
|
|
221
221
|
|
|
222
222
|
it 'should behave the same for public keys as private keys' do
|
|
223
|
-
pubkey2 =
|
|
224
|
-
pubkey3 =
|
|
223
|
+
pubkey2 = FactoryBot.create(:mdm_cred, :service => service, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_pubkey', :proof => "KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a")
|
|
224
|
+
pubkey3 = FactoryBot.create(:mdm_cred, :service => service, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_pubkey', :proof => "KEY=66:d4:22:6e:88:d6:74:A1:44:3e:d6:d5:AA:89:73:8b")
|
|
225
225
|
expect(pubkey2.ssh_key_matches?(ssh_pubkey)).to eq(true)
|
|
226
226
|
expect(pubkey2.ssh_key_matches?(pubkey3)).to eq(false)
|
|
227
227
|
end
|
|
228
228
|
|
|
229
229
|
it 'should always return false for non ssh key creds' do
|
|
230
|
-
cred2 =
|
|
231
|
-
cred3 =
|
|
230
|
+
cred2 = FactoryBot.create(:mdm_cred, :service => other_service, :ptype => 'password', :user => 'msfadmin', :pass => 'msfadmin' )
|
|
231
|
+
cred3 = FactoryBot.create(:mdm_cred, :service => other_service, :ptype => 'password', :user => 'msfadmin', :pass => 'msfadmin' )
|
|
232
232
|
expect(cred2.ssh_key_matches?(cred3)).to eq(false)
|
|
233
233
|
end
|
|
234
234
|
end
|
|
@@ -239,7 +239,7 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
239
239
|
#
|
|
240
240
|
|
|
241
241
|
let(:other_ssh_key) {
|
|
242
|
-
|
|
242
|
+
FactoryBot.create(
|
|
243
243
|
:mdm_cred,
|
|
244
244
|
pass: '/path/to/keyfile',
|
|
245
245
|
proof: 'KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a',
|
|
@@ -273,7 +273,7 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
273
273
|
#
|
|
274
274
|
|
|
275
275
|
let(:other_ssh_key) {
|
|
276
|
-
|
|
276
|
+
FactoryBot.create(
|
|
277
277
|
:mdm_cred,
|
|
278
278
|
pass: '/path/to/keyfile',
|
|
279
279
|
proof: 'KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a',
|
|
@@ -307,7 +307,7 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
307
307
|
#
|
|
308
308
|
|
|
309
309
|
let(:other_ssh_key) {
|
|
310
|
-
|
|
310
|
+
FactoryBot.create(
|
|
311
311
|
:mdm_cred,
|
|
312
312
|
pass: '/path/to/keyfile',
|
|
313
313
|
proof: 'KEY=57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a',
|
|
@@ -338,9 +338,9 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
338
338
|
|
|
339
339
|
context 'factory' do
|
|
340
340
|
it 'should be valid' do
|
|
341
|
-
cred =
|
|
341
|
+
cred = FactoryBot.build(:mdm_cred)
|
|
342
342
|
expect(cred).to be_valid
|
|
343
343
|
end
|
|
344
344
|
end
|
|
345
345
|
|
|
346
|
-
end
|
|
346
|
+
end
|
|
@@ -25,7 +25,7 @@ RSpec.describe Mdm::Event, type: :model do
|
|
|
25
25
|
|
|
26
26
|
context '#destroy' do
|
|
27
27
|
it 'should successfully destroy the object and all dependent objects' do
|
|
28
|
-
event =
|
|
28
|
+
event = FactoryBot.create(:mdm_event)
|
|
29
29
|
expect {
|
|
30
30
|
event.destroy
|
|
31
31
|
}.to_not raise_error
|
|
@@ -38,9 +38,9 @@ RSpec.describe Mdm::Event, type: :model do
|
|
|
38
38
|
|
|
39
39
|
context 'scopes' do
|
|
40
40
|
context 'flagged' do
|
|
41
|
-
let(:workspace) {
|
|
42
|
-
let(:flagged_event) {
|
|
43
|
-
let(:non_critical_event) {
|
|
41
|
+
let(:workspace) {FactoryBot.create(:mdm_workspace)}
|
|
42
|
+
let(:flagged_event) { FactoryBot.create(:mdm_event, :workspace => workspace, :name => 'flagme', :critical => true, :seen => false) }
|
|
43
|
+
let(:non_critical_event) { FactoryBot.create(:mdm_event, :workspace => workspace, :name => 'dontflagmebro', :critical => false, :seen => false) }
|
|
44
44
|
|
|
45
45
|
before(:example) do
|
|
46
46
|
flagged_event
|
|
@@ -63,8 +63,8 @@ RSpec.describe Mdm::Event, type: :model do
|
|
|
63
63
|
|
|
64
64
|
context 'module_run' do
|
|
65
65
|
it 'should only return module_run events' do
|
|
66
|
-
flagged_event =
|
|
67
|
-
non_critical_event =
|
|
66
|
+
flagged_event = FactoryBot.create(:mdm_event, :name => 'module_run')
|
|
67
|
+
non_critical_event = FactoryBot.create(:mdm_event, :name => 'dontflagmebro')
|
|
68
68
|
flagged_set = Mdm::Event.module_run
|
|
69
69
|
expect(flagged_set).to include(flagged_event)
|
|
70
70
|
expect(flagged_set).not_to include(non_critical_event)
|
|
@@ -74,7 +74,7 @@ RSpec.describe Mdm::Event, type: :model do
|
|
|
74
74
|
|
|
75
75
|
context 'validations' do
|
|
76
76
|
it 'should require name' do
|
|
77
|
-
unnamed_event =
|
|
77
|
+
unnamed_event = FactoryBot.build(:mdm_event, :name => nil)
|
|
78
78
|
expect(unnamed_event).not_to be_valid
|
|
79
79
|
expect(unnamed_event.errors[:name]).to include("can't be blank")
|
|
80
80
|
end
|
|
@@ -82,9 +82,9 @@ RSpec.describe Mdm::Event, type: :model do
|
|
|
82
82
|
|
|
83
83
|
context 'factory' do
|
|
84
84
|
it 'should be valid' do
|
|
85
|
-
event =
|
|
85
|
+
event = FactoryBot.build(:mdm_event)
|
|
86
86
|
expect(event).to be_valid
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
end
|
|
90
|
+
end
|
|
@@ -29,7 +29,7 @@ RSpec.describe Mdm::ExploitAttempt, type: :model do
|
|
|
29
29
|
|
|
30
30
|
context '#destroy' do
|
|
31
31
|
it 'should successfully destroy the object and all dependent objects' do
|
|
32
|
-
exploit_attempt =
|
|
32
|
+
exploit_attempt = FactoryBot.create(:mdm_exploit_attempt)
|
|
33
33
|
expect {
|
|
34
34
|
exploit_attempt.destroy
|
|
35
35
|
}.to_not raise_error
|
|
@@ -42,18 +42,18 @@ RSpec.describe Mdm::ExploitAttempt, type: :model do
|
|
|
42
42
|
|
|
43
43
|
context 'validations' do
|
|
44
44
|
it 'should only be valid with a host_id' do
|
|
45
|
-
orphaned_attempt =
|
|
45
|
+
orphaned_attempt = FactoryBot.build(:mdm_exploit_attempt, :host => nil)
|
|
46
46
|
expect(orphaned_attempt).not_to be_valid
|
|
47
47
|
expect(orphaned_attempt.errors[:host_id]).to include("can't be blank")
|
|
48
|
-
propper_attempt =
|
|
48
|
+
propper_attempt = FactoryBot.build(:mdm_exploit_attempt)
|
|
49
49
|
expect(propper_attempt).to be_valid
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
context 'factory' do
|
|
54
54
|
it 'should be valid' do
|
|
55
|
-
exploit_attempt =
|
|
55
|
+
exploit_attempt = FactoryBot.build(:mdm_exploit_attempt)
|
|
56
56
|
expect(exploit_attempt).to be_valid
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
|
-
end
|
|
59
|
+
end
|
|
@@ -24,7 +24,7 @@ RSpec.describe Mdm::ExploitedHost, type: :model do
|
|
|
24
24
|
|
|
25
25
|
context '#destroy' do
|
|
26
26
|
it 'should successfully destroy the object and all dependent objects' do
|
|
27
|
-
exploited_host =
|
|
27
|
+
exploited_host = FactoryBot.create(:mdm_exploited_host)
|
|
28
28
|
expect {
|
|
29
29
|
exploited_host.destroy
|
|
30
30
|
}.to_not raise_error
|
|
@@ -36,9 +36,9 @@ RSpec.describe Mdm::ExploitedHost, type: :model do
|
|
|
36
36
|
|
|
37
37
|
context 'factory' do
|
|
38
38
|
it 'should be valid' do
|
|
39
|
-
exploited_host =
|
|
39
|
+
exploited_host = FactoryBot.build(:mdm_exploited_host)
|
|
40
40
|
expect(exploited_host).to be_valid
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
end
|
|
44
|
+
end
|
|
@@ -20,7 +20,7 @@ RSpec.describe Mdm::HostDetail, type: :model do
|
|
|
20
20
|
|
|
21
21
|
context 'validations' do
|
|
22
22
|
it 'should only be valid with a host_id' do
|
|
23
|
-
orphan_detail =
|
|
23
|
+
orphan_detail = FactoryBot.build(:mdm_host_detail, :host => nil)
|
|
24
24
|
expect(orphan_detail).not_to be_valid
|
|
25
25
|
expect(orphan_detail.errors[:host_id]).to include("can't be blank")
|
|
26
26
|
end
|
|
@@ -28,14 +28,14 @@ RSpec.describe Mdm::HostDetail, type: :model do
|
|
|
28
28
|
|
|
29
29
|
context 'factory' do
|
|
30
30
|
it 'should be valid' do
|
|
31
|
-
host_detail =
|
|
31
|
+
host_detail = FactoryBot.build(:mdm_host_detail)
|
|
32
32
|
expect(host_detail).to be_valid
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
context '#destroy' do
|
|
37
37
|
it 'should successfully destroy the object' do
|
|
38
|
-
detail =
|
|
38
|
+
detail = FactoryBot.create(:mdm_host_detail)
|
|
39
39
|
expect{
|
|
40
40
|
detail.destroy
|
|
41
41
|
}.to_not raise_error
|
|
@@ -45,4 +45,4 @@ RSpec.describe Mdm::HostDetail, type: :model do
|
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
end
|
|
48
|
+
end
|