metasploit_data_models 2.0.17 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.travis.yml +1 -1
- data/Gemfile +3 -8
- data/lib/mdm/host/operating_system_normalization.rb +2 -1
- data/lib/metasploit_data_models/engine.rb +7 -7
- data/lib/metasploit_data_models/version.rb +1 -1
- data/metasploit_data_models.gemspec +3 -1
- data/spec/app/models/mdm/client_spec.rb +3 -3
- data/spec/app/models/mdm/cred_spec.rb +34 -34
- data/spec/app/models/mdm/event_spec.rb +9 -9
- data/spec/app/models/mdm/exploit_attempt_spec.rb +5 -5
- data/spec/app/models/mdm/exploited_host_spec.rb +3 -3
- data/spec/app/models/mdm/host_detail_spec.rb +4 -4
- data/spec/app/models/mdm/host_spec.rb +47 -47
- data/spec/app/models/mdm/host_tag_spec.rb +5 -5
- data/spec/app/models/mdm/listener_spec.rb +12 -12
- data/spec/app/models/mdm/loot_spec.rb +8 -8
- data/spec/app/models/mdm/module/action_spec.rb +2 -2
- data/spec/app/models/mdm/module/arch_spec.rb +2 -2
- data/spec/app/models/mdm/module/author_spec.rb +3 -3
- data/spec/app/models/mdm/module/detail_spec.rb +71 -71
- data/spec/app/models/mdm/module/mixin_spec.rb +2 -2
- data/spec/app/models/mdm/module/platform_spec.rb +2 -2
- data/spec/app/models/mdm/module/ref_spec.rb +5 -5
- data/spec/app/models/mdm/module/target_spec.rb +2 -2
- data/spec/app/models/mdm/nexpose_console_spec.rb +15 -15
- data/spec/app/models/mdm/note_spec.rb +11 -11
- data/spec/app/models/mdm/ref_spec.rb +6 -6
- data/spec/app/models/mdm/route_spec.rb +3 -3
- data/spec/app/models/mdm/service_spec.rb +20 -20
- data/spec/app/models/mdm/session_event_spec.rb +3 -3
- data/spec/app/models/mdm/session_spec.rb +14 -14
- data/spec/app/models/mdm/tag_spec.rb +12 -12
- data/spec/app/models/mdm/task_cred_spec.rb +6 -6
- data/spec/app/models/mdm/task_host_spec.rb +6 -6
- data/spec/app/models/mdm/task_service_spec.rb +6 -6
- data/spec/app/models/mdm/task_session_spec.rb +6 -6
- data/spec/app/models/mdm/task_spec.rb +3 -3
- data/spec/app/models/mdm/user_spec.rb +3 -3
- data/spec/app/models/mdm/vuln_attempt_spec.rb +4 -4
- data/spec/app/models/mdm/vuln_detail_spec.rb +3 -3
- data/spec/app/models/mdm/vuln_ref_spec.rb +4 -4
- data/spec/app/models/mdm/vuln_spec.rb +20 -20
- data/spec/app/models/mdm/web_form_spec.rb +3 -3
- data/spec/app/models/mdm/web_page_spec.rb +4 -4
- data/spec/app/models/mdm/web_site_spec.rb +15 -15
- data/spec/app/models/mdm/web_vuln_spec.rb +4 -4
- data/spec/app/models/mdm/workspace_spec.rb +25 -25
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +4 -4
- 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 +3 -3
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +5 -5
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +3 -3
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +4 -8
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +12 -12
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +16 -16
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +3 -3
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/structure.sql +2 -2
- data/spec/factories/mdm/addresses.rb +2 -2
- data/spec/factories/mdm/clients.rb +2 -2
- data/spec/factories/mdm/creds.rb +2 -2
- data/spec/factories/mdm/events.rb +3 -3
- data/spec/factories/mdm/exploit_attempts.rb +2 -2
- data/spec/factories/mdm/exploited_hosts.rb +1 -1
- data/spec/factories/mdm/fingerprints/nessus_fingerprints.rb +2 -2
- data/spec/factories/mdm/fingerprints/nexpose_fingerprints.rb +2 -2
- data/spec/factories/mdm/fingerprints/nmap_fingerprints.rb +2 -2
- data/spec/factories/mdm/fingerprints/retina_fingerprints.rb +2 -2
- data/spec/factories/mdm/fingerprints/session_fingerprints.rb +2 -2
- data/spec/factories/mdm/host_details.rb +2 -2
- data/spec/factories/mdm/host_tags.rb +2 -2
- data/spec/factories/mdm/hosts.rb +2 -2
- data/spec/factories/mdm/listeners.rb +2 -2
- data/spec/factories/mdm/loots.rb +2 -2
- data/spec/factories/mdm/module/actions.rb +2 -2
- data/spec/factories/mdm/module/archs.rb +2 -2
- data/spec/factories/mdm/module/authors.rb +2 -2
- data/spec/factories/mdm/module/details.rb +1 -1
- data/spec/factories/mdm/module/mixins.rb +2 -2
- data/spec/factories/mdm/module/platforms.rb +2 -2
- data/spec/factories/mdm/module/refs.rb +2 -2
- data/spec/factories/mdm/module/targets.rb +2 -2
- data/spec/factories/mdm/nexpose_consoles.rb +2 -2
- data/spec/factories/mdm/notes.rb +2 -2
- data/spec/factories/mdm/refs.rb +2 -2
- data/spec/factories/mdm/routes.rb +2 -2
- data/spec/factories/mdm/services.rb +3 -3
- data/spec/factories/mdm/session_events.rb +1 -1
- data/spec/factories/mdm/sessions.rb +2 -2
- data/spec/factories/mdm/tags.rb +2 -2
- data/spec/factories/mdm/task.rb +2 -2
- data/spec/factories/mdm/task_creds.rb +2 -2
- data/spec/factories/mdm/task_hosts.rb +2 -2
- data/spec/factories/mdm/task_services.rb +2 -2
- data/spec/factories/mdm/task_sessions.rb +2 -2
- data/spec/factories/mdm/users.rb +2 -2
- data/spec/factories/mdm/vuln_attempts.rb +2 -2
- data/spec/factories/mdm/vuln_details.rb +2 -2
- data/spec/factories/mdm/vuln_refs.rb +2 -2
- data/spec/factories/mdm/vulns.rb +2 -2
- data/spec/factories/mdm/web_forms.rb +1 -1
- data/spec/factories/mdm/web_pages.rb +2 -2
- data/spec/factories/mdm/web_sites.rb +2 -2
- data/spec/factories/mdm/web_vulns.rb +2 -2
- data/spec/factories/mdm/workspaces.rb +2 -2
- data/spec/factories/metasploit_data_models/automatic_exploitation/match_results.rb +1 -1
- data/spec/factories/metasploit_data_models/automatic_exploitation/match_sets.rb +2 -2
- data/spec/factories/metasploit_data_models/automatic_exploitation/matches.rb +1 -1
- data/spec/factories/metasploit_data_models/automatic_exploitation/runs.rb +1 -1
- data/spec/factories/module_runs.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +7 -7
- metadata.gz.sig +0 -0
@@ -2,7 +2,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
2
2
|
include_context 'Rex::Text'
|
3
3
|
|
4
4
|
subject(:host) do
|
5
|
-
|
5
|
+
FactoryBot.build(:mdm_host)
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:architectures) do
|
@@ -43,7 +43,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
43
43
|
context 'factory' do
|
44
44
|
context 'mdm_host' do
|
45
45
|
subject(:mdm_host) {
|
46
|
-
|
46
|
+
FactoryBot.build(:mdm_host)
|
47
47
|
}
|
48
48
|
|
49
49
|
it { is_expected.to be_valid }
|
@@ -58,21 +58,21 @@ RSpec.describe Mdm::Host, type: :model do
|
|
58
58
|
describe 'MAC address format validation' do
|
59
59
|
context 'when colon delimited' do
|
60
60
|
it 'is valid' do
|
61
|
-
host =
|
61
|
+
host = FactoryBot.build(:mdm_host, mac: '1a:2B:3c:4D:5e:6f')
|
62
62
|
expect(host).to be_valid
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
context 'when hyphen delimited' do
|
67
67
|
it 'is valid' do
|
68
|
-
host =
|
68
|
+
host = FactoryBot.build(:mdm_host, mac: '1a-2B-3c-4D-5e-6f')
|
69
69
|
expect(host).to be_valid
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
context 'when mixed colon-hyphen delimited ' do
|
74
74
|
it 'is invalid' do
|
75
|
-
host =
|
75
|
+
host = FactoryBot.build(:mdm_host, mac: '1a:2B:3c-4D:5e:6f')
|
76
76
|
expect(host).to be_invalid
|
77
77
|
end
|
78
78
|
end
|
@@ -80,16 +80,16 @@ RSpec.describe Mdm::Host, type: :model do
|
|
80
80
|
|
81
81
|
context '#destroy' do
|
82
82
|
it 'should successfully destroy the object and the dependent objects' do
|
83
|
-
host =
|
84
|
-
exploit_attempt =
|
85
|
-
exploited_host =
|
86
|
-
host_detail =
|
87
|
-
loot =
|
88
|
-
task_host =
|
89
|
-
note =
|
90
|
-
svc =
|
91
|
-
session =
|
92
|
-
vuln =
|
83
|
+
host = FactoryBot.create(:mdm_host)
|
84
|
+
exploit_attempt = FactoryBot.create(:mdm_exploit_attempt, :host => host)
|
85
|
+
exploited_host = FactoryBot.create(:mdm_exploited_host, :host => host)
|
86
|
+
host_detail = FactoryBot.create(:mdm_host_detail, :host => host)
|
87
|
+
loot = FactoryBot.create(:mdm_loot, :host => host)
|
88
|
+
task_host = FactoryBot.create(:mdm_task_host, :host => host)
|
89
|
+
note = FactoryBot.create(:mdm_note, :host => host)
|
90
|
+
svc = FactoryBot.create(:mdm_service, :host => host)
|
91
|
+
session = FactoryBot.create(:mdm_session, :host => host)
|
92
|
+
vuln = FactoryBot.create(:mdm_vuln, :host => host)
|
93
93
|
|
94
94
|
|
95
95
|
expect {
|
@@ -145,7 +145,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
145
145
|
|
146
146
|
context 'with Mdm::Vulns' do
|
147
147
|
let!(:vulns) do
|
148
|
-
|
148
|
+
FactoryBot.create_list(
|
149
149
|
:mdm_vuln,
|
150
150
|
2,
|
151
151
|
:host => host
|
@@ -154,30 +154,30 @@ RSpec.describe Mdm::Host, type: :model do
|
|
154
154
|
|
155
155
|
context 'with Mdm::Ref' do
|
156
156
|
let(:name) do
|
157
|
-
|
157
|
+
FactoryBot.generate :mdm_ref_name
|
158
158
|
end
|
159
159
|
|
160
160
|
let!(:ref) do
|
161
|
-
|
161
|
+
FactoryBot.create(:mdm_ref, :name => name)
|
162
162
|
end
|
163
163
|
|
164
164
|
context 'with Mdm::VulnRefs' do
|
165
165
|
let!(:vuln_refs) do
|
166
166
|
vulns.collect { |vuln|
|
167
|
-
|
167
|
+
FactoryBot.create(:mdm_vuln_ref, :ref => ref, :vuln => vuln)
|
168
168
|
}
|
169
169
|
end
|
170
170
|
|
171
171
|
context 'with Mdm::Module::Detail' do
|
172
172
|
let!(:module_detail) do
|
173
|
-
|
173
|
+
FactoryBot.create(
|
174
174
|
:mdm_module_detail
|
175
175
|
)
|
176
176
|
end
|
177
177
|
|
178
178
|
context 'with Mdm::Module::Ref with same name as Mdm::Ref' do
|
179
179
|
let!(:module_ref) do
|
180
|
-
|
180
|
+
FactoryBot.create(
|
181
181
|
:mdm_module_ref,
|
182
182
|
:detail => module_detail,
|
183
183
|
:name => name
|
@@ -390,7 +390,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
390
390
|
context 'factories' do
|
391
391
|
context 'full_mdm_host' do
|
392
392
|
subject(:full_mdm_host) do
|
393
|
-
|
393
|
+
FactoryBot.build(:full_mdm_host)
|
394
394
|
end
|
395
395
|
|
396
396
|
it { is_expected.to be_valid }
|
@@ -398,7 +398,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
398
398
|
|
399
399
|
context 'mdm_host' do
|
400
400
|
subject(:mdm_host) do
|
401
|
-
|
401
|
+
FactoryBot.build(:mdm_host)
|
402
402
|
end
|
403
403
|
|
404
404
|
it { is_expected.to be_valid }
|
@@ -414,10 +414,10 @@ RSpec.describe Mdm::Host, type: :model do
|
|
414
414
|
it 'should validate uniqueness of address scoped to workspace_id' do
|
415
415
|
address = '192.168.0.1'
|
416
416
|
|
417
|
-
workspace =
|
418
|
-
|
417
|
+
workspace = FactoryBot.create(:mdm_workspace)
|
418
|
+
FactoryBot.create(:mdm_host, :address => address, :workspace => workspace)
|
419
419
|
|
420
|
-
duplicate_host =
|
420
|
+
duplicate_host = FactoryBot.build(:mdm_host, :address => address, :workspace => workspace)
|
421
421
|
|
422
422
|
expect(duplicate_host).not_to be_valid
|
423
423
|
expect(duplicate_host.errors[:address]).to include('has already been taken')
|
@@ -425,9 +425,9 @@ RSpec.describe Mdm::Host, type: :model do
|
|
425
425
|
end
|
426
426
|
|
427
427
|
context 'arch' do
|
428
|
-
let(:workspace) {
|
428
|
+
let(:workspace) { FactoryBot.create(:mdm_workspace) }
|
429
429
|
let(:address) { '192.168.0.1' }
|
430
|
-
let(:host) {
|
430
|
+
let(:host) { FactoryBot.create(:mdm_host, :address => address, :workspace => workspace, :arch => arch) }
|
431
431
|
context 'with an unknown architecture' do
|
432
432
|
let(:arch) { "asdfasdf" }
|
433
433
|
it 'should normalize to Unknown' do
|
@@ -449,7 +449,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
449
449
|
|
450
450
|
context 'search scope' do
|
451
451
|
subject(:full_mdm_host) do
|
452
|
-
|
452
|
+
FactoryBot.create(:full_mdm_host)
|
453
453
|
end
|
454
454
|
|
455
455
|
def search_for(str)
|
@@ -732,17 +732,17 @@ RSpec.describe Mdm::Host, type: :model do
|
|
732
732
|
|
733
733
|
context '#validate_fingerprint_data' do
|
734
734
|
it 'should return false for an empty hash' do
|
735
|
-
fingerprint=
|
735
|
+
fingerprint= FactoryBot.build(:mdm_note, :data => {})
|
736
736
|
expect(host.validate_fingerprint_data(fingerprint)).to eq(false)
|
737
737
|
end
|
738
738
|
|
739
739
|
it 'should return false for postgresql fingerprints' do
|
740
|
-
fingerprint=
|
740
|
+
fingerprint= FactoryBot.build(:mdm_note, :ntype => 'postgresql.fingerprint', :data => {})
|
741
741
|
expect(host.validate_fingerprint_data(fingerprint)).to eq(false)
|
742
742
|
end
|
743
743
|
|
744
744
|
it 'should return false if the fingerprint does not contain a hash' do
|
745
|
-
fingerprint=
|
745
|
+
fingerprint= FactoryBot.build(:mdm_note, :data => 'this is not a fingerprint')
|
746
746
|
expect(host.validate_fingerprint_data(fingerprint)).to eq(false)
|
747
747
|
end
|
748
748
|
end
|
@@ -963,7 +963,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
963
963
|
context '#normalize_scanner_fp' do
|
964
964
|
context 'for session_fingerprint' do
|
965
965
|
it 'should return all the correct data for Windows XP SP3 x86' do
|
966
|
-
fingerprint =
|
966
|
+
fingerprint = FactoryBot.build(:mdm_session_fingerprint, :host => host)
|
967
967
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
968
968
|
expect(result['os.product']).to eq('Windows XP')
|
969
969
|
expect(result['os.version']).to eq('SP3')
|
@@ -974,7 +974,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
974
974
|
|
975
975
|
it 'should return all the correct data for Windows 2008 SP1 x64' do
|
976
976
|
fp_data = { :os => 'Microsoft Windows 2008 SP1', :arch => 'x64'}
|
977
|
-
fingerprint =
|
977
|
+
fingerprint = FactoryBot.build(:mdm_session_fingerprint, :host => host, :data => fp_data)
|
978
978
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
979
979
|
expect(result['os.product']).to eq('Windows Server 2008')
|
980
980
|
expect(result['os.version']).to eq('SP1')
|
@@ -986,7 +986,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
986
986
|
it 'should fingerprint Metasploitable correctly' do
|
987
987
|
# Taken from an actual session_fingerprint of Metasploitable 2
|
988
988
|
fp_data = { :os => 'Linux 2.6.24-16-server (i386)', :name => 'metasploitable'}
|
989
|
-
fingerprint =
|
989
|
+
fingerprint = FactoryBot.build(:mdm_session_fingerprint, :host => host, :data => fp_data)
|
990
990
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
991
991
|
expect(result['os.product']).to eq('Linux')
|
992
992
|
expect(result['host.name']).to eq('metasploitable')
|
@@ -997,7 +997,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
997
997
|
|
998
998
|
it 'should just populate os_name if it is unsure' do
|
999
999
|
fp_data = { :os => 'Darwin 12.3.0 x86_64 i386'}
|
1000
|
-
fingerprint =
|
1000
|
+
fingerprint = FactoryBot.build(:mdm_session_fingerprint, :host => host, :data => fp_data)
|
1001
1001
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1002
1002
|
expect(result['os.product']).to eq('Darwin 12.3.0 x86_64 i386')
|
1003
1003
|
expect(result['os.version']).to eq(nil)
|
@@ -1008,7 +1008,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1008
1008
|
|
1009
1009
|
context 'for nmap_fingerprint' do
|
1010
1010
|
it 'should return OS name for a Windows XP fingerprint' do
|
1011
|
-
fingerprint =
|
1011
|
+
fingerprint = FactoryBot.build(:mdm_nmap_fingerprint, :host => host)
|
1012
1012
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1013
1013
|
expect(result['os.product']).to eq('Windows XP')
|
1014
1014
|
expect(result['os.certainty'].to_f).to eq(described_class::MAX_NMAP_CERTAINTY)
|
@@ -1016,7 +1016,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1016
1016
|
|
1017
1017
|
it 'should return OS name for a Metasploitable fingerprint' do
|
1018
1018
|
fp_data = {:os_vendor=>"Linux", :os_family=>"Linux", :os_version=>"2.6.X", :os_accuracy=>100}
|
1019
|
-
fingerprint =
|
1019
|
+
fingerprint = FactoryBot.build(:mdm_nmap_fingerprint, :host => host, :data => fp_data)
|
1020
1020
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1021
1021
|
expect(result['os.product']).to eq('Linux')
|
1022
1022
|
expect(result['os.version']).to eq('2.6.X')
|
@@ -1025,7 +1025,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1025
1025
|
|
1026
1026
|
it 'should return OS name and flavor fo an OSX fingerprint' do
|
1027
1027
|
fp_data = {:os_vendor=>"Apple", :os_family=>"Mac OS X", :os_version=>"10.8.X", :os_accuracy=>100}
|
1028
|
-
fingerprint =
|
1028
|
+
fingerprint = FactoryBot.build(:mdm_nmap_fingerprint, :host => host, :data => fp_data)
|
1029
1029
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1030
1030
|
expect(result['os.product']).to eq('Mac OS X')
|
1031
1031
|
expect(result['os.vendor']).to eq('Apple')
|
@@ -1037,7 +1037,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1037
1037
|
context 'for nexpose_fingerprint' do
|
1038
1038
|
context 'of a Windows system' do
|
1039
1039
|
it 'should return a generic Windows fingerprint with no product info' do
|
1040
|
-
fingerprint =
|
1040
|
+
fingerprint = FactoryBot.build(:mdm_nexpose_fingerprint, :host => host)
|
1041
1041
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1042
1042
|
expect(result['os.product']).to eq('Windows')
|
1043
1043
|
expect(result['os.arch']).to eq('x86')
|
@@ -1046,7 +1046,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1046
1046
|
|
1047
1047
|
it 'should recognize a Windows 7 fingerprint' do
|
1048
1048
|
fp_data = {:family=>"Windows", :certainty=>"0.67", :vendor=>"Microsoft", :arch=>"x86", :product => 'Windows 7', :version => 'SP1'}
|
1049
|
-
fingerprint =
|
1049
|
+
fingerprint = FactoryBot.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
1050
1050
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1051
1051
|
expect(result['os.product']).to eq('Windows 7')
|
1052
1052
|
expect(result['os.version']).to eq('SP1')
|
@@ -1057,7 +1057,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1057
1057
|
|
1058
1058
|
it 'should recognize an OSX fingerprint' do
|
1059
1059
|
fp_data = {:family=>"Mac OS X", :certainty=>"0.80", :vendor=>"Apple"}
|
1060
|
-
fingerprint =
|
1060
|
+
fingerprint = FactoryBot.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
1061
1061
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1062
1062
|
expect(result['os.product']).to eq('Mac OS X')
|
1063
1063
|
expect(result['os.vendor']).to eq("Apple")
|
@@ -1065,7 +1065,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1065
1065
|
|
1066
1066
|
it 'should recognize a Cisco fingerprint' do
|
1067
1067
|
fp_data = {:family=>"IOS", :certainty=>"1.00", :vendor=>"Cisco", :version=>"11.2(8)SA2"}
|
1068
|
-
fingerprint =
|
1068
|
+
fingerprint = FactoryBot.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
1069
1069
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1070
1070
|
expect(result['os.product']).to eq('IOS')
|
1071
1071
|
expect(result['os.vendor']).to eq('Cisco')
|
@@ -1073,14 +1073,14 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1073
1073
|
|
1074
1074
|
it 'should recognize an embedded fingerprint' do
|
1075
1075
|
fp_data = {:family=>"embedded", :certainty=>"1.00", :vendor=>"Footek"}
|
1076
|
-
fingerprint =
|
1076
|
+
fingerprint = FactoryBot.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
1077
1077
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1078
1078
|
expect(result['os.product']).to eq('Footek')
|
1079
1079
|
end
|
1080
1080
|
|
1081
1081
|
it 'should handle an unknown fingerprint' do
|
1082
1082
|
fp_data = {:certainty=>"1.00", :vendor=>"Footek"}
|
1083
|
-
fingerprint =
|
1083
|
+
fingerprint = FactoryBot.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
1084
1084
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1085
1085
|
expect(result['os.product']).to eq('Footek')
|
1086
1086
|
end
|
@@ -1090,7 +1090,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1090
1090
|
|
1091
1091
|
context 'for retina_fingerprint' do
|
1092
1092
|
it 'should recognize a Windows fingerprint' do
|
1093
|
-
fingerprint =
|
1093
|
+
fingerprint = FactoryBot.build(:mdm_retina_fingerprint, :host => host)
|
1094
1094
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1095
1095
|
expect(result['os.product']).to eq( 'Windows Server 2003')
|
1096
1096
|
expect(result['os.arch']).to eq('x64')
|
@@ -1100,7 +1100,7 @@ RSpec.describe Mdm::Host, type: :model do
|
|
1100
1100
|
|
1101
1101
|
it 'should otherwise jsut copy the fingerprint to os_name' do
|
1102
1102
|
fp_data = { :os => 'Linux 2.6.X (i386)'}
|
1103
|
-
fingerprint =
|
1103
|
+
fingerprint = FactoryBot.build(:mdm_retina_fingerprint, :host => host, :data => fp_data)
|
1104
1104
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1105
1105
|
expect(result['os.product']).to eq( 'Linux 2.6.X (i386)')
|
1106
1106
|
expect(result['os.certainty'].to_f).to eq(0.8)
|
@@ -16,7 +16,7 @@ RSpec.describe Mdm::HostTag, type: :model do
|
|
16
16
|
context 'factories' do
|
17
17
|
context 'mdm_host_tag' do
|
18
18
|
subject(:mdm_host_tag) do
|
19
|
-
|
19
|
+
FactoryBot.build(:mdm_host_tag)
|
20
20
|
end
|
21
21
|
|
22
22
|
it { is_expected.to be_valid }
|
@@ -25,13 +25,13 @@ RSpec.describe Mdm::HostTag, type: :model do
|
|
25
25
|
|
26
26
|
context '#destroy' do
|
27
27
|
let(:tag) do
|
28
|
-
|
28
|
+
FactoryBot.create(
|
29
29
|
:mdm_tag
|
30
30
|
)
|
31
31
|
end
|
32
32
|
|
33
33
|
let!(:host_tag) do
|
34
|
-
|
34
|
+
FactoryBot.create(
|
35
35
|
:mdm_host_tag,
|
36
36
|
:tag => tag
|
37
37
|
)
|
@@ -45,7 +45,7 @@ RSpec.describe Mdm::HostTag, type: :model do
|
|
45
45
|
|
46
46
|
context 'with multiple Mdm::HostTags using same Mdm::Tag' do
|
47
47
|
let!(:other_host_tag) do
|
48
|
-
|
48
|
+
FactoryBot.create(
|
49
49
|
:mdm_host_tag,
|
50
50
|
:tag => tag
|
51
51
|
)
|
@@ -66,4 +66,4 @@ RSpec.describe Mdm::HostTag, type: :model do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
-
end
|
69
|
+
end
|
@@ -28,14 +28,14 @@ RSpec.describe Mdm::Listener, type: :model do
|
|
28
28
|
|
29
29
|
context 'factory' do
|
30
30
|
it 'should be valid' do
|
31
|
-
listener =
|
31
|
+
listener = FactoryBot.build(:mdm_listener)
|
32
32
|
expect(listener).to be_valid
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
context '#destroy' do
|
37
37
|
it 'should successfully destroy the object' do
|
38
|
-
listener =
|
38
|
+
listener = FactoryBot.create(:mdm_listener)
|
39
39
|
expect {
|
40
40
|
listener.destroy
|
41
41
|
}.to_not raise_error
|
@@ -48,31 +48,31 @@ RSpec.describe Mdm::Listener, type: :model do
|
|
48
48
|
context 'validations' do
|
49
49
|
context 'port' do
|
50
50
|
it 'should require a port' do
|
51
|
-
portless_listener =
|
51
|
+
portless_listener = FactoryBot.build(:mdm_listener, :port => nil)
|
52
52
|
expect(portless_listener).not_to be_valid
|
53
53
|
expect(portless_listener.errors[:port]).to include("can't be blank")
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'should not be valid for out-of-range numbers' do
|
57
|
-
out_of_range =
|
57
|
+
out_of_range = FactoryBot.build(:mdm_listener, :port => 70000)
|
58
58
|
expect(out_of_range).not_to be_valid
|
59
59
|
expect(out_of_range.errors[:port]).to include("is not included in the list")
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should not be valid for port 0' do
|
63
|
-
out_of_range =
|
63
|
+
out_of_range = FactoryBot.build(:mdm_listener, :port => 0)
|
64
64
|
expect(out_of_range).not_to be_valid
|
65
65
|
expect(out_of_range.errors[:port]).to include("is not included in the list")
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'should not be valid for decimal numbers' do
|
69
|
-
out_of_range =
|
69
|
+
out_of_range = FactoryBot.build(:mdm_listener, :port => 5.67)
|
70
70
|
expect(out_of_range).not_to be_valid
|
71
71
|
expect(out_of_range.errors[:port]).to include("must be an integer")
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'should not be valid for a negative number' do
|
75
|
-
out_of_range =
|
75
|
+
out_of_range = FactoryBot.build(:mdm_listener, :port => -8)
|
76
76
|
expect(out_of_range).not_to be_valid
|
77
77
|
expect(out_of_range.errors[:port]).to include("is not included in the list")
|
78
78
|
end
|
@@ -80,23 +80,23 @@ RSpec.describe Mdm::Listener, type: :model do
|
|
80
80
|
|
81
81
|
context 'address' do
|
82
82
|
it 'should require an address' do
|
83
|
-
addressless_listener =
|
83
|
+
addressless_listener = FactoryBot.build(:mdm_listener, :address => nil)
|
84
84
|
expect(addressless_listener).not_to be_valid
|
85
85
|
expect(addressless_listener.errors[:address]).to include("can't be blank")
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'should be valid for IPv4 format' do
|
89
|
-
ipv4_listener =
|
89
|
+
ipv4_listener = FactoryBot.build(:mdm_listener, :address => '192.168.1.120')
|
90
90
|
expect(ipv4_listener).to be_valid
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'should be valid for IPv6 format' do
|
94
|
-
ipv6_listener =
|
94
|
+
ipv6_listener = FactoryBot.build(:mdm_listener, :address => '2001:0db8:85a3:0000:0000:8a2e:0370:7334')
|
95
95
|
expect(ipv6_listener).to be_valid
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'should not be valid for strings not conforming to IPv4 or IPv6' do
|
99
|
-
invalid_listener =
|
99
|
+
invalid_listener = FactoryBot.build(:mdm_listener, :address => '1234-fark')
|
100
100
|
expect(invalid_listener).not_to be_valid
|
101
101
|
end
|
102
102
|
|
@@ -104,4 +104,4 @@ RSpec.describe Mdm::Listener, type: :model do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
|
107
|
-
end
|
107
|
+
end
|
@@ -30,14 +30,14 @@ RSpec.describe Mdm::Loot, type: :model do
|
|
30
30
|
|
31
31
|
context 'factory' do
|
32
32
|
it 'should be valid' do
|
33
|
-
loot =
|
33
|
+
loot = FactoryBot.build(:mdm_loot)
|
34
34
|
expect(loot).to be_valid
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
context '#destroy' do
|
39
39
|
it 'should successfully destroy the object' do
|
40
|
-
loot =
|
40
|
+
loot = FactoryBot.create(:mdm_loot)
|
41
41
|
expect {
|
42
42
|
loot.destroy
|
43
43
|
}.to_not raise_error
|
@@ -50,22 +50,22 @@ RSpec.describe Mdm::Loot, type: :model do
|
|
50
50
|
context 'scopes' do
|
51
51
|
context 'search' do
|
52
52
|
it 'should match on ltype' do
|
53
|
-
myloot =
|
53
|
+
myloot = FactoryBot.create(:mdm_loot, :ltype => 'find.this.ltype')
|
54
54
|
expect(Mdm::Loot.search('find.this.ltype')).to include(myloot)
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should match on name' do
|
58
|
-
myloot =
|
58
|
+
myloot = FactoryBot.create(:mdm_loot, :name => 'Find This')
|
59
59
|
expect(Mdm::Loot.search('Find This')).to include(myloot)
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should match on info' do
|
63
|
-
myloot =
|
63
|
+
myloot = FactoryBot.create(:mdm_loot, :info => 'Find This')
|
64
64
|
expect(Mdm::Loot.search('Find This')).to include(myloot)
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'should match on hostname' do
|
68
|
-
myloot =
|
68
|
+
myloot = FactoryBot.create(:mdm_loot, :info => 'Find This')
|
69
69
|
host_name = myloot.host.name
|
70
70
|
expect(Mdm::Loot.search(host_name)).to include(myloot)
|
71
71
|
end
|
@@ -75,10 +75,10 @@ RSpec.describe Mdm::Loot, type: :model do
|
|
75
75
|
context 'callbacks' do
|
76
76
|
context 'before_destroy' do
|
77
77
|
it 'should call #delete_file' do
|
78
|
-
myloot =
|
78
|
+
myloot = FactoryBot.create(:mdm_loot)
|
79
79
|
expect(myloot).to receive(:delete_file)
|
80
80
|
myloot.destroy
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
84
|
-
end
|
84
|
+
end
|
@@ -20,7 +20,7 @@ RSpec.describe Mdm::Module::Action, type: :model do
|
|
20
20
|
context 'factories' do
|
21
21
|
context 'mdm_module_action' do
|
22
22
|
subject(:mdm_module_action) do
|
23
|
-
|
23
|
+
FactoryBot.build(:mdm_module_action)
|
24
24
|
end
|
25
25
|
|
26
26
|
it { is_expected.to be_valid }
|
@@ -31,4 +31,4 @@ RSpec.describe Mdm::Module::Action, type: :model do
|
|
31
31
|
it { is_expected.to validate_presence_of(:detail) }
|
32
32
|
it { is_expected.to validate_presence_of(:name) }
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
@@ -20,7 +20,7 @@ RSpec.describe Mdm::Module::Arch, type: :model do
|
|
20
20
|
context 'factories' do
|
21
21
|
context 'mdm_module_arch' do
|
22
22
|
subject(:mdm_module_arch) do
|
23
|
-
|
23
|
+
FactoryBot.build(:mdm_module_arch)
|
24
24
|
end
|
25
25
|
|
26
26
|
it { is_expected.to be_valid }
|
@@ -31,4 +31,4 @@ RSpec.describe Mdm::Module::Arch, type: :model do
|
|
31
31
|
it { is_expected.to validate_presence_of(:detail) }
|
32
32
|
it { is_expected.to validate_presence_of(:name) }
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
@@ -21,7 +21,7 @@ RSpec.describe Mdm::Module::Author, type: :model do
|
|
21
21
|
context 'factories' do
|
22
22
|
context 'full_mdm_module_author' do
|
23
23
|
subject(:full_mdm_module_author) do
|
24
|
-
|
24
|
+
FactoryBot.build :full_mdm_module_author
|
25
25
|
end
|
26
26
|
|
27
27
|
it { is_expected.to be_valid }
|
@@ -37,7 +37,7 @@ RSpec.describe Mdm::Module::Author, type: :model do
|
|
37
37
|
|
38
38
|
context 'mdm_module_author' do
|
39
39
|
subject(:mdm_module_author) do
|
40
|
-
|
40
|
+
FactoryBot.build :mdm_module_author
|
41
41
|
end
|
42
42
|
|
43
43
|
it { is_expected.to be_valid }
|
@@ -49,4 +49,4 @@ RSpec.describe Mdm::Module::Author, type: :model do
|
|
49
49
|
it { is_expected.not_to validate_presence_of(:email) }
|
50
50
|
it { is_expected.to validate_presence_of(:name) }
|
51
51
|
end
|
52
|
-
end
|
52
|
+
end
|