metasploit_data_models 1.2.10 → 1.2.11
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.
- checksums.yaml +4 -4
- data/app/models/mdm/cred.rb +6 -6
- data/app/models/mdm/host.rb +4 -6
- data/app/models/mdm/workspace.rb +10 -10
- data/lib/metasploit_data_models.rb +2 -0
- data/lib/metasploit_data_models/version.rb +1 -1
- data/spec/app/models/mdm/cred_spec.rb +3 -3
- data/spec/app/models/mdm/event_spec.rb +1 -1
- data/spec/app/models/mdm/module/detail_spec.rb +2 -2
- data/spec/app/models/mdm/service_spec.rb +1 -1
- data/spec/app/models/mdm/web_page_spec.rb +47 -0
- data/spec/app/models/mdm/web_vuln_spec.rb +2 -2
- data/spec/app/models/mdm/workspace_spec.rb +14 -14
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +2 -2
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +2 -2
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -1
- data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +2 -2
- data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +1 -1
- data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +1 -1
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +1 -1
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +1 -1
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +2 -2
- data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +1 -1
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +12 -12
- data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +1 -1
- data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +1 -1
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +1 -1
- data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +2 -2
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +1 -1
- data/spec/app/validators/parameters_validator_spec.rb +1 -1
- data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +4 -4
- data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +1 -1
- data/spec/lib/metasploit_data_models/match/child_spec.rb +1 -1
- data/spec/lib/metasploit_data_models/match/parent_spec.rb +2 -2
- data/spec/spec_helper.rb +21 -1
- data/spec/support/matchers/match_regex_exactly.rb +1 -1
- data/spec/support/shared/contexts/rex/text.rb +2 -2
- data/spec/support/shared/examples/coerces_inet_column_type_to_string.rb +2 -2
- data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +1 -1
- data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +1 -1
- data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +1 -1
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +1 -1
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +1 -1
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/relation/visit/matching_record.rb +1 -1
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +1 -1
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb305b0bd34c74f0e886505e15ef87be7272559a
|
|
4
|
+
data.tar.gz: cbf95468d8ef5b3a29f0fe960db0bb2d947bc303
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9de430fb61f90d5b9070001aea9bfbfeecdded14f8c0257d280673079605ccd1b9d60d732f12ff0ac2d898f41dbed22c747ad9759ab69ec998b727119edbf1c
|
|
7
|
+
data.tar.gz: 255550ca4f43e04113c0fd2946f07afb4c0fb115150d46c5b11d39db0dda55a68b1ddb2543ffbe60a8fd99bac303eabc8aa8b1bc671b87ca63f6b46d34c46592
|
data/app/models/mdm/cred.rb
CHANGED
|
@@ -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 =
|
|
162
|
-
|
|
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 =
|
|
173
|
-
|
|
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
|
|
data/app/models/mdm/host.rb
CHANGED
|
@@ -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
|
-
|
|
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) }
|
data/app/models/mdm/workspace.rb
CHANGED
|
@@ -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
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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}.
|
|
@@ -253,7 +253,7 @@ RSpec.describe Mdm::Cred, type: :model do
|
|
|
253
253
|
# Callbacks
|
|
254
254
|
#
|
|
255
255
|
|
|
256
|
-
before(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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'
|
|
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(:
|
|
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'
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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'
|
|
206
|
-
|
|
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(:
|
|
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(:
|
|
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
|
-
|
|
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'
|
|
360
|
-
|
|
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(:
|
|
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
|
-
|
|
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(:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
89
|
+
before(:example) do
|
|
90
90
|
cidr.valid?
|
|
91
91
|
end
|
|
92
92
|
|
|
@@ -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'
|
|
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(:
|
|
252
|
+
before(:example) do
|
|
253
253
|
allow(single).to receive(:value).and_return(value)
|
|
254
254
|
end
|
|
255
255
|
|
|
@@ -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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
124
|
+
before(:example){ module_run.status = MetasploitDataModels::ModuleRun::ERROR}
|
|
125
125
|
|
|
126
126
|
it{ expect(module_run).to be_valid }
|
|
127
127
|
end
|
|
@@ -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(:
|
|
15
|
+
before(:example) do
|
|
16
16
|
port_range_operation.valid?
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -37,7 +37,7 @@ RSpec.describe MetasploitDataModels::Search::Operator::Port::List, type: :model
|
|
|
37
37
|
# Callbacks
|
|
38
38
|
#
|
|
39
39
|
|
|
40
|
-
before(:
|
|
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(:
|
|
146
|
+
before(:example) do
|
|
147
147
|
port_list_operator.attribute = attribute
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -68,7 +68,7 @@ RSpec.describe MetasploitDataModels::IPAddress::CIDR, type: :model do
|
|
|
68
68
|
# Callbacks
|
|
69
69
|
#
|
|
70
70
|
|
|
71
|
-
before(:
|
|
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(:
|
|
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'
|
|
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(:
|
|
176
|
+
before(:example) do
|
|
177
177
|
expect(including_class).to receive(:regexp).and_return(/regexp/)
|
|
178
178
|
end
|
|
179
179
|
|
|
@@ -50,7 +50,7 @@ RSpec.describe MetasploitDataModels::Match::Parent do
|
|
|
50
50
|
# Callbacks
|
|
51
51
|
#
|
|
52
52
|
|
|
53
|
-
before(:
|
|
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(:
|
|
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(:
|
|
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,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(:
|
|
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::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 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.
|
|
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:
|
|
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.
|
|
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
|