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,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Vuln do
1
+ RSpec.describe Mdm::Vuln, type: :model do
4
2
  subject(:vuln) do
5
3
  FactoryGirl.build(:mdm_vuln)
6
4
  end
@@ -44,7 +42,7 @@ describe Mdm::Vuln do
44
42
  it { is_expected.to have_many(:notes).class_name('Mdm::Note').dependent(:delete_all).order('notes.created_at') }
45
43
 
46
44
  context 'module_details' do
47
- it { should have_many(:module_details).class_name('Mdm::Module::Detail').through(:module_refs) }
45
+ it { is_expected.to have_many(:module_details).class_name('Mdm::Module::Detail').through(:module_refs) }
48
46
 
49
47
  context 'with Mdm::Refs' do
50
48
  let(:names) do
@@ -114,8 +112,8 @@ describe Mdm::Vuln do
114
112
  module_details << module_ref.detail
115
113
  end
116
114
 
117
- vuln.module_details.count.should < module_details.length
118
- module_details.uniq.count.should == vuln.module_details.count
115
+ expect(vuln.module_details.count).to be < module_details.length
116
+ expect(module_details.uniq.count).to eq(vuln.module_details.count)
119
117
  end
120
118
  end
121
119
  end
@@ -126,20 +124,20 @@ describe Mdm::Vuln do
126
124
 
127
125
  context 'database' do
128
126
  context 'columns' do
129
- it { should have_db_column(:exploited_at).of_type(:datetime) }
130
- it { should have_db_column(:host_id).of_type(:integer) }
131
- it { should have_db_column(:info).of_type(:string) }
132
- it { should have_db_column(:name).of_type(:string) }
133
- it { should have_db_column(:service_id).of_type(:integer) }
127
+ it { is_expected.to have_db_column(:exploited_at).of_type(:datetime) }
128
+ it { is_expected.to have_db_column(:host_id).of_type(:integer) }
129
+ it { is_expected.to have_db_column(:info).of_type(:string) }
130
+ it { is_expected.to have_db_column(:name).of_type(:string) }
131
+ it { is_expected.to have_db_column(:service_id).of_type(:integer) }
134
132
 
135
133
  context 'counter caches' do
136
- it { should have_db_column(:vuln_attempt_count).of_type(:integer).with_options(:default => 0) }
137
- it { should have_db_column(:vuln_detail_count).of_type(:integer).with_options(:default => 0) }
134
+ it { is_expected.to have_db_column(:vuln_attempt_count).of_type(:integer).with_options(:default => 0) }
135
+ it { is_expected.to have_db_column(:vuln_detail_count).of_type(:integer).with_options(:default => 0) }
138
136
  end
139
137
 
140
138
  context 'timestamps' do
141
- it { should have_db_column(:created_at).of_type(:datetime) }
142
- it { should have_db_column(:updated_at).of_type(:datetime) }
139
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
140
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
143
141
  end
144
142
  end
145
143
  end
@@ -150,7 +148,7 @@ describe Mdm::Vuln do
150
148
  FactoryGirl.build(:mdm_host_vuln)
151
149
  end
152
150
 
153
- it { should be_valid }
151
+ it { is_expected.to be_valid }
154
152
  end
155
153
 
156
154
  context 'mdm_service_vuln' do
@@ -158,7 +156,7 @@ describe Mdm::Vuln do
158
156
  FactoryGirl.build(:mdm_service_vuln)
159
157
  end
160
158
 
161
- it { should be_valid }
159
+ it { is_expected.to be_valid }
162
160
  end
163
161
 
164
162
  context 'mdm_vuln' do
@@ -166,7 +164,7 @@ describe Mdm::Vuln do
166
164
  FactoryGirl.build(:mdm_vuln)
167
165
  end
168
166
 
169
- it { should be_valid }
167
+ it { is_expected.to be_valid }
170
168
  end
171
169
  end
172
170
 
@@ -197,7 +195,7 @@ describe Mdm::Vuln do
197
195
  end
198
196
 
199
197
  it 'should match Mdm::Vuln' do
200
- results.should =~ [vuln]
198
+ expect(results).to match_array [vuln]
201
199
  end
202
200
  end
203
201
 
@@ -207,7 +205,7 @@ describe Mdm::Vuln do
207
205
  end
208
206
 
209
207
  it 'should not match Mdm::Vuln' do
210
- results.should be_empty
208
+ expect(results).to be_empty
211
209
  end
212
210
  end
213
211
  end
@@ -219,7 +217,7 @@ describe Mdm::Vuln do
219
217
  end
220
218
 
221
219
  it 'should match Mdm::Vuln' do
222
- results.should =~ [vuln]
220
+ expect(results).to match_array [vuln]
223
221
  end
224
222
  end
225
223
 
@@ -229,7 +227,7 @@ describe Mdm::Vuln do
229
227
  end
230
228
 
231
229
  it 'should not match Mdm::Vuln' do
232
- results.should be_empty
230
+ expect(results).to be_empty
233
231
  end
234
232
  end
235
233
 
@@ -239,7 +237,7 @@ describe Mdm::Vuln do
239
237
  end
240
238
 
241
239
  it 'should match Mdm::Vuln' do
242
- results.should =~ [vuln]
240
+ expect(results).to match_array [vuln]
243
241
  end
244
242
  end
245
243
 
@@ -249,7 +247,7 @@ describe Mdm::Vuln do
249
247
  end
250
248
 
251
249
  it 'should not match Mdm::Vuln' do
252
- results.should be_empty
250
+ expect(results).to be_empty
253
251
  end
254
252
  end
255
253
  end
@@ -259,7 +257,7 @@ describe Mdm::Vuln do
259
257
  end
260
258
 
261
259
  context 'validations' do
262
- it { should validate_presence_of :name }
260
+ it { is_expected.to validate_presence_of :name }
263
261
 
264
262
  context "invalid" do
265
263
  let(:mdm_vuln) do
@@ -270,7 +268,7 @@ describe Mdm::Vuln do
270
268
  str = Faker::Lorem.characters(256)
271
269
  mdm_vuln.name = str
272
270
  mdm_vuln.valid?
273
- mdm_vuln.errors[:name][0].should include "is too long"
271
+ expect(mdm_vuln.errors[:name][0]).to include "is too long"
274
272
  end
275
273
  end
276
274
  end
@@ -1,36 +1,34 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::WebForm do
1
+ RSpec.describe Mdm::WebForm, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:web_site).class_name('Mdm::WebSite') }
5
+ it { is_expected.to belong_to(:web_site).class_name('Mdm::WebSite') }
8
6
  end
9
7
 
10
8
  context 'database' do
11
9
 
12
10
  context 'timestamps'do
13
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
14
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
11
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
12
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
15
13
  end
16
14
 
17
15
  context 'columns' do
18
- it { should have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
19
- it { should have_db_column(:path).of_type(:text) }
20
- it { should have_db_column(:method).of_type(:string) }
21
- it { should have_db_column(:params).of_type(:text) }
22
- it { should have_db_column(:query).of_type(:text) }
16
+ it { is_expected.to have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
17
+ it { is_expected.to have_db_column(:path).of_type(:text) }
18
+ it { is_expected.to have_db_column(:method).of_type(:string) }
19
+ it { is_expected.to have_db_column(:params).of_type(:text) }
20
+ it { is_expected.to have_db_column(:query).of_type(:text) }
23
21
  end
24
22
 
25
23
  context 'indices' do
26
- it { should have_db_index(:path) }
24
+ it { is_expected.to have_db_index(:path) }
27
25
  end
28
26
  end
29
27
 
30
28
  context 'factory' do
31
29
  it 'should be valid' do
32
30
  web_form = FactoryGirl.build(:mdm_web_form)
33
- web_form.should be_valid
31
+ expect(web_form).to be_valid
34
32
  end
35
33
  end
36
34
 
@@ -1,44 +1,42 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::WebPage do
1
+ RSpec.describe Mdm::WebPage, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:web_site).class_name('Mdm::WebSite') }
5
+ it { is_expected.to belong_to(:web_site).class_name('Mdm::WebSite') }
8
6
  end
9
7
 
10
8
  context 'database' do
11
9
 
12
10
  context 'timestamps'do
13
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
14
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
15
- it { should have_db_column(:mtime).of_type(:datetime) }
11
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
12
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
13
+ it { is_expected.to have_db_column(:mtime).of_type(:datetime) }
16
14
  end
17
15
 
18
16
  context 'columns' do
19
- it { should have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
20
- it { should have_db_column(:path).of_type(:text) }
21
- it { should have_db_column(:query).of_type(:text) }
22
- it { should have_db_column(:code).of_type(:integer).with_options(:null => false) }
23
- it { should have_db_column(:cookie).of_type(:text) }
24
- it { should have_db_column(:auth).of_type(:text) }
25
- it { should have_db_column(:ctype).of_type(:text) }
26
- it { should have_db_column(:location).of_type(:text) }
27
- it { should have_db_column(:headers).of_type(:text) }
28
- it { should have_db_column(:body).of_type(:binary) }
29
- it { should have_db_column(:request).of_type(:binary) }
17
+ it { is_expected.to have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
18
+ it { is_expected.to have_db_column(:path).of_type(:text) }
19
+ it { is_expected.to have_db_column(:query).of_type(:text) }
20
+ it { is_expected.to have_db_column(:code).of_type(:integer).with_options(:null => false) }
21
+ it { is_expected.to have_db_column(:cookie).of_type(:text) }
22
+ it { is_expected.to have_db_column(:auth).of_type(:text) }
23
+ it { is_expected.to have_db_column(:ctype).of_type(:text) }
24
+ it { is_expected.to have_db_column(:location).of_type(:text) }
25
+ it { is_expected.to have_db_column(:headers).of_type(:text) }
26
+ it { is_expected.to have_db_column(:body).of_type(:binary) }
27
+ it { is_expected.to have_db_column(:request).of_type(:binary) }
30
28
  end
31
29
 
32
30
  context 'indices' do
33
- it { should have_db_index(:path) }
34
- it { should have_db_index(:query) }
31
+ it { is_expected.to have_db_index(:path) }
32
+ it { is_expected.to have_db_index(:query) }
35
33
  end
36
34
  end
37
35
 
38
36
  context 'factory' do
39
37
  it 'should be valid' do
40
38
  web_page = FactoryGirl.build(:mdm_web_page)
41
- web_page.should be_valid
39
+ expect(web_page).to be_valid
42
40
  end
43
41
  end
44
42
 
@@ -1,33 +1,31 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::WebSite do
1
+ RSpec.describe Mdm::WebSite, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'factory' do
7
5
  it 'should be valid' do
8
6
  web_site = FactoryGirl.build(:mdm_web_site)
9
- web_site.should be_valid
7
+ expect(web_site).to be_valid
10
8
  end
11
9
  end
12
10
 
13
11
  context 'database' do
14
12
 
15
13
  context 'timestamps'do
16
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
17
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
14
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
15
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
18
16
  end
19
17
 
20
18
  context 'columns' do
21
- it { should have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
22
- it { should have_db_column(:vhost).of_type(:string) }
23
- it { should have_db_column(:comments).of_type(:text) }
24
- it { should have_db_column(:options).of_type(:text) }
19
+ it { is_expected.to have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
20
+ it { is_expected.to have_db_column(:vhost).of_type(:string) }
21
+ it { is_expected.to have_db_column(:comments).of_type(:text) }
22
+ it { is_expected.to have_db_column(:options).of_type(:text) }
25
23
  end
26
24
 
27
25
  context 'indices' do
28
- it { should have_db_index(:comments) }
29
- it { should have_db_index(:options) }
30
- it { should have_db_index(:vhost) }
26
+ it { is_expected.to have_db_index(:comments) }
27
+ it { is_expected.to have_db_index(:options) }
28
+ it { is_expected.to have_db_index(:vhost) }
31
29
  end
32
30
  end
33
31
 
@@ -44,10 +42,10 @@ describe Mdm::WebSite do
44
42
  end
45
43
 
46
44
  context 'associations' do
47
- it { should belong_to(:service).class_name('Mdm::Service') }
48
- it { should have_many(:web_forms).class_name('Mdm::WebForm').dependent(:destroy) }
49
- it { should have_many(:web_pages).class_name('Mdm::WebPage').dependent(:destroy) }
50
- it { should have_many(:web_vulns).class_name('Mdm::WebVuln').dependent(:destroy) }
45
+ it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
46
+ it { is_expected.to have_many(:web_forms).class_name('Mdm::WebForm').dependent(:destroy) }
47
+ it { is_expected.to have_many(:web_pages).class_name('Mdm::WebPage').dependent(:destroy) }
48
+ it { is_expected.to have_many(:web_vulns).class_name('Mdm::WebVuln').dependent(:destroy) }
51
49
  end
52
50
 
53
51
  context 'methods' do
@@ -56,9 +54,9 @@ describe Mdm::WebSite do
56
54
  mysite = FactoryGirl.create(:mdm_web_site)
57
55
  FactoryGirl.create(:mdm_web_form, :web_site => mysite)
58
56
  FactoryGirl.create(:mdm_web_form, :web_site => mysite)
59
- mysite.form_count.should == 2
57
+ expect(mysite.form_count).to eq(2)
60
58
  FactoryGirl.create(:mdm_web_form, :web_site => mysite)
61
- mysite.form_count.should == 3
59
+ expect(mysite.form_count).to eq(3)
62
60
  end
63
61
  end
64
62
 
@@ -67,9 +65,9 @@ describe Mdm::WebSite do
67
65
  mysite = FactoryGirl.create(:mdm_web_site)
68
66
  FactoryGirl.create(:mdm_web_page, :web_site => mysite)
69
67
  FactoryGirl.create(:mdm_web_page, :web_site => mysite)
70
- mysite.page_count.should == 2
68
+ expect(mysite.page_count).to eq(2)
71
69
  FactoryGirl.create(:mdm_web_page, :web_site => mysite)
72
- mysite.page_count.should == 3
70
+ expect(mysite.page_count).to eq(3)
73
71
  end
74
72
  end
75
73
 
@@ -78,9 +76,9 @@ describe Mdm::WebSite do
78
76
  mysite = FactoryGirl.create(:mdm_web_site)
79
77
  FactoryGirl.create(:mdm_web_vuln, :web_site => mysite)
80
78
  FactoryGirl.create(:mdm_web_vuln, :web_site => mysite)
81
- mysite.vuln_count.should == 2
79
+ expect(mysite.vuln_count).to eq(2)
82
80
  FactoryGirl.create(:mdm_web_vuln, :web_site => mysite)
83
- mysite.vuln_count.should == 3
81
+ expect(mysite.vuln_count).to eq(3)
84
82
  end
85
83
  end
86
84
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::WebVuln do
1
+ RSpec.describe Mdm::WebVuln, type: :model do
4
2
  let(:confidence_range) do
5
3
  0 .. 100
6
4
  end
@@ -29,20 +27,20 @@ describe Mdm::WebVuln do
29
27
  it_should_behave_like 'Metasploit::Concern.run'
30
28
 
31
29
  context 'associations' do
32
- it { should belong_to(:web_site).class_name('Mdm::WebSite') }
30
+ it { is_expected.to belong_to(:web_site).class_name('Mdm::WebSite') }
33
31
  end
34
32
 
35
33
  context 'CONSTANTS' do
36
34
  it 'should define CONFIDENCE_RANGE' do
37
- described_class::CONFIDENCE_RANGE.should == confidence_range
35
+ expect(described_class::CONFIDENCE_RANGE).to eq(confidence_range)
38
36
  end
39
37
 
40
38
  it 'should define METHODS in any order' do
41
- described_class::METHODS.should =~ methods
39
+ expect(described_class::METHODS).to match_array methods
42
40
  end
43
41
 
44
42
  it 'should define RISK_RANGE' do
45
- described_class::RISK_RANGE.should == risk_range
43
+ expect(described_class::RISK_RANGE).to eq(risk_range)
46
44
  end
47
45
  end
48
46
 
@@ -60,33 +58,33 @@ describe Mdm::WebVuln do
60
58
 
61
59
  context 'database' do
62
60
  context 'columns' do
63
- it { should have_db_column(:blame).of_type(:text) }
64
- it { should have_db_column(:category).of_type(:text).with_options(:null => false) }
65
- it { should have_db_column(:confidence).of_type(:integer).with_options(:null => false) }
66
- it { should have_db_column(:description).of_type(:text) }
67
- it { should have_db_column(:method).of_type(:string).with_options(:limit => 1024, :null => false) }
68
- it { should have_db_column(:name).of_type(:string).with_options(:limit => 1024, :null => false) }
69
- it { should have_db_column(:owner).of_type(:string) }
70
- it { should have_db_column(:params).of_type(:text).with_options(:null => false) }
71
- it { should have_db_column(:path).of_type(:text).with_options(:null => false) }
72
- it { should have_db_column(:payload).of_type(:text) }
73
- it { should have_db_column(:pname).of_type(:text) }
74
- it { should have_db_column(:proof).of_type(:binary).with_options(:null => false) }
75
- it { should have_db_column(:query).of_type(:text) }
76
- it { should have_db_column(:request).of_type(:binary) }
77
- it { should have_db_column(:risk).of_type(:integer).with_options(:null => false) }
78
- it { should have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
61
+ it { is_expected.to have_db_column(:blame).of_type(:text) }
62
+ it { is_expected.to have_db_column(:category).of_type(:text).with_options(:null => false) }
63
+ it { is_expected.to have_db_column(:confidence).of_type(:integer).with_options(:null => false) }
64
+ it { is_expected.to have_db_column(:description).of_type(:text) }
65
+ it { is_expected.to have_db_column(:method).of_type(:string).with_options(:limit => 1024, :null => false) }
66
+ it { is_expected.to have_db_column(:name).of_type(:string).with_options(:limit => 1024, :null => false) }
67
+ it { is_expected.to have_db_column(:owner).of_type(:string) }
68
+ it { is_expected.to have_db_column(:params).of_type(:text).with_options(:null => false) }
69
+ it { is_expected.to have_db_column(:path).of_type(:text).with_options(:null => false) }
70
+ it { is_expected.to have_db_column(:payload).of_type(:text) }
71
+ it { is_expected.to have_db_column(:pname).of_type(:text) }
72
+ it { is_expected.to have_db_column(:proof).of_type(:binary).with_options(:null => false) }
73
+ it { is_expected.to have_db_column(:query).of_type(:text) }
74
+ it { is_expected.to have_db_column(:request).of_type(:binary) }
75
+ it { is_expected.to have_db_column(:risk).of_type(:integer).with_options(:null => false) }
76
+ it { is_expected.to have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
79
77
 
80
78
  context 'timestamps' do
81
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
82
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
79
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
80
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
83
81
  end
84
82
  end
85
83
 
86
84
  context 'indices' do
87
- it { should have_db_index(:method) }
88
- it { should have_db_index(:name) }
89
- it { should have_db_index(:path) }
85
+ it { is_expected.to have_db_index(:method) }
86
+ it { is_expected.to have_db_index(:name) }
87
+ it { is_expected.to have_db_index(:path) }
90
88
  end
91
89
  end
92
90
 
@@ -96,7 +94,7 @@ describe Mdm::WebVuln do
96
94
  FactoryGirl.build(:mdm_web_vuln)
97
95
  end
98
96
 
99
- it { should be_valid }
97
+ it { is_expected.to be_valid }
100
98
 
101
99
  context 'after reloading' do
102
100
  before(:each) do
@@ -104,21 +102,21 @@ describe Mdm::WebVuln do
104
102
  mdm_web_vuln.reload
105
103
  end
106
104
 
107
- it { should be_valid }
105
+ it { is_expected.to be_valid }
108
106
  end
109
107
  end
110
108
  end
111
109
 
112
110
  context 'validations' do
113
- it { should validate_presence_of :category }
114
- it { should validate_inclusion_of(:confidence).in_range(confidence_range) }
115
- it { should validate_inclusion_of(:method).in_array(methods) }
116
- it { should validate_presence_of :name }
117
- it { should validate_presence_of :path }
111
+ it { is_expected.to validate_presence_of :category }
112
+ it { is_expected.to validate_inclusion_of(:confidence).in_range(confidence_range) }
113
+ it { is_expected.to validate_inclusion_of(:method).in_array(methods) }
114
+ it { is_expected.to validate_presence_of :name }
115
+ it { is_expected.to validate_presence_of :path }
118
116
 
119
117
  context 'params' do
120
118
  it 'should not validate presence of params because it default to [] and can never be nil' do
121
- web_vuln.should_not validate_presence_of(:params)
119
+ expect(web_vuln).not_to validate_presence_of(:params)
122
120
  end
123
121
 
124
122
  context 'validates parameters' do
@@ -129,9 +127,9 @@ describe Mdm::WebVuln do
129
127
  it 'should validate params is an Array' do
130
128
  web_vuln.params = ''
131
129
 
132
- web_vuln.params.should_not be_an Array
133
- web_vuln.should_not be_valid
134
- web_vuln.errors[:params].should include(
130
+ expect(web_vuln.params).not_to be_an Array
131
+ expect(web_vuln).not_to be_valid
132
+ expect(web_vuln.errors[:params]).to include(
135
133
  "is not an Array. #{type_signature_sentence}"
136
134
  )
137
135
  end
@@ -140,7 +138,7 @@ describe Mdm::WebVuln do
140
138
  web_vuln.params = []
141
139
  web_vuln.valid?
142
140
 
143
- web_vuln.errors[:params].should be_empty
141
+ expect(web_vuln.errors[:params]).to be_empty
144
142
  end
145
143
 
146
144
  context 'with bad element' do
@@ -158,12 +156,12 @@ describe Mdm::WebVuln do
158
156
  end
159
157
 
160
158
  it 'should not be an Array' do
161
- web_vuln.params.first.should_not be_an Array
159
+ expect(web_vuln.params.first).not_to be_an Array
162
160
  end
163
161
 
164
162
  it 'should validate elements of params are Arrays' do
165
- web_vuln.should_not be_valid
166
- web_vuln.errors[:params].should include(
163
+ expect(web_vuln).not_to be_valid
164
+ expect(web_vuln.errors[:params]).to include(
167
165
  "has non-Array at index #{index} (#{element.inspect}). " \
168
166
  "#{type_signature_sentence}"
169
167
  )
@@ -176,12 +174,12 @@ describe Mdm::WebVuln do
176
174
  end
177
175
 
178
176
  it 'should have length < 2' do
179
- web_vuln.params.first.length.should < 2
177
+ expect(web_vuln.params.first.length).to be < 2
180
178
  end
181
179
 
182
180
  it 'should validate elements of params are not too short' do
183
- web_vuln.should_not be_valid
184
- web_vuln.errors[:params].should include(
181
+ expect(web_vuln).not_to be_valid
182
+ expect(web_vuln.errors[:params]).to include(
185
183
  "has too few elements at index #{index} (#{element.inspect}). " \
186
184
  "#{type_signature_sentence}"
187
185
  )
@@ -194,12 +192,12 @@ describe Mdm::WebVuln do
194
192
  end
195
193
 
196
194
  it 'should have length > 2' do
197
- web_vuln.params.first.length.should > 2
195
+ expect(web_vuln.params.first.length).to be > 2
198
196
  end
199
197
 
200
198
  it 'should validate elements of params are not too long' do
201
- web_vuln.should_not be_valid
202
- web_vuln.errors[:params].should include(
199
+ expect(web_vuln).not_to be_valid
200
+ expect(web_vuln.errors[:params]).to include(
203
201
  "has too many elements at index #{index} (#{element.inspect}). " \
204
202
  "#{type_signature_sentence}"
205
203
  )
@@ -218,12 +216,12 @@ describe Mdm::WebVuln do
218
216
  end
219
217
 
220
218
  it 'should have blank parameter name' do
221
- web_vuln.params.first.first.should be_empty
219
+ expect(web_vuln.params.first.first).to be_empty
222
220
  end
223
221
 
224
222
  it 'should validate that parameter name is not empty' do
225
- web_vuln.should_not be_valid
226
- web_vuln.errors[:params].should include(
223
+ expect(web_vuln).not_to be_valid
224
+ expect(web_vuln.errors[:params]).to include(
227
225
  "has blank parameter name at index #{index} " \
228
226
  "(#{element.inspect}). " \
229
227
  "#{type_signature_sentence}"
@@ -238,12 +236,12 @@ describe Mdm::WebVuln do
238
236
  end
239
237
 
240
238
  it 'should not have String for parameter name' do
241
- web_vuln.params.first.first.should_not be_a String
239
+ expect(web_vuln.params.first.first).not_to be_a String
242
240
  end
243
241
 
244
242
  it 'should validate that parameter name is a String' do
245
- web_vuln.should_not be_valid
246
- web_vuln.errors[:params].should include(
243
+ expect(web_vuln).not_to be_valid
244
+ expect(web_vuln.errors[:params]).to include(
247
245
  "has non-String parameter name (#{parameter_name.inspect}) " \
248
246
  "at index #{index} (#{element.inspect}). " \
249
247
  "#{type_signature_sentence}"
@@ -263,12 +261,12 @@ describe Mdm::WebVuln do
263
261
  end
264
262
 
265
263
  it 'should not have String for parameter name' do
266
- web_vuln.params.first.second.should_not be_a String
264
+ expect(web_vuln.params.first.second).not_to be_a String
267
265
  end
268
266
 
269
267
  it 'should validate that parameter value is a String' do
270
- web_vuln.should_not be_valid
271
- web_vuln.errors[:params].should include(
268
+ expect(web_vuln).not_to be_valid
269
+ expect(web_vuln.errors[:params]).to include(
272
270
  "has non-String parameter value (#{parameter_value}) " \
273
271
  "at index #{index} (#{element.inspect}). " \
274
272
  "#{type_signature_sentence}"
@@ -280,13 +278,13 @@ describe Mdm::WebVuln do
280
278
  end
281
279
  end
282
280
 
283
- it { should validate_presence_of :proof }
284
- it { should validate_inclusion_of(:risk).in_range(risk_range) }
285
- it { should validate_presence_of :web_site }
281
+ it { is_expected.to validate_presence_of :proof }
282
+ it { is_expected.to validate_inclusion_of(:risk).in_range(risk_range) }
283
+ it { is_expected.to validate_presence_of :web_site }
286
284
  end
287
285
 
288
286
  context 'serializations' do
289
- it { should serialize(:params).as_instance_of(MetasploitDataModels::Base64Serializer) }
287
+ it { is_expected.to serialize(:params).as_instance_of(MetasploitDataModels::Base64Serializer) }
290
288
  end
291
289
 
292
290
  context '#params' do
@@ -299,12 +297,12 @@ describe Mdm::WebVuln do
299
297
  end
300
298
 
301
299
  it 'should default to []' do
302
- params.should == default
300
+ expect(params).to eq(default)
303
301
  end
304
302
 
305
303
  it 'should return default if set to nil' do
306
304
  web_vuln.params = nil
307
- web_vuln.params.should == default
305
+ expect(web_vuln.params).to eq(default)
308
306
  end
309
307
 
310
308
  it 'should return default if set to nil and saved' do
@@ -312,7 +310,7 @@ describe Mdm::WebVuln do
312
310
  web_vuln.params = nil
313
311
  web_vuln.save!
314
312
 
315
- web_vuln.params.should == default
313
+ expect(web_vuln.params).to eq(default)
316
314
  end
317
315
  end
318
316
  end