metasploit_data_models 2.0.17 → 3.0.0
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/.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
@@ -1,16 +1,16 @@
|
|
1
1
|
RSpec.describe Mdm::Vuln, type: :model do
|
2
2
|
subject(:vuln) do
|
3
|
-
|
3
|
+
FactoryBot.build(:mdm_vuln)
|
4
4
|
end
|
5
5
|
|
6
6
|
it_should_behave_like 'Metasploit::Concern.run'
|
7
7
|
|
8
8
|
context '#destroy' do
|
9
9
|
it 'should successfully destroy the object and dependent objects' do
|
10
|
-
vuln =
|
11
|
-
vuln_attempt =
|
12
|
-
vuln_detail =
|
13
|
-
vuln_ref =
|
10
|
+
vuln = FactoryBot.create(:mdm_vuln)
|
11
|
+
vuln_attempt = FactoryBot.create(:mdm_vuln_attempt, :vuln => vuln)
|
12
|
+
vuln_detail = FactoryBot.create(:mdm_vuln_detail, :vuln => vuln)
|
13
|
+
vuln_ref = FactoryBot.create(:mdm_vuln_ref, :vuln => vuln)
|
14
14
|
expect {
|
15
15
|
vuln.destroy
|
16
16
|
}.to_not raise_error
|
@@ -49,20 +49,20 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
49
49
|
context 'with Mdm::Refs' do
|
50
50
|
let(:names) do
|
51
51
|
2.times.collect {
|
52
|
-
|
52
|
+
FactoryBot.generate :mdm_ref_name
|
53
53
|
}
|
54
54
|
end
|
55
55
|
|
56
56
|
let!(:refs) do
|
57
57
|
names.collect do |name|
|
58
|
-
|
58
|
+
FactoryBot.create(:mdm_ref, :name => name)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
context 'with Mdm::VulnRefs' do
|
63
63
|
let!(:vuln_refs) do
|
64
64
|
refs.collect { |ref|
|
65
|
-
|
65
|
+
FactoryBot.create(:mdm_vuln_ref, :ref => ref, :vuln => vuln)
|
66
66
|
}
|
67
67
|
end
|
68
68
|
|
@@ -74,7 +74,7 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
74
74
|
|
75
75
|
context 'with Mdm::Module::Detail' do
|
76
76
|
let!(:module_detail) do
|
77
|
-
|
77
|
+
FactoryBot.create(
|
78
78
|
:mdm_module_detail
|
79
79
|
)
|
80
80
|
end
|
@@ -82,7 +82,7 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
82
82
|
context 'with Mdm::Module::Refs with same names as Mdm::Refs' do
|
83
83
|
let!(:module_refs) do
|
84
84
|
names.each do |name|
|
85
|
-
|
85
|
+
FactoryBot.create(
|
86
86
|
:mdm_module_ref,
|
87
87
|
:detail => module_detail,
|
88
88
|
:name => name
|
@@ -149,7 +149,7 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
149
149
|
context 'factories' do
|
150
150
|
context 'mdm_host_vuln' do
|
151
151
|
subject(:mdm_host_vuln) do
|
152
|
-
|
152
|
+
FactoryBot.build(:mdm_host_vuln)
|
153
153
|
end
|
154
154
|
|
155
155
|
it { is_expected.to be_valid }
|
@@ -157,7 +157,7 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
157
157
|
|
158
158
|
context 'mdm_service_vuln' do
|
159
159
|
subject(:mdm_service_vuln) do
|
160
|
-
|
160
|
+
FactoryBot.build(:mdm_service_vuln)
|
161
161
|
end
|
162
162
|
|
163
163
|
it { is_expected.to be_valid }
|
@@ -165,7 +165,7 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
165
165
|
|
166
166
|
context 'mdm_vuln' do
|
167
167
|
subject(:mdm_vuln) do
|
168
|
-
|
168
|
+
FactoryBot.build(:mdm_vuln)
|
169
169
|
end
|
170
170
|
|
171
171
|
it { is_expected.to be_valid }
|
@@ -180,17 +180,17 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
let!(:vuln) do
|
183
|
-
|
183
|
+
FactoryBot.create(:mdm_vuln)
|
184
184
|
end
|
185
185
|
|
186
186
|
context 'with Mdm::Ref' do
|
187
187
|
let!(:ref) do
|
188
|
-
|
188
|
+
FactoryBot.create(:mdm_ref)
|
189
189
|
end
|
190
190
|
|
191
191
|
context 'with Mdm::VulnRef' do
|
192
192
|
let!(:vuln_ref) do
|
193
|
-
|
193
|
+
FactoryBot.create(:mdm_vuln_ref, :ref => ref, :vuln => vuln)
|
194
194
|
end
|
195
195
|
|
196
196
|
context 'with query matching Mdm::Ref#name' do
|
@@ -259,7 +259,7 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
259
259
|
|
260
260
|
context 'with Mdm::Host' do
|
261
261
|
context 'with query matching Mdm::Host address' do
|
262
|
-
let(:vuln_with_host) {
|
262
|
+
let(:vuln_with_host) { FactoryBot.create(:mdm_vuln, :host)}
|
263
263
|
let(:query) { vuln_with_host.host.address}
|
264
264
|
|
265
265
|
it 'should match Mdm::Vuln' do
|
@@ -268,7 +268,7 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
268
268
|
end
|
269
269
|
|
270
270
|
context 'with query matching Mdm::Host name' do
|
271
|
-
let(:vuln_with_host) {
|
271
|
+
let(:vuln_with_host) { FactoryBot.create(:mdm_vuln, :host)}
|
272
272
|
let(:query) { vuln_with_host.host.name}
|
273
273
|
|
274
274
|
it 'should match Mdm::Vuln' do
|
@@ -285,7 +285,7 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
285
285
|
|
286
286
|
context "invalid" do
|
287
287
|
let(:mdm_vuln) do
|
288
|
-
|
288
|
+
FactoryBot.build(:mdm_vuln)
|
289
289
|
end
|
290
290
|
|
291
291
|
it "should not allow :name over 255 characters" do
|
@@ -296,4 +296,4 @@ RSpec.describe Mdm::Vuln, type: :model do
|
|
296
296
|
end
|
297
297
|
end
|
298
298
|
end
|
299
|
-
end
|
299
|
+
end
|
@@ -27,14 +27,14 @@ RSpec.describe Mdm::WebForm, type: :model do
|
|
27
27
|
|
28
28
|
context 'factory' do
|
29
29
|
it 'should be valid' do
|
30
|
-
web_form =
|
30
|
+
web_form = FactoryBot.build(:mdm_web_form)
|
31
31
|
expect(web_form).to be_valid
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
context '#destroy' do
|
36
36
|
it 'should successfully destroy the object' do
|
37
|
-
web_form =
|
37
|
+
web_form = FactoryBot.create(:mdm_web_form)
|
38
38
|
expect {
|
39
39
|
web_form.destroy
|
40
40
|
}.to_not raise_error
|
@@ -43,4 +43,4 @@ RSpec.describe Mdm::WebForm, type: :model do
|
|
43
43
|
}.to raise_error(ActiveRecord::RecordNotFound)
|
44
44
|
end
|
45
45
|
end
|
46
|
-
end
|
46
|
+
end
|
@@ -7,7 +7,7 @@ RSpec.describe Mdm::WebPage, type: :model do
|
|
7
7
|
|
8
8
|
context 'serialized attributes' do
|
9
9
|
context 'cookie' do
|
10
|
-
let(:web_page) {
|
10
|
+
let(:web_page) { FactoryBot.create(:mdm_web_page, cookie: cookie) }
|
11
11
|
|
12
12
|
context 'with string cookie' do
|
13
13
|
let(:cookie) { "test_name=test_value" }
|
@@ -82,14 +82,14 @@ RSpec.describe Mdm::WebPage, type: :model do
|
|
82
82
|
|
83
83
|
context 'factory' do
|
84
84
|
it 'should be valid' do
|
85
|
-
web_page =
|
85
|
+
web_page = FactoryBot.build(:mdm_web_page)
|
86
86
|
expect(web_page).to be_valid
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
context '#destroy' do
|
91
91
|
it 'should successfully destroy the object' do
|
92
|
-
web_page =
|
92
|
+
web_page = FactoryBot.create(:mdm_web_page)
|
93
93
|
expect {
|
94
94
|
web_page.destroy
|
95
95
|
}.to_not raise_error
|
@@ -98,4 +98,4 @@ RSpec.describe Mdm::WebPage, type: :model do
|
|
98
98
|
}.to raise_error(ActiveRecord::RecordNotFound)
|
99
99
|
end
|
100
100
|
end
|
101
|
-
end
|
101
|
+
end
|
@@ -3,7 +3,7 @@ RSpec.describe Mdm::WebSite, type: :model do
|
|
3
3
|
|
4
4
|
context 'factory' do
|
5
5
|
it 'should be valid' do
|
6
|
-
web_site =
|
6
|
+
web_site = FactoryBot.build(:mdm_web_site)
|
7
7
|
expect(web_site).to be_valid
|
8
8
|
end
|
9
9
|
end
|
@@ -31,7 +31,7 @@ RSpec.describe Mdm::WebSite, type: :model do
|
|
31
31
|
|
32
32
|
context '#destroy' do
|
33
33
|
it 'should successfully destroy the object' do
|
34
|
-
web_site =
|
34
|
+
web_site = FactoryBot.create(:mdm_web_site)
|
35
35
|
expect {
|
36
36
|
web_site.destroy
|
37
37
|
}.to_not raise_error
|
@@ -51,35 +51,35 @@ RSpec.describe Mdm::WebSite, type: :model do
|
|
51
51
|
context 'methods' do
|
52
52
|
context '#form_count' do
|
53
53
|
it 'should return an accurate count of associated Webforms' do
|
54
|
-
mysite =
|
55
|
-
|
56
|
-
|
54
|
+
mysite = FactoryBot.create(:mdm_web_site)
|
55
|
+
FactoryBot.create(:mdm_web_form, :web_site => mysite)
|
56
|
+
FactoryBot.create(:mdm_web_form, :web_site => mysite)
|
57
57
|
expect(mysite.form_count).to eq(2)
|
58
|
-
|
58
|
+
FactoryBot.create(:mdm_web_form, :web_site => mysite)
|
59
59
|
expect(mysite.form_count).to eq(3)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
context '#page_count' do
|
64
64
|
it 'should return an accurate count of associated Webpages' do
|
65
|
-
mysite =
|
66
|
-
|
67
|
-
|
65
|
+
mysite = FactoryBot.create(:mdm_web_site)
|
66
|
+
FactoryBot.create(:mdm_web_page, :web_site => mysite)
|
67
|
+
FactoryBot.create(:mdm_web_page, :web_site => mysite)
|
68
68
|
expect(mysite.page_count).to eq(2)
|
69
|
-
|
69
|
+
FactoryBot.create(:mdm_web_page, :web_site => mysite)
|
70
70
|
expect(mysite.page_count).to eq(3)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
context '#vuln_count' do
|
75
75
|
it 'should return an accurate count of associated Webvulns' do
|
76
|
-
mysite =
|
77
|
-
|
78
|
-
|
76
|
+
mysite = FactoryBot.create(:mdm_web_site)
|
77
|
+
FactoryBot.create(:mdm_web_vuln, :web_site => mysite)
|
78
|
+
FactoryBot.create(:mdm_web_vuln, :web_site => mysite)
|
79
79
|
expect(mysite.vuln_count).to eq(2)
|
80
|
-
|
80
|
+
FactoryBot.create(:mdm_web_vuln, :web_site => mysite)
|
81
81
|
expect(mysite.vuln_count).to eq(3)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
|
-
end
|
85
|
+
end
|
@@ -46,7 +46,7 @@ RSpec.describe Mdm::WebVuln, type: :model do
|
|
46
46
|
|
47
47
|
context '#destroy' do
|
48
48
|
it 'should successfully destroy the object' do
|
49
|
-
web_vuln =
|
49
|
+
web_vuln = FactoryBot.create(:mdm_web_vuln)
|
50
50
|
expect {
|
51
51
|
web_vuln.destroy
|
52
52
|
}.to_not raise_error
|
@@ -91,7 +91,7 @@ RSpec.describe Mdm::WebVuln, type: :model do
|
|
91
91
|
context 'factories' do
|
92
92
|
context 'mdm_web_vuln' do
|
93
93
|
subject(:mdm_web_vuln) do
|
94
|
-
|
94
|
+
FactoryBot.build(:mdm_web_vuln)
|
95
95
|
end
|
96
96
|
|
97
97
|
it { is_expected.to be_valid }
|
@@ -302,11 +302,11 @@ RSpec.describe Mdm::WebVuln, type: :model do
|
|
302
302
|
end
|
303
303
|
|
304
304
|
it 'should return default if set to nil and saved' do
|
305
|
-
web_vuln =
|
305
|
+
web_vuln = FactoryBot.build(:mdm_web_vuln)
|
306
306
|
web_vuln.params = nil
|
307
307
|
web_vuln.save!
|
308
308
|
|
309
309
|
expect(web_vuln.params).to eq(default)
|
310
310
|
end
|
311
311
|
end
|
312
|
-
end
|
312
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
RSpec.describe Mdm::Workspace, type: :model do
|
2
2
|
subject(:workspace) do
|
3
|
-
|
3
|
+
FactoryBot.build(:mdm_workspace)
|
4
4
|
end
|
5
5
|
|
6
6
|
let(:default) do
|
@@ -11,16 +11,16 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
11
11
|
|
12
12
|
context 'factory' do
|
13
13
|
it 'should be valid' do
|
14
|
-
workspace =
|
14
|
+
workspace = FactoryBot.build(:mdm_workspace)
|
15
15
|
expect(workspace).to be_valid
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context '#destroy' do
|
20
20
|
it 'should successfully destroy the object and dependent objects' do
|
21
|
-
workspace =
|
22
|
-
listener =
|
23
|
-
task =
|
21
|
+
workspace = FactoryBot.create(:mdm_workspace)
|
22
|
+
listener = FactoryBot.create(:mdm_listener, :workspace => workspace)
|
23
|
+
task = FactoryBot.create(:mdm_task, :workspace => workspace)
|
24
24
|
|
25
25
|
expect {
|
26
26
|
workspace.destroy
|
@@ -98,38 +98,38 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
98
98
|
|
99
99
|
context 'methods' do
|
100
100
|
let(:hosts) do
|
101
|
-
|
101
|
+
FactoryBot.create_list(:mdm_host, 2, :workspace => workspace)
|
102
102
|
end
|
103
103
|
|
104
104
|
let(:other_hosts) do
|
105
|
-
|
105
|
+
FactoryBot.create_list(:mdm_host, 2, :workspace => other_workspace)
|
106
106
|
end
|
107
107
|
|
108
108
|
let(:other_services) do
|
109
109
|
other_hosts.collect do |host|
|
110
|
-
|
110
|
+
FactoryBot.create(:mdm_service, :host => host)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
let(:other_web_sites) do
|
115
115
|
other_services.collect { |service|
|
116
|
-
|
116
|
+
FactoryBot.create(:mdm_web_site, :service => service)
|
117
117
|
}
|
118
118
|
end
|
119
119
|
|
120
120
|
let(:other_workspace) do
|
121
|
-
|
121
|
+
FactoryBot.create(:mdm_workspace)
|
122
122
|
end
|
123
123
|
|
124
124
|
let(:services) do
|
125
125
|
hosts.collect do |host|
|
126
|
-
|
126
|
+
FactoryBot.create(:mdm_service, :host => host)
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
let(:web_sites) do
|
131
131
|
services.collect { |service|
|
132
|
-
|
132
|
+
FactoryBot.create(:mdm_web_site, :service => service)
|
133
133
|
}
|
134
134
|
end
|
135
135
|
|
@@ -140,13 +140,13 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
140
140
|
|
141
141
|
let!(:creds) do
|
142
142
|
services.collect do |service|
|
143
|
-
|
143
|
+
FactoryBot.create(:mdm_cred, :service => service)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
147
|
let!(:other_creds) do
|
148
148
|
other_services.collect do |service|
|
149
|
-
|
149
|
+
FactoryBot.create(:mdm_cred, :service => service)
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
@@ -183,7 +183,7 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
183
183
|
context 'default' do
|
184
184
|
context 'with default workspace' do
|
185
185
|
before(:example) do
|
186
|
-
|
186
|
+
FactoryBot.create(
|
187
187
|
:mdm_workspace,
|
188
188
|
:name => default
|
189
189
|
)
|
@@ -233,7 +233,7 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
233
233
|
|
234
234
|
context '#each_cred' do
|
235
235
|
it 'should pass each of the #creds to the block' do
|
236
|
-
creds =
|
236
|
+
creds = FactoryBot.create_list(:mdm_cred, 2)
|
237
237
|
allow(workspace).to receive(:creds).and_return(creds)
|
238
238
|
|
239
239
|
expect { |block|
|
@@ -244,7 +244,7 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
244
244
|
|
245
245
|
context '#each_host_tag' do
|
246
246
|
it 'should pass each of the #host_tags to the block' do
|
247
|
-
tags =
|
247
|
+
tags = FactoryBot.create_list(:mdm_tag, 2)
|
248
248
|
expect(workspace).to receive(:host_tags).and_return(tags)
|
249
249
|
|
250
250
|
expect { |block|
|
@@ -263,14 +263,14 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
263
263
|
#
|
264
264
|
|
265
265
|
let(:other_tags) do
|
266
|
-
|
266
|
+
FactoryBot.create_list(
|
267
267
|
:mdm_tag,
|
268
268
|
2
|
269
269
|
)
|
270
270
|
end
|
271
271
|
|
272
272
|
let(:tags) do
|
273
|
-
|
273
|
+
FactoryBot.create_list(
|
274
274
|
:mdm_tag,
|
275
275
|
2
|
276
276
|
)
|
@@ -284,7 +284,7 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
284
284
|
host_tags = []
|
285
285
|
|
286
286
|
hosts.zip(tags) do |host, tag|
|
287
|
-
host_tag =
|
287
|
+
host_tag = FactoryBot.create(:mdm_host_tag, :host => host, :tag => tag)
|
288
288
|
|
289
289
|
host_tags << host_tag
|
290
290
|
end
|
@@ -296,7 +296,7 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
296
296
|
host_tags = []
|
297
297
|
|
298
298
|
other_hosts.zip(other_tags) do |host, tag|
|
299
|
-
host_tag =
|
299
|
+
host_tag = FactoryBot.create(:mdm_host_tag, :host => host, :tag => tag)
|
300
300
|
|
301
301
|
host_tags << host_tag
|
302
302
|
end
|
@@ -371,13 +371,13 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
371
371
|
|
372
372
|
let!(:other_web_forms) do
|
373
373
|
other_web_sites.collect { |web_site|
|
374
|
-
|
374
|
+
FactoryBot.create(:web_form, :web_site => web_site)
|
375
375
|
}
|
376
376
|
end
|
377
377
|
|
378
378
|
let!(:web_forms) do
|
379
379
|
web_sites.collect { |web_site|
|
380
|
-
|
380
|
+
FactoryBot.create(:web_form, :web_site => web_site)
|
381
381
|
}
|
382
382
|
end
|
383
383
|
|
@@ -443,13 +443,13 @@ RSpec.describe Mdm::Workspace, type: :model do
|
|
443
443
|
|
444
444
|
let!(:other_web_vulns) do
|
445
445
|
other_web_sites.collect { |web_site|
|
446
|
-
|
446
|
+
FactoryBot.create(:mdm_web_vuln, :web_site => web_site)
|
447
447
|
}
|
448
448
|
end
|
449
449
|
|
450
450
|
let!(:web_vulns) do
|
451
451
|
web_sites.collect { |web_site|
|
452
|
-
|
452
|
+
FactoryBot.create(:mdm_web_vuln, :web_site => web_site)
|
453
453
|
}
|
454
454
|
end
|
455
455
|
|
@@ -15,9 +15,9 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::MatchResult, type: :
|
|
15
15
|
|
16
16
|
context 'scopes' do
|
17
17
|
before do
|
18
|
-
match_failed =
|
19
|
-
match_succeeded =
|
20
|
-
run =
|
18
|
+
match_failed = FactoryBot.create(:automatic_exploitation_match)
|
19
|
+
match_succeeded = FactoryBot.create(:automatic_exploitation_match)
|
20
|
+
run = FactoryBot.create(:automatic_exploitation_run)
|
21
21
|
|
22
22
|
described_class.create do |match_result|
|
23
23
|
match_result.match = match_failed
|
@@ -58,7 +58,7 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::MatchResult, type: :
|
|
58
58
|
context 'validations' do
|
59
59
|
context 'state' do
|
60
60
|
subject(:match_result) do
|
61
|
-
|
61
|
+
FactoryBot.build(:automatic_exploitation_match_result, state: state)
|
62
62
|
end
|
63
63
|
context 'with nil' do
|
64
64
|
let(:state) { nil }
|
@@ -23,7 +23,7 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::MatchSet, type: :mod
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "validations" do
|
26
|
-
subject(:match_set){
|
26
|
+
subject(:match_set){ FactoryBot.build(:automatic_exploitation_match_set)}
|
27
27
|
|
28
28
|
describe "missing user" do
|
29
29
|
before(:example) do
|
@@ -43,4 +43,4 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::MatchSet, type: :mod
|
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
-
end
|
46
|
+
end
|
@@ -3,8 +3,8 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::Match, type: :model
|
|
3
3
|
|
4
4
|
describe "associations" do
|
5
5
|
describe "connecting to a Mdm::Module::Detail" do
|
6
|
-
let(:vuln){
|
7
|
-
let(:module_detail){
|
6
|
+
let(:vuln){ FactoryBot.create(:mdm_vuln) }
|
7
|
+
let(:module_detail){FactoryBot.create(:mdm_module_detail)}
|
8
8
|
|
9
9
|
subject(:automatic_exploitation_match){ described_class.new }
|
10
10
|
|
@@ -20,7 +20,7 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::Match, type: :model
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "deleting the associated Mdm::Module::Detail" do
|
23
|
-
subject(:automatic_exploitation_match){
|
23
|
+
subject(:automatic_exploitation_match){ FactoryBot.create(:automatic_exploitation_match) }
|
24
24
|
let(:match_id){ automatic_exploitation_match.id }
|
25
25
|
|
26
26
|
before(:example) do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
RSpec.describe MetasploitDataModels::AutomaticExploitation::Run, type: :model do
|
2
|
-
subject(:run) {
|
2
|
+
subject(:run) { FactoryBot.create(:automatic_exploitation_run) }
|
3
3
|
|
4
4
|
|
5
5
|
describe "database" do
|
@@ -23,10 +23,10 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::Run, type: :model do
|
|
23
23
|
describe "destroying" do
|
24
24
|
describe "associated MatchResults" do
|
25
25
|
before(:example) do
|
26
|
-
match_set =
|
27
|
-
match =
|
26
|
+
match_set = FactoryBot.create(:automatic_exploitation_match_set)
|
27
|
+
match = FactoryBot.create(:automatic_exploitation_match, match_set: match_set)
|
28
28
|
run.match_set = match_set
|
29
|
-
|
29
|
+
FactoryBot.create(:automatic_exploitation_match_result, match: match, run: run)
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'should happen when you delete the Run' do
|
@@ -35,4 +35,4 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::Run, type: :model do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
|
2
2
|
|
3
|
-
subject(:module_run){
|
3
|
+
subject(:module_run){FactoryBot.build(:metasploit_data_models_module_run)}
|
4
4
|
|
5
5
|
context "database columns" do
|
6
6
|
it { is_expected.to have_db_column(:attempted_at).of_type(:datetime) }
|
@@ -34,7 +34,7 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
|
|
34
34
|
context "validations" do
|
35
35
|
describe "when a target_session is set on the module run" do
|
36
36
|
before(:example) do
|
37
|
-
module_run.target_session =
|
37
|
+
module_run.target_session = FactoryBot.build(:mdm_session)
|
38
38
|
end
|
39
39
|
|
40
40
|
context "when the module is an exploit" do
|
@@ -58,7 +58,7 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
|
|
58
58
|
|
59
59
|
describe "when a spawned_session is set on the module run" do
|
60
60
|
before(:example) do
|
61
|
-
module_run.spawned_session =
|
61
|
+
module_run.spawned_session = FactoryBot.build(:mdm_session)
|
62
62
|
end
|
63
63
|
|
64
64
|
context "when the module is not an exploit" do
|
@@ -101,7 +101,7 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Includes, type: :model do
|
|
101
101
|
|
102
102
|
context 'with Metasploit::Model::Search::Operator::Association' do
|
103
103
|
let(:association) do
|
104
|
-
|
104
|
+
FactoryBot.generate :metasploit_model_search_operator_association_association
|
105
105
|
end
|
106
106
|
|
107
107
|
let(:node) do
|
@@ -109,10 +109,6 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Includes, type: :model do
|
|
109
109
|
:association => association
|
110
110
|
)
|
111
111
|
end
|
112
|
-
|
113
|
-
it 'is #association' do
|
114
|
-
expect(visit).to eq(association)
|
115
|
-
end
|
116
112
|
end
|
117
113
|
|
118
114
|
context 'with Metasploit::Model::Search::Operator::Attribute' do
|
@@ -151,7 +147,7 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Includes, type: :model do
|
|
151
147
|
|
152
148
|
context 'with name' do
|
153
149
|
let(:name) do
|
154
|
-
|
150
|
+
FactoryBot.generate :mdm_host_name
|
155
151
|
end
|
156
152
|
|
157
153
|
let(:formatted) do
|
@@ -163,7 +159,7 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Includes, type: :model do
|
|
163
159
|
|
164
160
|
context 'with services.name' do
|
165
161
|
let(:name) do
|
166
|
-
|
162
|
+
FactoryBot.generate :mdm_service_name
|
167
163
|
end
|
168
164
|
|
169
165
|
let(:formatted) do
|
@@ -176,4 +172,4 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Includes, type: :model do
|
|
176
172
|
end
|
177
173
|
end
|
178
174
|
end
|
179
|
-
end
|
175
|
+
end
|