metasploit_data_models 1.2.10 → 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/mdm/cred.rb +6 -6
  3. data/app/models/mdm/host.rb +4 -6
  4. data/app/models/mdm/workspace.rb +10 -10
  5. data/lib/metasploit_data_models.rb +2 -0
  6. data/lib/metasploit_data_models/version.rb +1 -1
  7. data/spec/app/models/mdm/cred_spec.rb +3 -3
  8. data/spec/app/models/mdm/event_spec.rb +1 -1
  9. data/spec/app/models/mdm/module/detail_spec.rb +2 -2
  10. data/spec/app/models/mdm/service_spec.rb +1 -1
  11. data/spec/app/models/mdm/web_page_spec.rb +47 -0
  12. data/spec/app/models/mdm/web_vuln_spec.rb +2 -2
  13. data/spec/app/models/mdm/workspace_spec.rb +14 -14
  14. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +2 -2
  15. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +2 -2
  16. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -1
  17. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +2 -2
  18. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +1 -1
  19. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +1 -1
  20. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +1 -1
  21. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +1 -1
  22. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +2 -2
  23. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +1 -1
  24. data/spec/app/models/metasploit_data_models/module_run_spec.rb +12 -12
  25. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +1 -1
  26. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +1 -1
  27. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +1 -1
  28. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +2 -2
  29. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +1 -1
  30. data/spec/app/validators/parameters_validator_spec.rb +1 -1
  31. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +4 -4
  32. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +1 -1
  33. data/spec/lib/metasploit_data_models/match/child_spec.rb +1 -1
  34. data/spec/lib/metasploit_data_models/match/parent_spec.rb +2 -2
  35. data/spec/spec_helper.rb +21 -1
  36. data/spec/support/matchers/match_regex_exactly.rb +1 -1
  37. data/spec/support/shared/contexts/rex/text.rb +2 -2
  38. data/spec/support/shared/examples/coerces_inet_column_type_to_string.rb +2 -2
  39. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +1 -1
  40. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +1 -1
  41. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +1 -1
  42. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +1 -1
  43. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +1 -1
  44. data/spec/support/shared/examples/metasploit_data_models/search/visitor/relation/visit/matching_record.rb +1 -1
  45. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +1 -1
  46. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +1 -1
  47. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a742415475c3ecc46a6eb42ab6624c460e477d38
4
- data.tar.gz: f54104c06dae59d95ac70a845aff0a84702a583f
3
+ metadata.gz: eb305b0bd34c74f0e886505e15ef87be7272559a
4
+ data.tar.gz: cbf95468d8ef5b3a29f0fe960db0bb2d947bc303
5
5
  SHA512:
6
- metadata.gz: 88e35842d34a07e96c3d3bdc09ddd72c2b7297ab517fd455e0df40e7459593b7acd560b5e96f02919b652a8150a21efbc115c5d7eb741643c8619ea0367edaf2
7
- data.tar.gz: 50b0dd689434c86c8082d923e6dd5853a7eb094dbc5fbc646e0854f8b05923497c8f73117d2905cb081600fa666f6b72ecfe796b1aa1026173618b6f025def27
6
+ metadata.gz: c9de430fb61f90d5b9070001aea9bfbfeecdded14f8c0257d280673079605ccd1b9d60d732f12ff0ac2d898f41dbed22c747ad9759ab69ec998b727119edbf1c
7
+ data.tar.gz: 255550ca4f43e04113c0fd2946f07afb4c0fb115150d46c5b11d39db0dda55a68b1ddb2543ffbe60a8fd99bac303eabc8aa8b1bc671b87ca63f6b46d34c46592
@@ -158,9 +158,9 @@ class Mdm::Cred < ActiveRecord::Base
158
158
  # @return [ActiveRecord::Relation<Mdm::Cred>] ssh_key creds with matching {#ssh_key_id}.
159
159
  def ssh_private_keys
160
160
  return [] unless self.ssh_key_id
161
- matches = self.class.all(
162
- :conditions => ["creds.ptype = ? AND creds.proof ILIKE ?", "ssh_key", "%#{self.ssh_key_id}%"]
163
- )
161
+ matches = Mdm::Cred.where(
162
+ "ptype = ? AND proof ILIKE ?", "ssh_key", "%#{self.ssh_key_id}%"
163
+ ).to_a
164
164
  matches.select {|c| c.workspace == self.workspace}
165
165
  end
166
166
 
@@ -169,9 +169,9 @@ class Mdm::Cred < ActiveRecord::Base
169
169
  # @return [ActiveRecord::Relation<Mdm::Cred>] ssh_pubkey creds with matching {#ssh_key_id}.
170
170
  def ssh_public_keys
171
171
  return [] unless self.ssh_key_id
172
- matches = self.class.all(
173
- :conditions => ["creds.ptype = ? AND creds.proof ILIKE ?", "ssh_pubkey", "%#{self.ssh_key_id}%"]
174
- )
172
+ matches = Mdm::Cred.where(
173
+ "ptype = ? AND proof ILIKE ?", "ssh_pubkey", "%#{self.ssh_key_id}%"
174
+ ).to_a
175
175
  matches.select {|c| c.workspace == self.workspace}
176
176
  end
177
177
 
@@ -301,11 +301,11 @@ class Mdm::Host < ActiveRecord::Base
301
301
  # {Mdm::Module::Detail Details about modules} that were used to find {#vulns vulnerabilities} on this host.
302
302
  #
303
303
  # @return [ActiveRecord::Relation<Mdm::Module::Detail]
304
- has_many :module_details,
304
+ has_many :module_details, -> { uniq } ,
305
305
  :class_name => 'Mdm::Module::Detail',
306
306
  :source =>:detail,
307
- :through => :module_refs,
308
- :uniq => true
307
+ :through => :module_refs
308
+
309
309
 
310
310
  #
311
311
  # Attributes
@@ -498,9 +498,7 @@ class Mdm::Host < ActiveRecord::Base
498
498
  parameters = [formatted_parameter] * SEARCH_FIELDS.length
499
499
  conditions = [disjunction] + parameters
500
500
 
501
- {
502
- :conditions => conditions
503
- }
501
+ where(*conditions)
504
502
  }
505
503
  scope :tag_search,
506
504
  lambda { |*args| where("tags.name" => args[0]).includes(:tags) }
@@ -170,11 +170,11 @@ class Mdm::Workspace < ActiveRecord::Base
170
170
  #
171
171
  # @return [ActiveRecord::Relation<Mdm::Cred>]
172
172
  def creds
173
- Mdm::Cred.find(
174
- :all,
175
- :include => {:service => :host},
176
- :conditions => ["hosts.workspace_id = ?", self.id]
177
- )
173
+ Mdm::Cred
174
+ .joins(service: :host)
175
+ .where(hosts: {
176
+ workspace_id: self.id
177
+ })
178
178
  end
179
179
 
180
180
  # Returns default {Mdm::Workspace}.
@@ -224,11 +224,11 @@ class Mdm::Workspace < ActiveRecord::Base
224
224
  #
225
225
  # @return [ActiveRecord::Relation<Mdm::Tag>]
226
226
  def host_tags
227
- Mdm::Tag.find(
228
- :all,
229
- :include => :hosts,
230
- :conditions => ["hosts.workspace_id = ?", self.id]
231
- )
227
+ Mdm::Tag
228
+ .joins(:hosts)
229
+ .where(hosts: {
230
+ workspace_id: self.id
231
+ })
232
232
  end
233
233
 
234
234
  # Web forms found on {#web_sites}.
@@ -2,6 +2,8 @@
2
2
  # Core
3
3
  #
4
4
  require 'shellwords'
5
+ # So that Mdm::WebPage#cookie can support serializing a WEBrick::Cookie
6
+ require 'webrick'
5
7
 
6
8
  #
7
9
  # Gems
@@ -10,7 +10,7 @@ module MetasploitDataModels
10
10
  # The minor version number, scoped to the {MAJOR} version number.
11
11
  MINOR = 2
12
12
  # The patch version number, scoped to the {MAJOR} and {MINOR} version numbers.
13
- PATCH = 10
13
+ PATCH = 11
14
14
 
15
15
  #
16
16
  # Module Methods
@@ -253,7 +253,7 @@ RSpec.describe Mdm::Cred, type: :model do
253
253
  # Callbacks
254
254
  #
255
255
 
256
- before(:each) do
256
+ before(:example) do
257
257
  ssh_key
258
258
  ssh_pubkey
259
259
  end
@@ -287,7 +287,7 @@ RSpec.describe Mdm::Cred, type: :model do
287
287
  # Callbacks
288
288
  #
289
289
 
290
- before(:each) do
290
+ before(:example) do
291
291
  ssh_key
292
292
  ssh_pubkey
293
293
  end
@@ -321,7 +321,7 @@ RSpec.describe Mdm::Cred, type: :model do
321
321
  # Callbacks
322
322
  #
323
323
 
324
- before(:each) do
324
+ before(:example) do
325
325
  ssh_key
326
326
  ssh_pubkey
327
327
  end
@@ -42,7 +42,7 @@ RSpec.describe Mdm::Event, type: :model do
42
42
  let(:flagged_event) { FactoryGirl.create(:mdm_event, :workspace => workspace, :name => 'flagme', :critical => true, :seen => false) }
43
43
  let(:non_critical_event) { FactoryGirl.create(:mdm_event, :workspace => workspace, :name => 'dontflagmebro', :critical => false, :seen => false) }
44
44
 
45
- before(:each) do
45
+ before(:example) do
46
46
  flagged_event
47
47
  non_critical_event
48
48
  end
@@ -240,7 +240,7 @@ RSpec.describe Mdm::Module::Detail, type: :model do
240
240
  # validate_inclusion_of(:privileged).in_array([true, false]) will fail on the disallowed values check.
241
241
 
242
242
  context 'rank' do
243
- it 'validates rank is only an integer', pending: 'https://github.com/thoughtbot/shoulda-matchers/issues/784' do
243
+ it 'validates rank is only an integer' do
244
244
  is_expected.to validate_numericality_of(:rank).only_integer
245
245
  end
246
246
 
@@ -263,7 +263,7 @@ RSpec.describe Mdm::Module::Detail, type: :model do
263
263
  end
264
264
 
265
265
  context 'with saved' do
266
- before(:each) do
266
+ before(:example) do
267
267
  detail.save!
268
268
  end
269
269
 
@@ -180,7 +180,7 @@ RSpec.describe Mdm::Service, type: :model do
180
180
  FactoryGirl.build(:mdm_service)
181
181
  }
182
182
 
183
- it 'validate port is only an integer', pending: 'https://github.com/thoughtbot/shoulda-matchers/issues/784' do
183
+ it 'validate port is only an integer' do
184
184
  is_expected.to validate_numericality_of(:port).only_integer
185
185
  end
186
186
 
@@ -5,6 +5,53 @@ RSpec.describe Mdm::WebPage, type: :model do
5
5
  it { is_expected.to belong_to(:web_site).class_name('Mdm::WebSite') }
6
6
  end
7
7
 
8
+ context 'serialized attributes' do
9
+ context 'cookie' do
10
+ let(:web_page) { FactoryGirl.create(:mdm_web_page, cookie: cookie) }
11
+
12
+ context 'with string cookie' do
13
+ let(:cookie) { "test_name=test_value" }
14
+
15
+ it 'persists successfully' do
16
+ expect{web_page}.to change{Mdm::WebPage.count}.by(1)
17
+ end
18
+
19
+ it 'reading cookie returns a string' do
20
+ expect(web_page.cookie).to be_a String
21
+ end
22
+ end
23
+
24
+ context 'with Hash cookie' do
25
+ let(:cookie) do
26
+ {
27
+ name: 'test name',
28
+ value: 'test value'
29
+ }
30
+ end
31
+
32
+ it 'persists successfully' do
33
+ expect{web_page}.to change{Mdm::WebPage.count}.by(1)
34
+ end
35
+
36
+ it 'reading cookie returns a hash' do
37
+ expect(web_page.cookie).to be_a Hash
38
+ end
39
+ end
40
+
41
+ context 'with WEBrick::Cookie' do
42
+ let(:cookie) { WEBrick::Cookie.new('test name', 'test value') }
43
+
44
+ it 'persists successfully' do
45
+ expect{web_page}.to change{Mdm::WebPage.count}.by(1)
46
+ end
47
+
48
+ it 'reading cookie returns as WEBrick::Cookie object' do
49
+ expect(web_page.cookie).to be_a WEBrick::Cookie
50
+ end
51
+ end
52
+ end
53
+ end
54
+
8
55
  context 'database' do
9
56
 
10
57
  context 'timestamps'do
@@ -97,7 +97,7 @@ RSpec.describe Mdm::WebVuln, type: :model do
97
97
  it { is_expected.to be_valid }
98
98
 
99
99
  context 'after reloading' do
100
- before(:each) do
100
+ before(:example) do
101
101
  mdm_web_vuln.save!
102
102
  mdm_web_vuln.reload
103
103
  end
@@ -142,7 +142,7 @@ RSpec.describe Mdm::WebVuln, type: :model do
142
142
  web_vuln.params.index(element)
143
143
  end
144
144
 
145
- before(:each) do
145
+ before(:example) do
146
146
  web_vuln.params = [element]
147
147
  end
148
148
 
@@ -94,7 +94,7 @@ RSpec.describe Mdm::Workspace, type: :model do
94
94
  'must be a valid IP range'
95
95
  end
96
96
 
97
- before(:each) do
97
+ before(:example) do
98
98
  workspace.boundary = boundary
99
99
  workspace.valid?
100
100
  end
@@ -202,8 +202,8 @@ RSpec.describe Mdm::Workspace, type: :model do
202
202
  end
203
203
  end
204
204
 
205
- it 'should be an ActiveRecord::Relation', :pending => 'https://www.pivotaltracker.com/story/show/43219917' do
206
- should be_a ActiveRecord::Relation
205
+ it 'should be an ActiveRecord::Relation' do
206
+ expect(workspace.creds).to be_a ActiveRecord::Relation
207
207
  end
208
208
 
209
209
  it 'should include services' do
@@ -234,7 +234,7 @@ RSpec.describe Mdm::Workspace, type: :model do
234
234
 
235
235
  context 'default' do
236
236
  context 'with default workspace' do
237
- before(:each) do
237
+ before(:example) do
238
238
  FactoryGirl.create(
239
239
  :mdm_workspace,
240
240
  :name => default
@@ -271,7 +271,7 @@ RSpec.describe Mdm::Workspace, type: :model do
271
271
  end
272
272
 
273
273
  context 'with DEFAULT name' do
274
- before(:each) do
274
+ before(:example) do
275
275
  workspace.name = default
276
276
  end
277
277
 
@@ -306,7 +306,7 @@ RSpec.describe Mdm::Workspace, type: :model do
306
306
  end
307
307
 
308
308
  context '#host_tags' do
309
- subject(:host_tags) do
309
+ let(:host_tags) do
310
310
  workspace.host_tags
311
311
  end
312
312
 
@@ -356,8 +356,8 @@ RSpec.describe Mdm::Workspace, type: :model do
356
356
  host_tags
357
357
  end
358
358
 
359
- it 'should return an ActiveRecord::Relation', :pending => 'https://www.pivotaltracker.com/story/show/43219917' do
360
- should be_a ActiveRecord::Relation
359
+ it 'should return an ActiveRecord::Relation' do
360
+ expect(workspace.host_tags).to be_a ActiveRecord::Relation
361
361
  end
362
362
 
363
363
  it 'should return only Mdm::Tags from hosts in the workspace' do
@@ -378,7 +378,7 @@ RSpec.describe Mdm::Workspace, type: :model do
378
378
  workspace.send(:normalize)
379
379
  end
380
380
 
381
- before(:each) do
381
+ before(:example) do
382
382
  workspace.boundary = boundary
383
383
  end
384
384
 
@@ -434,7 +434,7 @@ RSpec.describe Mdm::Workspace, type: :model do
434
434
  end
435
435
 
436
436
  it 'should return an ActiveRecord:Relation' do
437
- should be_a ActiveRecord::Relation
437
+ is_expected.to be_a ActiveRecord::Relation
438
438
  end
439
439
 
440
440
  it 'should return only Mdm::WebPages from hosts in the workspace' do
@@ -459,13 +459,13 @@ RSpec.describe Mdm::Workspace, type: :model do
459
459
  # Let!s (let + before(:each))
460
460
  #
461
461
 
462
- before(:each) do
462
+ before(:example) do
463
463
  other_web_sites
464
464
  web_sites
465
465
  end
466
466
 
467
467
  it 'should return an ActiveRecord:Relation' do
468
- should be_a ActiveRecord::Relation
468
+ is_expected.to be_a ActiveRecord::Relation
469
469
  end
470
470
 
471
471
  it 'should return only Mdm::WebVulns from hosts in the workspace' do
@@ -506,7 +506,7 @@ RSpec.describe Mdm::Workspace, type: :model do
506
506
  end
507
507
 
508
508
  it 'should return an ActiveRecord:Relation' do
509
- should be_a ActiveRecord::Relation
509
+ is_expected.to be_a ActiveRecord::Relation
510
510
  end
511
511
 
512
512
  it 'should return only Mdm::WebVulns from hosts in the workspace' do
@@ -535,7 +535,7 @@ RSpec.describe Mdm::Workspace, type: :model do
535
535
 
536
536
  it 'should return an ActiveRecord:Relation',
537
537
  :pending => 'https://www.pivotaltracker.com/story/show/43219917' do
538
- should be_a ActiveRecord::Relation
538
+ is_expected.to be_a ActiveRecord::Relation
539
539
  end
540
540
 
541
541
  it "should reject #unique_web_forms from host addresses that aren't in addresses" do
@@ -26,7 +26,7 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::MatchSet, type: :mod
26
26
  subject(:match_set){ FactoryGirl.build(:automatic_exploitation_match_set)}
27
27
 
28
28
  describe "missing user" do
29
- before(:each) do
29
+ before(:example) do
30
30
  match_set.user = nil
31
31
  end
32
32
 
@@ -34,7 +34,7 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::MatchSet, type: :mod
34
34
  end
35
35
 
36
36
  describe "missing workspace" do
37
- before(:each) do
37
+ before(:example) do
38
38
  match_set.workspace = nil
39
39
  end
40
40
 
@@ -8,7 +8,7 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::Match, type: :model
8
8
 
9
9
  subject(:automatic_exploitation_match){ described_class.new }
10
10
 
11
- before(:each) do
11
+ before(:example) do
12
12
  automatic_exploitation_match.matchable = vuln
13
13
  automatic_exploitation_match.module_fullname = module_detail.fullname
14
14
  automatic_exploitation_match.save!
@@ -23,7 +23,7 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::Match, type: :model
23
23
  subject(:automatic_exploitation_match){ FactoryGirl.create(:automatic_exploitation_match) }
24
24
  let(:match_id){ automatic_exploitation_match.id }
25
25
 
26
- before(:each) do
26
+ before(:example) do
27
27
  automatic_exploitation_match.module_detail.destroy
28
28
  end
29
29
 
@@ -22,7 +22,7 @@ RSpec.describe MetasploitDataModels::AutomaticExploitation::Run, type: :model do
22
22
 
23
23
  describe "destroying" do
24
24
  describe "associated MatchResults" do
25
- before(:each) do
25
+ before(:example) do
26
26
  match_set = FactoryGirl.create(:automatic_exploitation_match_set)
27
27
  match = FactoryGirl.create(:automatic_exploitation_match, match_set: match_set)
28
28
  run.match_set = match_set
@@ -44,7 +44,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::CIDR, type: :model do
44
44
  it { is_expected.not_to be_valid }
45
45
 
46
46
  context 'errors' do
47
- before(:each) do
47
+ before(:example) do
48
48
  cidr.valid?
49
49
  end
50
50
 
@@ -86,7 +86,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::CIDR, type: :model do
86
86
  it { is_expected.not_to be_valid }
87
87
 
88
88
  context 'errors' do
89
- before(:each) do
89
+ before(:example) do
90
90
  cidr.valid?
91
91
  end
92
92
 
@@ -6,7 +6,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Nmap, type: :model do
6
6
  }
7
7
 
8
8
  context 'validation' do
9
- before(:each) do
9
+ before(:example) do
10
10
  nmap.valid?
11
11
  end
12
12
 
@@ -30,7 +30,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Range, type: :model do
30
30
  # Callbacks
31
31
  #
32
32
 
33
- before(:each) do
33
+ before(:example) do
34
34
  range.valid?
35
35
  end
36
36
 
@@ -71,7 +71,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List, type: :
71
71
  end
72
72
 
73
73
  context 'validation' do
74
- before(:each) do
74
+ before(:example) do
75
75
  nmap.valid?
76
76
  end
77
77
 
@@ -30,7 +30,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range, type:
30
30
  # Callbacks
31
31
  #
32
32
 
33
- before(:each) do
33
+ before(:example) do
34
34
  range.valid?
35
35
  end
36
36
 
@@ -10,7 +10,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Single, type: :mode
10
10
  }
11
11
 
12
12
  context 'validations' do
13
- it 'validates value is only an integer between 0 and 255 inclusive', pending: 'https://github.com/thoughtbot/shoulda-matchers/issues/784' do
13
+ it 'validates value is only an integer between 0 and 255 inclusive' do
14
14
  is_expected.to validate_numericality_of(:value).is_greater_than_or_equal_to(0).is_less_than_or_equal_to(255).only_integer
15
15
  end
16
16
  end
@@ -249,7 +249,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Single, type: :mode
249
249
  # Callbacks
250
250
  #
251
251
 
252
- before(:each) do
252
+ before(:example) do
253
253
  allow(single).to receive(:value).and_return(value)
254
254
  end
255
255
 
@@ -6,7 +6,7 @@ RSpec.describe MetasploitDataModels::IPAddress::V4::Single, type: :model do
6
6
  }
7
7
 
8
8
  context 'validation' do
9
- before(:each) do
9
+ before(:example) do
10
10
  single.valid?
11
11
  end
12
12
 
@@ -33,13 +33,13 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
33
33
 
34
34
  context "validations" do
35
35
  describe "when a target_session is set on the module run" do
36
- before(:each) do
36
+ before(:example) do
37
37
  module_run.target_session = FactoryGirl.build(:mdm_session)
38
38
  end
39
39
 
40
40
  context "when the module is an exploit" do
41
41
  context "and that exploit IS NOT local" do
42
- before(:each) do
42
+ before(:example) do
43
43
  module_run.module_fullname = 'exploit/windows/mah-crazy-exploit'
44
44
  end
45
45
 
@@ -47,7 +47,7 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
47
47
  end
48
48
 
49
49
  context "and that exploit IS local" do
50
- before(:each) do
50
+ before(:example) do
51
51
  module_run.module_fullname = 'exploit/windows/local/mah-crazy-exploit'
52
52
  end
53
53
 
@@ -57,14 +57,14 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
57
57
  end
58
58
 
59
59
  describe "when a spawned_session is set on the module run" do
60
- before(:each) do
60
+ before(:example) do
61
61
  module_run.spawned_session = FactoryGirl.build(:mdm_session)
62
62
  end
63
63
 
64
64
  context "when the module is not an exploit" do
65
65
 
66
66
  context "and it IS NOT a login scanner" do
67
- before(:each) do
67
+ before(:example) do
68
68
  module_run.module_fullname = 'post/multi/gather/steal-minecraft-maps'
69
69
  end
70
70
 
@@ -72,7 +72,7 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
72
72
  end
73
73
 
74
74
  context "and it IS a login scanner" do
75
- before(:each) do
75
+ before(:example) do
76
76
  module_run.module_fullname = 'auxiliary/scanner/ssh/ssh_login'
77
77
  end
78
78
 
@@ -82,14 +82,14 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
82
82
  end
83
83
 
84
84
  describe "attempted_at" do
85
- before(:each){ module_run.attempted_at = nil }
85
+ before(:example){ module_run.attempted_at = nil }
86
86
 
87
87
  it { is_expected.to_not be_valid }
88
88
  end
89
89
 
90
90
  describe "content information" do
91
91
  context "when there is no module_name" do
92
- before(:each) do
92
+ before(:example) do
93
93
  module_run.module_fullname = nil
94
94
  end
95
95
 
@@ -100,7 +100,7 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
100
100
 
101
101
  describe "status" do
102
102
  describe "invalidity" do
103
- before(:each) do
103
+ before(:example) do
104
104
  module_run.status = "invalid nonsense"
105
105
  end
106
106
 
@@ -109,19 +109,19 @@ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
109
109
 
110
110
  describe "validity" do
111
111
  context "when the module run succeeded" do
112
- before(:each){ module_run.status = MetasploitDataModels::ModuleRun::SUCCEED}
112
+ before(:example){ module_run.status = MetasploitDataModels::ModuleRun::SUCCEED}
113
113
 
114
114
  it{ expect(module_run).to be_valid }
115
115
  end
116
116
 
117
117
  context "when the module run went normally but failed" do
118
- before(:each){ module_run.status = MetasploitDataModels::ModuleRun::FAIL}
118
+ before(:example){ module_run.status = MetasploitDataModels::ModuleRun::FAIL}
119
119
 
120
120
  it{ expect(module_run).to be_valid }
121
121
  end
122
122
 
123
123
  context "when the module run errored out" do
124
- before(:each){ module_run.status = MetasploitDataModels::ModuleRun::ERROR}
124
+ before(:example){ module_run.status = MetasploitDataModels::ModuleRun::ERROR}
125
125
 
126
126
  it{ expect(module_run).to be_valid }
127
127
  end
@@ -27,7 +27,7 @@ RSpec.describe MetasploitDataModels::Search::Operation::IPAddress, type: :model
27
27
  # Callbacks
28
28
  #
29
29
 
30
- before(:each) do
30
+ before(:example) do
31
31
  operation.valid?
32
32
  end
33
33
 
@@ -12,7 +12,7 @@ RSpec.describe MetasploitDataModels::Search::Operation::Port::Range, type: :mode
12
12
  it { is_expected.to be_a MetasploitDataModels::Search::Operation::Range }
13
13
 
14
14
  context 'validations' do
15
- before(:each) do
15
+ before(:example) do
16
16
  port_range_operation.valid?
17
17
  end
18
18
 
@@ -28,7 +28,7 @@ RSpec.describe MetasploitDataModels::Search::Operation::Range, type: :model do
28
28
  # Callbacks
29
29
  #
30
30
 
31
- before(:each) do
31
+ before(:example) do
32
32
  range_operation.valid?
33
33
  end
34
34
 
@@ -37,7 +37,7 @@ RSpec.describe MetasploitDataModels::Search::Operator::Port::List, type: :model
37
37
  # Callbacks
38
38
  #
39
39
 
40
- before(:each) do
40
+ before(:example) do
41
41
  port_list_operator.attribute = value
42
42
  end
43
43
 
@@ -143,7 +143,7 @@ RSpec.describe MetasploitDataModels::Search::Operator::Port::List, type: :model
143
143
  # Callbacks
144
144
  #
145
145
 
146
- before(:each) do
146
+ before(:example) do
147
147
  port_list_operator.attribute = attribute
148
148
  end
149
149
 
@@ -45,7 +45,7 @@ RSpec.describe MetasploitDataModels::Search::Visitor::Relation, type: :model do
45
45
  double('Query')
46
46
  end
47
47
 
48
- before(:each) do
48
+ before(:example) do
49
49
  allow(query).to receive(:valid?).and_return(query)
50
50
 
51
51
  visitor.valid?
@@ -320,7 +320,7 @@ RSpec.describe ParametersValidator do
320
320
  ''
321
321
  end
322
322
 
323
- before(:each) do
323
+ before(:example) do
324
324
  validate_each
325
325
  end
326
326
 
@@ -68,7 +68,7 @@ RSpec.describe MetasploitDataModels::IPAddress::CIDR, type: :model do
68
68
  # Callbacks
69
69
  #
70
70
 
71
- before(:each) do
71
+ before(:example) do
72
72
  stub_const('IncludingClass', including_class)
73
73
  end
74
74
 
@@ -83,7 +83,7 @@ RSpec.describe MetasploitDataModels::IPAddress::CIDR, type: :model do
83
83
  end
84
84
 
85
85
  context 'validation errors on' do
86
- before(:each) do
86
+ before(:example) do
87
87
  including_class_instance.valid?
88
88
  end
89
89
 
@@ -138,7 +138,7 @@ RSpec.describe MetasploitDataModels::IPAddress::CIDR, type: :model do
138
138
  segment_count * segment_bits
139
139
  }
140
140
 
141
- it 'validates it is an integer between 0 and maximum_prefix_length', pending: 'https://github.com/thoughtbot/shoulda-matchers/issues/784' do
141
+ it 'validates it is an integer between 0 and maximum_prefix_length' do
142
142
  expect(including_class_instance).to validate_numericality_of(:prefix_length).only_integer.is_greater_than_or_equal_to(0).is_less_than_or_equal_to(maximum_prefix_length)
143
143
  end
144
144
  end
@@ -173,7 +173,7 @@ RSpec.describe MetasploitDataModels::IPAddress::CIDR, type: :model do
173
173
  including_class.match_regexp
174
174
  }
175
175
 
176
- before(:each) do
176
+ before(:example) do
177
177
  expect(including_class).to receive(:regexp).and_return(/regexp/)
178
178
  end
179
179
 
@@ -13,7 +13,7 @@ RSpec.describe MetasploitDataModels::IPAddress::Range do
13
13
  range.send(extreme)
14
14
  }
15
15
 
16
- before(:each) do
16
+ before(:example) do
17
17
  allow(range).to receive(:value).and_return(value)
18
18
  end
19
19
 
@@ -16,7 +16,7 @@ RSpec.describe MetasploitDataModels::Match::Child do
16
16
  }
17
17
  }
18
18
 
19
- before(:each) do
19
+ before(:example) do
20
20
  stub_const('ExtendingClass', extending_class)
21
21
  stub_const('ExtendingClass::REGEXP', /\d+-\d+/)
22
22
  end
@@ -50,7 +50,7 @@ RSpec.describe MetasploitDataModels::Match::Parent do
50
50
  # Callbacks
51
51
  #
52
52
 
53
- before(:each) do
53
+ before(:example) do
54
54
  stub_const('NumberChild', number_child_class)
55
55
  stub_const('NumberChild::REGEXP', /\d+/)
56
56
 
@@ -123,7 +123,7 @@ RSpec.describe MetasploitDataModels::Match::Parent do
123
123
  # Callbacks
124
124
  #
125
125
 
126
- before(:each) do
126
+ before(:example) do
127
127
  including_class.match_children_named child_classes.map(&:name)
128
128
  end
129
129
 
data/spec/spec_helper.rb CHANGED
@@ -123,10 +123,30 @@ RSpec.configure do |config|
123
123
 
124
124
  config.use_transactional_fixtures = true
125
125
 
126
- config.before(:each) do
126
+ config.before(:example) do
127
127
  # Rex is only available when testing with metasploit-framework or pro, so stub out the methods that require it
128
128
  allow_any_instance_of(Mdm::Workspace).to receive(:valid_ip_or_range?).and_return(true)
129
129
  end
130
+
131
+ # rspec-rails 3 will no longer automatically infer an example group's spec type
132
+ # from the file location. You can explicitly opt-in to the feature using this
133
+ # config option.
134
+ # To explicitly tag specs without using automatic inference, set the `:type`
135
+ # metadata manually:
136
+ #
137
+ # describe ThingsController, :type => :controller do
138
+ # # Equivalent to being in spec/controllers
139
+ # end
140
+ config.infer_spec_type_from_file_location!
141
+
142
+ # Setting this config option `false` removes rspec-core's monkey patching of the
143
+ # top level methods like `describe`, `shared_examples_for` and `shared_context`
144
+ # on `main` and `Module`. The methods are always available through the `RSpec`
145
+ # module like `RSpec.describe` regardless of this setting.
146
+ # For backwards compatibility this defaults to `true`.
147
+ #
148
+ # https://relishapp.com/rspec/rspec-core/v/3-0/docs/configuration/global-namespace-dsl
149
+ config.expose_dsl_globally = false
130
150
  end
131
151
 
132
152
  Shoulda::Matchers.configure do |config|
@@ -1,6 +1,6 @@
1
1
  # Checks that the string matches the
2
2
  RSpec::Matchers.define :match_string_exactly do |string|
3
- failure_message_for_should do |regexp|
3
+ failure_message do |regexp|
4
4
  match = regexp.match(string)
5
5
 
6
6
  failure_message = "expected #{regexp} to match #{string}"
@@ -1,5 +1,5 @@
1
- shared_context 'Rex::Text' do
2
- before(:each) do
1
+ RSpec.shared_context 'Rex::Text' do
2
+ before(:example) do
3
3
  rex_text = Module.new do
4
4
  def self.ascii_safe_hex(str, whitespace=false)
5
5
  if whitespace
@@ -1,10 +1,10 @@
1
- shared_examples_for 'coerces inet column type to string' do |column|
1
+ RSpec.shared_examples_for 'coerces inet column type to string' do |column|
2
2
  raise ArgumentError, 'must pass the column name' unless column
3
3
 
4
4
  context 'with an inet column' do
5
5
  let(:address) { '10.0.0.1' }
6
6
 
7
- before(:each) do
7
+ before(:example) do
8
8
  subject.update_attribute column, address
9
9
  end
10
10
 
@@ -1,4 +1,4 @@
1
- shared_examples_for 'Mdm::Module::Detail does not support stance with mtype' do |mtype|
1
+ RSpec.shared_examples_for 'Mdm::Module::Detail does not support stance with mtype' do |mtype|
2
2
  context "with #{mtype.inspect}" do
3
3
  # define as a let so that lets from outer context can access option to set detail.
4
4
  let(:mtype) do
@@ -1,4 +1,4 @@
1
- shared_examples_for 'Mdm::Module::Detail supports stance with mtype' do |mtype|
1
+ RSpec.shared_examples_for 'Mdm::Module::Detail supports stance with mtype' do |mtype|
2
2
  context "with #{mtype.inspect}" do
3
3
  # define as a let so that lets from outer context can access option to set detail.
4
4
  let(:mtype) do
@@ -1,4 +1,4 @@
1
- shared_examples_for 'MetasploitDataModels::Search::Operation::IPAddress::*.match' do |options={}|
1
+ RSpec.shared_examples_for 'MetasploitDataModels::Search::Operation::IPAddress::*.match' do |options={}|
2
2
  options.assert_valid_keys(4, 6)
3
3
 
4
4
  subject(:match) {
@@ -1,4 +1,4 @@
1
- shared_examples_for 'MetasploitDataModels::Search::Visitor::Includes#visit with #children' do
1
+ RSpec.shared_examples_for 'MetasploitDataModels::Search::Visitor::Includes#visit with #children' do
2
2
  let(:children) do
3
3
  2.times.collect { |n|
4
4
  double("Child #{n}")
@@ -1,4 +1,4 @@
1
- shared_examples_for 'MetasploitDataModels::Search::Visitor::Includes#visit with Metasploit::Model::Search::Operation::Base' do
1
+ RSpec.shared_examples_for 'MetasploitDataModels::Search::Visitor::Includes#visit with Metasploit::Model::Search::Operation::Base' do
2
2
  let(:operator) do
3
3
  double('Operation Operator')
4
4
  end
@@ -1,4 +1,4 @@
1
- shared_examples_for 'MetasploitDataModels::Search::Visitor::Relation#visit matching record' do |options={}|
1
+ RSpec.shared_examples_for 'MetasploitDataModels::Search::Visitor::Relation#visit matching record' do |options={}|
2
2
  options.assert_valid_keys(:attribute, :association)
3
3
 
4
4
  attribute = options.fetch(:attribute)
@@ -1,4 +1,4 @@
1
- shared_examples_for 'MetasploitDataModels::Search::Visitor::Where#visit with equality operation' do
1
+ RSpec.shared_examples_for 'MetasploitDataModels::Search::Visitor::Where#visit with equality operation' do
2
2
  let(:node) do
3
3
  node_class.new(
4
4
  :operator => operator,
@@ -1,4 +1,4 @@
1
- shared_examples_for 'MetasploitDataModels::Search::Visitor::Where#visit with Metasploit::Model::Search*::Group::Base' do |options={}|
1
+ RSpec.shared_examples_for 'MetasploitDataModels::Search::Visitor::Where#visit with Metasploit::Model::Search*::Group::Base' do |options={}|
2
2
  options.assert_valid_keys(:arel_class)
3
3
 
4
4
  arel_class = options.fetch(:arel_class)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasploit_data_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.10
4
+ version: 1.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Huckins
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-12-04 00:00:00.000000000 Z
14
+ date: 2016-02-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: metasploit-version
@@ -731,7 +731,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
731
731
  version: '0'
732
732
  requirements: []
733
733
  rubyforge_project:
734
- rubygems_version: 2.4.8
734
+ rubygems_version: 2.4.6
735
735
  signing_key:
736
736
  specification_version: 4
737
737
  summary: Database code for MSF and Metasploit Pro