ruby-nmap 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +3 -2
- data/ChangeLog.md +17 -0
- data/LICENSE.txt +1 -1
- data/README.md +0 -2
- data/lib/nmap/command.rb +57 -18
- data/lib/nmap/version.rb +3 -1
- data/lib/nmap/xml/address.rb +2 -0
- data/lib/nmap/xml/cpe/url.rb +2 -0
- data/lib/nmap/xml/cpe.rb +3 -1
- data/lib/nmap/xml/hop.rb +2 -0
- data/lib/nmap/xml/host.rb +14 -12
- data/lib/nmap/xml/host_script.rb +3 -1
- data/lib/nmap/xml/hostname.rb +2 -0
- data/lib/nmap/xml/ip_id_sequence.rb +3 -1
- data/lib/nmap/xml/os.rb +5 -3
- data/lib/nmap/xml/os_class.rb +3 -1
- data/lib/nmap/xml/os_match.rb +2 -0
- data/lib/nmap/xml/port.rb +4 -2
- data/lib/nmap/xml/postscript.rb +3 -1
- data/lib/nmap/xml/prescript.rb +3 -1
- data/lib/nmap/xml/run_stat.rb +2 -0
- data/lib/nmap/xml/scan.rb +2 -0
- data/lib/nmap/xml/scan_task.rb +2 -0
- data/lib/nmap/xml/scanner.rb +2 -0
- data/lib/nmap/xml/script.rb +2 -0
- data/lib/nmap/xml/scripts.rb +3 -2
- data/lib/nmap/xml/sequence.rb +3 -1
- data/lib/nmap/xml/service.rb +3 -1
- data/lib/nmap/xml/status.rb +2 -0
- data/lib/nmap/xml/tcp_sequence.rb +4 -2
- data/lib/nmap/xml/tcp_ts_sequence.rb +3 -1
- data/lib/nmap/xml/traceroute.rb +3 -1
- data/lib/nmap/xml/uptime.rb +2 -0
- data/lib/nmap/xml.rb +9 -7
- data/lib/nmap.rb +5 -3
- data/ruby-nmap.gemspec +2 -4
- data/spec/command_spec.rb +507 -23
- metadata +9 -4
data/spec/command_spec.rb
CHANGED
@@ -43,9 +43,9 @@ describe Nmap::Command do
|
|
43
43
|
context "but it's less than 1" do
|
44
44
|
let(:value) { '0' }
|
45
45
|
|
46
|
-
it "must return [false, \"
|
46
|
+
it "must return [false, \"must be a valid port number or service name (...)\"]" do
|
47
47
|
expect(subject.validate(value)).to eq(
|
48
|
-
[false, "
|
48
|
+
[false, "must be a valid port number or service name (#{value.inspect})"]
|
49
49
|
)
|
50
50
|
end
|
51
51
|
end
|
@@ -53,9 +53,9 @@ describe Nmap::Command do
|
|
53
53
|
context "but it's greater than 65535" do
|
54
54
|
let(:value) { '65536' }
|
55
55
|
|
56
|
-
it "must return [false, \"
|
56
|
+
it "must return [false, \"must be a valid port number or service name (...)\"]" do
|
57
57
|
expect(subject.validate(value)).to eq(
|
58
|
-
[false, "
|
58
|
+
[false, "must be a valid port number or service name (#{value.inspect})"]
|
59
59
|
)
|
60
60
|
end
|
61
61
|
end
|
@@ -87,8 +87,10 @@ describe Nmap::Command do
|
|
87
87
|
context "and it starts with digits" do
|
88
88
|
let(:value) { "1ci-smcs" }
|
89
89
|
|
90
|
-
it "must return
|
91
|
-
expect(subject.validate(value)).to
|
90
|
+
it "must return [false, \"must be a valid port number or service name (...)\"]" do
|
91
|
+
expect(subject.validate(value)).to eq(
|
92
|
+
[false, "must be a valid port number or service name (#{value.inspect})"]
|
93
|
+
)
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
@@ -101,7 +103,7 @@ describe Nmap::Command do
|
|
101
103
|
end
|
102
104
|
|
103
105
|
context "and it contains a '-' character" do
|
104
|
-
let(:value) { "
|
106
|
+
let(:value) { "iphone-sync" }
|
105
107
|
|
106
108
|
it "must return true" do
|
107
109
|
expect(subject.validate(value)).to be(true)
|
@@ -111,9 +113,9 @@ describe Nmap::Command do
|
|
111
113
|
context "but it starts with a '-' character" do
|
112
114
|
let(:value) { "-foo" }
|
113
115
|
|
114
|
-
it "must return [false, \"must be a port number or service name (...)\"]" do
|
116
|
+
it "must return [false, \"must be a valid port number or service name (...)\"]" do
|
115
117
|
expect(subject.validate(value)).to eq(
|
116
|
-
[false, "must be a port number or service name (#{value.inspect})"]
|
118
|
+
[false, "must be a valid port number or service name (#{value.inspect})"]
|
117
119
|
)
|
118
120
|
end
|
119
121
|
end
|
@@ -121,9 +123,9 @@ describe Nmap::Command do
|
|
121
123
|
context "but it ends with a '-' character" do
|
122
124
|
let(:value) { "foo-" }
|
123
125
|
|
124
|
-
it "must return [false, \"must be a port number or service name (...)\"]" do
|
126
|
+
it "must return [false, \"must be a valid port number or service name (...)\"]" do
|
125
127
|
expect(subject.validate(value)).to eq(
|
126
|
-
[false, "must be a port number or service name (#{value.inspect})"]
|
128
|
+
[false, "must be a valid port number or service name (#{value.inspect})"]
|
127
129
|
)
|
128
130
|
end
|
129
131
|
end
|
@@ -139,9 +141,9 @@ describe Nmap::Command do
|
|
139
141
|
context "but it starts with a '_' character" do
|
140
142
|
let(:value) { "_foo" }
|
141
143
|
|
142
|
-
it "must return [false, \"must be a port number or service name (...)\"]" do
|
144
|
+
it "must return [false, \"must be a valid port number or service name (...)\"]" do
|
143
145
|
expect(subject.validate(value)).to eq(
|
144
|
-
[false, "must be a port number or service name (#{value.inspect})"]
|
146
|
+
[false, "must be a valid port number or service name (#{value.inspect})"]
|
145
147
|
)
|
146
148
|
end
|
147
149
|
end
|
@@ -149,9 +151,9 @@ describe Nmap::Command do
|
|
149
151
|
context "but it ends with a '_' character" do
|
150
152
|
let(:value) { "foo_" }
|
151
153
|
|
152
|
-
it "must return [false, \"must be a port number or service name (...)\"]" do
|
154
|
+
it "must return [false, \"must be a valid port number or service name (...)\"]" do
|
153
155
|
expect(subject.validate(value)).to eq(
|
154
|
-
[false, "must be a port number or service name (#{value.inspect})"]
|
156
|
+
[false, "must be a valid port number or service name (#{value.inspect})"]
|
155
157
|
)
|
156
158
|
end
|
157
159
|
end
|
@@ -167,19 +169,19 @@ describe Nmap::Command do
|
|
167
169
|
context "but it starts with a '/' character" do
|
168
170
|
let(:value) { "/foo" }
|
169
171
|
|
170
|
-
it "must return [false, \"must be a port number or service name (...)\"]" do
|
172
|
+
it "must return [false, \"must be a valid port number or service name (...)\"]" do
|
171
173
|
expect(subject.validate(value)).to eq(
|
172
|
-
[false, "must be a port number or service name (#{value.inspect})"]
|
174
|
+
[false, "must be a valid port number or service name (#{value.inspect})"]
|
173
175
|
)
|
174
176
|
end
|
175
177
|
end
|
176
178
|
|
177
|
-
context "but it
|
179
|
+
context "but it ends with a '/' character" do
|
178
180
|
let(:value) { "foo/" }
|
179
181
|
|
180
|
-
it "must return [false, \"must be a port number or service name (...)\"]" do
|
182
|
+
it "must return [false, \"must be a valid port number or service name (...)\"]" do
|
181
183
|
expect(subject.validate(value)).to eq(
|
182
|
-
[false, "must be a port number or service name (#{value.inspect})"]
|
184
|
+
[false, "must be a valid port number or service name (#{value.inspect})"]
|
183
185
|
)
|
184
186
|
end
|
185
187
|
end
|
@@ -191,9 +193,211 @@ describe Nmap::Command do
|
|
191
193
|
describe described_class::PortRange do
|
192
194
|
describe "#validate" do
|
193
195
|
context "when given an Integer value" do
|
196
|
+
let(:value) { 443 }
|
197
|
+
|
198
|
+
it "must return true" do
|
199
|
+
expect(subject.validate(value)).to be(true)
|
200
|
+
end
|
201
|
+
|
202
|
+
context "but it's less than 1" do
|
203
|
+
let(:value) { 0 }
|
204
|
+
|
205
|
+
it "must return [false, \"(...) not within the range of acceptable values (1..65535)\"]" do
|
206
|
+
expect(subject.validate(value)).to eq(
|
207
|
+
[false, "(#{value.inspect}) not within the range of acceptable values (1..65535)"]
|
208
|
+
)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context "but it's greater than 65535" do
|
213
|
+
let(:value) { 65536 }
|
214
|
+
|
215
|
+
it "must return [false, \"(...) not within the range of acceptable values (1..65535)\"]" do
|
216
|
+
expect(subject.validate(value)).to eq(
|
217
|
+
[false, "(#{value.inspect}) not within the range of acceptable values (1..65535)"]
|
218
|
+
)
|
219
|
+
end
|
220
|
+
end
|
194
221
|
end
|
195
222
|
|
196
223
|
context "when given a String value" do
|
224
|
+
context "and it's a number" do
|
225
|
+
let(:value) { '443' }
|
226
|
+
|
227
|
+
it "must return true" do
|
228
|
+
expect(subject.validate(value)).to be(true)
|
229
|
+
end
|
230
|
+
|
231
|
+
context "but it's less than 1" do
|
232
|
+
let(:value) { '0' }
|
233
|
+
|
234
|
+
it "must return [false, \"must be a valid port number, port range, or service name (...)\"]" do
|
235
|
+
expect(subject.validate(value)).to eq(
|
236
|
+
[false, "must be a valid port number, port range, or service name (#{value.inspect})"]
|
237
|
+
)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
context "but it's greater than 65535" do
|
242
|
+
let(:value) { '65536' }
|
243
|
+
|
244
|
+
it "must return [false, \"(...) not within the range of acceptable values (1..65535)\"]" do
|
245
|
+
expect(subject.validate(value)).to eq(
|
246
|
+
[false, "must be a valid port number, port range, or service name (#{value.inspect})"]
|
247
|
+
)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
context "and it's a range of two numbers" do
|
253
|
+
let(:value) { "1-1024" }
|
254
|
+
|
255
|
+
it "must return true" do
|
256
|
+
expect(subject.validate(value)).to be(true)
|
257
|
+
end
|
258
|
+
|
259
|
+
context "but the first number is omitted" do
|
260
|
+
let(:value) { "-1024" }
|
261
|
+
|
262
|
+
it "must return true" do
|
263
|
+
expect(subject.validate(value)).to be(true)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
context "but the last number is omitted" do
|
268
|
+
let(:value) { "1-" }
|
269
|
+
|
270
|
+
it "must return true" do
|
271
|
+
expect(subject.validate(value)).to be(true)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
context "and it's a service name" do
|
277
|
+
let(:value) { "http" }
|
278
|
+
|
279
|
+
it "must return true" do
|
280
|
+
expect(subject.validate(value)).to be(true)
|
281
|
+
end
|
282
|
+
|
283
|
+
context "and it ends with a '*' character" do
|
284
|
+
let(:value) { "http*" }
|
285
|
+
|
286
|
+
it "must return true" do
|
287
|
+
expect(subject.validate(value)).to be(true)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
context "and it contains uppercase letters" do
|
292
|
+
let(:value) { "XmlIpcRegSvc" }
|
293
|
+
|
294
|
+
it "must return true" do
|
295
|
+
expect(subject.validate(value)).to be(true)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
context "and it starts with digits" do
|
300
|
+
let(:value) { "1ci-smcs" }
|
301
|
+
|
302
|
+
it "must return [false, \"must be a valid port number, port range, or service name (...)\"]" do
|
303
|
+
expect(subject.validate(value)).to eq(
|
304
|
+
[false, "must be a valid port number, port range, or service name (#{value.inspect})"]
|
305
|
+
)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
context "and it contains digits" do
|
310
|
+
let(:value) { "neo4j" }
|
311
|
+
|
312
|
+
it "must return true" do
|
313
|
+
expect(subject.validate(value)).to be(true)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
context "and it contains a '-' character" do
|
318
|
+
let(:value) { "iphone-sync" }
|
319
|
+
|
320
|
+
it "must return true" do
|
321
|
+
expect(subject.validate(value)).to be(true)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
context "but it starts with a '-' character" do
|
326
|
+
let(:value) { "-foo" }
|
327
|
+
|
328
|
+
it "must return [false, \"must be a valid port number, port range, or service name (...)\"]" do
|
329
|
+
expect(subject.validate(value)).to eq(
|
330
|
+
[false, "must be a valid port number, port range, or service name (#{value.inspect})"]
|
331
|
+
)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
context "but it ends with a '-' character" do
|
336
|
+
let(:value) { "foo-" }
|
337
|
+
|
338
|
+
it "must return [false, \"must be a valid port number, port range, or service name (...)\"]" do
|
339
|
+
expect(subject.validate(value)).to eq(
|
340
|
+
[false, "must be a valid port number, port range, or service name (#{value.inspect})"]
|
341
|
+
)
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
context "and it contains a '_' character" do
|
346
|
+
let(:value) { "kerberos_master" }
|
347
|
+
|
348
|
+
it "must return true" do
|
349
|
+
expect(subject.validate(value)).to be(true)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
context "but it starts with a '_' character" do
|
354
|
+
let(:value) { "_foo" }
|
355
|
+
|
356
|
+
it "must return [false, \"must be a valid port number, port range, or service name (...)\"]" do
|
357
|
+
expect(subject.validate(value)).to eq(
|
358
|
+
[false, "must be a valid port number, port range, or service name (#{value.inspect})"]
|
359
|
+
)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
context "but it ends with a '_' character" do
|
364
|
+
let(:value) { "foo_" }
|
365
|
+
|
366
|
+
it "must return [false, \"must be a valid port number, port range, or service name (...)\"]" do
|
367
|
+
expect(subject.validate(value)).to eq(
|
368
|
+
[false, "must be a valid port number, port range, or service name (#{value.inspect})"]
|
369
|
+
)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
context "and it contain's a '/' character" do
|
374
|
+
let(:value) { "cl/1" }
|
375
|
+
|
376
|
+
it "must return true" do
|
377
|
+
expect(subject.validate(value)).to be(true)
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
context "but it starts with a '/' character" do
|
382
|
+
let(:value) { "/foo" }
|
383
|
+
|
384
|
+
it "must return [false, \"must be a valid port number, port range, or service name (...)\"]" do
|
385
|
+
expect(subject.validate(value)).to eq(
|
386
|
+
[false, "must be a valid port number, port range, or service name (#{value.inspect})"]
|
387
|
+
)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
context "but it starts with a '/' character" do
|
392
|
+
let(:value) { "foo/" }
|
393
|
+
|
394
|
+
it "must return [false, \"must be a valid port number, port range, or service name (...)\"]" do
|
395
|
+
expect(subject.validate(value)).to eq(
|
396
|
+
[false, "must be a valid port number, port range, or service name (#{value.inspect})"]
|
397
|
+
)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
197
401
|
end
|
198
402
|
|
199
403
|
context "when given a Range of port numbers" do
|
@@ -226,12 +430,292 @@ describe Nmap::Command do
|
|
226
430
|
|
227
431
|
describe described_class::PortRangeList do
|
228
432
|
describe "#validate" do
|
229
|
-
context "when given
|
433
|
+
context "when given an Integer value" do
|
230
434
|
let(:value) { 443 }
|
231
435
|
|
232
436
|
it "must return true" do
|
233
437
|
expect(subject.validate(value)).to be(true)
|
234
438
|
end
|
439
|
+
|
440
|
+
context "but it's less than 1" do
|
441
|
+
let(:value) { 0 }
|
442
|
+
|
443
|
+
it "must return [false, \"element (...) not within the range of acceptable values (1..65535)\"]" do
|
444
|
+
expect(subject.validate(value)).to eq(
|
445
|
+
[false, "element (#{value.inspect}) not within the range of acceptable values (1..65535)"]
|
446
|
+
)
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
context "but it's greater than 65535" do
|
451
|
+
let(:value) { 65536 }
|
452
|
+
|
453
|
+
it "must return [false, \"element (...) not within the range of acceptable values (1..65535)\"]" do
|
454
|
+
expect(subject.validate(value)).to eq(
|
455
|
+
[false, "element (#{value.inspect}) not within the range of acceptable values (1..65535)"]
|
456
|
+
)
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
context "when given a String value" do
|
462
|
+
context "and it's a number" do
|
463
|
+
let(:value) { '443' }
|
464
|
+
|
465
|
+
it "must return true" do
|
466
|
+
expect(subject.validate(value)).to be(true)
|
467
|
+
end
|
468
|
+
|
469
|
+
context "but it's less than 1" do
|
470
|
+
let(:value) { '0' }
|
471
|
+
|
472
|
+
it "must return [false, \"not a valid port range list (...)\"]" do
|
473
|
+
expect(subject.validate(value)).to eq(
|
474
|
+
[false, "not a valid port range list (#{value.inspect})"]
|
475
|
+
)
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
context "but it's greater than 65535" do
|
480
|
+
let(:value) { '65536' }
|
481
|
+
|
482
|
+
it "must return [false, \"(...) not within the range of acceptable values (1..65535)\"]" do
|
483
|
+
expect(subject.validate(value)).to eq(
|
484
|
+
[false, "not a valid port range list (#{value.inspect})"]
|
485
|
+
)
|
486
|
+
end
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
context "and it's a range of two numbers" do
|
491
|
+
let(:value) { "1-1024" }
|
492
|
+
|
493
|
+
it "must return true" do
|
494
|
+
expect(subject.validate(value)).to be(true)
|
495
|
+
end
|
496
|
+
|
497
|
+
context "but the first number is omitted" do
|
498
|
+
let(:value) { "-1024" }
|
499
|
+
|
500
|
+
it "must return true" do
|
501
|
+
expect(subject.validate(value)).to be(true)
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
context "but the last number is omitted" do
|
506
|
+
let(:value) { "1-" }
|
507
|
+
|
508
|
+
it "must return true" do
|
509
|
+
expect(subject.validate(value)).to be(true)
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
514
|
+
context "and it's a service name" do
|
515
|
+
let(:value) { "http" }
|
516
|
+
|
517
|
+
it "must return true" do
|
518
|
+
expect(subject.validate(value)).to be(true)
|
519
|
+
end
|
520
|
+
|
521
|
+
context "and it ends with a '*' character" do
|
522
|
+
let(:value) { "http*" }
|
523
|
+
|
524
|
+
it "must return true" do
|
525
|
+
expect(subject.validate(value)).to be(true)
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
context "and it contains uppercase letters" do
|
530
|
+
let(:value) { "XmlIpcRegSvc" }
|
531
|
+
|
532
|
+
it "must return true" do
|
533
|
+
expect(subject.validate(value)).to be(true)
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
537
|
+
context "and it starts with digits" do
|
538
|
+
let(:value) { "1ci-smcs" }
|
539
|
+
|
540
|
+
it "must return [false, \"not a valid port range list (...)\"]" do
|
541
|
+
expect(subject.validate(value)).to eq(
|
542
|
+
[false, "not a valid port range list (#{value.inspect})"]
|
543
|
+
)
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
547
|
+
context "and it contains digits" do
|
548
|
+
let(:value) { "neo4j" }
|
549
|
+
|
550
|
+
it "must return true" do
|
551
|
+
expect(subject.validate(value)).to be(true)
|
552
|
+
end
|
553
|
+
end
|
554
|
+
|
555
|
+
context "and it contains a '-' character" do
|
556
|
+
let(:value) { "iphone-sync" }
|
557
|
+
|
558
|
+
it "must return true" do
|
559
|
+
expect(subject.validate(value)).to be(true)
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
context "but it starts with a '-' character" do
|
564
|
+
let(:value) { "-foo" }
|
565
|
+
|
566
|
+
it "must return [false, \"not a valid port range list (...)\"]" do
|
567
|
+
expect(subject.validate(value)).to eq(
|
568
|
+
[false, "not a valid port range list (#{value.inspect})"]
|
569
|
+
)
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
context "but it ends with a '-' character" do
|
574
|
+
let(:value) { "foo-" }
|
575
|
+
|
576
|
+
it "must return [false, \"not a valid port range list (...)\"]" do
|
577
|
+
expect(subject.validate(value)).to eq(
|
578
|
+
[false, "not a valid port range list (#{value.inspect})"]
|
579
|
+
)
|
580
|
+
end
|
581
|
+
end
|
582
|
+
|
583
|
+
context "and it contains a '_' character" do
|
584
|
+
let(:value) { "kerberos_master" }
|
585
|
+
|
586
|
+
it "must return true" do
|
587
|
+
expect(subject.validate(value)).to be(true)
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
context "but it starts with a '_' character" do
|
592
|
+
let(:value) { "_foo" }
|
593
|
+
|
594
|
+
it "must return [false, \"not a valid port range list (...)\"]" do
|
595
|
+
expect(subject.validate(value)).to eq(
|
596
|
+
[false, "not a valid port range list (#{value.inspect})"]
|
597
|
+
)
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
601
|
+
context "but it ends with a '_' character" do
|
602
|
+
let(:value) { "foo_" }
|
603
|
+
|
604
|
+
it "must return [false, \"not a valid port range list (...)\"]" do
|
605
|
+
expect(subject.validate(value)).to eq(
|
606
|
+
[false, "not a valid port range list (#{value.inspect})"]
|
607
|
+
)
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
611
|
+
context "and it contain's a '/' character" do
|
612
|
+
let(:value) { "cl/1" }
|
613
|
+
|
614
|
+
it "must return true" do
|
615
|
+
expect(subject.validate(value)).to be(true)
|
616
|
+
end
|
617
|
+
end
|
618
|
+
|
619
|
+
context "but it starts with a '/' character" do
|
620
|
+
let(:value) { "/foo" }
|
621
|
+
|
622
|
+
it "must return [false, \"not a valid port range list (...)\"]" do
|
623
|
+
expect(subject.validate(value)).to eq(
|
624
|
+
[false, "not a valid port range list (#{value.inspect})"]
|
625
|
+
)
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
context "but it starts with a '/' character" do
|
630
|
+
let(:value) { "foo/" }
|
631
|
+
|
632
|
+
it "must return [false, \"not a valid port range list (...)\"]" do
|
633
|
+
expect(subject.validate(value)).to eq(
|
634
|
+
[false, "not a valid port range list (#{value.inspect})"]
|
635
|
+
)
|
636
|
+
end
|
637
|
+
end
|
638
|
+
end
|
639
|
+
|
640
|
+
context "and it's a comma separated list of port numbers" do
|
641
|
+
let(:value) { "1,22,80,443" }
|
642
|
+
|
643
|
+
it "must return true" do
|
644
|
+
expect(subject.validate(value)).to be(true)
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
648
|
+
context "and it's a comma separated list of port ranges" do
|
649
|
+
let(:value) { "1-22,8000-9000" }
|
650
|
+
|
651
|
+
it "must return true" do
|
652
|
+
expect(subject.validate(value)).to be(true)
|
653
|
+
end
|
654
|
+
end
|
655
|
+
|
656
|
+
context "and it's a comma separated list of port numbers and ranges" do
|
657
|
+
let(:value) { "1-22,80,443,8000-9000" }
|
658
|
+
|
659
|
+
it "must return true" do
|
660
|
+
expect(subject.validate(value)).to be(true)
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
context "and it's a range of two numbers, with a protocol prefix" do
|
665
|
+
let(:value) { "T:1-1024" }
|
666
|
+
|
667
|
+
it "must return true" do
|
668
|
+
expect(subject.validate(value)).to be(true)
|
669
|
+
end
|
670
|
+
|
671
|
+
context "but the first number is omitted" do
|
672
|
+
let(:value) { "T:-1024" }
|
673
|
+
|
674
|
+
it "must return true" do
|
675
|
+
expect(subject.validate(value)).to be(true)
|
676
|
+
end
|
677
|
+
end
|
678
|
+
|
679
|
+
context "but the last number is omitted" do
|
680
|
+
let(:value) { "T:1-" }
|
681
|
+
|
682
|
+
it "must return true" do
|
683
|
+
expect(subject.validate(value)).to be(true)
|
684
|
+
end
|
685
|
+
end
|
686
|
+
end
|
687
|
+
|
688
|
+
context "and it's a service name, with a protocol prefix" do
|
689
|
+
let(:value) { "T:http" }
|
690
|
+
|
691
|
+
it "must return true" do
|
692
|
+
expect(subject.validate(value)).to be(true)
|
693
|
+
end
|
694
|
+
end
|
695
|
+
|
696
|
+
context "and it's a comma separated list of port numbers, with protocol prefixes" do
|
697
|
+
let(:value) { "T:1,T:22,T:80,T:443,U:9000" }
|
698
|
+
|
699
|
+
it "must return true" do
|
700
|
+
expect(subject.validate(value)).to be(true)
|
701
|
+
end
|
702
|
+
end
|
703
|
+
|
704
|
+
context "and it's a comma separated list of port ranges, with protocol prefixes" do
|
705
|
+
let(:value) { "T:1-22,U:8000-9000" }
|
706
|
+
|
707
|
+
it "must return true" do
|
708
|
+
expect(subject.validate(value)).to be(true)
|
709
|
+
end
|
710
|
+
end
|
711
|
+
|
712
|
+
context "and it's a comma separated list of port numbers and ranges, with protocol prefixes" do
|
713
|
+
let(:value) { "T:1-22,T:80,T:443,U:8000-9000" }
|
714
|
+
|
715
|
+
it "must return true" do
|
716
|
+
expect(subject.validate(value)).to be(true)
|
717
|
+
end
|
718
|
+
end
|
235
719
|
end
|
236
720
|
|
237
721
|
context "when given a Range of port numbers" do
|
@@ -319,9 +803,9 @@ describe Nmap::Command do
|
|
319
803
|
{tcp: [1,2,3,4], udp: [1, bad_port, 3], sctp: [1,2,3,4]}
|
320
804
|
end
|
321
805
|
|
322
|
-
it "must return [false, \"element
|
806
|
+
it "must return [false, \"element element must be a valid port number, port range, or service name (...)\"]" do
|
323
807
|
expect(subject.validate(value)).to eq(
|
324
|
-
[false, "element
|
808
|
+
[false, "element must be a valid port number, port range, or service name (#{bad_port.inspect})"]
|
325
809
|
)
|
326
810
|
end
|
327
811
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-nmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -145,7 +145,12 @@ files:
|
|
145
145
|
homepage: https://github.com/postmodern/ruby-nmap#readme
|
146
146
|
licenses:
|
147
147
|
- MIT
|
148
|
-
metadata:
|
148
|
+
metadata:
|
149
|
+
documentation_uri: https://rubydoc.info/gems/ruby-nmap
|
150
|
+
source_code_uri: https://github.com/postmodern/ruby-nmap
|
151
|
+
bug_tracker_uri: https://github.com/postmodern/ruby-nmap/issues
|
152
|
+
changelog_uri: https://github.com/postmodern/ruby-nmap/blob/master/ChangeLog.md
|
153
|
+
rubygems_mfa_required: 'true'
|
149
154
|
post_install_message:
|
150
155
|
rdoc_options: []
|
151
156
|
require_paths:
|
@@ -162,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
167
|
version: '0'
|
163
168
|
requirements:
|
164
169
|
- nmap >= 5.00
|
165
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.4.10
|
166
171
|
signing_key:
|
167
172
|
specification_version: 4
|
168
173
|
summary: A Ruby API to nmap.
|