Skip to content

Commit 8bff4e9

Browse files
author
HD Moore
committed
Merge branch 'master' of github.com:rapid7/metasploit-framework
2 parents 7c207a7 + e14b4fc commit 8bff4e9

File tree

4 files changed

+4
-88
lines changed

4 files changed

+4
-88
lines changed

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,29 +2070,6 @@ def cmd_set(*args)
20702070
return true
20712071
end
20722072

2073-
# If the value starts with file: exists, and size isn't too big load the file as the value
2074-
# Otherwise keep the old value
2075-
if value =~ /^file:(.*)/
2076-
fname = $1
2077-
2078-
begin
2079-
fd = ::File.new(fname, 'rb')
2080-
rescue ::Errno::ENOENT
2081-
print_error('The file name specified does not exist')
2082-
value = datastore[name]
2083-
fd = nil
2084-
end
2085-
2086-
if fd && fd.stat.size > (1024 * 1024)
2087-
print_error('The file name specified is too big (over 1Mb)')
2088-
value = datastore[name]
2089-
fd.close
2090-
elsif fd
2091-
value = fd.read(fd.stat.size)
2092-
fd.close
2093-
end
2094-
end
2095-
20962073
if append
20972074
datastore[name] = datastore[name] + value
20982075
else

spec/lib/msf/core/opt_address_range_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
{ :value => "192.0.2.0-255", :normalized => "192.0.2.0-255" },
1111
{ :value => "192.0.2.0,1-255", :normalized => "192.0.2.0,1-255" },
1212
{ :value => "192.0.2.*", :normalized => "192.0.2.*" },
13-
{ :value => "192.0.2.0-192.0.2.255", :normalized => "192.0.2.0-192.0.2.255" }
13+
{ :value => "192.0.2.0-192.0.2.255", :normalized => "192.0.2.0-192.0.2.255" },
14+
{ :value => "file:#{File.expand_path('short_address_list.txt',FILE_FIXTURES_PATH)}", :normalized => '192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5'}
1415
]
1516
invalid_values = [
1617
# Too many dots

spec/lib/msf/core/opt_raw_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
describe Msf::OptRaw do
77

88
valid_values = [
9-
{ :value => 'foo', :normalized => 'foo' }
9+
{ :value => 'foo', :normalized => 'foo' },
10+
{ :value => "file:#{File.expand_path('string_list.txt',FILE_FIXTURES_PATH)}",:normalized => "foo\nbar\nbaz" }
1011
]
1112
invalid_values = []
1213

spec/lib/msf/ui/console/command_dispatcher/core_spec.rb

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -161,69 +161,6 @@ def set_and_test_variable(name, framework_value, module_value, framework_re, mod
161161
set_and_test_variable(name, 'FRAMEWORK', 'MODULE', /^#{name} => FRAMEWORK$/, /^#{name} => MODULE$/)
162162
end
163163

164-
context "when using file: prefix in the value" do
165-
context "when the file exists" do
166-
167-
before(:each) do
168-
allow(::File).to receive(:new) do |filename, mode|
169-
fd = StringIO.new(file_contents, mode)
170-
fd
171-
end
172-
173-
allow_any_instance_of(::StringIO).to receive(:stat) do |io|
174-
file_contents
175-
end
176-
end
177-
178-
context "when the size is 1MB" do
179-
let(:file_name) do
180-
::Rex::Text.rand_text_alpha(10).upcase
181-
end
182-
183-
let(:file_contents) do
184-
::Rex::Text.rand_text_alpha(1024 * 1024).upcase
185-
end
186-
187-
it "should show the new value" do
188-
set_and_test_variable(name, nil, "file:/#{file_name}", nil, /^#{name} => #{file_contents}$/)
189-
end
190-
end
191-
192-
context "when the size is greater than 1MB" do
193-
let(:file_name) do
194-
::Rex::Text.rand_text_alpha(10).upcase
195-
end
196-
197-
let(:file_contents) do
198-
::Rex::Text.rand_text_alpha(1024 * 1025).upcase
199-
end
200-
201-
it "should show the old value" do
202-
set_and_test_variable(name, nil, "file:/#{file_name}", nil, /^#{name} => $/)
203-
end
204-
end
205-
206-
context "when the size is less than 1MB" do
207-
let(:file_name) do
208-
::Rex::Text.rand_text_alpha(10).upcase
209-
end
210-
211-
let(:file_contents) do
212-
::Rex::Text.rand_text_alpha(10).upcase
213-
end
214-
215-
it "should show the new value" do
216-
set_and_test_variable(name, nil, "file:/#{file_name}", nil, /^#{name} => #{file_contents}$/)
217-
end
218-
end
219-
end
220-
221-
context "when the file doesn't exist" do
222-
it "should show the old value" do
223-
set_and_test_variable(name, nil, "file:/#{::Rex::Text.rand_text_alpha(10).upcase}", nil, /^#{name} => $/)
224-
end
225-
end
226-
end
227164
end
228165
end
229166
end

0 commit comments

Comments
 (0)