metasploit_data_models 0.19.0-java → 0.19.3-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/mdm/service.rb +14 -0
- data/lib/metasploit_data_models/version.rb +1 -1
- data/spec/app/models/mdm/service_spec.rb +10 -0
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +183 -59
- data/spec/factories/mdm/creds.rb +9 -0
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86e9158eae3b18e46236337d7bdab2419e9154a2
|
4
|
+
data.tar.gz: 104007fc1ebaa66c300080abc1a0cc3afb938c6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 137f136749c44c6d6fbcd6cbfa06516d11c595b63b10cf0f38a9ed18d2cbc649b5300ac9d2fbac44997a1b83fec14e716a1aec0874cc48cf41343d627a1b05ae
|
7
|
+
data.tar.gz: f26e756aa5dc9d17eb79cdecd735ca7fd04a2ded251b950ecd35a3166569768959565a84c1a7c7337bceee6dc16f4f6682328abc57c878fff6d0fd55cddf1cdc
|
data/app/models/mdm/service.rb
CHANGED
@@ -185,6 +185,12 @@ class Mdm::Service < ActiveRecord::Base
|
|
185
185
|
#
|
186
186
|
#
|
187
187
|
|
188
|
+
#
|
189
|
+
# Search Associations
|
190
|
+
#
|
191
|
+
|
192
|
+
search_association :host
|
193
|
+
|
188
194
|
#
|
189
195
|
# Search Attributes
|
190
196
|
#
|
@@ -202,6 +208,14 @@ class Mdm::Service < ActiveRecord::Base
|
|
202
208
|
# Search Withs
|
203
209
|
#
|
204
210
|
|
211
|
+
# Have to declare on Mdm::Service because non-attribute operators cannot function as association operators
|
212
|
+
search_with MetasploitDataModels::Search::Operator::Multitext,
|
213
|
+
name: :'host.os',
|
214
|
+
operator_names: [
|
215
|
+
:'host.os_name',
|
216
|
+
:'host.os_flavor',
|
217
|
+
:'host.os_sp'
|
218
|
+
]
|
205
219
|
search_with MetasploitDataModels::Search::Operator::Port::List
|
206
220
|
|
207
221
|
#
|
@@ -6,7 +6,7 @@ module MetasploitDataModels
|
|
6
6
|
# The minor version number, scoped to the {MAJOR} version number.
|
7
7
|
MINOR = 19
|
8
8
|
# The patch number, scoped to the {MINOR} version number.
|
9
|
-
PATCH =
|
9
|
+
PATCH = 3
|
10
10
|
|
11
11
|
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the `PRERELEASE` in the
|
12
12
|
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
@@ -119,6 +119,16 @@ describe Mdm::Service do
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
+
context 'search' do
|
123
|
+
let(:base_class) {
|
124
|
+
described_class
|
125
|
+
}
|
126
|
+
|
127
|
+
context 'associations' do
|
128
|
+
it_should_behave_like 'search_association', :host
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
122
132
|
context "validations" do
|
123
133
|
subject(:mdm_service) {
|
124
134
|
FactoryGirl.build(:mdm_service)
|
@@ -172,6 +172,32 @@ describe MetasploitDataModels::Search::Visitor::Relation do
|
|
172
172
|
# Don't use factories to prevent prefix aliasing when sequences go from 1 to 10 or 10 to 100
|
173
173
|
#
|
174
174
|
|
175
|
+
let(:non_matching_host) {
|
176
|
+
FactoryGirl.create(
|
177
|
+
:mdm_host,
|
178
|
+
name: non_matching_host_name,
|
179
|
+
os_flavor: non_matching_host_os_flavor,
|
180
|
+
os_name: non_matching_host_os_name,
|
181
|
+
os_sp: non_matching_host_os_sp
|
182
|
+
)
|
183
|
+
}
|
184
|
+
|
185
|
+
let(:non_matching_host_name) {
|
186
|
+
'mdm_host_name_b'
|
187
|
+
}
|
188
|
+
|
189
|
+
let(:non_matching_host_os_flavor) {
|
190
|
+
'mdm_host_os_flavor_b'
|
191
|
+
}
|
192
|
+
|
193
|
+
let(:non_matching_host_os_name) {
|
194
|
+
'mdm_host_os_name_b'
|
195
|
+
}
|
196
|
+
|
197
|
+
let(:non_matching_host_os_sp) {
|
198
|
+
'mdm_host_os_sp_b'
|
199
|
+
}
|
200
|
+
|
175
201
|
let(:non_matching_info) {
|
176
202
|
'mdm_service_info_c'
|
177
203
|
}
|
@@ -195,13 +221,13 @@ describe MetasploitDataModels::Search::Visitor::Relation do
|
|
195
221
|
let!(:non_matching_record) {
|
196
222
|
FactoryGirl.create(
|
197
223
|
:mdm_service,
|
224
|
+
host: non_matching_host,
|
198
225
|
info: non_matching_info,
|
199
226
|
name: non_matching_name,
|
200
227
|
port: non_matching_port,
|
201
228
|
proto: non_matching_proto
|
202
229
|
)
|
203
230
|
}
|
204
|
-
p
|
205
231
|
|
206
232
|
context 'with port' do
|
207
233
|
#
|
@@ -294,6 +320,32 @@ describe MetasploitDataModels::Search::Visitor::Relation do
|
|
294
320
|
# Don't use factories to prevent prefix aliasing when sequences go from 1 to 10 or 10 to 100
|
295
321
|
#
|
296
322
|
|
323
|
+
let(:matching_host) {
|
324
|
+
FactoryGirl.create(
|
325
|
+
:mdm_host,
|
326
|
+
name: matching_host_name,
|
327
|
+
os_flavor: matching_host_os_flavor,
|
328
|
+
os_name: matching_host_os_name,
|
329
|
+
os_sp: matching_host_os_sp
|
330
|
+
)
|
331
|
+
}
|
332
|
+
|
333
|
+
let(:matching_host_name) {
|
334
|
+
'mdm_host_name_a'
|
335
|
+
}
|
336
|
+
|
337
|
+
let(:matching_host_os_flavor) {
|
338
|
+
'mdm_host_os_flavor_a'
|
339
|
+
}
|
340
|
+
|
341
|
+
let(:matching_host_os_name) {
|
342
|
+
'mdm_host_os_name_a'
|
343
|
+
}
|
344
|
+
|
345
|
+
let(:matching_host_os_sp) {
|
346
|
+
'mdm_host_os_sp_a'
|
347
|
+
}
|
348
|
+
|
297
349
|
let(:matching_info) {
|
298
350
|
'mdm_service_info_a'
|
299
351
|
}
|
@@ -317,6 +369,7 @@ describe MetasploitDataModels::Search::Visitor::Relation do
|
|
317
369
|
let!(:matching_record) {
|
318
370
|
FactoryGirl.create(
|
319
371
|
:mdm_service,
|
372
|
+
host: matching_host,
|
320
373
|
info: matching_info,
|
321
374
|
name: matching_name,
|
322
375
|
port: matching_port,
|
@@ -324,6 +377,70 @@ describe MetasploitDataModels::Search::Visitor::Relation do
|
|
324
377
|
)
|
325
378
|
}
|
326
379
|
|
380
|
+
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
|
381
|
+
association: :host,
|
382
|
+
attribute: :name
|
383
|
+
|
384
|
+
context 'with host.os' do
|
385
|
+
let(:matching_host_os_flavor) {
|
386
|
+
'XP'
|
387
|
+
}
|
388
|
+
|
389
|
+
let(:matching_host_os_name) {
|
390
|
+
'Microsoft Windows'
|
391
|
+
}
|
392
|
+
|
393
|
+
let(:matching_host_os_sp) {
|
394
|
+
'SP1'
|
395
|
+
}
|
396
|
+
|
397
|
+
context 'with a combination of Mdm::Host#os_name and Mdm:Host#os_sp' do
|
398
|
+
let(:formatted) {
|
399
|
+
%Q{host.os:"win xp"}
|
400
|
+
}
|
401
|
+
|
402
|
+
it 'finds matching record' do
|
403
|
+
expect(visit).to match_array [matching_record]
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
context 'with a combination of Mdm::Host#os_flavor and Mdm::Host#os_sp' do
|
408
|
+
let(:formatted) {
|
409
|
+
%Q{host.os:"xp sp1"}
|
410
|
+
}
|
411
|
+
|
412
|
+
it 'finds matching record' do
|
413
|
+
expect(visit).to match_array [matching_record]
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
context 'with multiple records matching one word' do
|
418
|
+
let(:formatted) {
|
419
|
+
%Q{host.os:"win xp"}
|
420
|
+
}
|
421
|
+
|
422
|
+
let(:non_matching_host_os_name) {
|
423
|
+
'Microsoft Windows'
|
424
|
+
}
|
425
|
+
|
426
|
+
it 'finds only matching record by other words refining search' do
|
427
|
+
expect(visit).to match_array [matching_record]
|
428
|
+
end
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
|
433
|
+
association: :host,
|
434
|
+
attribute: :os_flavor
|
435
|
+
|
436
|
+
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
|
437
|
+
association: :host,
|
438
|
+
attribute: :os_name
|
439
|
+
|
440
|
+
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
|
441
|
+
association: :host,
|
442
|
+
attribute: :os_sp
|
443
|
+
|
327
444
|
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
|
328
445
|
attribute: :info
|
329
446
|
|
@@ -335,7 +452,16 @@ describe MetasploitDataModels::Search::Visitor::Relation do
|
|
335
452
|
|
336
453
|
context 'with all operators' do
|
337
454
|
let(:formatted) {
|
338
|
-
%Q{
|
455
|
+
%Q{
|
456
|
+
host.name:#{matching_host_name}
|
457
|
+
host.os:"#{matching_host_os_name} #{matching_host_os_flavor} #{matching_host_os_sp}"
|
458
|
+
host.os_flavor:#{matching_host_os_flavor}
|
459
|
+
host.os_name:#{matching_host_os_name}
|
460
|
+
host.os_sp:#{matching_host_os_sp}
|
461
|
+
name:#{matching_name}
|
462
|
+
port:#{matching_port}
|
463
|
+
proto:#{matching_proto}
|
464
|
+
}
|
339
465
|
}
|
340
466
|
|
341
467
|
it 'finds only matching record' do
|
@@ -567,67 +693,65 @@ describe MetasploitDataModels::Search::Visitor::Relation do
|
|
567
693
|
end
|
568
694
|
end
|
569
695
|
|
696
|
+
context 'with Mdm::Tag' do
|
697
|
+
#
|
698
|
+
# lets
|
699
|
+
#
|
700
|
+
|
701
|
+
let(:klass) {
|
702
|
+
Mdm::Tag
|
703
|
+
}
|
704
|
+
|
705
|
+
let(:matching_desc) {
|
706
|
+
'This is a description'
|
707
|
+
}
|
570
708
|
|
571
|
-
|
709
|
+
let(:matching_name) {
|
710
|
+
'matching.tag'
|
711
|
+
}
|
712
|
+
|
713
|
+
let(:non_matching_desc) {
|
714
|
+
'This could be a description'
|
715
|
+
}
|
572
716
|
|
573
|
-
|
574
|
-
|
575
|
-
# lets
|
576
|
-
#
|
577
|
-
|
578
|
-
let(:klass) {
|
579
|
-
Mdm::Tag
|
580
|
-
}
|
581
|
-
|
582
|
-
let(:matching_desc) {
|
583
|
-
'This is a description'
|
584
|
-
}
|
585
|
-
|
586
|
-
let(:matching_name) {
|
587
|
-
'matching.tag'
|
588
|
-
}
|
589
|
-
|
590
|
-
let(:non_matching_desc) {
|
591
|
-
'This could be a description'
|
592
|
-
}
|
593
|
-
|
594
|
-
let(:non_matching_name) {
|
595
|
-
'tag.does.not.match'
|
596
|
-
}
|
597
|
-
|
598
|
-
#
|
599
|
-
# let!s
|
600
|
-
#
|
601
|
-
|
602
|
-
let!(:matching_record) {
|
603
|
-
FactoryGirl.create(
|
604
|
-
:mdm_tag,
|
605
|
-
desc: matching_desc,
|
606
|
-
name: matching_name
|
607
|
-
)
|
608
|
-
}
|
609
|
-
|
610
|
-
let!(:non_matching_record) {
|
611
|
-
FactoryGirl.create(
|
612
|
-
:mdm_tag,
|
613
|
-
desc: non_matching_desc,
|
614
|
-
name: non_matching_name
|
615
|
-
)
|
616
|
-
}
|
617
|
-
|
618
|
-
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
|
619
|
-
attribute: :desc
|
620
|
-
|
621
|
-
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
|
622
|
-
attribute: :name
|
623
|
-
|
624
|
-
context 'with all operators' do
|
625
|
-
let(:formatted) {
|
626
|
-
%Q{desc:"#{matching_desc}" name:"#{matching_name}"}
|
717
|
+
let(:non_matching_name) {
|
718
|
+
'tag.does.not.match'
|
627
719
|
}
|
628
720
|
|
629
|
-
|
630
|
-
|
721
|
+
#
|
722
|
+
# let!s
|
723
|
+
#
|
724
|
+
|
725
|
+
let!(:matching_record) {
|
726
|
+
FactoryGirl.create(
|
727
|
+
:mdm_tag,
|
728
|
+
desc: matching_desc,
|
729
|
+
name: matching_name
|
730
|
+
)
|
731
|
+
}
|
732
|
+
|
733
|
+
let!(:non_matching_record) {
|
734
|
+
FactoryGirl.create(
|
735
|
+
:mdm_tag,
|
736
|
+
desc: non_matching_desc,
|
737
|
+
name: non_matching_name
|
738
|
+
)
|
739
|
+
}
|
740
|
+
|
741
|
+
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
|
742
|
+
attribute: :desc
|
743
|
+
|
744
|
+
it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
|
745
|
+
attribute: :name
|
746
|
+
|
747
|
+
context 'with all operators' do
|
748
|
+
let(:formatted) {
|
749
|
+
%Q{desc:"#{matching_desc}" name:"#{matching_name}"}
|
750
|
+
}
|
751
|
+
|
752
|
+
it 'should find only matching record' do
|
753
|
+
expect(visit).to match_array([matching_record])
|
754
|
+
end
|
631
755
|
end
|
632
756
|
end
|
633
757
|
end
|
data/spec/factories/mdm/creds.rb
CHANGED
@@ -4,5 +4,14 @@ FactoryGirl.define do
|
|
4
4
|
# Associations
|
5
5
|
#
|
6
6
|
association :service, :factory => :mdm_service
|
7
|
+
|
8
|
+
active true
|
9
|
+
pass{ generate :mdm_cred_pass }
|
10
|
+
ptype 'password'
|
11
|
+
user{ generate :mdm_user_username }
|
12
|
+
end
|
13
|
+
|
14
|
+
sequence :mdm_cred_pass do |n|
|
15
|
+
"mahp455w3rd!-#{n}"
|
7
16
|
end
|
8
17
|
end
|
data/spec/spec_helper.rb
CHANGED
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: 0.19.
|
4
|
+
version: 0.19.3
|
5
5
|
platform: java
|
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: 2014-07-
|
14
|
+
date: 2014-07-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|