ronin 2.0.0.beta1 → 2.0.0.beta2

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +72 -4
  3. data/data/new/project/Rakefile +3 -3
  4. data/data/new/project/project.rb.erb +1 -1
  5. data/gemspec.yml +12 -6
  6. data/lib/ronin/cli/char_set_options.rb +81 -68
  7. data/lib/ronin/cli/commands/dns.rb +3 -95
  8. data/lib/ronin/cli/commands/extract.rb +17 -7
  9. data/lib/ronin/cli/commands/grep.rb +17 -7
  10. data/lib/ronin/cli/commands/hexdump.rb +8 -2
  11. data/lib/ronin/cli/commands/host.rb +6 -88
  12. data/lib/ronin/cli/commands/http.rb +11 -11
  13. data/lib/ronin/cli/commands/public_suffix_list.rb +16 -2
  14. data/lib/ronin/cli/commands/tld_list.rb +16 -2
  15. data/lib/ronin/cli/dns.rb +136 -0
  16. data/lib/ronin/cli/pattern_options.rb +200 -85
  17. data/lib/ronin/cli.rb +5 -0
  18. data/lib/ronin/version.rb +1 -1
  19. data/man/ronin-extract.1 +52 -12
  20. data/man/ronin-extract.1.md +42 -12
  21. data/man/ronin-grep.1 +52 -12
  22. data/man/ronin-grep.1.md +42 -12
  23. data/man/ronin-http.1 +2 -2
  24. data/man/ronin-http.1.md +1 -1
  25. data/ronin.gemspec +2 -1
  26. metadata +15 -25
  27. data/spec/cli/command_spec.rb +0 -10
  28. data/spec/cli/commands/decode_spec.rb +0 -152
  29. data/spec/cli/commands/encode_spec.rb +0 -152
  30. data/spec/cli/commands/escape_spec.rb +0 -128
  31. data/spec/cli/commands/quote_spec.rb +0 -76
  32. data/spec/cli/commands/unescape_spec.rb +0 -128
  33. data/spec/cli/commands/unquote_spec.rb +0 -80
  34. data/spec/cli/fixtures/file.txt +0 -3
  35. data/spec/cli/fixtures/file2.txt +0 -3
  36. data/spec/cli/key_options_spec.rb +0 -56
  37. data/spec/cli/method_options_spec.rb +0 -71
  38. data/spec/cli/string_methods_command_spec.rb +0 -25
  39. data/spec/cli/string_processor_command_spec.rb +0 -258
  40. data/spec/cli/value_processor_command_spec.rb +0 -127
  41. data/spec/spec_helper.rb +0 -5
  42. data/spec/version_spec.rb +0 -11
@@ -1,258 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/cli/string_processor_command'
3
-
4
- describe Ronin::CLI::StringProcessorCommand do
5
- module TestStringProcessorCommand
6
- class TestCommand < Ronin::CLI::StringProcessorCommand
7
-
8
- def process_string(string)
9
- string.reverse
10
- end
11
-
12
- end
13
- end
14
-
15
- let(:test_class) { TestStringProcessorCommand::TestCommand }
16
- subject { test_class.new }
17
-
18
- describe described_class::StringValue do
19
- let(:string) { "foo" }
20
-
21
- subject { described_class.new(string) }
22
-
23
- describe "#initialize" do
24
- it "must set #string" do
25
- expect(subject.string).to eq(string)
26
- end
27
- end
28
- end
29
-
30
- describe described_class::FileValue do
31
- let(:file) { "file.txt" }
32
-
33
- subject { described_class.new(file) }
34
-
35
- describe "#initialize" do
36
- it "must set #file" do
37
- expect(subject.file).to eq(file)
38
- end
39
- end
40
- end
41
-
42
- describe "#initialize" do
43
- it "must initialize #input_values to an empty Array" do
44
- expect(subject.input_values).to eq([])
45
- end
46
- end
47
-
48
- describe "options" do
49
- describe "--string" do
50
- let(:string1) { "foo" }
51
- let(:string2) { "bar" }
52
- let(:argv) { ['--string', string1, '--string', string2] }
53
-
54
- before { subject.parse_options(argv) }
55
-
56
- it "must append a #{described_class}::StringValue to #input_values" do
57
- expect(subject.input_values.length).to eq(2)
58
-
59
- expect(subject.input_values[0]).to be_kind_of(described_class::StringValue)
60
- expect(subject.input_values[0].string).to eq(string1)
61
-
62
- expect(subject.input_values[1]).to be_kind_of(described_class::StringValue)
63
- expect(subject.input_values[1].string).to eq(string2)
64
- end
65
- end
66
-
67
- describe "--file" do
68
- let(:file1) { "foo" }
69
- let(:file2) { "bar" }
70
- let(:argv) { ['--file', file1, '--file', file2] }
71
-
72
- before { subject.parse_options(argv) }
73
-
74
- it "must append a #{described_class}::FileValue to #input_values" do
75
- expect(subject.input_values.length).to eq(2)
76
-
77
- expect(subject.input_values[0]).to be_kind_of(described_class::FileValue)
78
- expect(subject.input_values[0].file).to eq(file1)
79
-
80
- expect(subject.input_values[1]).to be_kind_of(described_class::FileValue)
81
- expect(subject.input_values[1].file).to eq(file2)
82
- end
83
- end
84
- end
85
-
86
- let(:fixtures_dir) { File.join(__dir__,'fixtures') }
87
- let(:file) { File.join(fixtures_dir,'file.txt') }
88
- let(:file2) { File.join(fixtures_dir,'file2.txt') }
89
-
90
- describe "#run" do
91
- context "when arguments are given" do
92
- let(:args) { [file, file2] }
93
-
94
- let(:expected_values) { [File.read(file), File.read(file2)] }
95
- let(:expected_output) do
96
- expected_values.map(&:reverse).join($/) + $/
97
- end
98
-
99
- it "must read and process each argument as a file in full" do
100
- expect {
101
- subject.run(*args)
102
- }.to output(expected_output).to_stdout
103
- end
104
-
105
- context "and when --file or --string options are given" do
106
- let(:string) { "abc" }
107
- let(:argv) { ['--string', string, '--file', file] }
108
-
109
- before { subject.parse_options(argv) }
110
-
111
- let(:expected_values) do
112
- [string, File.read(file)] + args.map { |path| File.read(path) }
113
- end
114
- let(:expected_output) do
115
- expected_values.map(&:reverse).join($/) + $/
116
- end
117
-
118
- it "must process the input from the --file and --string options then read and process the arguments" do
119
- expect {
120
- subject.run(*args)
121
- }.to output(expected_output).to_stdout
122
- end
123
- end
124
- end
125
-
126
- context "when no arguments are given" do
127
- context "but --file or --string options are given" do
128
- let(:string) { "abc" }
129
- let(:argv) { ['--string', string, '--file', file] }
130
-
131
- before { subject.parse_options(argv) }
132
-
133
- let(:expected_values) { [string, File.read(file)] }
134
- let(:expected_output) do
135
- expected_values.map(&:reverse).join($/) + $/
136
- end
137
-
138
- it "must process the input from the --file and --string options in the order given" do
139
- expect {
140
- subject.run()
141
- }.to output(expected_output).to_stdout
142
- end
143
- end
144
-
145
- context "and no options were given" do
146
- let(:expected_output) { File.read(file).reverse + $/ }
147
-
148
- let(:stdin) { File.open(file) }
149
- subject { test_class.new(stdin: stdin) }
150
-
151
- it "must read and process input from stdin in full" do
152
- expect {
153
- subject.run()
154
- }.to output(expected_output).to_stdout
155
- end
156
- end
157
- end
158
- end
159
-
160
- describe "#open_file" do
161
- let(:path) { __FILE__ }
162
-
163
- context "when given a block" do
164
- it "must yield the newly opened File" do
165
- expect { |b|
166
- subject.open_file(path,&b)
167
- }.to yield_with_args(File)
168
- end
169
-
170
- it "must open the file in non-binary mode by default" do
171
- file_binmode = nil
172
-
173
- subject.open_file(path) do |file|
174
- file_binmode = file.binmode?
175
- end
176
-
177
- expect(file_binmode).to be(false)
178
- end
179
- end
180
-
181
- context "when no block is given" do
182
- it "must return the opened File" do
183
- file = subject.open_file(path)
184
-
185
- expect(file).to be_kind_of(File)
186
- expect(file.path).to eq(path)
187
- end
188
-
189
- it "must open the file in non-binary mode by default" do
190
- file = subject.open_file(path)
191
-
192
- expect(file.binmode?).to be(false)
193
- end
194
- end
195
- end
196
-
197
- describe "#process_input" do
198
- let(:input) { File.open(file) }
199
- let(:expected_output) { File.read(file).reverse + $/ }
200
-
201
- it "must read the input stream and process the full String" do
202
- expect {
203
- subject.process_input(input)
204
- }.to output(expected_output).to_stdout
205
- end
206
-
207
- context "when the --multiline option is given" do
208
- let(:argv) { %w[--multiline] }
209
- let(:expected_output) do
210
- File.readlines(file, chomp: true).map(&:reverse).join($/) + $/
211
- end
212
-
213
- before { subject.parse_options(argv) }
214
-
215
- it "must read and process each line of the input" do
216
- expect {
217
- subject.process_input(input)
218
- }.to output(expected_output).to_stdout
219
- end
220
-
221
- context "and the --keep-newlines option is given" do
222
- let(:argv) { %w[--multiline --keep-newlines] }
223
-
224
- let(:expected_output) do
225
- File.readlines(file).map(&:reverse).join($/) + $/
226
- end
227
-
228
- it "must not omit the newline character at the end of each line" do
229
- expect {
230
- subject.process_input(input)
231
- }.to output(expected_output).to_stdout
232
- end
233
- end
234
- end
235
- end
236
-
237
- describe "#process_string" do
238
- subject { described_class.new }
239
-
240
- let(:string) { "foo" }
241
-
242
- it do
243
- expect {
244
- subject.process_string(string)
245
- }.to raise_error(NotImplementedError,"#{subject.class}#process_string method was not implemented")
246
- end
247
- end
248
-
249
- describe "#print_string" do
250
- let(:string) { "hello world" }
251
-
252
- it "must print the string using #puts" do
253
- expect(subject).to receive(:puts).with(string)
254
-
255
- subject.print_string(string)
256
- end
257
- end
258
- end
@@ -1,127 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/cli/value_processor_command'
3
-
4
- describe Ronin::CLI::ValueProcessorCommand do
5
- module TestValueProcessorCommand
6
- class TestCommand < Ronin::CLI::ValueProcessorCommand
7
-
8
- def process_value(string)
9
- puts string.reverse
10
- end
11
-
12
- end
13
- end
14
-
15
- let(:test_class) { TestValueProcessorCommand::TestCommand }
16
- subject { test_class.new }
17
-
18
- describe "#initialize" do
19
- it "must initialize #files to an empty Array" do
20
- expect(subject.files).to eq([])
21
- end
22
- end
23
-
24
- describe "options" do
25
- describe "--file" do
26
- let(:file1) { 'file1.txt' }
27
- let(:file2) { 'file2.txt' }
28
- let(:argv) do
29
- ['--file', file1, '--file', file2]
30
- end
31
- before { subject.parse_options(argv) }
32
-
33
- it "must append the argument value to #files" do
34
- expect(subject.files).to eq([file1, file2])
35
- end
36
- end
37
- end
38
-
39
- let(:fixtures_dir) { File.join(__dir__,'fixtures') }
40
- let(:file) { File.join(fixtures_dir,'file.txt') }
41
-
42
- describe "#run" do
43
- context "when arguments are given" do
44
- let(:args) { %w[foo bar baz] }
45
- let(:expected_output) do
46
- args.map(&:reverse).join($/) + $/
47
- end
48
-
49
- it "must process each argument and print output to stdout" do
50
- expect {
51
- subject.run(*args)
52
- }.to output(expected_output).to_stdout
53
- end
54
- end
55
-
56
- context "when --file options are given" do
57
- let(:argv) { ['--file', file] }
58
- let(:expected_output) do
59
- File.readlines(file, chomp: true).map(&:reverse).join($/) + $/
60
- end
61
-
62
- before { subject.parse_options(argv) }
63
-
64
- it "must read and process each --file argument and print output to stdout" do
65
- expect {
66
- subject.run()
67
- }.to output(expected_output).to_stdout
68
- end
69
- end
70
-
71
- context "when --file options and arguments are given" do
72
- let(:argv) { ['--file', file] }
73
- let(:args) { %w[abc def ghi] }
74
-
75
- let(:expected_values) { File.readlines(file, chomp: true) + args }
76
- let(:expected_output) do
77
- expected_values.map(&:reverse).join($/) + $/
78
- end
79
-
80
- before { subject.parse_options(argv) }
81
-
82
- it "must read and process the --file arguments then the arguments" do
83
- expect {
84
- subject.run(*args)
85
- }.to output(expected_output).to_stdout
86
- end
87
- end
88
-
89
- context "when neither --file options nor arguments are given" do
90
- it "must print an error message to stderr and exit with 1" do
91
- expect(subject).to receive(:print_error).with(
92
- "must specify one or more arguments, or the --file option"
93
- )
94
-
95
- expect {
96
- subject.run()
97
- }.to raise_error(SystemExit) do |error|
98
- expect(error.status).to eq(1)
99
- end
100
- end
101
- end
102
- end
103
-
104
- describe "#process_file" do
105
- let(:expected_output) do
106
- File.readlines(file, chomp: true).map(&:reverse).join($/) + $/
107
- end
108
-
109
- it "must read and process each line of the file and print them to stdout" do
110
- expect {
111
- subject.process_file(file)
112
- }.to output(expected_output).to_stdout
113
- end
114
- end
115
-
116
- describe "#process_value" do
117
- subject { described_class.new }
118
-
119
- let(:value) { "foo" }
120
-
121
- it do
122
- expect {
123
- subject.process_value(value)
124
- }.to raise_error(NotImplementedError,"#{subject.class}#process_value method was not implemented")
125
- end
126
- end
127
- end
data/spec/spec_helper.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'rspec'
2
- require 'simplecov'
3
- SimpleCov.start
4
-
5
- include Ronin
data/spec/version_spec.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/version'
3
-
4
- describe Ronin do
5
- it "should have a version" do
6
- version = subject.const_get('VERSION')
7
-
8
- expect(version).not_to be_nil
9
- expect(version).not_to be_empty
10
- end
11
- end