metasploit_data_models 0.24.4 → 0.24.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -3
  3. data/.travis.yml +3 -6
  4. data/CONTRIBUTING.md +52 -10
  5. data/Gemfile +8 -1
  6. data/Rakefile +0 -23
  7. data/app/models/mdm/api_key.rb +1 -41
  8. data/app/models/mdm/client.rb +1 -41
  9. data/app/models/mdm/cred.rb +19 -107
  10. data/app/models/mdm/event.rb +1 -48
  11. data/app/models/mdm/exploit_attempt.rb +16 -65
  12. data/app/models/mdm/exploited_host.rb +1 -28
  13. data/app/models/mdm/host_detail.rb +1 -45
  14. data/app/models/mdm/host_tag.rb +8 -6
  15. data/app/models/mdm/listener.rb +1 -53
  16. data/app/models/mdm/macro.rb +0 -42
  17. data/app/models/mdm/mod_ref.rb +0 -21
  18. data/app/models/mdm/module/action.rb +0 -15
  19. data/app/models/mdm/module/arch.rb +0 -10
  20. data/app/models/mdm/module/author.rb +0 -16
  21. data/app/models/mdm/module/mixin.rb +0 -13
  22. data/app/models/mdm/module/platform.rb +0 -11
  23. data/app/models/mdm/module/target.rb +0 -18
  24. data/app/models/mdm/nexpose_console.rb +4 -82
  25. data/app/models/mdm/profile.rb +0 -36
  26. data/app/models/mdm/route.rb +5 -17
  27. data/app/models/mdm/session_event.rb +1 -33
  28. data/app/models/mdm/tag.rb +10 -49
  29. data/app/models/mdm/task.rb +45 -94
  30. data/app/models/mdm/task_cred.rb +0 -29
  31. data/app/models/mdm/task_host.rb +0 -25
  32. data/app/models/mdm/task_service.rb +0 -25
  33. data/app/models/mdm/task_session.rb +0 -25
  34. data/app/models/mdm/user.rb +6 -188
  35. data/app/models/mdm/vuln_attempt.rb +12 -37
  36. data/app/models/mdm/vuln_detail.rb +5 -139
  37. data/app/models/mdm/vuln_ref.rb +1 -4
  38. data/app/models/mdm/web_form.rb +1 -35
  39. data/app/models/mdm/web_page.rb +1 -70
  40. data/app/models/mdm/web_site.rb +1 -51
  41. data/app/models/mdm/wmap_request.rb +0 -85
  42. data/app/models/mdm/wmap_target.rb +0 -40
  43. data/app/models/mdm/workspace.rb +14 -152
  44. data/app/models/metasploit_data_models/automatic_exploitation.rb +16 -0
  45. data/app/models/metasploit_data_models/automatic_exploitation/match.rb +24 -19
  46. data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +5 -33
  47. data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +4 -22
  48. data/app/models/metasploit_data_models/automatic_exploitation/run.rb +3 -13
  49. data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
  50. data/app/models/metasploit_data_models/module_run.rb +1 -1
  51. data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
  52. data/app/validators/ip_format_validator.rb +0 -4
  53. data/app/validators/parameters_validator.rb +0 -12
  54. data/app/validators/password_is_strong_validator.rb +1 -10
  55. data/lib/mdm/host/operating_system_normalization.rb +10 -7
  56. data/lib/metasploit_data_models.rb +0 -4
  57. data/lib/metasploit_data_models/engine.rb +0 -2
  58. data/lib/metasploit_data_models/serialized_prefs.rb +0 -6
  59. data/lib/metasploit_data_models/version.rb +10 -24
  60. data/lib/tasks/yard.rake +33 -0
  61. data/metasploit_data_models.gemspec +2 -9
  62. data/spec/app/models/mdm/api_key_spec.rb +3 -1
  63. data/spec/app/models/mdm/client_spec.rb +11 -9
  64. data/spec/app/models/mdm/cred_spec.rb +54 -42
  65. data/spec/app/models/mdm/event_spec.rb +23 -21
  66. data/spec/app/models/mdm/exploit_attempt_spec.rb +21 -19
  67. data/spec/app/models/mdm/exploited_host_spec.rb +13 -11
  68. data/spec/app/models/mdm/host_detail_spec.rb +17 -15
  69. data/spec/app/models/mdm/host_spec.rb +260 -261
  70. data/spec/app/models/mdm/host_tag_spec.rb +8 -6
  71. data/spec/app/models/mdm/listener_spec.rb +32 -30
  72. data/spec/app/models/mdm/loot_spec.rb +23 -21
  73. data/spec/app/models/mdm/macro_spec.rb +3 -1
  74. data/spec/app/models/mdm/mod_ref_spec.rb +3 -1
  75. data/spec/app/models/mdm/module/action_spec.rb +12 -10
  76. data/spec/app/models/mdm/module/arch_spec.rb +12 -10
  77. data/spec/app/models/mdm/module/author_spec.rb +17 -22
  78. data/spec/app/models/mdm/module/detail_spec.rb +75 -184
  79. data/spec/app/models/mdm/module/mixin_spec.rb +12 -10
  80. data/spec/app/models/mdm/module/platform_spec.rb +12 -10
  81. data/spec/app/models/mdm/module/ref_spec.rb +12 -10
  82. data/spec/app/models/mdm/module/target_spec.rb +15 -13
  83. data/spec/app/models/mdm/nexpose_console_spec.rb +37 -35
  84. data/spec/app/models/mdm/note_spec.rb +25 -23
  85. data/spec/app/models/mdm/profile_spec.rb +3 -1
  86. data/spec/app/models/mdm/ref_spec.rb +12 -10
  87. data/spec/app/models/mdm/route_spec.rb +8 -6
  88. data/spec/app/models/mdm/service_spec.rb +40 -38
  89. data/spec/app/models/mdm/session_event_spec.rb +12 -10
  90. data/spec/app/models/mdm/session_spec.rb +15 -13
  91. data/spec/app/models/mdm/tag_spec.rb +29 -29
  92. data/spec/app/models/mdm/task_cred_spec.rb +11 -9
  93. data/spec/app/models/mdm/task_host_spec.rb +11 -9
  94. data/spec/app/models/mdm/task_service_spec.rb +11 -9
  95. data/spec/app/models/mdm/task_session_spec.rb +9 -7
  96. data/spec/app/models/mdm/task_spec.rb +29 -27
  97. data/spec/app/models/mdm/user_spec.rb +19 -17
  98. data/spec/app/models/mdm/vuln_attempt_spec.rb +16 -14
  99. data/spec/app/models/mdm/vuln_detail_spec.rb +28 -26
  100. data/spec/app/models/mdm/vuln_ref_spec.rb +10 -8
  101. data/spec/app/models/mdm/vuln_spec.rb +26 -24
  102. data/spec/app/models/mdm/web_form_spec.rb +13 -11
  103. data/spec/app/models/mdm/web_page_spec.rb +21 -19
  104. data/spec/app/models/mdm/web_site_spec.rb +23 -21
  105. data/spec/app/models/mdm/web_vuln_spec.rb +65 -63
  106. data/spec/app/models/mdm/wmap_request_spec.rb +3 -1
  107. data/spec/app/models/mdm/wmap_target_spec.rb +3 -1
  108. data/spec/app/models/mdm/workspace_spec.rb +100 -97
  109. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +5 -3
  110. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +15 -13
  111. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +3 -1
  112. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +3 -1
  113. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +12 -10
  114. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +6 -4
  115. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +23 -21
  116. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +11 -9
  117. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +23 -21
  118. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +6 -4
  119. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +15 -22
  120. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +6 -4
  121. data/spec/app/models/metasploit_data_models/module_run_spec.rb +3 -1
  122. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +20 -18
  123. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +8 -6
  124. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +10 -8
  125. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +10 -8
  126. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +4 -2
  127. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +10 -8
  128. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +8 -6
  129. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +11 -9
  130. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +7 -5
  131. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +19 -17
  132. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +7 -5
  133. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +23 -61
  134. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +10 -8
  135. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  136. data/spec/app/validators/password_is_strong_validator_spec.rb +46 -54
  137. data/spec/dummy/db/structure.sql +3403 -0
  138. data/spec/factories/mdm/module/details.rb +1 -1
  139. data/spec/lib/base64_serializer_spec.rb +19 -19
  140. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +12 -18
  141. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +6 -4
  142. data/spec/lib/metasploit_data_models/match/child_spec.rb +4 -2
  143. data/spec/lib/metasploit_data_models/match/parent_spec.rb +6 -4
  144. data/spec/lib/metasploit_data_models/version_spec.rb +141 -3
  145. data/spec/spec_helper.rb +12 -86
  146. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
  147. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
  148. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
  149. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
  150. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
  151. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
  152. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +6 -7
  153. metadata +9 -67
  154. data/CHANGELOG.md +0 -6
  155. data/RELEASING.md +0 -88
  156. data/UPGRADING.md +0 -1
  157. data/lib/metasploit_data_models/automatic_exploitation.rb +0 -25
  158. data/spec/lib/metasploit_data_models_spec.rb +0 -4
@@ -1,3 +1,5 @@
1
- RSpec.describe Mdm::WmapRequest, type: :model do
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::WmapRequest do
2
4
  it_should_behave_like 'Metasploit::Concern.run'
3
5
  end
@@ -1,3 +1,5 @@
1
- RSpec.describe Mdm::WmapTarget, type: :model do
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::WmapTarget do
2
4
  it_should_behave_like 'Metasploit::Concern.run'
3
5
  end
@@ -1,4 +1,6 @@
1
- RSpec.describe Mdm::Workspace, type: :model do
1
+ require 'spec_helper'
2
+
3
+ describe Mdm::Workspace do
2
4
  subject(:workspace) do
3
5
  FactoryGirl.build(:mdm_workspace)
4
6
  end
@@ -12,7 +14,7 @@ RSpec.describe Mdm::Workspace, type: :model do
12
14
  context 'factory' do
13
15
  it 'should be valid' do
14
16
  workspace = FactoryGirl.build(:mdm_workspace)
15
- expect(workspace).to be_valid
17
+ workspace.should be_valid
16
18
  end
17
19
  end
18
20
 
@@ -38,27 +40,27 @@ RSpec.describe Mdm::Workspace, type: :model do
38
40
  end
39
41
 
40
42
  context 'associations' do
41
- it { is_expected.to have_many(:clients).class_name('Mdm::Client').through(:hosts) }
42
- it { is_expected.to have_many(:creds).class_name('Mdm::Cred').through(:services) }
43
- it { is_expected.to have_many(:events).class_name('Mdm::Event') }
44
- it { is_expected.to have_many(:exploited_hosts).class_name('Mdm::ExploitedHost').through(:hosts) }
45
- it { is_expected.to have_many(:hosts).class_name('Mdm::Host') }
46
- it { is_expected.to have_many(:listeners).class_name('Mdm::Listener').dependent(:destroy) }
47
- it { is_expected.to have_many(:loots).class_name('Mdm::Loot').through(:hosts) }
48
- it { is_expected.to have_many(:notes).class_name('Mdm::Note') }
49
- it { is_expected.to belong_to(:owner).class_name('Mdm::User').with_foreign_key('owner_id') }
50
- it { is_expected.to have_many(:services).class_name('Mdm::Service').through(:hosts).with_foreign_key('service_id') }
51
- it { is_expected.to have_many(:sessions).class_name('Mdm::Session').through(:hosts) }
52
- it { is_expected.to have_many(:tasks).class_name('Mdm::Task').dependent(:destroy).order('created_at DESC') }
53
- it { is_expected.to have_and_belong_to_many(:users).class_name('Mdm::User') }
54
- it { is_expected.to have_many(:vulns).class_name('Mdm::Vuln').through(:hosts) }
43
+ it { should have_many(:clients).class_name('Mdm::Client').through(:hosts) }
44
+ it { should have_many(:creds).class_name('Mdm::Cred').through(:services) }
45
+ it { should have_many(:events).class_name('Mdm::Event') }
46
+ it { should have_many(:exploited_hosts).class_name('Mdm::ExploitedHost').through(:hosts) }
47
+ it { should have_many(:hosts).class_name('Mdm::Host') }
48
+ it { should have_many(:listeners).class_name('Mdm::Listener').dependent(:destroy) }
49
+ it { should have_many(:loots).class_name('Mdm::Loot').through(:hosts) }
50
+ it { should have_many(:notes).class_name('Mdm::Note') }
51
+ it { should belong_to(:owner).class_name('Mdm::User').with_foreign_key('owner_id') }
52
+ it { should have_many(:services).class_name('Mdm::Service').through(:hosts).with_foreign_key('service_id') }
53
+ it { should have_many(:sessions).class_name('Mdm::Session').through(:hosts) }
54
+ it { should have_many(:tasks).class_name('Mdm::Task').dependent(:destroy).order('created_at DESC') }
55
+ it { should have_and_belong_to_many(:users).class_name('Mdm::User') }
56
+ it { should have_many(:vulns).class_name('Mdm::Vuln').through(:hosts) }
55
57
  end
56
58
 
57
59
  context 'callbacks' do
58
60
  context 'before_save' do
59
61
  context '#normalize' do
60
62
  it 'should be called' do
61
- expect(workspace).to receive(:normalize)
63
+ workspace.should_receive(:normalize)
62
64
  workspace.run_callbacks(:save, false)
63
65
  end
64
66
  end
@@ -66,21 +68,21 @@ RSpec.describe Mdm::Workspace, type: :model do
66
68
  end
67
69
 
68
70
  context 'columns' do
69
- it { is_expected.to have_db_column(:boundary).of_type(:string).with_options(:limit => 4 * (2 ** 10)) }
70
- it { is_expected.to have_db_column(:description).of_type(:string).with_options(:limit => 4 * (2 ** 10)) }
71
- it { is_expected.to have_db_column(:limit_to_network).of_type(:boolean).with_options(:default => false, :null => false) }
72
- it { is_expected.to have_db_column(:name).of_type(:string) }
73
- it { is_expected.to have_db_column(:owner_id).of_type(:integer) }
71
+ it { should have_db_column(:boundary).of_type(:string).with_options(:limit => 4 * (2 ** 10)) }
72
+ it { should have_db_column(:description).of_type(:string).with_options(:limit => 4 * (2 ** 10)) }
73
+ it { should have_db_column(:limit_to_network).of_type(:boolean).with_options(:default => false, :null => false) }
74
+ it { should have_db_column(:name).of_type(:string) }
75
+ it { should have_db_column(:owner_id).of_type(:integer) }
74
76
 
75
77
  context 'timestamps' do
76
- it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
77
- it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
78
+ it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
79
+ it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
78
80
  end
79
81
  end
80
82
 
81
83
  context 'CONSTANTS' do
82
84
  it 'should define the DEFAULT name' do
83
- expect(described_class::DEFAULT).to eq(default)
85
+ described_class::DEFAULT.should == default
84
86
  end
85
87
  end
86
88
 
@@ -99,8 +101,8 @@ RSpec.describe Mdm::Workspace, type: :model do
99
101
  workspace.valid?
100
102
  end
101
103
 
102
- it 'should validate using #valid_ip_or_range?' do
103
- expect(workspace).to receive(:valid_ip_or_range?).with(boundary).and_return(false)
104
+ it 'should validate using #valid_ip_or_range?', :pending => 'https://www.pivotaltracker.com/story/show/43244445' do
105
+ workspace.should_receive(:valid_ip_or_range?).with(boundary).and_return(false)
104
106
 
105
107
  workspace.valid?
106
108
  end
@@ -111,7 +113,7 @@ RSpec.describe Mdm::Workspace, type: :model do
111
113
  end
112
114
 
113
115
  it 'should not record an error' do
114
- expect(workspace.errors[:boundary]).not_to include(error)
116
+ workspace.errors[:boundary].should_not include(error)
115
117
  end
116
118
  end
117
119
 
@@ -121,7 +123,7 @@ RSpec.describe Mdm::Workspace, type: :model do
121
123
  end
122
124
 
123
125
  it 'should not record an error' do
124
- expect(workspace.errors[:boundary]).not_to include(error)
126
+ workspace.errors[:boundary].should_not include(error)
125
127
  end
126
128
  end
127
129
 
@@ -131,20 +133,20 @@ RSpec.describe Mdm::Workspace, type: :model do
131
133
  end
132
134
 
133
135
  it 'should record error that boundary must be a valid IP range', :pending => 'https://www.pivotaltracker.com/story/show/43171927' do
134
- expect(workspace).not_to be_valid
135
- expect(workkspace.errors[:boundary]).to include(error)
136
+ workspace.should_not be_valid
137
+ workkspace.errors[:boundary].should include(error)
136
138
  end
137
139
  end
138
140
  end
139
141
 
140
142
  context 'description' do
141
- it { is_expected.to ensure_length_of(:description).is_at_most(4 * (2 ** 10)) }
143
+ it { should ensure_length_of(:description).is_at_most(4 * (2 ** 10)) }
142
144
  end
143
145
 
144
146
  context 'name' do
145
- it { is_expected.to ensure_length_of(:name).is_at_most(2**8 - 1) }
146
- it { is_expected.to validate_presence_of :name }
147
- it { is_expected.to validate_uniqueness_of :name }
147
+ it { should ensure_length_of(:name).is_at_most(2**8 - 1) }
148
+ it { should validate_presence_of :name }
149
+ it { should validate_uniqueness_of :name }
148
150
  end
149
151
  end
150
152
 
@@ -210,25 +212,27 @@ RSpec.describe Mdm::Workspace, type: :model do
210
212
  # to_a to make query return instances
211
213
  found_creds = workspace.creds.to_a
212
214
 
213
- expect(found_creds.length).to be > 0
215
+ found_creds.length.should > 0
216
+ found_cred = found_creds.first
217
+
218
+ end
219
+
220
+ it 'should include hosts' do
221
+ found_creds = workspace.creds.to_a
214
222
 
215
- expect(
216
- found_creds.none? { |found_cred|
217
- found_cred.service.nil?
218
- }
219
- ).to eq(true)
223
+ found_creds.length.should > 0
224
+ found_cred = found_creds.first
225
+ service = found_cred.service
220
226
  end
221
227
 
222
228
  it 'should return only Mdm::Creds from hosts in workspace' do
223
229
  found_creds = workspace.creds
224
230
 
225
- expect(found_creds.length).to eq(creds.length)
231
+ found_creds.length.should == creds.length
226
232
 
227
- expect(
228
- found_creds.all? { |cred|
229
- cred.service.host.workspace == workspace
230
- }
231
- ).to eq(true)
233
+ found_creds.all? { |cred|
234
+ cred.service.host.workspace == workspace
235
+ }.should be_true
232
236
  end
233
237
  end
234
238
 
@@ -248,7 +252,7 @@ RSpec.describe Mdm::Workspace, type: :model do
248
252
  workspace = described_class.default
249
253
  }.to change(Mdm::Workspace, :count).by(0)
250
254
 
251
- expect(workspace).to be_default
255
+ workspace.should be_default
252
256
  end
253
257
  end
254
258
 
@@ -260,7 +264,7 @@ RSpec.describe Mdm::Workspace, type: :model do
260
264
  workspace = described_class.default
261
265
  }.to change(Mdm::Workspace, :count).by(1)
262
266
 
263
- expect(workspace).to be_default
267
+ workspace.should be_default
264
268
  end
265
269
  end
266
270
  end
@@ -275,18 +279,20 @@ RSpec.describe Mdm::Workspace, type: :model do
275
279
  workspace.name = default
276
280
  end
277
281
 
278
- it { is_expected.to eq(true) }
282
+ it {
283
+ should be_true
284
+ }
279
285
  end
280
286
 
281
287
  context 'without DEFAULT name' do
282
- it { is_expected.to eq(false) }
288
+ it { should be_false }
283
289
  end
284
290
  end
285
291
 
286
292
  context '#each_cred' do
287
293
  it 'should pass each of the #creds to the block' do
288
294
  creds = FactoryGirl.create_list(:mdm_cred, 2)
289
- allow(workspace).to receive(:creds).and_return(creds)
295
+ workspace.stub(:creds => creds)
290
296
 
291
297
  expect { |block|
292
298
  workspace.each_cred(&block)
@@ -297,7 +303,7 @@ RSpec.describe Mdm::Workspace, type: :model do
297
303
  context '#each_host_tag' do
298
304
  it 'should pass each of the #host_tags to the block' do
299
305
  tags = FactoryGirl.create_list(:mdm_tag, 2)
300
- expect(workspace).to receive(:host_tags).and_return(tags)
306
+ workspace.stub(:host_tags => tags)
301
307
 
302
308
  expect { |block|
303
309
  workspace.each_host_tag(&block)
@@ -306,14 +312,6 @@ RSpec.describe Mdm::Workspace, type: :model do
306
312
  end
307
313
 
308
314
  context '#host_tags' do
309
- subject(:host_tags) do
310
- workspace.host_tags
311
- end
312
-
313
- #
314
- # lets
315
- #
316
-
317
315
  let(:other_tags) do
318
316
  FactoryGirl.create_list(
319
317
  :mdm_tag,
@@ -328,11 +326,15 @@ RSpec.describe Mdm::Workspace, type: :model do
328
326
  )
329
327
  end
330
328
 
329
+ subject(:host_tags) do
330
+ workspace.host_tags
331
+ end
332
+
331
333
  #
332
334
  # Let!s (let + before(:each))
333
335
  #
334
336
 
335
- let!(:first_host_tags) do
337
+ let!(:host_tags) do
336
338
  host_tags = []
337
339
 
338
340
  hosts.zip(tags) do |host, tag|
@@ -344,7 +346,7 @@ RSpec.describe Mdm::Workspace, type: :model do
344
346
  host_tags
345
347
  end
346
348
 
347
- let!(:second_host_tags) do
349
+ let!(:other_host_tags) do
348
350
  host_tags = []
349
351
 
350
352
  other_hosts.zip(other_tags) do |host, tag|
@@ -360,16 +362,24 @@ RSpec.describe Mdm::Workspace, type: :model do
360
362
  should be_a ActiveRecord::Relation
361
363
  end
362
364
 
365
+ it 'should include hosts' do
366
+ found_tags = workspace.host_tags.to_a
367
+
368
+ found_tags.length.should > 0
369
+
370
+ tag = found_tags.first
371
+ end
372
+
363
373
  it 'should return only Mdm::Tags from hosts in the workspace' do
364
- expect(host_tags.length).to eq(tags.length)
374
+ found_tags = workspace.host_tags
365
375
 
366
- expect(
367
- host_tags.all? { |tag|
368
- tag.hosts.any? { |host|
369
- host.workspace == workspace
370
- }
371
- }
372
- ).to eq(true)
376
+ found_tags.length.should == tags.length
377
+
378
+ found_tags.all? { |tag|
379
+ tag.hosts.any? { |host|
380
+ host.workspace == workspace
381
+ }
382
+ }.should be_true
373
383
  end
374
384
  end
375
385
 
@@ -394,7 +404,7 @@ RSpec.describe Mdm::Workspace, type: :model do
394
404
  it "should remove spaces" do
395
405
  normalize
396
406
 
397
- expect(workspace.boundary).to eq(stripped_boundary)
407
+ workspace.boundary.should == stripped_boundary
398
408
  end
399
409
  end
400
410
 
@@ -441,13 +451,11 @@ RSpec.describe Mdm::Workspace, type: :model do
441
451
  it 'should return only Mdm::WebPages from hosts in the workspace' do
442
452
  found_web_forms = workspace.web_forms
443
453
 
444
- expect(found_web_forms.length).to eq(web_forms.length)
454
+ found_web_forms.length.should == web_forms.length
445
455
 
446
- expect(
447
- found_web_forms.all? { |web_form|
448
- web_form.web_site.service.host.workspace == workspace
449
- }
450
- ).to eq(true)
456
+ found_web_forms.all? { |web_form|
457
+ web_form.web_site.service.host.workspace == workspace
458
+ }.should be_true
451
459
  end
452
460
  end
453
461
 
@@ -472,17 +480,15 @@ RSpec.describe Mdm::Workspace, type: :model do
472
480
 
473
481
  it 'should return only Mdm::WebVulns from hosts in the workspace' do
474
482
  # there are more web sites than those in the workspace
475
- expect(Mdm::WebSite.count).to be > web_sites.count
483
+ Mdm::WebSite.count.should > web_sites.count
476
484
 
477
485
  found_web_sites = workspace.web_sites
478
486
 
479
- expect(found_web_sites.length).to eq(web_sites.count)
487
+ found_web_sites.length.should == web_sites.count
480
488
 
481
- expect(
482
- found_web_sites.all? { |web_site|
483
- web_site.service.host.workspace == workspace
484
- }
485
- ).to eq(true)
489
+ found_web_sites.all? { |web_site|
490
+ web_site.service.host.workspace == workspace
491
+ }.should be_true
486
492
  end
487
493
  end
488
494
 
@@ -513,17 +519,16 @@ RSpec.describe Mdm::Workspace, type: :model do
513
519
  end
514
520
 
515
521
  it 'should return only Mdm::WebVulns from hosts in the workspace' do
516
- expect(Mdm::WebVuln.count).to be > web_vulns.length
522
+ Mdm::WebVuln.count.should > web_vulns.length
517
523
 
518
524
  found_web_vulns = workspace.web_vulns
519
525
 
520
- expect(found_web_vulns.length).to eq(web_vulns.length)
526
+ found_web_vulns.length.should == web_vulns.length
527
+
528
+ found_web_vulns.all? { |web_vuln|
529
+ web_vuln.web_site.service.host.workspace == workspace
530
+ }.should be_true
521
531
 
522
- expect(
523
- found_web_vulns.all? { |web_vuln|
524
- web_vuln.web_site.service.host.workspace == workspace
525
- }
526
- ).to eq(true)
527
532
  end
528
533
  end
529
534
 
@@ -544,11 +549,9 @@ RSpec.describe Mdm::Workspace, type: :model do
544
549
  it "should reject #unique_web_forms from host addresses that aren't in addresses" do
545
550
  web_forms = workspace.web_unique_forms([selected_address])
546
551
 
547
- expect(
548
- web_forms.all? { |web_form|
549
- expect(web_form.web_site.service.host.address).to eq(selected_address)
550
- }
551
- ).to eq(true)
552
+ web_forms.all? { |web_form|
553
+ web_form.web_site.service.host.address.should == selected_address
554
+ }.should be_true
552
555
  end
553
556
  end
554
557
  end
@@ -1,4 +1,6 @@
1
- RSpec.describe MetasploitDataModels::AutomaticExploitation::MatchResult, type: :model do
1
+ require 'spec_helper'
2
+
3
+ describe MetasploitDataModels::AutomaticExploitation::MatchResult do
2
4
  it_should_behave_like 'Metasploit::Concern.run'
3
5
 
4
6
  context "database" do
@@ -9,8 +11,8 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::MatchResult, type: :
9
11
  end
10
12
 
11
13
  context 'associations' do
12
- it { is_expected.to belong_to(:match).class_name('MetasploitDataModels::AutomaticExploitation::Match') }
13
- it { is_expected.to belong_to(:run).class_name('MetasploitDataModels::AutomaticExploitation::Run') }
14
+ it { should belong_to(:match).class_name('MetasploitDataModels::AutomaticExploitation::Match') }
15
+ it { should belong_to(:run).class_name('MetasploitDataModels::AutomaticExploitation::Run') }
14
16
  end
15
17
 
16
18
  context 'scopes' do
@@ -1,25 +1,27 @@
1
- RSpec.describe MetasploitDataModels::AutomaticExploitation::MatchSet, type: :model do
1
+ require 'spec_helper'
2
+
3
+ describe MetasploitDataModels::AutomaticExploitation::MatchSet do
2
4
  describe "database" do
3
5
  describe "foreign_keys" do
4
- it { is_expected.to have_db_column(:workspace_id).of_type(:integer) }
5
- it { is_expected.to have_db_column(:user_id).of_type(:integer) }
6
+ it { should have_db_column(:workspace_id).of_type(:integer) }
7
+ it { should have_db_column(:user_id).of_type(:integer) }
6
8
  end
7
9
 
8
10
  describe "indices" do
9
- it { is_expected.to have_db_index(:user_id) }
10
- it { is_expected.to have_db_index(:workspace_id) }
11
+ it { should have_db_index(:user_id) }
12
+ it { should have_db_index(:workspace_id) }
11
13
  end
12
14
  end
13
15
 
14
16
  describe "associations" do
15
- it { is_expected.to have_many(:matches).class_name('MetasploitDataModels::AutomaticExploitation::Match') }
16
- it { is_expected.to have_many(:matches).inverse_of(:match_set) }
17
- it { is_expected.to have_many(:runs).class_name('MetasploitDataModels::AutomaticExploitation::Run') }
18
- it { is_expected.to have_many(:runs).inverse_of(:match_set) }
19
- it { is_expected.to belong_to(:user).class_name('Mdm::User') }
20
- it { is_expected.to belong_to(:user).inverse_of(:automatic_exploitation_match_sets) }
21
- it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
22
- it { is_expected.to belong_to(:workspace).inverse_of(:automatic_exploitation_match_sets) }
17
+ it { should have_many(:matches).class_name('MetasploitDataModels::AutomaticExploitation::Match') }
18
+ it { should have_many(:matches).inverse_of(:match_set) }
19
+ it { should have_many(:runs).class_name('MetasploitDataModels::AutomaticExploitation::Run') }
20
+ it { should have_many(:runs).inverse_of(:match_set) }
21
+ it { should belong_to(:user).class_name('Mdm::User') }
22
+ it { should belong_to(:user).inverse_of(:automatic_exploitation_match_sets) }
23
+ it { should belong_to(:workspace).class_name('Mdm::Workspace') }
24
+ it { should belong_to(:workspace).inverse_of(:automatic_exploitation_match_sets) }
23
25
  end
24
26
 
25
27
  describe "validations" do