metasploit_data_models 0.24.0 → 0.24.1.pre.rspec.pre.3.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -3
- data/Gemfile +1 -3
- data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
- data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
- data/app/validators/password_is_strong_validator.rb +1 -1
- data/lib/mdm/host/operating_system_normalization.rb +0 -10
- data/lib/metasploit_data_models/version.rb +2 -2
- data/metasploit_data_models.gemspec +1 -1
- data/spec/app/models/mdm/api_key_spec.rb +1 -3
- data/spec/app/models/mdm/client_spec.rb +9 -11
- data/spec/app/models/mdm/cred_spec.rb +42 -54
- data/spec/app/models/mdm/event_spec.rb +21 -23
- data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
- data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
- data/spec/app/models/mdm/host_detail_spec.rb +15 -17
- data/spec/app/models/mdm/host_spec.rb +261 -260
- data/spec/app/models/mdm/host_tag_spec.rb +6 -8
- data/spec/app/models/mdm/listener_spec.rb +30 -32
- data/spec/app/models/mdm/loot_spec.rb +21 -23
- data/spec/app/models/mdm/macro_spec.rb +1 -3
- data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
- data/spec/app/models/mdm/module/action_spec.rb +10 -12
- data/spec/app/models/mdm/module/arch_spec.rb +10 -12
- data/spec/app/models/mdm/module/author_spec.rb +22 -17
- data/spec/app/models/mdm/module/detail_spec.rb +184 -75
- data/spec/app/models/mdm/module/mixin_spec.rb +10 -12
- data/spec/app/models/mdm/module/platform_spec.rb +10 -12
- data/spec/app/models/mdm/module/ref_spec.rb +10 -12
- data/spec/app/models/mdm/module/target_spec.rb +13 -15
- data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
- data/spec/app/models/mdm/note_spec.rb +23 -25
- data/spec/app/models/mdm/profile_spec.rb +1 -3
- data/spec/app/models/mdm/ref_spec.rb +10 -12
- data/spec/app/models/mdm/route_spec.rb +6 -8
- data/spec/app/models/mdm/service_spec.rb +38 -40
- data/spec/app/models/mdm/session_event_spec.rb +10 -12
- data/spec/app/models/mdm/session_spec.rb +13 -15
- data/spec/app/models/mdm/tag_spec.rb +29 -29
- data/spec/app/models/mdm/task_cred_spec.rb +9 -11
- data/spec/app/models/mdm/task_host_spec.rb +9 -11
- data/spec/app/models/mdm/task_service_spec.rb +9 -11
- data/spec/app/models/mdm/task_session_spec.rb +7 -9
- data/spec/app/models/mdm/task_spec.rb +27 -29
- data/spec/app/models/mdm/user_spec.rb +17 -19
- data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
- data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
- data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
- data/spec/app/models/mdm/vuln_spec.rb +24 -26
- data/spec/app/models/mdm/web_form_spec.rb +11 -13
- data/spec/app/models/mdm/web_page_spec.rb +19 -21
- data/spec/app/models/mdm/web_site_spec.rb +21 -23
- data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
- data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
- data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
- data/spec/app/models/mdm/workspace_spec.rb +97 -100
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
- data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
- data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
- data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
- data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
- data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
- data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
- data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
- data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
- data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
- data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
- data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
- data/spec/app/validators/parameters_validator_spec.rb +29 -29
- data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
- data/spec/dummy/db/structure.sql +1 -0
- data/spec/lib/base64_serializer_spec.rb +19 -19
- data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
- data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
- data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
- data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
- data/spec/lib/metasploit_data_models/version_spec.rb +3 -5
- data/spec/spec_helper.rb +72 -6
- data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
- data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
- data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
- metadata +6 -6
@@ -1,31 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::ExploitAttempt do
|
1
|
+
RSpec.describe Mdm::ExploitAttempt, type: :model do
|
4
2
|
it_should_behave_like 'Metasploit::Concern.run'
|
5
3
|
|
6
4
|
context 'associations' do
|
7
|
-
it {
|
5
|
+
it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
|
8
6
|
end
|
9
7
|
|
10
8
|
context 'database' do
|
11
9
|
|
12
10
|
context 'timestamps'do
|
13
|
-
it {
|
11
|
+
it { is_expected.to have_db_column(:attempted_at).of_type(:datetime) }
|
14
12
|
end
|
15
13
|
|
16
14
|
context 'columns' do
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
15
|
+
it { is_expected.to have_db_column(:host_id).of_type(:integer) }
|
16
|
+
it { is_expected.to have_db_column(:service_id).of_type(:integer) }
|
17
|
+
it { is_expected.to have_db_column(:vuln_id).of_type(:integer) }
|
18
|
+
it { is_expected.to have_db_column(:exploited).of_type(:boolean) }
|
19
|
+
it { is_expected.to have_db_column(:fail_reason).of_type(:string) }
|
20
|
+
it { is_expected.to have_db_column(:username).of_type(:string) }
|
21
|
+
it { is_expected.to have_db_column(:module).of_type(:text) }
|
22
|
+
it { is_expected.to have_db_column(:session_id).of_type(:integer) }
|
23
|
+
it { is_expected.to have_db_column(:loot_id).of_type(:integer) }
|
24
|
+
it { is_expected.to have_db_column(:port).of_type(:integer) }
|
25
|
+
it { is_expected.to have_db_column(:proto).of_type(:string) }
|
26
|
+
it { is_expected.to have_db_column(:fail_detail).of_type(:text) }
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
@@ -45,17 +43,17 @@ describe Mdm::ExploitAttempt do
|
|
45
43
|
context 'validations' do
|
46
44
|
it 'should only be valid with a host_id' do
|
47
45
|
orphaned_attempt = FactoryGirl.build(:mdm_exploit_attempt, :host => nil)
|
48
|
-
orphaned_attempt.
|
49
|
-
orphaned_attempt.errors[:host_id].
|
46
|
+
expect(orphaned_attempt).not_to be_valid
|
47
|
+
expect(orphaned_attempt.errors[:host_id]).to include("can't be blank")
|
50
48
|
propper_attempt = FactoryGirl.build(:mdm_exploit_attempt)
|
51
|
-
propper_attempt.
|
49
|
+
expect(propper_attempt).to be_valid
|
52
50
|
end
|
53
51
|
end
|
54
52
|
|
55
53
|
context 'factory' do
|
56
54
|
it 'should be valid' do
|
57
55
|
exploit_attempt = FactoryGirl.build(:mdm_exploit_attempt)
|
58
|
-
exploit_attempt.
|
56
|
+
expect(exploit_attempt).to be_valid
|
59
57
|
end
|
60
58
|
end
|
61
59
|
end
|
@@ -1,26 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::ExploitedHost do
|
1
|
+
RSpec.describe Mdm::ExploitedHost, type: :model do
|
4
2
|
it_should_behave_like 'Metasploit::Concern.run'
|
5
3
|
|
6
4
|
context 'associations' do
|
7
|
-
it {
|
8
|
-
it {
|
5
|
+
it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
|
6
|
+
it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
|
9
7
|
end
|
10
8
|
|
11
9
|
context 'database' do
|
12
10
|
|
13
11
|
context 'timestamps'do
|
14
|
-
it {
|
15
|
-
it {
|
12
|
+
it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
|
13
|
+
it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
|
16
14
|
end
|
17
15
|
|
18
16
|
context 'columns' do
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
17
|
+
it { is_expected.to have_db_column(:host_id).of_type(:integer).with_options(:null => false) }
|
18
|
+
it { is_expected.to have_db_column(:service_id).of_type(:integer) }
|
19
|
+
it { is_expected.to have_db_column(:name).of_type(:string) }
|
20
|
+
it { is_expected.to have_db_column(:session_uuid).of_type(:string) }
|
21
|
+
it { is_expected.to have_db_column(:payload).of_type(:string) }
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
@@ -39,7 +37,7 @@ describe Mdm::ExploitedHost do
|
|
39
37
|
context 'factory' do
|
40
38
|
it 'should be valid' do
|
41
39
|
exploited_host = FactoryGirl.build(:mdm_exploited_host)
|
42
|
-
exploited_host.
|
40
|
+
expect(exploited_host).to be_valid
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -1,37 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::HostDetail do
|
1
|
+
RSpec.describe Mdm::HostDetail, type: :model do
|
4
2
|
it_should_behave_like 'Metasploit::Concern.run'
|
5
3
|
|
6
4
|
context 'associations' do
|
7
|
-
it {
|
5
|
+
it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
|
8
6
|
end
|
9
7
|
|
10
8
|
context 'database' do
|
11
|
-
it {
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
16
|
-
it {
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
9
|
+
it { is_expected.to have_db_column(:host_id).of_type(:integer) }
|
10
|
+
it { is_expected.to have_db_column(:nx_console_id).of_type(:integer) }
|
11
|
+
it { is_expected.to have_db_column(:nx_device_id).of_type(:integer) }
|
12
|
+
it { is_expected.to have_db_column(:src).of_type(:string) }
|
13
|
+
it { is_expected.to have_db_column(:nx_site_name).of_type(:string) }
|
14
|
+
it { is_expected.to have_db_column(:nx_site_importance).of_type(:string) }
|
15
|
+
it { is_expected.to have_db_column(:src).of_type(:string) }
|
16
|
+
it { is_expected.to have_db_column(:nx_site_name).of_type(:string) }
|
17
|
+
it { is_expected.to have_db_column(:nx_scan_template).of_type(:string) }
|
18
|
+
it { is_expected.to have_db_column(:nx_risk_score).of_type(:float) }
|
21
19
|
end
|
22
20
|
|
23
21
|
context 'validations' do
|
24
22
|
it 'should only be valid with a host_id' do
|
25
23
|
orphan_detail = FactoryGirl.build(:mdm_host_detail, :host => nil)
|
26
|
-
orphan_detail.
|
27
|
-
orphan_detail.errors[:host_id].
|
24
|
+
expect(orphan_detail).not_to be_valid
|
25
|
+
expect(orphan_detail.errors[:host_id]).to include("can't be blank")
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
31
29
|
context 'factory' do
|
32
30
|
it 'should be valid' do
|
33
31
|
host_detail = FactoryGirl.build(:mdm_host_detail)
|
34
|
-
host_detail.
|
32
|
+
expect(host_detail).to be_valid
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::Host do
|
1
|
+
RSpec.describe Mdm::Host, type: :model do
|
4
2
|
subject(:host) do
|
5
3
|
FactoryGirl.build(:mdm_host)
|
6
4
|
end
|
@@ -41,15 +39,18 @@ describe Mdm::Host do
|
|
41
39
|
it_should_behave_like 'Metasploit::Concern.run'
|
42
40
|
|
43
41
|
context 'factory' do
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
context 'mdm_host' do
|
43
|
+
subject(:mdm_host) {
|
44
|
+
FactoryGirl.build(:mdm_host)
|
45
|
+
}
|
46
|
+
|
47
|
+
it { is_expected.to be_valid }
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
51
|
context 'Constants' do
|
51
52
|
subject(:max_nmap_certainty) { described_class::MAX_NMAP_CERTAINTY }
|
52
|
-
it {
|
53
|
+
it { is_expected.to eq(0.84) }
|
53
54
|
end
|
54
55
|
|
55
56
|
context '#destroy' do
|
@@ -103,19 +104,19 @@ describe Mdm::Host do
|
|
103
104
|
end
|
104
105
|
|
105
106
|
context 'associations' do
|
106
|
-
it {
|
107
|
-
it {
|
108
|
-
it {
|
109
|
-
it {
|
110
|
-
it {
|
111
|
-
it {
|
112
|
-
it {
|
113
|
-
it {
|
114
|
-
it {
|
115
|
-
it {
|
107
|
+
it { is_expected.to have_many(:creds).class_name('Mdm::Cred').through(:services) }
|
108
|
+
it { is_expected.to have_many(:clients).class_name('Mdm::Client').dependent(:destroy) }
|
109
|
+
it { is_expected.to have_many(:exploit_attempts).class_name('Mdm::ExploitAttempt').dependent(:destroy) }
|
110
|
+
it { is_expected.to have_many(:exploited_hosts).class_name('Mdm::ExploitedHost').dependent(:destroy) }
|
111
|
+
it { is_expected.to have_many(:host_details).class_name('Mdm::HostDetail').dependent(:destroy) }
|
112
|
+
it { is_expected.to have_many(:hosts_tags).class_name('Mdm::HostTag') }
|
113
|
+
it { is_expected.to have_many(:loots).class_name('Mdm::Loot').dependent(:destroy).order('loots.created_at DESC') }
|
114
|
+
it { is_expected.to have_many(:module_runs).class_name('MetasploitDataModels::ModuleRun') }
|
115
|
+
it { is_expected.to have_many(:task_hosts).class_name('Mdm::TaskHost').dependent(:destroy) }
|
116
|
+
it { is_expected.to have_many(:tasks).class_name('Mdm::Task').through(:task_hosts) }
|
116
117
|
|
117
118
|
context 'module_details' do
|
118
|
-
it {
|
119
|
+
it { is_expected.to have_many(:module_details).class_name('Mdm::Module::Detail').through(:module_refs) }
|
119
120
|
|
120
121
|
context 'with Mdm::Vulns' do
|
121
122
|
let!(:vulns) do
|
@@ -188,8 +189,8 @@ describe Mdm::Host do
|
|
188
189
|
module_details << module_ref.detail
|
189
190
|
end
|
190
191
|
|
191
|
-
|
192
|
-
module_details.uniq.count.
|
192
|
+
expect(architectures).to include('mips')
|
193
|
+
expect(module_details.uniq.count).to eq(host.module_details.count)
|
193
194
|
end
|
194
195
|
end
|
195
196
|
end
|
@@ -198,17 +199,17 @@ describe Mdm::Host do
|
|
198
199
|
end
|
199
200
|
end
|
200
201
|
|
201
|
-
it {
|
202
|
-
it {
|
203
|
-
it {
|
204
|
-
it {
|
205
|
-
it {
|
206
|
-
it {
|
207
|
-
it {
|
208
|
-
it {
|
209
|
-
it {
|
210
|
-
it {
|
211
|
-
it {
|
202
|
+
it { is_expected.to have_many(:module_refs).class_name('Mdm::Module::Ref').through(:refs) }
|
203
|
+
it { is_expected.to have_many(:notes).class_name('Mdm::Note').dependent(:delete_all).order('notes.created_at') }
|
204
|
+
it { is_expected.to have_many(:refs).class_name('Mdm::Ref').through(:vuln_refs) }
|
205
|
+
it { is_expected.to have_many(:services).class_name('Mdm::Service').dependent(:destroy).order('services.port, services.proto') }
|
206
|
+
it { is_expected.to have_many(:service_notes).through(:services) }
|
207
|
+
it { is_expected.to have_many(:sessions).class_name('Mdm::Session').dependent(:destroy).order('sessions.opened_at') }
|
208
|
+
it { is_expected.to have_many(:tags).class_name('Mdm::Tag').through(:hosts_tags) }
|
209
|
+
it { is_expected.to have_many(:vulns).class_name('Mdm::Vuln').dependent(:delete_all) }
|
210
|
+
it { is_expected.to have_many(:vuln_refs).class_name('Mdm::VulnRef') }
|
211
|
+
it { is_expected.to have_many(:web_sites).class_name('Mdm::WebSite').through(:services) }
|
212
|
+
it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
|
212
213
|
end
|
213
214
|
|
214
215
|
context 'CONSTANTS' do
|
@@ -218,70 +219,70 @@ describe Mdm::Host do
|
|
218
219
|
end
|
219
220
|
|
220
221
|
it 'should be an Array<String>' do
|
221
|
-
architectures.
|
222
|
+
expect(architectures).to include('mips')
|
222
223
|
|
223
224
|
architectures.each do |architecture|
|
224
|
-
|
225
|
+
expect(architectures).to include('mips')
|
225
226
|
end
|
226
227
|
end
|
227
228
|
|
228
229
|
it 'should include both endians of ARM' do
|
229
|
-
architectures.
|
230
|
-
architectures.
|
230
|
+
expect(architectures).to include('mips')
|
231
|
+
expect(architectures).to include('mips')
|
231
232
|
end
|
232
233
|
|
233
234
|
it 'should include 32-bit and 64-bit versions of Cell Broadband Engine Architecture' do
|
234
|
-
architectures.
|
235
|
-
architectures.
|
235
|
+
expect(architectures).to include('mips')
|
236
|
+
expect(architectures).to include('mips')
|
236
237
|
end
|
237
238
|
|
238
239
|
it 'should include cmd for command shell' do
|
239
|
-
architectures.
|
240
|
+
expect(architectures).to include('mips')
|
240
241
|
end
|
241
242
|
|
242
243
|
it 'should include java for Java Virtual Machine' do
|
243
|
-
architectures.
|
244
|
+
expect(architectures).to include('mips')
|
244
245
|
end
|
245
246
|
|
246
247
|
it 'should include plain and endian-ware MIPS' do
|
247
|
-
architectures.
|
248
|
-
architectures.
|
249
|
-
architectures.
|
248
|
+
expect(architectures).to include('mips')
|
249
|
+
expect(architectures).to include('mipsbe')
|
250
|
+
expect(architectures).to include('mipsle')
|
250
251
|
end
|
251
252
|
|
252
253
|
it 'should include php for PHP code' do
|
253
|
-
architectures.
|
254
|
+
expect(architectures).to include('php')
|
254
255
|
end
|
255
256
|
|
256
257
|
it 'should include 32-bit and 64-bit PowerPC' do
|
257
|
-
architectures.
|
258
|
-
architectures.
|
258
|
+
expect(architectures).to include('ppc')
|
259
|
+
expect(architectures).to include('ppc64')
|
259
260
|
end
|
260
261
|
|
261
262
|
it 'should include ruby for Ruby code' do
|
262
|
-
architectures.
|
263
|
+
expect(architectures).to include('ruby')
|
263
264
|
end
|
264
265
|
|
265
266
|
it 'should include sparc for Sparc' do
|
266
|
-
architectures.
|
267
|
+
expect(architectures).to include('sparc')
|
267
268
|
end
|
268
269
|
|
269
270
|
it 'should include tty for Terminals' do
|
270
|
-
architectures.
|
271
|
+
expect(architectures).to include('tty')
|
271
272
|
end
|
272
273
|
|
273
274
|
it 'should include 32-bit and 64-bit x86' do
|
274
|
-
architectures.
|
275
|
-
architectures.
|
276
|
-
architectures.
|
275
|
+
expect(architectures).to include('x64')
|
276
|
+
expect(architectures).to include('x86')
|
277
|
+
expect(architectures).to include('x86_64')
|
277
278
|
end
|
278
279
|
|
279
280
|
it 'should include blank string to indicate no detection has happened' do
|
280
|
-
architectures.
|
281
|
+
expect(architectures).to include('')
|
281
282
|
end
|
282
283
|
|
283
284
|
it 'should include "Unknown" for failed detection attempts' do
|
284
|
-
architectures.
|
285
|
+
expect(architectures).to include('Unknown')
|
285
286
|
end
|
286
287
|
|
287
288
|
end
|
@@ -292,71 +293,71 @@ describe Mdm::Host do
|
|
292
293
|
end
|
293
294
|
|
294
295
|
it 'should be an Array<String>' do
|
295
|
-
search_fields.
|
296
|
+
expect(search_fields).to be_an Array
|
296
297
|
|
297
298
|
search_fields.each { |search_field|
|
298
|
-
search_field.
|
299
|
+
expect(search_field).to be_a String
|
299
300
|
}
|
300
301
|
end
|
301
302
|
|
302
303
|
it 'should cast address to text' do
|
303
|
-
search_fields.
|
304
|
+
expect(search_fields).to include('address::text')
|
304
305
|
end
|
305
306
|
|
306
|
-
it {
|
307
|
-
it {
|
308
|
-
it {
|
309
|
-
it {
|
310
|
-
it {
|
311
|
-
it {
|
312
|
-
it {
|
307
|
+
it { is_expected.to include('comments') }
|
308
|
+
it { is_expected.to include('mac') }
|
309
|
+
it { is_expected.to include('name') }
|
310
|
+
it { is_expected.to include('os_flavor') }
|
311
|
+
it { is_expected.to include('os_name') }
|
312
|
+
it { is_expected.to include('os_sp') }
|
313
|
+
it { is_expected.to include('purpose') }
|
313
314
|
end
|
314
315
|
|
315
316
|
it 'should define STATES in any order' do
|
316
|
-
described_class::STATES.
|
317
|
+
expect(described_class::STATES).to match_array(states)
|
317
318
|
end
|
318
319
|
end
|
319
320
|
|
320
321
|
context 'database' do
|
321
322
|
context 'columns' do
|
322
|
-
it {
|
323
|
-
it {
|
324
|
-
it {
|
325
|
-
it {
|
326
|
-
it {
|
327
|
-
it {
|
328
|
-
it {
|
329
|
-
it {
|
330
|
-
it {
|
331
|
-
it {
|
332
|
-
it {
|
333
|
-
it {
|
334
|
-
it {
|
335
|
-
it {
|
336
|
-
it {
|
337
|
-
it {
|
323
|
+
it { is_expected.to have_db_column(:address).of_type(:string).with_options(:null => false) }
|
324
|
+
it { is_expected.to have_db_column(:arch).of_type(:string) }
|
325
|
+
it { is_expected.to have_db_column(:comm).of_type(:string) }
|
326
|
+
it { is_expected.to have_db_column(:comments).of_type(:text) }
|
327
|
+
it { is_expected.to have_db_column(:info).of_type(:string).with_options(:limit => 2 ** 16) }
|
328
|
+
it { is_expected.to have_db_column(:mac).of_type(:string) }
|
329
|
+
it { is_expected.to have_db_column(:name).of_type(:string) }
|
330
|
+
it { is_expected.to have_db_column(:os_flavor).of_type(:string) }
|
331
|
+
it { is_expected.to have_db_column(:os_lang).of_type(:string) }
|
332
|
+
it { is_expected.to have_db_column(:os_name).of_type(:string) }
|
333
|
+
it { is_expected.to have_db_column(:os_sp).of_type(:string) }
|
334
|
+
it { is_expected.to have_db_column(:purpose).of_type(:text) }
|
335
|
+
it { is_expected.to have_db_column(:scope).of_type(:text) }
|
336
|
+
it { is_expected.to have_db_column(:state).of_type(:string) }
|
337
|
+
it { is_expected.to have_db_column(:virtual_host).of_type(:text) }
|
338
|
+
it { is_expected.to have_db_column(:workspace_id).of_type(:integer).with_options(:null => false) }
|
338
339
|
|
339
340
|
context 'counter caches' do
|
340
|
-
it {
|
341
|
-
it {
|
342
|
-
it {
|
343
|
-
it {
|
344
|
-
it {
|
341
|
+
it { is_expected.to have_db_column(:exploit_attempt_count).of_type(:integer).with_options(:default => 0) }
|
342
|
+
it { is_expected.to have_db_column(:host_detail_count).of_type(:integer).with_options(:default => 0) }
|
343
|
+
it { is_expected.to have_db_column(:note_count).of_type(:integer).with_options(:default => 0) }
|
344
|
+
it { is_expected.to have_db_column(:service_count).of_type(:integer).with_options(:default => 0) }
|
345
|
+
it { is_expected.to have_db_column(:vuln_count).of_type(:integer).with_options(:default => 0) }
|
345
346
|
end
|
346
347
|
|
347
348
|
context 'timestamps' do
|
348
|
-
it {
|
349
|
-
it {
|
349
|
+
it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
|
350
|
+
it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
|
350
351
|
end
|
351
352
|
end
|
352
353
|
|
353
354
|
context 'indices' do
|
354
|
-
it {
|
355
|
-
it {
|
356
|
-
it {
|
357
|
-
it {
|
358
|
-
it {
|
359
|
-
it {
|
355
|
+
it { is_expected.to have_db_index([:workspace_id, :address]).unique(true) }
|
356
|
+
it { is_expected.to have_db_index(:name) }
|
357
|
+
it { is_expected.to have_db_index(:os_flavor) }
|
358
|
+
it { is_expected.to have_db_index(:os_name) }
|
359
|
+
it { is_expected.to have_db_index(:purpose) }
|
360
|
+
it { is_expected.to have_db_index(:state) }
|
360
361
|
end
|
361
362
|
end
|
362
363
|
|
@@ -366,7 +367,7 @@ describe Mdm::Host do
|
|
366
367
|
FactoryGirl.build(:full_mdm_host)
|
367
368
|
end
|
368
369
|
|
369
|
-
it {
|
370
|
+
it { is_expected.to be_valid }
|
370
371
|
end
|
371
372
|
|
372
373
|
context 'mdm_host' do
|
@@ -374,14 +375,14 @@ describe Mdm::Host do
|
|
374
375
|
FactoryGirl.build(:mdm_host)
|
375
376
|
end
|
376
377
|
|
377
|
-
it {
|
378
|
+
it { is_expected.to be_valid }
|
378
379
|
end
|
379
380
|
end
|
380
381
|
|
381
382
|
context 'validations' do
|
382
383
|
context 'address' do
|
383
|
-
it {
|
384
|
-
it {
|
384
|
+
it { is_expected.to ensure_exclusion_of(:address).in_array(['127.0.0.1']) }
|
385
|
+
it { is_expected.to validate_presence_of(:address) }
|
385
386
|
|
386
387
|
# can't use validate_uniqueness_of(:address).scoped_to(:workspace_id) because it will attempt to set workspace_id
|
387
388
|
# to `nil`, which will make the `:null => false` constraint on hosts.workspace_id to fail.
|
@@ -393,8 +394,8 @@ describe Mdm::Host do
|
|
393
394
|
|
394
395
|
duplicate_host = FactoryGirl.build(:mdm_host, :address => address, :workspace => workspace)
|
395
396
|
|
396
|
-
duplicate_host.
|
397
|
-
duplicate_host.errors[:address].
|
397
|
+
expect(duplicate_host).not_to be_valid
|
398
|
+
expect(duplicate_host.errors[:address]).to include('has already been taken')
|
398
399
|
end
|
399
400
|
end
|
400
401
|
|
@@ -405,19 +406,19 @@ describe Mdm::Host do
|
|
405
406
|
context 'with an unknown architecture' do
|
406
407
|
let(:arch) { "asdfasdf" }
|
407
408
|
it 'should normalize to Unknown' do
|
408
|
-
host.
|
409
|
-
host.arch.
|
409
|
+
expect(host).to be_valid
|
410
|
+
expect(host.arch).to be described_class::UNKNOWN_ARCHITECTURE
|
410
411
|
end
|
411
412
|
end
|
412
413
|
described_class::ARCHITECTURES.each do |arch|
|
413
414
|
context "with known architecture '#{arch}'" do
|
414
415
|
let(:arch) { arch }
|
415
|
-
it {
|
416
|
+
it { is_expected.to be_valid }
|
416
417
|
end
|
417
418
|
end
|
418
419
|
end
|
419
|
-
it {
|
420
|
-
it {
|
420
|
+
it { is_expected.to ensure_inclusion_of(:state).in_array(states).allow_nil }
|
421
|
+
it { is_expected.to validate_presence_of(:workspace) }
|
421
422
|
end
|
422
423
|
|
423
424
|
context 'search scope' do
|
@@ -431,13 +432,13 @@ describe Mdm::Host do
|
|
431
432
|
|
432
433
|
context 'searching for an empty string' do
|
433
434
|
it 'should return any hosts in the database' do
|
434
|
-
search_for('').
|
435
|
+
expect(search_for('')).to include(subject)
|
435
436
|
end
|
436
437
|
end
|
437
438
|
|
438
439
|
context 'searching for an existing Host\'s name' do
|
439
440
|
it 'should return the host' do
|
440
|
-
search_for(subject.name).
|
441
|
+
expect(search_for(subject.name)).to include(subject)
|
441
442
|
end
|
442
443
|
end
|
443
444
|
end
|
@@ -446,139 +447,139 @@ describe Mdm::Host do
|
|
446
447
|
context '#get_arch_from_string' do
|
447
448
|
context "should return 'x64'" do
|
448
449
|
it "when the string contains 'x64'" do
|
449
|
-
host.send(:get_arch_from_string, 'blahx64blah').
|
450
|
+
expect(host.send(:get_arch_from_string, 'blahx64blah')).to eq('x64')
|
450
451
|
end
|
451
452
|
|
452
453
|
it "when the string contains 'X64'" do
|
453
|
-
host.send(:get_arch_from_string, 'blahX64blah').
|
454
|
+
expect(host.send(:get_arch_from_string, 'blahX64blah')).to eq('x64')
|
454
455
|
end
|
455
456
|
|
456
457
|
it "when the string contains 'x86_64'" do
|
457
|
-
host.send(:get_arch_from_string, 'blahx86_64blah').
|
458
|
+
expect(host.send(:get_arch_from_string, 'blahx86_64blah')).to eq('x64')
|
458
459
|
end
|
459
460
|
|
460
461
|
it "when the string contains 'X86_64'" do
|
461
|
-
host.send(:get_arch_from_string, 'blahX86_64blah').
|
462
|
+
expect(host.send(:get_arch_from_string, 'blahX86_64blah')).to eq('x64')
|
462
463
|
end
|
463
464
|
|
464
465
|
it "when the string contains 'amd64'" do
|
465
|
-
host.send(:get_arch_from_string, 'blahamd64blah').
|
466
|
+
expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x64')
|
466
467
|
end
|
467
468
|
|
468
469
|
it "when the string contains 'AMD64'" do
|
469
|
-
host.send(:get_arch_from_string, 'blahAMD64blah').
|
470
|
+
expect(host.send(:get_arch_from_string, 'blahAMD64blah')).to eq('x64')
|
470
471
|
end
|
471
472
|
|
472
473
|
it "when the string contains 'aMd64'" do
|
473
|
-
host.send(:get_arch_from_string, 'blahamd64blah').
|
474
|
+
expect(host.send(:get_arch_from_string, 'blahamd64blah')).to eq('x64')
|
474
475
|
end
|
475
476
|
end
|
476
477
|
|
477
478
|
context "should return 'x86'" do
|
478
479
|
it "when the string contains 'x86'" do
|
479
|
-
host.send(:get_arch_from_string, 'blahx86blah').
|
480
|
+
expect(host.send(:get_arch_from_string, 'blahx86blah')).to eq('x86')
|
480
481
|
end
|
481
482
|
|
482
483
|
it "when the string contains 'X86'" do
|
483
|
-
host.send(:get_arch_from_string, 'blahX86blah').
|
484
|
+
expect(host.send(:get_arch_from_string, 'blahX86blah')).to eq('x86')
|
484
485
|
end
|
485
486
|
|
486
487
|
it "when the string contains 'i386'" do
|
487
|
-
host.send(:get_arch_from_string, 'blahi386blah').
|
488
|
+
expect(host.send(:get_arch_from_string, 'blahi386blah')).to eq('x86')
|
488
489
|
end
|
489
490
|
|
490
491
|
it "when the string contains 'I386'" do
|
491
|
-
host.send(:get_arch_from_string, 'blahI386blah').
|
492
|
+
expect(host.send(:get_arch_from_string, 'blahI386blah')).to eq('x86')
|
492
493
|
end
|
493
494
|
|
494
495
|
it "when the string contains 'i486'" do
|
495
|
-
host.send(:get_arch_from_string, 'blahi486blah').
|
496
|
+
expect(host.send(:get_arch_from_string, 'blahi486blah')).to eq('x86')
|
496
497
|
end
|
497
498
|
|
498
499
|
it "when the string contains 'i586'" do
|
499
|
-
host.send(:get_arch_from_string, 'blahi586blah').
|
500
|
+
expect(host.send(:get_arch_from_string, 'blahi586blah')).to eq('x86')
|
500
501
|
end
|
501
502
|
|
502
503
|
it "when the string contains 'i686'" do
|
503
|
-
host.send(:get_arch_from_string, 'blahi386blah').
|
504
|
+
expect(host.send(:get_arch_from_string, 'blahi386blah')).to eq('x86')
|
504
505
|
end
|
505
506
|
end
|
506
507
|
|
507
508
|
context "should return 'ppc'" do
|
508
509
|
it "when the string contains 'PowerPC'" do
|
509
|
-
host.send(:get_arch_from_string, 'blahPowerPCblah').
|
510
|
+
expect(host.send(:get_arch_from_string, 'blahPowerPCblah')).to eq('ppc')
|
510
511
|
end
|
511
512
|
|
512
513
|
it "when the string contains 'PPC'" do
|
513
|
-
host.send(:get_arch_from_string, 'blahPPCblah').
|
514
|
+
expect(host.send(:get_arch_from_string, 'blahPPCblah')).to eq('ppc')
|
514
515
|
end
|
515
516
|
|
516
517
|
it "when the string contains 'POWER'" do
|
517
|
-
host.send(:get_arch_from_string, 'blahPOWERblah').
|
518
|
+
expect(host.send(:get_arch_from_string, 'blahPOWERblah')).to eq('ppc')
|
518
519
|
end
|
519
520
|
|
520
521
|
it "when the string contains 'ppc'" do
|
521
|
-
host.send(:get_arch_from_string, 'blahppcblah').
|
522
|
+
expect(host.send(:get_arch_from_string, 'blahppcblah')).to eq('ppc')
|
522
523
|
end
|
523
524
|
end
|
524
525
|
|
525
526
|
context 'should return nil' do
|
526
527
|
it 'when PowerPC is cased incorrectly' do
|
527
|
-
host.send(:get_arch_from_string, 'powerPC').
|
528
|
-
host.send(:get_arch_from_string, 'Powerpc').
|
528
|
+
expect(host.send(:get_arch_from_string, 'powerPC')).to eq(nil)
|
529
|
+
expect(host.send(:get_arch_from_string, 'Powerpc')).to eq(nil)
|
529
530
|
end
|
530
531
|
|
531
532
|
it 'when no recognized arch string is present' do
|
532
|
-
host.send(:get_arch_from_string, 'blahblah').
|
533
|
+
expect(host.send(:get_arch_from_string, 'blahblah')).to eq(nil)
|
533
534
|
end
|
534
535
|
end
|
535
536
|
|
536
537
|
it "should return 'sparc' if the string contains SPARC, regardless of case" do
|
537
|
-
host.send(:get_arch_from_string, 'blahSPARCblah').
|
538
|
-
host.send(:get_arch_from_string, 'blahSPaRCblah').
|
539
|
-
host.send(:get_arch_from_string, 'blahsparcblah').
|
538
|
+
expect(host.send(:get_arch_from_string, 'blahSPARCblah')).to eq('sparc')
|
539
|
+
expect(host.send(:get_arch_from_string, 'blahSPaRCblah')).to eq('sparc')
|
540
|
+
expect(host.send(:get_arch_from_string, 'blahsparcblah')).to eq('sparc')
|
540
541
|
end
|
541
542
|
|
542
543
|
it "should return 'arm' if the string contains 'ARM', regardless of case" do
|
543
|
-
host.send(:get_arch_from_string, 'blahARMblah').
|
544
|
-
host.send(:get_arch_from_string, 'blahArMblah').
|
545
|
-
host.send(:get_arch_from_string, 'blaharmblah').
|
544
|
+
expect(host.send(:get_arch_from_string, 'blahARMblah')).to eq('arm')
|
545
|
+
expect(host.send(:get_arch_from_string, 'blahArMblah')).to eq('arm')
|
546
|
+
expect(host.send(:get_arch_from_string, 'blaharmblah')).to eq('arm')
|
546
547
|
end
|
547
548
|
|
548
549
|
it "should return 'mips' if the string contains 'MIPS', regardless of case" do
|
549
|
-
host.send(:get_arch_from_string, 'blahMIPSblah').
|
550
|
-
host.send(:get_arch_from_string, 'blahMiPslah').
|
551
|
-
host.send(:get_arch_from_string, 'blahmipsblah').
|
550
|
+
expect(host.send(:get_arch_from_string, 'blahMIPSblah')).to eq('mips')
|
551
|
+
expect(host.send(:get_arch_from_string, 'blahMiPslah')).to eq('mips')
|
552
|
+
expect(host.send(:get_arch_from_string, 'blahmipsblah')).to eq('mips')
|
552
553
|
end
|
553
554
|
end
|
554
555
|
|
555
556
|
context '#parse_windows_os_str' do
|
556
557
|
it 'should always return the os_name as Windows' do
|
557
558
|
result = host.send(:parse_windows_os_str, '')
|
558
|
-
result['os.product'].
|
559
|
+
expect(result['os.product']).to eq('Windows')
|
559
560
|
end
|
560
561
|
|
561
562
|
context 'arch' do
|
562
563
|
it 'should return a value for arch if there is one' do
|
563
564
|
result = host.send(:parse_windows_os_str, 'Windows x64')
|
564
|
-
result['os.arch'].
|
565
|
+
expect(result['os.arch']).to eq('x64')
|
565
566
|
end
|
566
567
|
|
567
568
|
it "should not have an arch key if we don't know the arch" do
|
568
569
|
result = host.send(:parse_windows_os_str, 'Windows')
|
569
|
-
result.has_key?('os.arch').
|
570
|
+
expect(result.has_key?('os.arch')).to eq(false)
|
570
571
|
end
|
571
572
|
end
|
572
573
|
|
573
574
|
context 'Service Pack' do
|
574
575
|
it 'should be returned if we see Service Pack X' do
|
575
576
|
result = host.send(:parse_windows_os_str, 'Windows XP Service Pack 1')
|
576
|
-
result['os.version'].
|
577
|
+
expect(result['os.version']).to eq('SP1')
|
577
578
|
end
|
578
579
|
|
579
580
|
it 'should be returned if we see SPX' do
|
580
581
|
result = host.send(:parse_windows_os_str, 'Windows XP SP3')
|
581
|
-
result['os.version'].
|
582
|
+
expect(result['os.version']).to eq('SP3')
|
582
583
|
end
|
583
584
|
end
|
584
585
|
|
@@ -586,141 +587,137 @@ describe Mdm::Host do
|
|
586
587
|
|
587
588
|
it "should appear as Windows 95 for 'Windows 95" do
|
588
589
|
result = host.send(:parse_windows_os_str, 'Windows 95')
|
589
|
-
result['os.product'].
|
590
|
+
expect(result['os.product']).to eq('Windows 95')
|
590
591
|
end
|
591
592
|
|
592
593
|
it "should appear as Windows NT 3.51 for 'Windows NT 3.51" do
|
593
594
|
result = host.send(:parse_windows_os_str, 'Windows NT 3.51')
|
594
|
-
result['os.product'].
|
595
|
+
expect(result['os.product']).to eq('Windows NT 3.51')
|
595
596
|
end
|
596
597
|
|
597
598
|
it "should appear as Windows NT 4.0 for 'Windows NT 4.0" do
|
598
599
|
result = host.send(:parse_windows_os_str, 'Windows NT 4.0')
|
599
|
-
result['os.product'].
|
600
|
+
expect(result['os.product']).to eq('Windows NT 4.0')
|
600
601
|
end
|
601
602
|
|
602
603
|
it "should appear as Windows 98 for 'Windows 98" do
|
603
604
|
result = host.send(:parse_windows_os_str, 'Windows 98')
|
604
|
-
result['os.product'].
|
605
|
+
expect(result['os.product']).to eq('Windows 98')
|
605
606
|
end
|
606
607
|
|
607
608
|
it "should appear as Windows ME for 'Windows ME" do
|
608
609
|
result = host.send(:parse_windows_os_str, 'Windows ME')
|
609
|
-
result['os.product'].
|
610
|
+
expect(result['os.product']).to eq('Windows ME')
|
610
611
|
end
|
611
612
|
|
612
613
|
it "should appear as Windows 2003 for '.NET Server'" do
|
613
614
|
result = host.send(:parse_windows_os_str, 'Windows .NET Server')
|
614
|
-
result['os.product'].
|
615
|
+
expect(result['os.product']).to eq('Windows Server 2003')
|
615
616
|
end
|
616
617
|
|
617
618
|
it 'should be recognized for Windows XP' do
|
618
619
|
result = host.send(:parse_windows_os_str, 'Windows XP')
|
619
|
-
result['os.product'].
|
620
|
+
expect(result['os.product']).to eq('Windows XP')
|
620
621
|
end
|
621
622
|
|
622
623
|
it 'should be recognized for Windows Server 2000' do
|
623
624
|
result = host.send(:parse_windows_os_str, 'Windows 2000')
|
624
|
-
result['os.product'].
|
625
|
+
expect(result['os.product']).to eq('Windows Server 2000')
|
625
626
|
end
|
626
627
|
|
627
628
|
it 'should be recognized for Windows Server 2003' do
|
628
629
|
result = host.send(:parse_windows_os_str, 'Windows 2003')
|
629
|
-
result['os.product'].
|
630
|
+
expect(result['os.product']).to eq('Windows Server 2003')
|
630
631
|
end
|
631
632
|
|
632
633
|
it 'should be recognized for Windows 2008' do
|
633
634
|
result = host.send(:parse_windows_os_str, 'Windows 2008')
|
634
|
-
result['os.product'].
|
635
|
+
expect(result['os.product']).to eq('Windows Server 2008')
|
635
636
|
end
|
636
637
|
|
637
638
|
it 'should be recognized for Windows 2012' do
|
638
639
|
result = host.send(:parse_windows_os_str, 'Windows 2012')
|
639
|
-
result['os.product'].
|
640
|
+
expect(result['os.product']).to eq('Windows Server 2012')
|
640
641
|
end
|
641
642
|
|
642
643
|
it 'should be recognized for Windows Vista' do
|
643
644
|
result = host.send(:parse_windows_os_str, 'Windows Vista')
|
644
|
-
result['os.product'].
|
645
|
+
expect(result['os.product']).to eq('Windows Vista')
|
645
646
|
end
|
646
647
|
|
647
648
|
it 'should be recognized for Windows Server 2000' do
|
648
649
|
result = host.send(:parse_windows_os_str, 'Windows 2000 Advanced Server')
|
649
|
-
result['os.product'].
|
650
|
+
expect(result['os.product']).to eq('Windows Server 2000')
|
650
651
|
end
|
651
652
|
|
652
653
|
it 'should be recognized for Windows 7' do
|
653
654
|
result = host.send(:parse_windows_os_str, 'Windows 7')
|
654
|
-
result['os.product'].
|
655
|
+
expect(result['os.product']).to eq('Windows 7')
|
655
656
|
end
|
656
657
|
|
657
658
|
it 'should be recognized for Windows 7 Ultimate Edition' do
|
658
659
|
result = host.send(:parse_windows_os_str, 'Windows 7 Ultimate Edition')
|
659
|
-
result['os.product'].
|
660
|
-
result['os.edition'].
|
660
|
+
expect(result['os.product']).to eq('Windows 7')
|
661
|
+
expect(result['os.edition']).to eq('Ultimate')
|
661
662
|
end
|
662
663
|
|
663
664
|
it 'should be recognized for Windows 8' do
|
664
665
|
result = host.send(:parse_windows_os_str, 'Windows 8')
|
665
|
-
result['os.product'].
|
666
|
+
expect(result['os.product']).to eq('Windows 8')
|
666
667
|
end
|
667
668
|
|
668
669
|
it 'should be recognized for Windows 8.1' do
|
669
670
|
result = host.send(:parse_windows_os_str, 'Windows 8.1')
|
670
|
-
result['os.product'].
|
671
|
+
expect(result['os.product']).to eq('Windows 8.1')
|
671
672
|
end
|
672
673
|
|
673
674
|
it 'should be recognized for Windows 8.2' do
|
674
675
|
result = host.send(:parse_windows_os_str, 'Windows 8.2')
|
675
|
-
result['os.product'].
|
676
|
+
expect(result['os.product']).to eq('Windows 8.2')
|
676
677
|
end
|
677
678
|
|
678
679
|
it 'should be recognized as Windows XP, Build 2600, SP3' do
|
679
680
|
result = host.send(:parse_windows_os_str, 'Windows XP (Build 2600, Service Pack 3).')
|
680
|
-
result['os.product'].
|
681
|
-
result['os.build'].
|
682
|
-
result['os.version'].
|
681
|
+
expect(result['os.product']).to eq('Windows XP')
|
682
|
+
expect(result['os.build']).to eq('2600')
|
683
|
+
expect(result['os.version']).to eq('SP3')
|
683
684
|
end
|
684
685
|
|
685
686
|
it 'should be recognized as Windows Server 2003, Build 3790' do
|
686
687
|
result = host.send(:parse_windows_os_str, 'Windows .NET Server (Build 3790).')
|
687
|
-
result['os.product'].
|
688
|
-
result['os.build'].
|
688
|
+
expect(result['os.product']).to eq('Windows Server 2003')
|
689
|
+
expect(result['os.build']).to eq('3790')
|
689
690
|
end
|
690
691
|
|
691
692
|
it 'should be recognized as Windows Server 2008, Build 6001, SP1' do
|
692
693
|
result = host.send(:parse_windows_os_str, 'Windows 2008 (Build 6001, Service Pack 1).')
|
693
|
-
result['os.product'].
|
694
|
-
result['os.build'].
|
695
|
-
result['os.version'].
|
694
|
+
expect(result['os.product']).to eq('Windows Server 2008')
|
695
|
+
expect(result['os.build']).to eq('6001')
|
696
|
+
expect(result['os.version']).to eq('SP1')
|
696
697
|
end
|
697
698
|
|
698
699
|
it 'should default to Windows <name> if all else fails' do
|
699
700
|
result = host.send(:parse_windows_os_str, 'Windows Foobar Service Pack 3')
|
700
|
-
result['os.product'].
|
701
|
-
result['os.version'].
|
701
|
+
expect(result['os.product']).to eq('Windows Foobar')
|
702
|
+
expect(result['os.version']).to eq('SP3')
|
702
703
|
end
|
703
704
|
end
|
704
705
|
end
|
705
706
|
|
706
707
|
context '#validate_fingerprint_data' do
|
707
|
-
before(:each) do
|
708
|
-
host.stub(:dlog)
|
709
|
-
end
|
710
|
-
|
711
708
|
it 'should return false for an empty hash' do
|
712
709
|
fingerprint= FactoryGirl.build(:mdm_note, :data => {})
|
713
|
-
host.validate_fingerprint_data(fingerprint).
|
710
|
+
expect(host.validate_fingerprint_data(fingerprint)).to eq(false)
|
714
711
|
end
|
715
712
|
|
716
713
|
it 'should return false for postgresql fingerprints' do
|
717
714
|
fingerprint= FactoryGirl.build(:mdm_note, :ntype => 'postgresql.fingerprint', :data => {})
|
718
|
-
host.validate_fingerprint_data(fingerprint).
|
715
|
+
expect(host.validate_fingerprint_data(fingerprint)).to eq(false)
|
719
716
|
end
|
720
717
|
|
721
718
|
it 'should return false if the fingerprint does not contain a hash' do
|
722
719
|
fingerprint= FactoryGirl.build(:mdm_note, :data => 'this is not a fingerprint')
|
723
|
-
host.validate_fingerprint_data(fingerprint).
|
720
|
+
expect(host.validate_fingerprint_data(fingerprint)).to eq(false)
|
724
721
|
end
|
725
722
|
end
|
726
723
|
|
@@ -728,91 +725,95 @@ describe Mdm::Host do
|
|
728
725
|
context '#apply_match_to_host' do
|
729
726
|
|
730
727
|
before(:each) do
|
731
|
-
stub_const(
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
728
|
+
stub_const(
|
729
|
+
'Rex::Text',
|
730
|
+
Module.new do
|
731
|
+
def self.ascii_safe_hex(unsanitized)
|
732
|
+
# Pass back the sanitized value for the stub
|
733
|
+
unsanitized.unpack("C*").pack("C*").gsub(/([\x00-\x08\x0b\x0c\x0e-\x1f\x80-\xFF])/n){ |x| "\\x%.2x" % x.unpack("C*")[0]}
|
734
|
+
end
|
735
|
+
end
|
736
|
+
)
|
736
737
|
end
|
737
738
|
|
738
739
|
it 'should set host.mac when host.mac is present' do
|
739
740
|
match = { 'host.mac' => '00:11:22:33:44:55' }
|
740
741
|
host.send(:apply_match_to_host, match)
|
741
|
-
host.mac.
|
742
|
+
expect(host.mac).to eq('00:11:22:33:44:55')
|
742
743
|
end
|
743
744
|
|
744
745
|
it 'should set host.name when host.name is present' do
|
745
746
|
match = { 'host.name' => 'webbyweb' }
|
746
747
|
host.send(:apply_match_to_host, match)
|
747
|
-
host.name.
|
748
|
+
expect(host.name).to eq('webbyweb')
|
748
749
|
end
|
749
750
|
|
750
751
|
it 'should set host.arch when os.arch is present' do
|
751
752
|
match = { 'os.arch' => 'x86' }
|
752
753
|
host.send(:apply_match_to_host, match)
|
753
|
-
host.arch.
|
754
|
+
expect(host.arch).to eq('x86')
|
754
755
|
end
|
755
756
|
|
756
757
|
it 'should set host.name to an escaped hex value when host.name contains high bytes' do
|
757
758
|
match = { 'host.name' => "HighBytes\xff\xf0".force_encoding('binary') }
|
758
759
|
host.send(:apply_match_to_host, match)
|
759
|
-
host.name.
|
760
|
+
expect(host.name).to eq("HighBytes\\xff\\xf0")
|
760
761
|
end
|
761
762
|
|
762
763
|
it 'should set host.purpose to client when os.product is Windows XP' do
|
763
764
|
match = { 'os.product' => 'Windows XP' }
|
764
765
|
host.send(:apply_match_to_host, match)
|
765
|
-
host.os_name.
|
766
|
-
host.purpose.
|
766
|
+
expect(host.os_name).to eq('Windows XP')
|
767
|
+
expect(host.purpose).to eq('client')
|
767
768
|
end
|
768
769
|
|
769
770
|
it 'should set host.purpose to server when os.product is Windows 2012' do
|
770
771
|
match = { 'os.product' => 'Windows 2012' }
|
771
772
|
host.send(:apply_match_to_host, match)
|
772
|
-
host.os_name.
|
773
|
-
host.purpose.
|
773
|
+
expect(host.os_name).to eq('Windows 2012')
|
774
|
+
expect(host.purpose).to eq('server')
|
774
775
|
end
|
775
776
|
|
776
777
|
it 'should set host.purpose to printer when os.device is Print server' do
|
777
778
|
match = { 'os.device' => 'Print server' }
|
778
779
|
host.send(:apply_match_to_host, match)
|
779
|
-
host.purpose.
|
780
|
+
expect(host.purpose).to eq('printer')
|
780
781
|
end
|
781
782
|
|
782
783
|
it 'should set host.os_lang to English when os.language is English' do
|
783
784
|
match = { 'os.language' => 'English' }
|
784
785
|
host.send(:apply_match_to_host, match)
|
785
|
-
host.os_lang.
|
786
|
+
expect(host.os_lang).to eq('English')
|
786
787
|
end
|
787
788
|
|
788
789
|
it 'should set host.os_name to Windows 8.1 when os.product is Windows 8.1' do
|
789
790
|
match = { 'os.product' => 'Windows 8.1' }
|
790
791
|
host.send(:apply_match_to_host, match)
|
791
|
-
host.os_name.
|
792
|
+
expect(host.os_name).to eq('Windows 8.1')
|
792
793
|
end
|
793
794
|
|
794
795
|
it 'should set host.os_name to Windows when os.product is not set and os.family is Windows' do
|
795
796
|
match = { 'os.family' => 'Windows' }
|
796
797
|
host.send(:apply_match_to_host, match)
|
797
|
-
host.os_name.
|
798
|
+
expect(host.os_name).to eq('Windows')
|
798
799
|
end
|
799
800
|
|
800
801
|
it 'should set host.os_flavor to Professional when os.edition is Professional' do
|
801
802
|
match = { 'os.edition' => 'Professional' }
|
802
803
|
host.send(:apply_match_to_host, match)
|
803
|
-
host.os_flavor.
|
804
|
+
expect(host.os_flavor).to eq('Professional')
|
804
805
|
end
|
805
806
|
|
806
807
|
it 'should set host.os_sp to SP2 when os.version is SP2' do
|
807
808
|
match = { 'os.version' => 'SP2' }
|
808
809
|
host.send(:apply_match_to_host, match)
|
809
|
-
host.os_sp.
|
810
|
+
expect(host.os_sp).to eq('SP2')
|
810
811
|
end
|
811
812
|
|
812
813
|
it 'should set host.os_sp to 3.2.11 when os.version is nil and linux.kernel.version is 3.2.11' do
|
813
814
|
match = { 'linux.kernel.version' => '3.2.11' }
|
814
815
|
host.send(:apply_match_to_host, match)
|
815
|
-
host.os_sp.
|
816
|
+
expect(host.os_sp).to eq('3.2.11')
|
816
817
|
end
|
817
818
|
end
|
818
819
|
|
@@ -821,33 +822,33 @@ describe Mdm::Host do
|
|
821
822
|
it 'should convert Service Pack X to SPX' do
|
822
823
|
match = { 'os.version' => 'Service Pack 2' }
|
823
824
|
result = host.send(:normalize_match, match)
|
824
|
-
result['os.version'].
|
825
|
+
expect(result['os.version']).to eq('SP2')
|
825
826
|
end
|
826
827
|
|
827
828
|
it 'should not convert No Service Pack to SP' do
|
828
829
|
match = { 'os.version' => 'No Service Pack' }
|
829
830
|
result = host.send(:normalize_match, match)
|
830
|
-
result['os.version'].
|
831
|
+
expect(result['os.version']).to eq('No Service Pack')
|
831
832
|
end
|
832
833
|
|
833
834
|
it 'should convert Apple Mac OS X to Mac OS X' do
|
834
835
|
match = { 'os.product' => 'Apple Mac OS X' }
|
835
836
|
result = host.send(:normalize_match, match)
|
836
|
-
result['os.product'].
|
837
|
-
result['os.vendor'].
|
837
|
+
expect(result['os.product']).to eq('Mac OS X')
|
838
|
+
expect(result['os.vendor']).to eq('Apple')
|
838
839
|
end
|
839
840
|
|
840
841
|
it 'should convert Microsoft Windows to Windows' do
|
841
842
|
match = { 'os.product' => 'Microsoft Windows 7' }
|
842
843
|
result = host.send(:normalize_match, match)
|
843
|
-
result['os.product'].
|
844
|
-
result['os.vendor'].
|
844
|
+
expect(result['os.product']).to eq('Windows 7')
|
845
|
+
expect(result['os.vendor']).to eq('Microsoft')
|
845
846
|
end
|
846
847
|
|
847
848
|
it 'should convert Windows Server 2012 to Windows 2012' do
|
848
849
|
match = { 'os.product' => 'Windows Server 2012' }
|
849
850
|
result = host.send(:normalize_match, match)
|
850
|
-
result['os.product'].
|
851
|
+
expect(result['os.product']).to eq('Windows 2012')
|
851
852
|
end
|
852
853
|
end
|
853
854
|
|
@@ -856,55 +857,55 @@ describe Mdm::Host do
|
|
856
857
|
it 'should detect Windows XP as a client' do
|
857
858
|
match = { 'os.product' => 'Windows XP' }
|
858
859
|
result = host.send(:guess_purpose_from_match, match)
|
859
|
-
result.
|
860
|
+
expect(result).to eq('client')
|
860
861
|
end
|
861
862
|
|
862
863
|
it 'should detect Windows 8.1 as a client' do
|
863
864
|
match = { 'os.product' => 'Windows 8.1' }
|
864
865
|
result = host.send(:guess_purpose_from_match, match)
|
865
|
-
result.
|
866
|
+
expect(result).to eq('client')
|
866
867
|
end
|
867
868
|
|
868
869
|
it 'should detect Windows 2000 as a server' do
|
869
870
|
match = { 'os.product' => 'Windows 2000' }
|
870
871
|
result = host.send(:guess_purpose_from_match, match)
|
871
|
-
result.
|
872
|
+
expect(result).to eq('server')
|
872
873
|
end
|
873
874
|
|
874
875
|
it 'should detect Windows Server 2012 as a server' do
|
875
876
|
match = { 'os.product' => 'Windows Server 2012' }
|
876
877
|
result = host.send(:guess_purpose_from_match, match)
|
877
|
-
result.
|
878
|
+
expect(result).to eq('server')
|
878
879
|
end
|
879
880
|
|
880
881
|
it 'should detect Linux as a server' do
|
881
882
|
match = { 'os.product' => 'Linux' }
|
882
883
|
result = host.send(:guess_purpose_from_match, match)
|
883
|
-
result.
|
884
|
+
expect(result).to eq('server')
|
884
885
|
end
|
885
886
|
|
886
887
|
it 'should detect JetDirect as a printer' do
|
887
888
|
match = { 'os.product' => 'JetDirect', 'os.device' => 'Print server' }
|
888
889
|
result = host.send(:guess_purpose_from_match, match)
|
889
|
-
result.
|
890
|
+
expect(result).to eq('printer')
|
890
891
|
end
|
891
892
|
|
892
893
|
it 'should detect Unknown Printer as a printer' do
|
893
894
|
match = { 'os.product' => 'Unknown Printer' }
|
894
895
|
result = host.send(:guess_purpose_from_match, match)
|
895
|
-
result.
|
896
|
+
expect(result).to eq('printer')
|
896
897
|
end
|
897
898
|
|
898
899
|
it 'should detect Linksys Router as a router' do
|
899
900
|
match = { 'os.product' => 'Linksys', 'os.device' => 'Router' }
|
900
901
|
result = host.send(:guess_purpose_from_match, match)
|
901
|
-
result.
|
902
|
+
expect(result).to eq('router')
|
902
903
|
end
|
903
904
|
|
904
905
|
it 'should detect CheckPoint Firewall-1 as a firewall' do
|
905
906
|
match = { 'os.vendor' => 'Check Point', 'os.product' => 'Firewall-1' }
|
906
907
|
result = host.send(:guess_purpose_from_match, match)
|
907
|
-
result.
|
908
|
+
expect(result).to eq('firewall')
|
908
909
|
end
|
909
910
|
end
|
910
911
|
|
@@ -913,22 +914,22 @@ describe Mdm::Host do
|
|
913
914
|
it 'should return all the correct data for Windows XP SP3 x86' do
|
914
915
|
fingerprint = FactoryGirl.build(:mdm_session_fingerprint, :host => host)
|
915
916
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
916
|
-
result['os.product'].
|
917
|
-
result['os.version'].
|
918
|
-
result['os.arch'].
|
919
|
-
result['host.name'].
|
920
|
-
result['os.certainty'].to_f.
|
917
|
+
expect(result['os.product']).to eq('Windows XP')
|
918
|
+
expect(result['os.version']).to eq('SP3')
|
919
|
+
expect(result['os.arch']).to eq('x86')
|
920
|
+
expect(result['host.name']).to eq(nil)
|
921
|
+
expect(result['os.certainty'].to_f).to eq(0.8)
|
921
922
|
end
|
922
923
|
|
923
924
|
it 'should return all the correct data for Windows 2008 SP1 x64' do
|
924
925
|
fp_data = { :os => 'Microsoft Windows 2008 SP1', :arch => 'x64'}
|
925
926
|
fingerprint = FactoryGirl.build(:mdm_session_fingerprint, :host => host, :data => fp_data)
|
926
927
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
927
|
-
result['os.product'].
|
928
|
-
result['os.version'].
|
929
|
-
result['os.arch'].
|
930
|
-
result['host.name'].
|
931
|
-
result['os.certainty'].to_f.
|
928
|
+
expect(result['os.product']).to eq('Windows Server 2008')
|
929
|
+
expect(result['os.version']).to eq('SP1')
|
930
|
+
expect(result['os.arch']).to eq('x64')
|
931
|
+
expect(result['host.name']).to eq(nil)
|
932
|
+
expect(result['os.certainty'].to_f).to eq(0.8)
|
932
933
|
end
|
933
934
|
|
934
935
|
it 'should fingerprint Metasploitable correctly' do
|
@@ -936,21 +937,21 @@ describe Mdm::Host do
|
|
936
937
|
fp_data = { :os => 'Linux 2.6.24-16-server (i386)', :name => 'metasploitable'}
|
937
938
|
fingerprint = FactoryGirl.build(:mdm_session_fingerprint, :host => host, :data => fp_data)
|
938
939
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
939
|
-
result['os.product'].
|
940
|
-
result['host.name'].
|
941
|
-
result['os.version'].
|
942
|
-
result['os.arch'].
|
943
|
-
result['os.certainty'].to_f.
|
940
|
+
expect(result['os.product']).to eq('Linux')
|
941
|
+
expect(result['host.name']).to eq('metasploitable')
|
942
|
+
expect(result['os.version']).to eq('2.6.24-16-server')
|
943
|
+
expect(result['os.arch']).to eq('x86')
|
944
|
+
expect(result['os.certainty'].to_f).to eq(0.8)
|
944
945
|
end
|
945
946
|
|
946
947
|
it 'should just populate os_name if it is unsure' do
|
947
948
|
fp_data = { :os => 'Darwin 12.3.0 x86_64 i386'}
|
948
949
|
fingerprint = FactoryGirl.build(:mdm_session_fingerprint, :host => host, :data => fp_data)
|
949
950
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
950
|
-
result['os.product'].
|
951
|
-
result['os.version'].
|
952
|
-
result['os.arch'].
|
953
|
-
result['os.certainty'].
|
951
|
+
expect(result['os.product']).to eq('Darwin 12.3.0 x86_64 i386')
|
952
|
+
expect(result['os.version']).to eq(nil)
|
953
|
+
expect(result['os.arch']).to eq(nil)
|
954
|
+
expect(result['os.certainty']).to eq(0.8)
|
954
955
|
end
|
955
956
|
end
|
956
957
|
|
@@ -958,27 +959,27 @@ describe Mdm::Host do
|
|
958
959
|
it 'should return OS name for a Windows XP fingerprint' do
|
959
960
|
fingerprint = FactoryGirl.build(:mdm_nmap_fingerprint, :host => host)
|
960
961
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
961
|
-
result['os.product'].
|
962
|
-
result['os.certainty'].to_f.
|
962
|
+
expect(result['os.product']).to eq('Windows XP')
|
963
|
+
expect(result['os.certainty'].to_f).to eq(described_class::MAX_NMAP_CERTAINTY)
|
963
964
|
end
|
964
965
|
|
965
966
|
it 'should return OS name for a Metasploitable fingerprint' do
|
966
967
|
fp_data = {:os_vendor=>"Linux", :os_family=>"Linux", :os_version=>"2.6.X", :os_accuracy=>100}
|
967
968
|
fingerprint = FactoryGirl.build(:mdm_nmap_fingerprint, :host => host, :data => fp_data)
|
968
969
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
969
|
-
result['os.product'].
|
970
|
-
result['os.version'].
|
971
|
-
result['os.certainty'].to_f.
|
970
|
+
expect(result['os.product']).to eq('Linux')
|
971
|
+
expect(result['os.version']).to eq('2.6.X')
|
972
|
+
expect(result['os.certainty'].to_f).to eq(described_class::MAX_NMAP_CERTAINTY)
|
972
973
|
end
|
973
974
|
|
974
975
|
it 'should return OS name and flavor fo an OSX fingerprint' do
|
975
976
|
fp_data = {:os_vendor=>"Apple", :os_family=>"Mac OS X", :os_version=>"10.8.X", :os_accuracy=>100}
|
976
977
|
fingerprint = FactoryGirl.build(:mdm_nmap_fingerprint, :host => host, :data => fp_data)
|
977
978
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
978
|
-
result['os.product'].
|
979
|
-
result['os.vendor'].
|
980
|
-
result['os.version'].
|
981
|
-
result['os.certainty'].to_f.
|
979
|
+
expect(result['os.product']).to eq('Mac OS X')
|
980
|
+
expect(result['os.vendor']).to eq('Apple')
|
981
|
+
expect(result['os.version']).to eq('10.8.X')
|
982
|
+
expect(result['os.certainty'].to_f).to eq(described_class::MAX_NMAP_CERTAINTY)
|
982
983
|
end
|
983
984
|
end
|
984
985
|
|
@@ -987,19 +988,19 @@ describe Mdm::Host do
|
|
987
988
|
it 'should return a generic Windows fingerprint with no product info' do
|
988
989
|
fingerprint = FactoryGirl.build(:mdm_nexpose_fingerprint, :host => host)
|
989
990
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
990
|
-
result['os.product'].
|
991
|
-
result['os.arch'].
|
992
|
-
result['os.certainty'].to_f.
|
991
|
+
expect(result['os.product']).to eq('Windows')
|
992
|
+
expect(result['os.arch']).to eq('x86')
|
993
|
+
expect(result['os.certainty'].to_f).to eq(0.67)
|
993
994
|
end
|
994
995
|
|
995
996
|
it 'should recognize a Windows 7 fingerprint' do
|
996
997
|
fp_data = {:family=>"Windows", :certainty=>"0.67", :vendor=>"Microsoft", :arch=>"x86", :product => 'Windows 7', :version => 'SP1'}
|
997
998
|
fingerprint = FactoryGirl.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
998
999
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
999
|
-
result['os.product'].
|
1000
|
-
result['os.version'].
|
1001
|
-
result['os.arch'].
|
1002
|
-
result['os.certainty'].to_f.
|
1000
|
+
expect(result['os.product']).to eq('Windows 7')
|
1001
|
+
expect(result['os.version']).to eq('SP1')
|
1002
|
+
expect(result['os.arch']).to eq('x86')
|
1003
|
+
expect(result['os.certainty'].to_f).to eq(0.67)
|
1003
1004
|
end
|
1004
1005
|
end
|
1005
1006
|
|
@@ -1007,30 +1008,30 @@ describe Mdm::Host do
|
|
1007
1008
|
fp_data = {:family=>"Mac OS X", :certainty=>"0.80", :vendor=>"Apple"}
|
1008
1009
|
fingerprint = FactoryGirl.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
1009
1010
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1010
|
-
result['os.product'].
|
1011
|
-
result['os.vendor'].
|
1011
|
+
expect(result['os.product']).to eq('Mac OS X')
|
1012
|
+
expect(result['os.vendor']).to eq("Apple")
|
1012
1013
|
end
|
1013
1014
|
|
1014
1015
|
it 'should recognize a Cisco fingerprint' do
|
1015
1016
|
fp_data = {:family=>"IOS", :certainty=>"1.00", :vendor=>"Cisco", :version=>"11.2(8)SA2"}
|
1016
1017
|
fingerprint = FactoryGirl.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
1017
1018
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1018
|
-
result['os.product'].
|
1019
|
-
result['os.vendor'].
|
1019
|
+
expect(result['os.product']).to eq('IOS')
|
1020
|
+
expect(result['os.vendor']).to eq('Cisco')
|
1020
1021
|
end
|
1021
1022
|
|
1022
1023
|
it 'should recognize an embedded fingerprint' do
|
1023
1024
|
fp_data = {:family=>"embedded", :certainty=>"1.00", :vendor=>"Footek"}
|
1024
1025
|
fingerprint = FactoryGirl.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
1025
1026
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1026
|
-
result['os.product'].
|
1027
|
+
expect(result['os.product']).to eq('Footek')
|
1027
1028
|
end
|
1028
1029
|
|
1029
1030
|
it 'should handle an unknown fingerprint' do
|
1030
1031
|
fp_data = {:certainty=>"1.00", :vendor=>"Footek"}
|
1031
1032
|
fingerprint = FactoryGirl.build(:mdm_nexpose_fingerprint, :host => host, :data => fp_data)
|
1032
1033
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1033
|
-
result['os.product'].
|
1034
|
+
expect(result['os.product']).to eq('Footek')
|
1034
1035
|
end
|
1035
1036
|
|
1036
1037
|
|
@@ -1040,18 +1041,18 @@ describe Mdm::Host do
|
|
1040
1041
|
it 'should recognize a Windows fingerprint' do
|
1041
1042
|
fingerprint = FactoryGirl.build(:mdm_retina_fingerprint, :host => host)
|
1042
1043
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1043
|
-
result['os.product'].
|
1044
|
-
result['os.arch'].
|
1045
|
-
result['os.version'].
|
1046
|
-
result['os.certainty'].to_f.
|
1044
|
+
expect(result['os.product']).to eq( 'Windows Server 2003')
|
1045
|
+
expect(result['os.arch']).to eq('x64')
|
1046
|
+
expect(result['os.version']).to eq('SP2')
|
1047
|
+
expect(result['os.certainty'].to_f).to eq(0.8)
|
1047
1048
|
end
|
1048
1049
|
|
1049
1050
|
it 'should otherwise jsut copy the fingerprint to os_name' do
|
1050
1051
|
fp_data = { :os => 'Linux 2.6.X (i386)'}
|
1051
1052
|
fingerprint = FactoryGirl.build(:mdm_retina_fingerprint, :host => host, :data => fp_data)
|
1052
1053
|
result = host.send(:normalize_scanner_fp, fingerprint).first
|
1053
|
-
result['os.product'].
|
1054
|
-
result['os.certainty'].to_f.
|
1054
|
+
expect(result['os.product']).to eq( 'Linux 2.6.X (i386)')
|
1055
|
+
expect(result['os.certainty'].to_f).to eq(0.8)
|
1055
1056
|
end
|
1056
1057
|
end
|
1057
1058
|
end
|