metasploit_data_models 1.0.0.pre.rails.pre.4.0b → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -2
  3. data/.travis.yml +6 -3
  4. data/CHANGELOG.md +6 -0
  5. data/CONTRIBUTING.md +10 -52
  6. data/Gemfile +4 -6
  7. data/RELEASING.md +88 -0
  8. data/Rakefile +23 -0
  9. data/UPGRADING.md +1 -0
  10. data/app/models/mdm/api_key.rb +41 -1
  11. data/app/models/mdm/client.rb +41 -1
  12. data/app/models/mdm/cred.rb +116 -28
  13. data/app/models/mdm/event.rb +47 -0
  14. data/app/models/mdm/exploit_attempt.rb +65 -16
  15. data/app/models/mdm/exploited_host.rb +27 -0
  16. data/app/models/mdm/host_detail.rb +44 -0
  17. data/app/models/mdm/host_tag.rb +6 -8
  18. data/app/models/mdm/listener.rb +52 -0
  19. data/app/models/mdm/macro.rb +42 -0
  20. data/app/models/mdm/mod_ref.rb +21 -1
  21. data/app/models/mdm/module/action.rb +15 -0
  22. data/app/models/mdm/module/arch.rb +10 -0
  23. data/app/models/mdm/module/author.rb +17 -1
  24. data/app/models/mdm/module/mixin.rb +13 -0
  25. data/app/models/mdm/module/platform.rb +11 -0
  26. data/app/models/mdm/module/target.rb +18 -0
  27. data/app/models/mdm/nexpose_console.rb +82 -4
  28. data/app/models/mdm/profile.rb +36 -0
  29. data/app/models/mdm/route.rb +16 -4
  30. data/app/models/mdm/session_event.rb +32 -0
  31. data/app/models/mdm/tag.rb +48 -9
  32. data/app/models/mdm/task.rb +85 -46
  33. data/app/models/mdm/task_cred.rb +29 -0
  34. data/app/models/mdm/task_host.rb +25 -0
  35. data/app/models/mdm/task_service.rb +25 -0
  36. data/app/models/mdm/task_session.rb +25 -0
  37. data/app/models/mdm/user.rb +192 -6
  38. data/app/models/mdm/vuln_attempt.rb +37 -12
  39. data/app/models/mdm/vuln_detail.rb +138 -5
  40. data/app/models/mdm/vuln_ref.rb +3 -0
  41. data/app/models/mdm/web_form.rb +34 -0
  42. data/app/models/mdm/web_page.rb +69 -0
  43. data/app/models/mdm/web_site.rb +50 -0
  44. data/app/models/mdm/wmap_request.rb +85 -0
  45. data/app/models/mdm/wmap_target.rb +40 -0
  46. data/app/models/mdm/workspace.rb +160 -17
  47. data/app/models/metasploit_data_models/automatic_exploitation/match.rb +13 -23
  48. data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +25 -4
  49. data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +15 -4
  50. data/app/models/metasploit_data_models/automatic_exploitation/run.rb +7 -3
  51. data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
  52. data/app/models/metasploit_data_models/module_run.rb +1 -1
  53. data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
  54. data/app/validators/ip_format_validator.rb +4 -0
  55. data/app/validators/parameters_validator.rb +12 -0
  56. data/app/validators/password_is_strong_validator.rb +10 -1
  57. data/lib/mdm/host/operating_system_normalization.rb +7 -10
  58. data/lib/metasploit_data_models.rb +4 -0
  59. data/lib/metasploit_data_models/automatic_exploitation.rb +25 -0
  60. data/lib/metasploit_data_models/engine.rb +2 -0
  61. data/lib/metasploit_data_models/serialized_prefs.rb +6 -0
  62. data/lib/metasploit_data_models/version.rb +30 -7
  63. data/metasploit_data_models.gemspec +9 -2
  64. data/spec/app/models/mdm/api_key_spec.rb +1 -3
  65. data/spec/app/models/mdm/client_spec.rb +9 -11
  66. data/spec/app/models/mdm/cred_spec.rb +42 -54
  67. data/spec/app/models/mdm/event_spec.rb +22 -24
  68. data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
  69. data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
  70. data/spec/app/models/mdm/host_detail_spec.rb +15 -17
  71. data/spec/app/models/mdm/host_spec.rb +262 -260
  72. data/spec/app/models/mdm/host_tag_spec.rb +6 -8
  73. data/spec/app/models/mdm/listener_spec.rb +30 -32
  74. data/spec/app/models/mdm/loot_spec.rb +21 -23
  75. data/spec/app/models/mdm/macro_spec.rb +1 -3
  76. data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
  77. data/spec/app/models/mdm/module/action_spec.rb +8 -10
  78. data/spec/app/models/mdm/module/arch_spec.rb +8 -10
  79. data/spec/app/models/mdm/module/author_spec.rb +19 -14
  80. data/spec/app/models/mdm/module/detail_spec.rb +184 -75
  81. data/spec/app/models/mdm/module/mixin_spec.rb +8 -10
  82. data/spec/app/models/mdm/module/platform_spec.rb +8 -10
  83. data/spec/app/models/mdm/module/ref_spec.rb +8 -10
  84. data/spec/app/models/mdm/module/target_spec.rb +10 -12
  85. data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
  86. data/spec/app/models/mdm/note_spec.rb +23 -25
  87. data/spec/app/models/mdm/profile_spec.rb +1 -3
  88. data/spec/app/models/mdm/ref_spec.rb +9 -12
  89. data/spec/app/models/mdm/route_spec.rb +6 -8
  90. data/spec/app/models/mdm/service_spec.rb +38 -40
  91. data/spec/app/models/mdm/session_event_spec.rb +10 -12
  92. data/spec/app/models/mdm/session_spec.rb +13 -15
  93. data/spec/app/models/mdm/tag_spec.rb +29 -30
  94. data/spec/app/models/mdm/task_cred_spec.rb +9 -11
  95. data/spec/app/models/mdm/task_host_spec.rb +9 -11
  96. data/spec/app/models/mdm/task_service_spec.rb +9 -11
  97. data/spec/app/models/mdm/task_session_spec.rb +7 -9
  98. data/spec/app/models/mdm/task_spec.rb +27 -29
  99. data/spec/app/models/mdm/user_spec.rb +17 -19
  100. data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
  101. data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
  102. data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
  103. data/spec/app/models/mdm/vuln_spec.rb +24 -26
  104. data/spec/app/models/mdm/web_form_spec.rb +11 -13
  105. data/spec/app/models/mdm/web_page_spec.rb +19 -21
  106. data/spec/app/models/mdm/web_site_spec.rb +21 -23
  107. data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
  108. data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
  109. data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
  110. data/spec/app/models/mdm/workspace_spec.rb +97 -100
  111. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
  112. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
  113. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
  114. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
  115. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
  116. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
  117. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
  118. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
  119. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
  120. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
  121. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
  122. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
  123. data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
  124. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
  125. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
  126. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
  127. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
  128. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
  129. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
  130. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
  131. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
  132. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
  133. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
  134. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
  135. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
  136. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
  137. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  138. data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
  139. data/spec/lib/base64_serializer_spec.rb +19 -21
  140. data/spec/lib/ipaddr_spec.rb +1 -3
  141. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
  142. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
  143. data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
  144. data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
  145. data/spec/lib/metasploit_data_models/version_spec.rb +3 -139
  146. data/spec/lib/metasploit_data_models_spec.rb +4 -0
  147. data/spec/spec_helper.rb +86 -12
  148. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
  149. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
  150. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
  151. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
  152. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
  153. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
  154. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
  155. metadata +74 -14
  156. data/app/models/metasploit_data_models/automatic_exploitation.rb +0 -16
  157. data/lib/tasks/yard.rake +0 -33
@@ -1,29 +1,27 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Cred do
1
+ RSpec.describe Mdm::Cred, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context "Associations" do
7
- it { should have_many(:task_creds).class_name('Mdm::TaskCred').dependent(:destroy) }
8
- it { should have_many(:tasks).class_name('Mdm::Task').through(:task_creds) }
9
- it { should belong_to(:service).class_name('Mdm::Service') }
5
+ it { is_expected.to have_many(:task_creds).class_name('Mdm::TaskCred').dependent(:destroy) }
6
+ it { is_expected.to have_many(:tasks).class_name('Mdm::Task').through(:task_creds) }
7
+ it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
10
8
  end
11
9
 
12
10
  context 'database' do
13
11
  context 'timestamps' do
14
- it { should have_db_column(:created_at).of_type(:datetime) }
15
- it { should have_db_column(:updated_at).of_type(:datetime) }
12
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
13
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
16
14
  end
17
15
 
18
16
  context 'columns' do
19
- it { should have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
20
- it { should have_db_column(:user).of_type(:string) }
21
- it { should have_db_column(:pass).of_type(:string) }
22
- it { should have_db_column(:active).of_type(:boolean).with_options(:default => true) }
23
- it { should have_db_column(:proof).of_type(:string) }
24
- it { should have_db_column(:ptype).of_type(:string) }
25
- it { should have_db_column(:source_id).of_type(:integer) }
26
- it { should have_db_column(:source_type).of_type(:string) }
17
+ it { is_expected.to have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
18
+ it { is_expected.to have_db_column(:user).of_type(:string) }
19
+ it { is_expected.to have_db_column(:pass).of_type(:string) }
20
+ it { is_expected.to have_db_column(:active).of_type(:boolean).with_options(:default => true) }
21
+ it { is_expected.to have_db_column(:proof).of_type(:string) }
22
+ it { is_expected.to have_db_column(:ptype).of_type(:string) }
23
+ it { is_expected.to have_db_column(:source_id).of_type(:integer) }
24
+ it { is_expected.to have_db_column(:source_type).of_type(:string) }
27
25
  end
28
26
  end
29
27
 
@@ -68,25 +66,23 @@ describe Mdm::Cred do
68
66
 
69
67
  context 'constants' do
70
68
  it 'should define the key_id regex' do
71
- described_class::KEY_ID_REGEX.should == /([0-9a-fA-F:]{47})/
69
+ expect(described_class::KEY_ID_REGEX).to eq(/([0-9a-fA-F:]{47})/)
72
70
  end
73
71
 
74
72
  it 'should define ptypes to humanize' do
75
- described_class::PTYPES.should == {
76
- 'read/write password' => 'password_rw',
77
- 'read-only password' => 'password_ro',
78
- 'SMB hash' => 'smb_hash',
79
- 'SSH private key' => 'ssh_key',
80
- 'SSH public key' => 'ssh_pubkey'
81
- }
73
+ expect(described_class::PTYPES).to eq(
74
+ {
75
+ 'read/write password' => 'password_rw',
76
+ 'read-only password' => 'password_ro',
77
+ 'SMB hash' => 'smb_hash',
78
+ 'SSH private key' => 'ssh_key',
79
+ 'SSH public key' => 'ssh_pubkey'
80
+ }
81
+ )
82
82
  end
83
83
  end
84
84
 
85
85
  context 'methods' do
86
- #
87
- # lets
88
- #
89
-
90
86
  let(:host) {
91
87
  FactoryGirl.create(
92
88
  :mdm_host,
@@ -134,55 +130,47 @@ describe Mdm::Cred do
134
130
  FactoryGirl.create(:mdm_workspace)
135
131
  }
136
132
 
137
- #
138
- # Callbacks
139
- #
140
-
141
- before(:all) do
142
- Mdm::Workspace.any_instance.stub(:valid_ip_or_range? => true)
143
- end
144
-
145
133
  context '#ptype_human' do
146
134
  it "should return 'read/write password' for 'password_rw'" do
147
135
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_rw')
148
- cred.ptype_human.should == 'read/write password'
136
+ expect(cred.ptype_human).to eq('read/write password')
149
137
  end
150
138
 
151
139
  it "should return 'read-only password' for 'password_ro'" do
152
140
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_ro')
153
- cred.ptype_human.should == 'read-only password'
141
+ expect(cred.ptype_human).to eq('read-only password')
154
142
  end
155
143
 
156
144
  it "should return 'SMB Hash' for 'smb_hash'" do
157
145
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'smb_hash')
158
- cred.ptype_human.should == 'SMB hash'
146
+ expect(cred.ptype_human).to eq('SMB hash')
159
147
  end
160
148
 
161
149
  it "should return 'SSH private key' for 'ssh_key'" do
162
150
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'ssh_key')
163
- cred.ptype_human.should == 'SSH private key'
151
+ expect(cred.ptype_human).to eq('SSH private key')
164
152
  end
165
153
 
166
154
  it "should return 'SSH public key' for 'ssh_pubkey'" do
167
155
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'ssh_pubkey')
168
- cred.ptype_human.should == 'SSH public key'
156
+ expect(cred.ptype_human).to eq('SSH public key')
169
157
  end
170
158
  end
171
159
 
172
160
  context '#ssh_key_id' do
173
161
  it 'should return nil if not an ssh_key' do
174
162
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => 'msfadmin', :ptype => 'password_rw')
175
- cred.ssh_key_id.should == nil
163
+ expect(cred.ssh_key_id).to eq(nil)
176
164
  end
177
165
 
178
166
  it 'should return nil if proof does not contain the key id' do
179
167
  cred = FactoryGirl.build(:mdm_cred, :user => 'msfadmin', :pass => '/path/to/keyfile', :ptype => 'ssh_key', :proof => "no key here")
180
- cred.ssh_key_id.should == nil
168
+ expect(cred.ssh_key_id).to eq(nil)
181
169
  end
182
170
 
183
171
  it 'should return the key id for an ssh_key' do
184
172
  cred = FactoryGirl.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")
185
- cred.ssh_key_id.should == '57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a'
173
+ expect(cred.ssh_key_id).to eq('57:c3:11:5d:77:c5:63:90:33:2d:c5:c4:99:78:62:7a')
186
174
  end
187
175
 
188
176
  end
@@ -234,14 +222,14 @@ describe Mdm::Cred do
234
222
  it 'should behave the same for public keys as private keys' do
235
223
  pubkey2 = FactoryGirl.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")
236
224
  pubkey3 = FactoryGirl.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")
237
- pubkey2.ssh_key_matches?(ssh_pubkey).should == true
238
- pubkey2.ssh_key_matches?(pubkey3).should == false
225
+ expect(pubkey2.ssh_key_matches?(ssh_pubkey)).to eq(true)
226
+ expect(pubkey2.ssh_key_matches?(pubkey3)).to eq(false)
239
227
  end
240
228
 
241
229
  it 'should always return false for non ssh key creds' do
242
230
  cred2 = FactoryGirl.create(:mdm_cred, :service => other_service, :ptype => 'password', :user => 'msfadmin', :pass => 'msfadmin' )
243
231
  cred3 = FactoryGirl.create(:mdm_cred, :service => other_service, :ptype => 'password', :user => 'msfadmin', :pass => 'msfadmin' )
244
- cred2.ssh_key_matches?(cred3).should == false
232
+ expect(cred2.ssh_key_matches?(cred3)).to eq(false)
245
233
  end
246
234
  end
247
235
 
@@ -271,11 +259,11 @@ describe Mdm::Cred do
271
259
  end
272
260
 
273
261
  it 'should return all ssh private keys with a matching id' do
274
- other_ssh_key.ssh_keys.should include(ssh_key)
262
+ expect(other_ssh_key.ssh_keys).to include(ssh_key)
275
263
  end
276
264
 
277
265
  it 'should return all ssh public keys with a matching id' do
278
- other_ssh_key.ssh_keys.should include(ssh_pubkey)
266
+ expect(other_ssh_key.ssh_keys).to include(ssh_pubkey)
279
267
  end
280
268
  end
281
269
 
@@ -305,11 +293,11 @@ describe Mdm::Cred do
305
293
  end
306
294
 
307
295
  it 'should return ssh private keys with matching ids' do
308
- other_ssh_key.ssh_private_keys.should include(ssh_key)
296
+ expect(other_ssh_key.ssh_private_keys).to include(ssh_key)
309
297
  end
310
298
 
311
299
  it 'should not return ssh public keys with matching ids' do
312
- other_ssh_key.ssh_private_keys.should_not include(ssh_pubkey)
300
+ expect(other_ssh_key.ssh_private_keys).not_to include(ssh_pubkey)
313
301
  end
314
302
  end
315
303
 
@@ -339,11 +327,11 @@ describe Mdm::Cred do
339
327
  end
340
328
 
341
329
  it 'should not return ssh private keys with matching ids' do
342
- other_ssh_key.ssh_public_keys.should_not include(ssh_key)
330
+ expect(other_ssh_key.ssh_public_keys).not_to include(ssh_key)
343
331
  end
344
332
 
345
333
  it 'should return ssh public keys with matching ids' do
346
- other_ssh_key.ssh_public_keys.should include(ssh_pubkey)
334
+ expect(other_ssh_key.ssh_public_keys).to include(ssh_pubkey)
347
335
  end
348
336
  end
349
337
  end
@@ -351,7 +339,7 @@ describe Mdm::Cred do
351
339
  context 'factory' do
352
340
  it 'should be valid' do
353
341
  cred = FactoryGirl.build(:mdm_cred)
354
- cred.should be_valid
342
+ expect(cred).to be_valid
355
343
  end
356
344
  end
357
345
 
@@ -1,27 +1,25 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Event do
1
+ RSpec.describe Mdm::Event, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:host).class_name('Mdm::Host') }
8
- it { should belong_to(:workspace).class_name('Mdm::Workspace') }
5
+ it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
6
+ it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
9
7
  end
10
8
 
11
9
  context 'database' do
12
10
  context 'timestamps' do
13
- it { should have_db_column(:created_at).of_type(:datetime) }
14
- it { should have_db_column(:updated_at).of_type(:datetime) }
11
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
12
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
15
13
  end
16
14
 
17
15
  context 'columns' do
18
- it { should have_db_column(:workspace_id).of_type(:integer) }
19
- it { should have_db_column(:host_id).of_type(:integer) }
20
- it { should have_db_column(:name).of_type(:string) }
21
- it { should have_db_column(:critical).of_type(:boolean) }
22
- it { should have_db_column(:seen).of_type(:boolean) }
23
- it { should have_db_column(:username).of_type(:string) }
24
- it { should have_db_column(:info).of_type(:text) }
16
+ it { is_expected.to have_db_column(:workspace_id).of_type(:integer) }
17
+ it { is_expected.to have_db_column(:host_id).of_type(:integer) }
18
+ it { is_expected.to have_db_column(:name).of_type(:string) }
19
+ it { is_expected.to have_db_column(:critical).of_type(:boolean) }
20
+ it { is_expected.to have_db_column(:seen).of_type(:boolean) }
21
+ it { is_expected.to have_db_column(:username).of_type(:string) }
22
+ it { is_expected.to have_db_column(:info).of_type(:text) }
25
23
  end
26
24
  end
27
25
 
@@ -43,23 +41,23 @@ describe Mdm::Event do
43
41
  let(:workspace) {FactoryGirl.create(:mdm_workspace)}
44
42
  let(:flagged_event) { FactoryGirl.create(:mdm_event, :workspace => workspace, :name => 'flagme', :critical => true, :seen => false) }
45
43
  let(:non_critical_event) { FactoryGirl.create(:mdm_event, :workspace => workspace, :name => 'dontflagmebro', :critical => false, :seen => false) }
46
-
44
+
47
45
  before(:each) do
48
46
  flagged_event
49
47
  non_critical_event
50
48
  end
51
-
49
+
52
50
  it 'should included critical unseen events' do
53
- Mdm::Event.flagged.should eq [flagged_event]
51
+ expect(Mdm::Event.flagged).to eq [flagged_event]
54
52
  end
55
53
  it 'should exclude non-critical events' do
56
- Mdm::Event.flagged.should_not include(non_critical_event)
54
+ expect(Mdm::Event.flagged).not_to include(non_critical_event)
57
55
  end
58
56
 
59
57
  it 'should exclude critical seen events' do
60
58
  flagged_event.seen = true
61
59
  flagged_event.save
62
- Mdm::Event.flagged.should_not include(flagged_event)
60
+ expect(Mdm::Event.flagged).not_to include(flagged_event)
63
61
  end
64
62
  end
65
63
 
@@ -68,8 +66,8 @@ describe Mdm::Event do
68
66
  flagged_event = FactoryGirl.create(:mdm_event, :name => 'module_run')
69
67
  non_critical_event = FactoryGirl.create(:mdm_event, :name => 'dontflagmebro')
70
68
  flagged_set = Mdm::Event.module_run
71
- flagged_set.should include(flagged_event)
72
- flagged_set.should_not include(non_critical_event)
69
+ expect(flagged_set).to include(flagged_event)
70
+ expect(flagged_set).not_to include(non_critical_event)
73
71
  end
74
72
  end
75
73
  end
@@ -77,15 +75,15 @@ describe Mdm::Event do
77
75
  context 'validations' do
78
76
  it 'should require name' do
79
77
  unnamed_event = FactoryGirl.build(:mdm_event, :name => nil)
80
- unnamed_event.should_not be_valid
81
- unnamed_event.errors[:name].should include("can't be blank")
78
+ expect(unnamed_event).not_to be_valid
79
+ expect(unnamed_event.errors[:name]).to include("can't be blank")
82
80
  end
83
81
  end
84
82
 
85
83
  context 'factory' do
86
84
  it 'should be valid' do
87
85
  event = FactoryGirl.build(:mdm_event)
88
- event.should be_valid
86
+ expect(event).to be_valid
89
87
  end
90
88
  end
91
89
 
@@ -1,31 +1,29 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::ExploitAttempt do
1
+ RSpec.describe Mdm::ExploitAttempt, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:host).class_name('Mdm::Host') }
5
+ it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
8
6
  end
9
7
 
10
8
  context 'database' do
11
9
 
12
10
  context 'timestamps'do
13
- it { should have_db_column(:attempted_at).of_type(:datetime) }
11
+ it { is_expected.to have_db_column(:attempted_at).of_type(:datetime) }
14
12
  end
15
13
 
16
14
  context 'columns' do
17
- it { should have_db_column(:host_id).of_type(:integer) }
18
- it { should have_db_column(:service_id).of_type(:integer) }
19
- it { should have_db_column(:vuln_id).of_type(:integer) }
20
- it { should have_db_column(:exploited).of_type(:boolean) }
21
- it { should have_db_column(:fail_reason).of_type(:string) }
22
- it { should have_db_column(:username).of_type(:string) }
23
- it { should have_db_column(:module).of_type(:text) }
24
- it { should have_db_column(:session_id).of_type(:integer) }
25
- it { should have_db_column(:loot_id).of_type(:integer) }
26
- it { should have_db_column(:port).of_type(:integer) }
27
- it { should have_db_column(:proto).of_type(:string) }
28
- it { should have_db_column(:fail_detail).of_type(:text) }
15
+ it { is_expected.to have_db_column(:host_id).of_type(:integer) }
16
+ it { is_expected.to have_db_column(:service_id).of_type(:integer) }
17
+ it { is_expected.to have_db_column(:vuln_id).of_type(:integer) }
18
+ it { is_expected.to have_db_column(:exploited).of_type(:boolean) }
19
+ it { is_expected.to have_db_column(:fail_reason).of_type(:string) }
20
+ it { is_expected.to have_db_column(:username).of_type(:string) }
21
+ it { is_expected.to have_db_column(:module).of_type(:text) }
22
+ it { is_expected.to have_db_column(:session_id).of_type(:integer) }
23
+ it { is_expected.to have_db_column(:loot_id).of_type(:integer) }
24
+ it { is_expected.to have_db_column(:port).of_type(:integer) }
25
+ it { is_expected.to have_db_column(:proto).of_type(:string) }
26
+ it { is_expected.to have_db_column(:fail_detail).of_type(:text) }
29
27
  end
30
28
  end
31
29
 
@@ -45,17 +43,17 @@ describe Mdm::ExploitAttempt do
45
43
  context 'validations' do
46
44
  it 'should only be valid with a host_id' do
47
45
  orphaned_attempt = FactoryGirl.build(:mdm_exploit_attempt, :host => nil)
48
- orphaned_attempt.should_not be_valid
49
- orphaned_attempt.errors[:host_id].should include("can't be blank")
46
+ expect(orphaned_attempt).not_to be_valid
47
+ expect(orphaned_attempt.errors[:host_id]).to include("can't be blank")
50
48
  propper_attempt = FactoryGirl.build(:mdm_exploit_attempt)
51
- propper_attempt.should be_valid
49
+ expect(propper_attempt).to be_valid
52
50
  end
53
51
  end
54
52
 
55
53
  context 'factory' do
56
54
  it 'should be valid' do
57
55
  exploit_attempt = FactoryGirl.build(:mdm_exploit_attempt)
58
- exploit_attempt.should be_valid
56
+ expect(exploit_attempt).to be_valid
59
57
  end
60
58
  end
61
59
  end
@@ -1,26 +1,24 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::ExploitedHost do
1
+ RSpec.describe Mdm::ExploitedHost, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:host).class_name('Mdm::Host') }
8
- it { should belong_to(:service).class_name('Mdm::Service') }
5
+ it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
6
+ it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
9
7
  end
10
8
 
11
9
  context 'database' do
12
10
 
13
11
  context 'timestamps'do
14
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
15
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
12
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
13
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
16
14
  end
17
15
 
18
16
  context 'columns' do
19
- it { should have_db_column(:host_id).of_type(:integer).with_options(:null => false) }
20
- it { should have_db_column(:service_id).of_type(:integer) }
21
- it { should have_db_column(:name).of_type(:string) }
22
- it { should have_db_column(:session_uuid).of_type(:string) }
23
- it { should have_db_column(:payload).of_type(:string) }
17
+ it { is_expected.to have_db_column(:host_id).of_type(:integer).with_options(:null => false) }
18
+ it { is_expected.to have_db_column(:service_id).of_type(:integer) }
19
+ it { is_expected.to have_db_column(:name).of_type(:string) }
20
+ it { is_expected.to have_db_column(:session_uuid).of_type(:string) }
21
+ it { is_expected.to have_db_column(:payload).of_type(:string) }
24
22
  end
25
23
  end
26
24
 
@@ -39,7 +37,7 @@ describe Mdm::ExploitedHost do
39
37
  context 'factory' do
40
38
  it 'should be valid' do
41
39
  exploited_host = FactoryGirl.build(:mdm_exploited_host)
42
- exploited_host.should be_valid
40
+ expect(exploited_host).to be_valid
43
41
  end
44
42
  end
45
43
 
@@ -1,37 +1,35 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::HostDetail do
1
+ RSpec.describe Mdm::HostDetail, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:host).class_name('Mdm::Host') }
5
+ it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
8
6
  end
9
7
 
10
8
  context 'database' do
11
- it { should have_db_column(:host_id).of_type(:integer) }
12
- it { should have_db_column(:nx_console_id).of_type(:integer) }
13
- it { should have_db_column(:nx_device_id).of_type(:integer) }
14
- it { should have_db_column(:src).of_type(:string) }
15
- it { should have_db_column(:nx_site_name).of_type(:string) }
16
- it { should have_db_column(:nx_site_importance).of_type(:string) }
17
- it { should have_db_column(:src).of_type(:string) }
18
- it { should have_db_column(:nx_site_name).of_type(:string) }
19
- it { should have_db_column(:nx_scan_template).of_type(:string) }
20
- it { should have_db_column(:nx_risk_score).of_type(:float) }
9
+ it { is_expected.to have_db_column(:host_id).of_type(:integer) }
10
+ it { is_expected.to have_db_column(:nx_console_id).of_type(:integer) }
11
+ it { is_expected.to have_db_column(:nx_device_id).of_type(:integer) }
12
+ it { is_expected.to have_db_column(:src).of_type(:string) }
13
+ it { is_expected.to have_db_column(:nx_site_name).of_type(:string) }
14
+ it { is_expected.to have_db_column(:nx_site_importance).of_type(:string) }
15
+ it { is_expected.to have_db_column(:src).of_type(:string) }
16
+ it { is_expected.to have_db_column(:nx_site_name).of_type(:string) }
17
+ it { is_expected.to have_db_column(:nx_scan_template).of_type(:string) }
18
+ it { is_expected.to have_db_column(:nx_risk_score).of_type(:float) }
21
19
  end
22
20
 
23
21
  context 'validations' do
24
22
  it 'should only be valid with a host_id' do
25
23
  orphan_detail = FactoryGirl.build(:mdm_host_detail, :host => nil)
26
- orphan_detail.should_not be_valid
27
- orphan_detail.errors[:host_id].should include("can't be blank")
24
+ expect(orphan_detail).not_to be_valid
25
+ expect(orphan_detail.errors[:host_id]).to include("can't be blank")
28
26
  end
29
27
  end
30
28
 
31
29
  context 'factory' do
32
30
  it 'should be valid' do
33
31
  host_detail = FactoryGirl.build(:mdm_host_detail)
34
- host_detail.should be_valid
32
+ expect(host_detail).to be_valid
35
33
  end
36
34
  end
37
35