metasploit_data_models 1.0.0.pre.rails.pre.4.0b → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -2
- data/.travis.yml +6 -3
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +10 -52
- data/Gemfile +4 -6
- data/RELEASING.md +88 -0
- data/Rakefile +23 -0
- data/UPGRADING.md +1 -0
- data/app/models/mdm/api_key.rb +41 -1
- data/app/models/mdm/client.rb +41 -1
- data/app/models/mdm/cred.rb +116 -28
- data/app/models/mdm/event.rb +47 -0
- data/app/models/mdm/exploit_attempt.rb +65 -16
- data/app/models/mdm/exploited_host.rb +27 -0
- data/app/models/mdm/host_detail.rb +44 -0
- data/app/models/mdm/host_tag.rb +6 -8
- data/app/models/mdm/listener.rb +52 -0
- data/app/models/mdm/macro.rb +42 -0
- data/app/models/mdm/mod_ref.rb +21 -1
- data/app/models/mdm/module/action.rb +15 -0
- data/app/models/mdm/module/arch.rb +10 -0
- data/app/models/mdm/module/author.rb +17 -1
- data/app/models/mdm/module/mixin.rb +13 -0
- data/app/models/mdm/module/platform.rb +11 -0
- data/app/models/mdm/module/target.rb +18 -0
- data/app/models/mdm/nexpose_console.rb +82 -4
- data/app/models/mdm/profile.rb +36 -0
- data/app/models/mdm/route.rb +16 -4
- data/app/models/mdm/session_event.rb +32 -0
- data/app/models/mdm/tag.rb +48 -9
- data/app/models/mdm/task.rb +85 -46
- data/app/models/mdm/task_cred.rb +29 -0
- data/app/models/mdm/task_host.rb +25 -0
- data/app/models/mdm/task_service.rb +25 -0
- data/app/models/mdm/task_session.rb +25 -0
- data/app/models/mdm/user.rb +192 -6
- data/app/models/mdm/vuln_attempt.rb +37 -12
- data/app/models/mdm/vuln_detail.rb +138 -5
- data/app/models/mdm/vuln_ref.rb +3 -0
- data/app/models/mdm/web_form.rb +34 -0
- data/app/models/mdm/web_page.rb +69 -0
- data/app/models/mdm/web_site.rb +50 -0
- data/app/models/mdm/wmap_request.rb +85 -0
- data/app/models/mdm/wmap_target.rb +40 -0
- data/app/models/mdm/workspace.rb +160 -17
- data/app/models/metasploit_data_models/automatic_exploitation/match.rb +13 -23
- data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +25 -4
- data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +15 -4
- data/app/models/metasploit_data_models/automatic_exploitation/run.rb +7 -3
- data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
- data/app/models/metasploit_data_models/module_run.rb +1 -1
- data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
- data/app/validators/ip_format_validator.rb +4 -0
- data/app/validators/parameters_validator.rb +12 -0
- data/app/validators/password_is_strong_validator.rb +10 -1
- data/lib/mdm/host/operating_system_normalization.rb +7 -10
- data/lib/metasploit_data_models.rb +4 -0
- data/lib/metasploit_data_models/automatic_exploitation.rb +25 -0
- data/lib/metasploit_data_models/engine.rb +2 -0
- data/lib/metasploit_data_models/serialized_prefs.rb +6 -0
- data/lib/metasploit_data_models/version.rb +30 -7
- data/metasploit_data_models.gemspec +9 -2
- 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 +22 -24
- 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 +262 -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 +8 -10
- data/spec/app/models/mdm/module/arch_spec.rb +8 -10
- data/spec/app/models/mdm/module/author_spec.rb +19 -14
- data/spec/app/models/mdm/module/detail_spec.rb +184 -75
- data/spec/app/models/mdm/module/mixin_spec.rb +8 -10
- data/spec/app/models/mdm/module/platform_spec.rb +8 -10
- data/spec/app/models/mdm/module/ref_spec.rb +8 -10
- data/spec/app/models/mdm/module/target_spec.rb +10 -12
- 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 +9 -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 -30
- 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/lib/base64_serializer_spec.rb +19 -21
- data/spec/lib/ipaddr_spec.rb +1 -3
- 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 -139
- data/spec/lib/metasploit_data_models_spec.rb +4 -0
- data/spec/spec_helper.rb +86 -12
- 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 +74 -14
- data/app/models/metasploit_data_models/automatic_exploitation.rb +0 -16
- data/lib/tasks/yard.rake +0 -33
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe MetasploitDataModels::IPAddress::V4::CIDR do
|
1
|
+
RSpec.describe MetasploitDataModels::IPAddress::V4::CIDR, type: :model do
|
4
2
|
subject(:cidr) {
|
5
3
|
described_class.new(
|
6
4
|
value: formatted_value
|
@@ -11,14 +9,14 @@ describe MetasploitDataModels::IPAddress::V4::CIDR do
|
|
11
9
|
nil
|
12
10
|
}
|
13
11
|
|
14
|
-
it {
|
12
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::CIDR }
|
15
13
|
|
16
14
|
context 'address_class' do
|
17
15
|
subject(:address_class) {
|
18
16
|
described_class.address_class
|
19
17
|
}
|
20
18
|
|
21
|
-
it {
|
19
|
+
it { is_expected.to eq(MetasploitDataModels::IPAddress::V4::Single) }
|
22
20
|
end
|
23
21
|
|
24
22
|
context 'validations' do
|
@@ -35,7 +33,7 @@ describe MetasploitDataModels::IPAddress::V4::CIDR do
|
|
35
33
|
"#{formatted_address}/#{formatted_prefix_length}"
|
36
34
|
}
|
37
35
|
|
38
|
-
it {
|
36
|
+
it { is_expected.to be_valid }
|
39
37
|
end
|
40
38
|
|
41
39
|
context 'with IPv4 address' do
|
@@ -43,7 +41,7 @@ describe MetasploitDataModels::IPAddress::V4::CIDR do
|
|
43
41
|
formatted_address
|
44
42
|
}
|
45
43
|
|
46
|
-
it {
|
44
|
+
it { is_expected.not_to be_valid }
|
47
45
|
|
48
46
|
context 'errors' do
|
49
47
|
before(:each) do
|
@@ -55,7 +53,7 @@ describe MetasploitDataModels::IPAddress::V4::CIDR do
|
|
55
53
|
cidr.errors[:address]
|
56
54
|
}
|
57
55
|
|
58
|
-
it {
|
56
|
+
it { is_expected.to be_empty }
|
59
57
|
end
|
60
58
|
|
61
59
|
context 'on #prefix_length' do
|
@@ -67,7 +65,7 @@ describe MetasploitDataModels::IPAddress::V4::CIDR do
|
|
67
65
|
I18n.translate!('errors.messages.not_a_number')
|
68
66
|
}
|
69
67
|
|
70
|
-
it {
|
68
|
+
it { is_expected.to include(blank_error) }
|
71
69
|
end
|
72
70
|
end
|
73
71
|
end
|
@@ -85,7 +83,7 @@ describe MetasploitDataModels::IPAddress::V4::CIDR do
|
|
85
83
|
'48'
|
86
84
|
}
|
87
85
|
|
88
|
-
it {
|
86
|
+
it { is_expected.not_to be_valid }
|
89
87
|
|
90
88
|
context 'errors' do
|
91
89
|
before(:each) do
|
@@ -101,7 +99,7 @@ describe MetasploitDataModels::IPAddress::V4::CIDR do
|
|
101
99
|
I18n.translate!('errors.messages.invalid')
|
102
100
|
}
|
103
101
|
|
104
|
-
it {
|
102
|
+
it { is_expected.to include(invalid_error) }
|
105
103
|
end
|
106
104
|
|
107
105
|
context 'on #prefix_length' do
|
@@ -113,7 +111,7 @@ describe MetasploitDataModels::IPAddress::V4::CIDR do
|
|
113
111
|
I18n.translate!('errors.messages.less_than_or_equal_to', count: 32)
|
114
112
|
}
|
115
113
|
|
116
|
-
it {
|
114
|
+
it { is_expected.to include(too_big_error) }
|
117
115
|
end
|
118
116
|
end
|
119
117
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe MetasploitDataModels::IPAddress::V4::Nmap do
|
1
|
+
RSpec.describe MetasploitDataModels::IPAddress::V4::Nmap, type: :model do
|
4
2
|
subject(:nmap) {
|
5
3
|
described_class.new(
|
6
4
|
value: formatted_value
|
@@ -41,7 +39,7 @@ describe MetasploitDataModels::IPAddress::V4::Nmap do
|
|
41
39
|
'1.2.3.4'
|
42
40
|
}
|
43
41
|
|
44
|
-
it {
|
42
|
+
it { is_expected.to be_empty }
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
@@ -57,7 +55,7 @@ describe MetasploitDataModels::IPAddress::V4::Nmap do
|
|
57
55
|
)
|
58
56
|
}
|
59
57
|
|
60
|
-
it {
|
58
|
+
it { is_expected.to include length_error }
|
61
59
|
end
|
62
60
|
end
|
63
61
|
end
|
@@ -86,7 +84,7 @@ describe MetasploitDataModels::IPAddress::V4::Nmap do
|
|
86
84
|
nil
|
87
85
|
}
|
88
86
|
|
89
|
-
it {
|
87
|
+
it { is_expected.to be_nil }
|
90
88
|
end
|
91
89
|
|
92
90
|
context 'with matching formatted value' do
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe MetasploitDataModels::IPAddress::V4::Range do
|
1
|
+
RSpec.describe MetasploitDataModels::IPAddress::V4::Range, type: :model do
|
4
2
|
subject(:range) {
|
5
3
|
described_class.new(
|
6
4
|
value: formatted_value
|
@@ -47,7 +45,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
47
45
|
nil
|
48
46
|
}
|
49
47
|
|
50
|
-
it {
|
48
|
+
it { is_expected.to include presence_error }
|
51
49
|
end
|
52
50
|
|
53
51
|
context 'with MetasploitDataModels::IPAddress::V4::Single' do
|
@@ -56,7 +54,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
56
54
|
'1.1.1.1-256.256.256.256'
|
57
55
|
}
|
58
56
|
|
59
|
-
it {
|
57
|
+
it { is_expected.not_to include invalid_error }
|
60
58
|
end
|
61
59
|
|
62
60
|
context 'without valid' do
|
@@ -64,7 +62,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
64
62
|
'256.256.256.256-257.257.257.257'
|
65
63
|
}
|
66
64
|
|
67
|
-
it {
|
65
|
+
it { is_expected.to include invalid_error }
|
68
66
|
end
|
69
67
|
end
|
70
68
|
end
|
@@ -81,7 +79,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
81
79
|
nil
|
82
80
|
}
|
83
81
|
|
84
|
-
it {
|
82
|
+
it { is_expected.to include presence_error }
|
85
83
|
end
|
86
84
|
|
87
85
|
context 'with MetasploitDataModels::IPAddress::V4::Single' do
|
@@ -90,7 +88,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
90
88
|
'256.256.256.256-1.1.1.1'
|
91
89
|
}
|
92
90
|
|
93
|
-
it {
|
91
|
+
it { is_expected.not_to include invalid_error }
|
94
92
|
end
|
95
93
|
|
96
94
|
context 'without valid' do
|
@@ -98,7 +96,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
98
96
|
'257.257.257.257-256.256.256.256'
|
99
97
|
}
|
100
98
|
|
101
|
-
it {
|
99
|
+
it { is_expected.to include invalid_error }
|
102
100
|
end
|
103
101
|
end
|
104
102
|
end
|
@@ -122,7 +120,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
122
120
|
nil
|
123
121
|
}
|
124
122
|
|
125
|
-
it {
|
123
|
+
it { is_expected.not_to include error }
|
126
124
|
end
|
127
125
|
|
128
126
|
context 'with incomparables' do
|
@@ -130,7 +128,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
130
128
|
'a-1'
|
131
129
|
}
|
132
130
|
|
133
|
-
it {
|
131
|
+
it { is_expected.not_to include error }
|
134
132
|
end
|
135
133
|
|
136
134
|
context 'with numbers' do
|
@@ -139,7 +137,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
139
137
|
'1.1.1.1-2.2.2.2'
|
140
138
|
}
|
141
139
|
|
142
|
-
it {
|
140
|
+
it { is_expected.not_to include error }
|
143
141
|
end
|
144
142
|
|
145
143
|
context 'out of order' do
|
@@ -147,7 +145,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
147
145
|
'2.2.2.2-1.1.1.1'
|
148
146
|
}
|
149
147
|
|
150
|
-
it {
|
148
|
+
it { is_expected.to include error }
|
151
149
|
end
|
152
150
|
end
|
153
151
|
end
|
@@ -206,7 +204,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
206
204
|
'1..2'
|
207
205
|
}
|
208
206
|
|
209
|
-
it {
|
207
|
+
it { is_expected.to eq('-') }
|
210
208
|
end
|
211
209
|
end
|
212
210
|
|
@@ -221,14 +219,14 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
221
219
|
'1.1.1.1-2.2.2.2'
|
222
220
|
}
|
223
221
|
|
224
|
-
it {
|
222
|
+
it { is_expected.to be_a Range }
|
225
223
|
|
226
224
|
context 'Range#begin' do
|
227
225
|
subject(:range_begin) {
|
228
226
|
value.begin
|
229
227
|
}
|
230
228
|
|
231
|
-
it {
|
229
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Single }
|
232
230
|
|
233
231
|
it "is value before '-'" do
|
234
232
|
expect(range_begin).to eq(MetasploitDataModels::IPAddress::V4::Single.new(value: '1.1.1.1'))
|
@@ -240,7 +238,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
240
238
|
value.end
|
241
239
|
}
|
242
240
|
|
243
|
-
it {
|
241
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Single }
|
244
242
|
|
245
243
|
it "is value after '-'" do
|
246
244
|
expect(range_end).to eq(MetasploitDataModels::IPAddress::V4::Single.new(value: '2.2.2.2'))
|
@@ -253,21 +251,21 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
253
251
|
'-'
|
254
252
|
}
|
255
253
|
|
256
|
-
it {
|
254
|
+
it { is_expected.to be_a Range }
|
257
255
|
|
258
256
|
context 'Range#begin' do
|
259
257
|
subject(:range_begin) {
|
260
258
|
value.begin
|
261
259
|
}
|
262
260
|
|
263
|
-
it {
|
261
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Single }
|
264
262
|
|
265
263
|
context 'MetasploitDataModels::IPAddress::V4::Single#value' do
|
266
264
|
subject(:begin_value) {
|
267
265
|
range_begin.value
|
268
266
|
}
|
269
267
|
|
270
|
-
it {
|
268
|
+
it { is_expected.to eq('') }
|
271
269
|
end
|
272
270
|
end
|
273
271
|
|
@@ -276,14 +274,14 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
276
274
|
value.end
|
277
275
|
}
|
278
276
|
|
279
|
-
it {
|
277
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Single }
|
280
278
|
|
281
279
|
context 'MetasploitDataModels::IPAddress::V4::Single#value' do
|
282
280
|
subject(:end_value) {
|
283
281
|
range_end.value
|
284
282
|
}
|
285
283
|
|
286
|
-
it {
|
284
|
+
it { is_expected.to eq('') }
|
287
285
|
end
|
288
286
|
end
|
289
287
|
end
|
@@ -294,7 +292,7 @@ describe MetasploitDataModels::IPAddress::V4::Range do
|
|
294
292
|
'1'
|
295
293
|
end
|
296
294
|
|
297
|
-
it {
|
295
|
+
it { is_expected.not_to be_a Range }
|
298
296
|
end
|
299
297
|
end
|
300
298
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List do
|
1
|
+
RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List, type: :model do
|
4
2
|
subject(:nmap) {
|
5
3
|
described_class.new(
|
6
4
|
value: formatted_value
|
@@ -68,7 +66,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List do
|
|
68
66
|
described_class::SEPARATOR
|
69
67
|
}
|
70
68
|
|
71
|
-
it {
|
69
|
+
it { is_expected.to eq(',') }
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
@@ -91,7 +89,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List do
|
|
91
89
|
nil
|
92
90
|
}
|
93
91
|
|
94
|
-
it {
|
92
|
+
it { is_expected.to include blank_error }
|
95
93
|
end
|
96
94
|
|
97
95
|
context 'with matching String' do
|
@@ -100,7 +98,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List do
|
|
100
98
|
'1,2-3'
|
101
99
|
}
|
102
100
|
|
103
|
-
it {
|
101
|
+
it { is_expected.to be_empty }
|
104
102
|
end
|
105
103
|
|
106
104
|
context 'with invalid MetasploitDataModels::IPAddress::V4::Nmap::Range' do
|
@@ -131,7 +129,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List do
|
|
131
129
|
'non_matching_string'
|
132
130
|
}
|
133
131
|
|
134
|
-
it {
|
132
|
+
it { is_expected.to include array_error }
|
135
133
|
end
|
136
134
|
end
|
137
135
|
end
|
@@ -185,7 +183,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List do
|
|
185
183
|
value.first
|
186
184
|
}
|
187
185
|
|
188
|
-
it {
|
186
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Segment::Single }
|
189
187
|
|
190
188
|
context 'MetasploitDataModels::IPAddress::V4::Segment::Single#value' do
|
191
189
|
it 'is value from formatted_value' do
|
@@ -217,7 +215,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List do
|
|
217
215
|
value.first
|
218
216
|
}
|
219
217
|
|
220
|
-
it {
|
218
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range }
|
221
219
|
|
222
220
|
context 'MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range#value' do
|
223
221
|
subject(:element_value) {
|
@@ -229,7 +227,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List do
|
|
229
227
|
element_value.begin
|
230
228
|
}
|
231
229
|
|
232
|
-
it {
|
230
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Segment::Single }
|
233
231
|
|
234
232
|
context 'MetasploitDataModels::IPAddress::V4::Segment::Single#value' do
|
235
233
|
it 'is beginning of formatted value' do
|
@@ -243,7 +241,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::List do
|
|
243
241
|
element_value.end
|
244
242
|
}
|
245
243
|
|
246
|
-
it {
|
244
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Segment::Single }
|
247
245
|
|
248
246
|
context 'MetasploitDataModels::IPAddress::V4::Segment::Single#value' do
|
249
247
|
it 'is beginning of formatted value' do
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
1
|
+
RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range, type: :model do
|
4
2
|
subject(:range) {
|
5
3
|
described_class.new(
|
6
4
|
value: formatted_value
|
@@ -47,7 +45,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
47
45
|
nil
|
48
46
|
}
|
49
47
|
|
50
|
-
it {
|
48
|
+
it { is_expected.to include presence_error }
|
51
49
|
end
|
52
50
|
|
53
51
|
context 'with MetasploitDataModels::IPAddress::V4::Segment' do
|
@@ -56,7 +54,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
56
54
|
'1-256'
|
57
55
|
}
|
58
56
|
|
59
|
-
it {
|
57
|
+
it { is_expected.not_to include invalid_error }
|
60
58
|
end
|
61
59
|
|
62
60
|
context 'without valid' do
|
@@ -64,7 +62,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
64
62
|
'256-257'
|
65
63
|
}
|
66
64
|
|
67
|
-
it {
|
65
|
+
it { is_expected.to include invalid_error }
|
68
66
|
end
|
69
67
|
end
|
70
68
|
end
|
@@ -81,7 +79,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
81
79
|
nil
|
82
80
|
}
|
83
81
|
|
84
|
-
it {
|
82
|
+
it { is_expected.to include presence_error }
|
85
83
|
end
|
86
84
|
|
87
85
|
context 'with MetasploitDataModels::IPAddress::V4::Segment' do
|
@@ -90,7 +88,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
90
88
|
'256-1'
|
91
89
|
}
|
92
90
|
|
93
|
-
it {
|
91
|
+
it { is_expected.not_to include invalid_error }
|
94
92
|
end
|
95
93
|
|
96
94
|
context 'without valid' do
|
@@ -98,7 +96,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
98
96
|
'257-256'
|
99
97
|
}
|
100
98
|
|
101
|
-
it {
|
99
|
+
it { is_expected.to include invalid_error }
|
102
100
|
end
|
103
101
|
end
|
104
102
|
end
|
@@ -122,7 +120,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
122
120
|
nil
|
123
121
|
}
|
124
122
|
|
125
|
-
it {
|
123
|
+
it { is_expected.not_to include error }
|
126
124
|
end
|
127
125
|
|
128
126
|
context 'with incomparables' do
|
@@ -130,7 +128,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
130
128
|
'a-1'
|
131
129
|
}
|
132
130
|
|
133
|
-
it {
|
131
|
+
it { is_expected.not_to include error }
|
134
132
|
end
|
135
133
|
|
136
134
|
context 'with numbers' do
|
@@ -139,7 +137,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
139
137
|
'1-2'
|
140
138
|
}
|
141
139
|
|
142
|
-
it {
|
140
|
+
it { is_expected.not_to include error }
|
143
141
|
end
|
144
142
|
|
145
143
|
context 'out of order' do
|
@@ -147,7 +145,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
147
145
|
'2-1'
|
148
146
|
}
|
149
147
|
|
150
|
-
it {
|
148
|
+
it { is_expected.to include error }
|
151
149
|
end
|
152
150
|
end
|
153
151
|
end
|
@@ -206,7 +204,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
206
204
|
'1..2'
|
207
205
|
}
|
208
206
|
|
209
|
-
it {
|
207
|
+
it { is_expected.to eq('-') }
|
210
208
|
end
|
211
209
|
end
|
212
210
|
|
@@ -221,14 +219,14 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
221
219
|
'1-2'
|
222
220
|
}
|
223
221
|
|
224
|
-
it {
|
222
|
+
it { is_expected.to be_a Range }
|
225
223
|
|
226
224
|
context 'Range#begin' do
|
227
225
|
subject(:range_begin) {
|
228
226
|
value.begin
|
229
227
|
}
|
230
228
|
|
231
|
-
it {
|
229
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Segment::Single }
|
232
230
|
|
233
231
|
context 'MetasploitDataModels::IPAddress::V4::Segment::Single#value' do
|
234
232
|
it "is value before '-'" do
|
@@ -242,7 +240,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
242
240
|
value.end
|
243
241
|
}
|
244
242
|
|
245
|
-
it {
|
243
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Segment::Single }
|
246
244
|
|
247
245
|
context 'MetasploitDataModels::IPAddress::V4::Segment::Single#value' do
|
248
246
|
it "is value after '-'" do
|
@@ -257,21 +255,21 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
257
255
|
'-'
|
258
256
|
}
|
259
257
|
|
260
|
-
it {
|
258
|
+
it { is_expected.to be_a Range }
|
261
259
|
|
262
260
|
context 'Range#begin' do
|
263
261
|
subject(:range_begin) {
|
264
262
|
value.begin
|
265
263
|
}
|
266
264
|
|
267
|
-
it {
|
265
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Segment::Single }
|
268
266
|
|
269
267
|
context 'MetasploitDataModels::IPAddress::V4::Segment::Single#value' do
|
270
268
|
subject(:begin_value) {
|
271
269
|
range_begin.value
|
272
270
|
}
|
273
271
|
|
274
|
-
it {
|
272
|
+
it { is_expected.to eq('') }
|
275
273
|
end
|
276
274
|
end
|
277
275
|
|
@@ -280,14 +278,14 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
280
278
|
value.end
|
281
279
|
}
|
282
280
|
|
283
|
-
it {
|
281
|
+
it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Segment::Single }
|
284
282
|
|
285
283
|
context 'MetasploitDataModels::IPAddress::V4::Segment::Single#value' do
|
286
284
|
subject(:end_value) {
|
287
285
|
range_end.value
|
288
286
|
}
|
289
287
|
|
290
|
-
it {
|
288
|
+
it { is_expected.to eq('') }
|
291
289
|
end
|
292
290
|
end
|
293
291
|
end
|
@@ -298,7 +296,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range do
|
|
298
296
|
'1'
|
299
297
|
end
|
300
298
|
|
301
|
-
it {
|
299
|
+
it { is_expected.not_to be_a Range }
|
302
300
|
end
|
303
301
|
end
|
304
302
|
end
|