forked from ronin-rb/ronin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpattern_options_spec.rb
711 lines (618 loc) · 30.8 KB
/
pattern_options_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
require 'spec_helper'
require 'ronin/cli/pattern_options'
require 'ronin/cli/command'
describe Ronin::CLI::PatternOptions do
module TestPatternOptions
class TestCommand < Ronin::CLI::Command
include Ronin::CLI::PatternOptions
end
end
let(:command_class) { TestPatternOptions::TestCommand }
subject { command_class.new }
describe ".included" do
subject { command_class }
#
# Numeric pattern options
#
it "must define a '-N,--number' option" do
expect(subject.options[:number]).to_not be(nil)
expect(subject.options[:number].short).to eq('-N')
expect(subject.options[:number].value).to be(nil)
expect(subject.options[:number].desc).to eq('Searches for all numbers')
end
it "must define a '-X,--hex-number' option" do
expect(subject.options[:hex_number]).to_not be(nil)
expect(subject.options[:hex_number].short).to eq('-X')
expect(subject.options[:hex_number].value).to be(nil)
expect(subject.options[:hex_number].desc).to eq('Searches for all hexadecimal numbers')
end
it "must define a '-V,--version-number' option" do
expect(subject.options[:version_number]).to_not be(nil)
expect(subject.options[:version_number].short).to eq('-V')
expect(subject.options[:version_number].value).to be(nil)
expect(subject.options[:version_number].desc).to eq('Searches for all version numbers')
end
it "must define a '--alpha' option" do
expect(subject.options[:alpha]).to_not be(nil)
expect(subject.options[:alpha].short).to be(nil)
expect(subject.options[:alpha].value).to be(nil)
expect(subject.options[:alpha].desc).to eq('Searches for all alphabetic characters')
end
it "must define a '--uppercase' option" do
expect(subject.options[:uppercase]).to_not be(nil)
expect(subject.options[:uppercase].short).to be(nil)
expect(subject.options[:uppercase].value).to be(nil)
expect(subject.options[:uppercase].desc).to eq('Searches for all uppercase alphabetic characters')
end
it "must define a '--lowercase' option" do
expect(subject.options[:lowercase]).to_not be(nil)
expect(subject.options[:lowercase].short).to be(nil)
expect(subject.options[:lowercase].value).to be(nil)
expect(subject.options[:lowercase].desc).to eq('Searches for all lowercase alphabetic characters')
end
it "must define a '--alpha-numeric' option" do
expect(subject.options[:alpha_numeric]).to_not be(nil)
expect(subject.options[:alpha_numeric].short).to be(nil)
expect(subject.options[:alpha_numeric].value).to be(nil)
expect(subject.options[:alpha_numeric].desc).to eq('Searches for all alphanumeric characters')
end
it "must define a '--hex' option" do
expect(subject.options[:hex]).to_not be(nil)
expect(subject.options[:hex].short).to be(nil)
expect(subject.options[:hex].value).to be(nil)
expect(subject.options[:hex].desc).to eq('Searches for all hexadecimal characters')
end
it "must define a '--uppercase-hex' option" do
expect(subject.options[:uppercase_hex]).to_not be(nil)
expect(subject.options[:uppercase_hex].short).to be(nil)
expect(subject.options[:uppercase_hex].value).to be(nil)
expect(subject.options[:uppercase_hex].desc).to eq('Searches for all uppercase hexadecimal characters')
end
it "must define a '--lowercase-hex' option" do
expect(subject.options[:lowercase_hex]).to_not be(nil)
expect(subject.options[:lowercase_hex].short).to be(nil)
expect(subject.options[:lowercase_hex].value).to be(nil)
expect(subject.options[:lowercase_hex].desc).to eq('Searches for all lowercase hexadecimal characters')
end
#
# Language pattern options
#
it "must define a '-w,--word' option" do
expect(subject.options[:word]).to_not be(nil)
expect(subject.options[:word].short).to eq('-w')
expect(subject.options[:word].value).to be(nil)
expect(subject.options[:word].desc).to eq('Searches for all words')
end
#
# Network pattern options
#
it "must define a '--mac-addr' option" do
expect(subject.options[:mac_addr]).to_not be(nil)
expect(subject.options[:mac_addr].short).to be(nil)
expect(subject.options[:mac_addr].value).to be(nil)
expect(subject.options[:mac_addr].desc).to eq('Searches for all MAC addresses')
end
it "must define a '-4,--ipv4-addr' option" do
expect(subject.options[:ipv4_addr]).to_not be(nil)
expect(subject.options[:ipv4_addr].short).to eq('-4')
expect(subject.options[:ipv4_addr].value).to be(nil)
expect(subject.options[:ipv4_addr].desc).to eq('Searches for all IPv4 addresses')
end
it "must define a '-6,--ipv6-addr' option" do
expect(subject.options[:ipv6_addr]).to_not be(nil)
expect(subject.options[:ipv6_addr].short).to eq('-6')
expect(subject.options[:ipv6_addr].value).to be(nil)
expect(subject.options[:ipv6_addr].desc).to eq('Searches for all IPv6 addresses')
end
it "must define a '-I,--ip' option" do
expect(subject.options[:ip]).to_not be(nil)
expect(subject.options[:ip].short).to eq('-I')
expect(subject.options[:ip].value).to be(nil)
expect(subject.options[:ip].desc).to eq('Searches for all IP addresses')
end
it "must define a '-H,--host' option" do
expect(subject.options[:host]).to_not be(nil)
expect(subject.options[:host].short).to eq('-H')
expect(subject.options[:host].value).to be(nil)
expect(subject.options[:host].desc).to eq('Searches for all host names')
end
it "must define a '-D,--domain' option" do
expect(subject.options[:domain]).to_not be(nil)
expect(subject.options[:domain].short).to eq('-D')
expect(subject.options[:domain].value).to be(nil)
expect(subject.options[:domain].desc).to eq('Searches for all domain names')
end
it "must define a '--uri' option" do
expect(subject.options[:uri]).to_not be(nil)
expect(subject.options[:uri].short).to be(nil)
expect(subject.options[:uri].value).to be(nil)
expect(subject.options[:uri].desc).to eq('Searches for all URIs')
end
it "must define a '-U,--url' option" do
expect(subject.options[:url]).to_not be(nil)
expect(subject.options[:url].short).to eq('-U')
expect(subject.options[:url].value).to be(nil)
expect(subject.options[:url].desc).to eq('Searches for all URLs')
end
#
# PII pattern options
#
it "must define a '--user-name' option" do
expect(subject.options[:user_name]).to_not be(nil)
expect(subject.options[:user_name].short).to be(nil)
expect(subject.options[:user_name].value).to be(nil)
expect(subject.options[:user_name].desc).to eq('Searches for all user names')
end
it "must define a '-E,--email-addr' option" do
expect(subject.options[:email_addr]).to_not be(nil)
expect(subject.options[:email_addr].short).to eq('-E')
expect(subject.options[:email_addr].value).to be(nil)
expect(subject.options[:email_addr].desc).to eq('Searches for all email addresses')
end
it "must define a '--obfuscated-email-addr' option" do
expect(subject.options[:obfuscated_email_addr]).to_not be(nil)
expect(subject.options[:obfuscated_email_addr].short).to be(nil)
expect(subject.options[:obfuscated_email_addr].value).to be(nil)
expect(subject.options[:obfuscated_email_addr].desc).to eq('Searches for all obfuscated email addresses')
end
it "must define a '--phone-number' option" do
expect(subject.options[:phone_number]).to_not be(nil)
expect(subject.options[:phone_number].short).to be(nil)
expect(subject.options[:phone_number].value).to be(nil)
expect(subject.options[:phone_number].desc).to eq('Searches for all phone numbers')
end
it "must define a '--ssn' option" do
expect(subject.options[:ssn]).to_not be(nil)
expect(subject.options[:ssn].short).to be(nil)
expect(subject.options[:ssn].value).to be(nil)
expect(subject.options[:ssn].desc).to eq('Searches for all Social Security Numbers (SSNs)')
end
it "must define a '--amex-cc' option" do
expect(subject.options[:amex_cc]).to_not be(nil)
expect(subject.options[:amex_cc].short).to be(nil)
expect(subject.options[:amex_cc].value).to be(nil)
expect(subject.options[:amex_cc].desc).to eq('Searches for all AMEX Credit Card numbers')
end
it "must define a '--discover-cc' option" do
expect(subject.options[:discover_cc]).to_not be(nil)
expect(subject.options[:discover_cc].short).to be(nil)
expect(subject.options[:discover_cc].value).to be(nil)
expect(subject.options[:discover_cc].desc).to eq('Searches for all Discover Card numbers')
end
it "must define a '--mastercard-cc' option" do
expect(subject.options[:mastercard_cc]).to_not be(nil)
expect(subject.options[:mastercard_cc].short).to be(nil)
expect(subject.options[:mastercard_cc].value).to be(nil)
expect(subject.options[:mastercard_cc].desc).to eq('Searches for all MasterCard numbers')
end
it "must define a '--visa-cc' option" do
expect(subject.options[:visa_cc]).to_not be(nil)
expect(subject.options[:visa_cc].short).to be(nil)
expect(subject.options[:visa_cc].value).to be(nil)
expect(subject.options[:visa_cc].desc).to eq('Searches for all VISA Credit Card numbers')
end
it "must define a '--visa-mastercard-cc' option" do
expect(subject.options[:visa_mastercard_cc]).to_not be(nil)
expect(subject.options[:visa_mastercard_cc].short).to be(nil)
expect(subject.options[:visa_mastercard_cc].value).to be(nil)
expect(subject.options[:visa_mastercard_cc].desc).to eq('Searches for all VISA MasterCard numbers')
end
it "must define a '--cc' option" do
expect(subject.options[:cc]).to_not be(nil)
expect(subject.options[:cc].short).to be(nil)
expect(subject.options[:cc].value).to be(nil)
expect(subject.options[:cc].desc).to eq('Searches for all Credit Card numbers')
end
#
# File System pattern options
#
it "must define a '--file-name' option" do
expect(subject.options[:file_name]).to_not be(nil)
expect(subject.options[:file_name].short).to be(nil)
expect(subject.options[:file_name].value).to be(nil)
expect(subject.options[:file_name].desc).to eq('Searches for all file names')
end
it "must define a '--dir-name' option" do
expect(subject.options[:dir_name]).to_not be(nil)
expect(subject.options[:dir_name].short).to be(nil)
expect(subject.options[:dir_name].value).to be(nil)
expect(subject.options[:dir_name].desc).to eq('Searches for all directory names')
end
it "must define a '--relative-unix-path' option" do
expect(subject.options[:relative_unix_path]).to_not be(nil)
expect(subject.options[:relative_unix_path].short).to be(nil)
expect(subject.options[:relative_unix_path].value).to be(nil)
expect(subject.options[:relative_unix_path].desc).to eq('Searches for all relative UNIX paths')
end
it "must define a '--absolute-unix-path' option" do
expect(subject.options[:absolute_unix_path]).to_not be(nil)
expect(subject.options[:absolute_unix_path].short).to be(nil)
expect(subject.options[:absolute_unix_path].value).to be(nil)
expect(subject.options[:absolute_unix_path].desc).to eq('Searches for all absolute UNIX paths')
end
it "must define a '--unix-path' option" do
expect(subject.options[:unix_path]).to_not be(nil)
expect(subject.options[:unix_path].short).to be(nil)
expect(subject.options[:unix_path].value).to be(nil)
expect(subject.options[:unix_path].desc).to eq('Searches for all UNIX paths')
end
it "must define a '--relative-windows-path' option" do
expect(subject.options[:relative_windows_path]).to_not be(nil)
expect(subject.options[:relative_windows_path].short).to be(nil)
expect(subject.options[:relative_windows_path].value).to be(nil)
expect(subject.options[:relative_windows_path].desc).to eq('Searches for all relative Windows paths')
end
it "must define a '--absolute-windows-path' option" do
expect(subject.options[:absolute_windows_path]).to_not be(nil)
expect(subject.options[:absolute_windows_path].short).to be(nil)
expect(subject.options[:absolute_windows_path].value).to be(nil)
expect(subject.options[:absolute_windows_path].desc).to eq('Searches for all absolute Windows paths')
end
it "must define a '--windows-path' option" do
expect(subject.options[:windows_path]).to_not be(nil)
expect(subject.options[:windows_path].short).to be(nil)
expect(subject.options[:windows_path].value).to be(nil)
expect(subject.options[:windows_path].desc).to eq('Searches for all Windows paths')
end
it "must define a '--relative-path' option" do
expect(subject.options[:relative_path]).to_not be(nil)
expect(subject.options[:relative_path].short).to be(nil)
expect(subject.options[:relative_path].value).to be(nil)
expect(subject.options[:relative_path].desc).to eq('Searches for all relative paths')
end
it "must define a '--absolute-path' option" do
expect(subject.options[:absolute_path]).to_not be(nil)
expect(subject.options[:absolute_path].short).to be(nil)
expect(subject.options[:absolute_path].value).to be(nil)
expect(subject.options[:absolute_path].desc).to eq('Searches for all absolute paths')
end
it "must define a '--path' option" do
expect(subject.options[:path]).to_not be(nil)
expect(subject.options[:path].short).to eq('-P')
expect(subject.options[:path].value).to be(nil)
expect(subject.options[:path].desc).to eq('Searches for all paths')
end
#
# Source Code pattern options
#
it "must define a '--identifier' option" do
expect(subject.options[:identifier]).to_not be(nil)
expect(subject.options[:identifier].short).to be(nil)
expect(subject.options[:identifier].value).to be(nil)
expect(subject.options[:identifier].desc).to eq('Searches for all identifier names')
end
it "must define a '--variable-name' option" do
expect(subject.options[:variable_name]).to_not be(nil)
expect(subject.options[:variable_name].short).to be(nil)
expect(subject.options[:variable_name].value).to be(nil)
expect(subject.options[:variable_name].desc).to eq('Searches for all variable names')
end
it "must define a '--variable-assignment' option" do
expect(subject.options[:variable_assignment]).to_not be(nil)
expect(subject.options[:variable_assignment].short).to be(nil)
expect(subject.options[:variable_assignment].value).to be(nil)
expect(subject.options[:variable_assignment].desc).to eq('Searches for all variable assignments')
end
it "must define a '--function-name' option" do
expect(subject.options[:function_name]).to_not be(nil)
expect(subject.options[:function_name].short).to be(nil)
expect(subject.options[:function_name].value).to be(nil)
expect(subject.options[:function_name].desc).to eq('Searches for all function names')
end
it "must define a '--single-quoted-string' option" do
expect(subject.options[:single_quoted_string]).to_not be(nil)
expect(subject.options[:single_quoted_string].short).to be(nil)
expect(subject.options[:single_quoted_string].value).to be(nil)
expect(subject.options[:single_quoted_string].desc).to eq('Searches for all single-quoted strings')
end
it "must define a '--double-quoted-string' option" do
expect(subject.options[:double_quoted_string]).to_not be(nil)
expect(subject.options[:double_quoted_string].short).to be(nil)
expect(subject.options[:double_quoted_string].value).to be(nil)
expect(subject.options[:double_quoted_string].desc).to eq('Searches for all double-quoted strings')
end
it "must define a '--string' option" do
expect(subject.options[:string]).to_not be(nil)
expect(subject.options[:string].short).to eq('-S')
expect(subject.options[:string].value).to be(nil)
expect(subject.options[:string].desc).to eq('Searches for all quoted strings')
end
it "must define a '--base64 ' option" do
expect(subject.options[:base64]).to_not be(nil)
expect(subject.options[:base64].short).to eq('-B')
expect(subject.options[:base64].value).to be(nil)
expect(subject.options[:base64].desc).to eq('Searches for all Base64 strings')
end
it "must define a '--c-comment' option" do
expect(subject.options[:c_comment]).to_not be(nil)
expect(subject.options[:c_comment].short).to be(nil)
expect(subject.options[:c_comment].value).to be(nil)
expect(subject.options[:c_comment].desc).to eq('Searches for all C comments')
end
it "must define a '--cpp-comment' option" do
expect(subject.options[:cpp_comment]).to_not be(nil)
expect(subject.options[:cpp_comment].short).to be(nil)
expect(subject.options[:cpp_comment].value).to be(nil)
expect(subject.options[:cpp_comment].desc).to eq('Searches for all C++ comments')
end
it "must define a '--java-comment' option" do
expect(subject.options[:java_comment]).to_not be(nil)
expect(subject.options[:java_comment].short).to be(nil)
expect(subject.options[:java_comment].value).to be(nil)
expect(subject.options[:java_comment].desc).to eq('Searches for all Java comments')
end
it "must define a '--javascript-comment' option" do
expect(subject.options[:javascript_comment]).to_not be(nil)
expect(subject.options[:javascript_comment].short).to be(nil)
expect(subject.options[:javascript_comment].value).to be(nil)
expect(subject.options[:javascript_comment].desc).to eq('Searches for all JavaScript comments')
end
it "must define a '--shell-comment' option" do
expect(subject.options[:shell_comment]).to_not be(nil)
expect(subject.options[:shell_comment].short).to be(nil)
expect(subject.options[:shell_comment].value).to be(nil)
expect(subject.options[:shell_comment].desc).to eq('Searches for all Shell comments')
end
it "must define a '--ruby-comment' option" do
expect(subject.options[:ruby_comment]).to_not be(nil)
expect(subject.options[:ruby_comment].short).to be(nil)
expect(subject.options[:ruby_comment].value).to be(nil)
expect(subject.options[:ruby_comment].desc).to eq('Searches for all Ruby comments')
end
it "must define a '--python-comment' option" do
expect(subject.options[:python_comment]).to_not be(nil)
expect(subject.options[:python_comment].short).to be(nil)
expect(subject.options[:python_comment].value).to be(nil)
expect(subject.options[:python_comment].desc).to eq('Searches for all Python comments')
end
it "must define a '--comment' option" do
expect(subject.options[:comment]).to_not be(nil)
expect(subject.options[:comment].short).to be(nil)
expect(subject.options[:comment].value).to be(nil)
expect(subject.options[:comment].desc).to eq('Searches for all comments')
end
#
# Cryptographic pattern options
#
it "must define a '--md5' option" do
expect(subject.options[:md5]).to_not be(nil)
expect(subject.options[:md5].short).to be(nil)
expect(subject.options[:md5].value).to be(nil)
expect(subject.options[:md5].desc).to eq('Searches for all MD5 hashes')
end
it "must define a '--sha1' option" do
expect(subject.options[:sha1]).to_not be(nil)
expect(subject.options[:sha1].short).to be(nil)
expect(subject.options[:sha1].value).to be(nil)
expect(subject.options[:sha1].desc).to eq('Searches for all SHA1 hashes')
end
it "must define a '--sha256' option" do
expect(subject.options[:sha256]).to_not be(nil)
expect(subject.options[:sha256].short).to be(nil)
expect(subject.options[:sha256].value).to be(nil)
expect(subject.options[:sha256].desc).to eq('Searches for all SHA256 hashes')
end
it "must define a '--sha512' option" do
expect(subject.options[:sha512]).to_not be(nil)
expect(subject.options[:sha512].short).to be(nil)
expect(subject.options[:sha512].value).to be(nil)
expect(subject.options[:sha512].desc).to eq('Searches for all SHA512 hashes')
end
it "must define a '--hash' option" do
expect(subject.options[:hash]).to_not be(nil)
expect(subject.options[:hash].short).to be(nil)
expect(subject.options[:hash].value).to be(nil)
expect(subject.options[:hash].desc).to eq('Searches for all hashes')
end
it "must define a '--ssh-public-key' option" do
expect(subject.options[:ssh_public_key]).to_not be(nil)
expect(subject.options[:ssh_public_key].short).to be(nil)
expect(subject.options[:ssh_public_key].value).to be(nil)
expect(subject.options[:ssh_public_key].desc).to eq('Searches for all SSH public key data')
end
it "must define a '--public-key' option" do
expect(subject.options[:public_key]).to_not be(nil)
expect(subject.options[:public_key].short).to be(nil)
expect(subject.options[:public_key].value).to be(nil)
expect(subject.options[:public_key].desc).to eq('Searches for all public key data')
end
#
# Credentials pattern options
#
it "must define a '--ssh-private-key' option" do
expect(subject.options[:ssh_private_key]).to_not be(nil)
expect(subject.options[:ssh_private_key].short).to be(nil)
expect(subject.options[:ssh_private_key].value).to be(nil)
expect(subject.options[:ssh_private_key].desc).to eq('Searches for all SSH private key data')
end
it "must define a '--dsa-private-key' option" do
expect(subject.options[:dsa_private_key]).to_not be(nil)
expect(subject.options[:dsa_private_key].short).to be(nil)
expect(subject.options[:dsa_private_key].value).to be(nil)
expect(subject.options[:dsa_private_key].desc).to eq('Searches for all DSA private key data')
end
it "must define a '--ec-private-key' option" do
expect(subject.options[:ec_private_key]).to_not be(nil)
expect(subject.options[:ec_private_key].short).to be(nil)
expect(subject.options[:ec_private_key].value).to be(nil)
expect(subject.options[:ec_private_key].desc).to eq('Searches for all EC private key data')
end
it "must define a '--rsa-private-key' option" do
expect(subject.options[:rsa_private_key]).to_not be(nil)
expect(subject.options[:rsa_private_key].short).to be(nil)
expect(subject.options[:rsa_private_key].value).to be(nil)
expect(subject.options[:rsa_private_key].desc).to eq('Searches for all RSA private key data')
end
it "must define a '--private-key' option" do
expect(subject.options[:private_key]).to_not be(nil)
expect(subject.options[:private_key].short).to eq('-K')
expect(subject.options[:private_key].value).to be(nil)
expect(subject.options[:private_key].desc).to eq('Searches for all private key data')
end
it "must define a '--aws-access-key-id' option" do
expect(subject.options[:aws_access_key_id]).to_not be(nil)
expect(subject.options[:aws_access_key_id].short).to be(nil)
expect(subject.options[:aws_access_key_id].value).to be(nil)
expect(subject.options[:aws_access_key_id].desc).to eq('Searches for all AWS access key IDs')
end
it "must define a '--aws-secret-access-key' option" do
expect(subject.options[:aws_secret_access_key]).to_not be(nil)
expect(subject.options[:aws_secret_access_key].short).to be(nil)
expect(subject.options[:aws_secret_access_key].value).to be(nil)
expect(subject.options[:aws_secret_access_key].desc).to eq('Searches for all AWS secret access keys')
end
it "must define a '--api-key' option" do
expect(subject.options[:api_key]).to_not be(nil)
expect(subject.options[:api_key].short).to eq('-A')
expect(subject.options[:api_key].value).to be(nil)
expect(subject.options[:api_key].desc).to eq('Searches for all API keys')
end
#
# General options
#
it "must define a '-e,--regexp' option" do
expect(subject.options[:regexp]).to_not be(nil)
expect(subject.options[:regexp].short).to eq('-e')
expect(subject.options[:regexp].value.type).to eq(Regexp)
expect(subject.options[:regexp].desc).to eq('Custom regular expression to search for')
end
end
describe "#option_parser" do
shared_examples_for "pattern option" do |flag,constant|
describe "when given '#{flag}'" do
let(:flag) { flag }
before { subject.option_parser.parse([flag]) }
it "must set #pattern to Ronin::Support::Text::Patterns::#{constant}" do
expect(subject.pattern).to be(
Ronin::Support::Text::Patterns.const_get(constant)
)
end
end
end
#
# Numeric pattern options
#
include_context "pattern option", '-N', :NUMBER
include_context "pattern option", '--number', :NUMBER
include_context "pattern option", '-X', :HEX_NUMBER
include_context "pattern option", '--hex-number', :HEX_NUMBER
include_context "pattern option", '--version-number', :VERSION_NUMBER
#
# Language pattern options
#
include_context "pattern option", '-w', :WORD
include_context "pattern option", '--word', :WORD
#
# Network pattern options
#
include_context "pattern option", '--mac-addr', :MAC_ADDR
include_context "pattern option", '-4', :IPV4_ADDR
include_context "pattern option", '--ipv4-addr', :IPV4_ADDR
include_context "pattern option", '-6', :IPV6_ADDR
include_context "pattern option", '--ipv6-addr', :IPV6_ADDR
include_context "pattern option", '-I', :IP
include_context "pattern option", '--ip', :IP
include_context "pattern option", '-H', :HOST_NAME
include_context "pattern option", '--host', :HOST_NAME
include_context "pattern option", '-D', :DOMAIN
include_context "pattern option", '--domain', :DOMAIN
include_context "pattern option", '--URI', :URI
include_context "pattern option", '-U', :URL
include_context "pattern option", '--URL', :URL
#
# PII pattern options
#
include_context "pattern option", '--user-name', :USER_NAME
include_context "pattern option", '-E', :EMAIL_ADDR
include_context "pattern option", '--email-addr', :EMAIL_ADDRESS
include_context "pattern option", '--obfuscated-email-addr', :OBFUSCATED_EMAIL_ADDRESS
include_context "pattern option", '--phone-number', :PHONE_NUMBER
include_context "pattern option", '--ssn', :SSN
include_context "pattern option", '--amex-cc', :AMEX_CC
include_context "pattern option", '--discover-cc', :DISCOVER_CC
include_context "pattern option", '--mastercard-cc', :MASTERCARD_CC
include_context "pattern option", '--visa-cc', :VISA_CC
include_context "pattern option", '--visa-mastercard-cc', :VISA_MASTERCARD_CC
include_context "pattern option", '--cc', :CC
#
# File System pattern options
#
include_context "pattern option", '--file-name', :FILE_NAME
include_context "pattern option", '--dir-name', :DIR_NAME
include_context "pattern option", '--relative-unix-path', :RELATIVE_UNIX_PATH
include_context "pattern option", '--absolute-unix-path', :ABSOLUTE_UNIX_PATH
include_context "pattern option", '--unix-path', :UNIX_PATH
include_context "pattern option", '--relative-windows-path', :RELATIVE_WINDOWS_PATH
include_context "pattern option", '--absolute-windows-path', :ABSOLUTE_WINDOWS_PATH
include_context "pattern option", '--windows-path', :WINDOWS_PATH
include_context "pattern option", '--relative-path', :RELATIVE_PATH
include_context "pattern option", '--absolute-path', :ABSOLUTE_PATH
include_context "pattern option", '--path', :PATH
include_context "pattern option", '-P', :PATH
#
# Source Code pattern options
#
include_context "pattern option", '--identifier', :IDENTIFIER
include_context "pattern option", '--variable-name', :VARIABLE_NAME
include_context "pattern option", '--variable-assignment', :VARIABLE_ASSIGNMENT
include_context "pattern option", '--function-name', :FUNCTION_NAME
include_context "pattern option", '--single-quoted-string', :SINGLE_QUOTED_STRING
include_context "pattern option", '--double-quoted-string', :DOUBLE_QUOTED_STRING
include_context "pattern option", '--string', :STRING
include_context "pattern option", '-S', :STRING
include_context "pattern option", '--base64', :BASE64
include_context "pattern option", '-B', :BASE64
include_context "pattern option", '--c-comment', :C_COMMENT
include_context "pattern option", '--cpp-comment', :CPP_COMMENT
include_context "pattern option", '--java-comment', :JAVA_COMMENT
include_context "pattern option", '--javascript-comment', :JAVASCRIPT_COMMENT
include_context "pattern option", '--shell-comment', :SHELL_COMMENT
include_context "pattern option", '--ruby-comment', :RUBY_COMMENT
include_context "pattern option", '--python-comment', :PYTHON_COMMENT
include_context "pattern option", '--comment', :COMMENT
#
# Cryptographic pattern options
#
include_context "pattern option", '--md5', :MD5
include_context "pattern option", '--sha1', :SHA1
include_context "pattern option", '--sha256', :SHA256
include_context "pattern option", '--sha512', :SHA512
include_context "pattern option", '--hash', :HASH
include_context "pattern option", '--ssh-public-key', :SSH_PUBLIC_KEY
include_context "pattern option", '--public-key', :PUBLIC_KEY
#
# Credentials pattern options
#
include_context "pattern option", '--ssh-private-key', :SSH_PRIVATE_KEY
include_context "pattern option", '--dsa-private-key', :DSA_PRIVATE_KEY
include_context "pattern option", '--ec-private-key', :EC_PRIVATE_KEY
include_context "pattern option", '--rsa-private-key', :RSA_PRIVATE_KEY
include_context "pattern option", '--private-key', :PRIVATE_KEY
include_context "pattern option", '-K', :PRIVATE_KEY
include_context "pattern option", '--aws-access-key-id', :AWS_ACCESS_KEY_ID
include_context "pattern option", '--aws-secret-access-key', :AWS_SECRET_ACCESS_KEY
include_context "pattern option", '--api-key', :API_KEY
include_context "pattern option", '-A', :API_KEY
#
# General options
#
context "when givne '-e /regexp/'" do
let(:regexp) { /foo/ }
before do
subject.option_parser.parse(['-e', regexp.inspect])
end
it "must set #pattern to the given regexp" do
expect(subject.pattern).to eq(regexp)
end
end
context "when givne '--regexp /regexp/'" do
let(:regexp) { /foo/ }
before do
subject.option_parser.parse(['--regexp', regexp.inspect])
end
it "must set #pattern to the given regexp" do
expect(subject.pattern).to eq(regexp)
end
end
end
end