Files
metasploit-gs/lib/msf/core/opt_raw.rb
T
dwelch-r7 e7061439ef Adds rhost url support behind a feature flag
Tidy up test

Return a string instead of a URI object

Code review comments

Rubcocop
2020-08-18 12:25:27 +01:00

39 lines
565 B
Ruby

# -*- coding: binary -*-
module Msf
###
#
# Raw, arbitrary data option.
#
###
class OptRaw < OptBase
def type
return 'raw'
end
def validate_on_assignment?
false
end
def normalize(value)
if (value.to_s =~ /^file:(.*)/)
path = $1
begin
value = File.read(path)
rescue ::Errno::ENOENT, ::Errno::EISDIR
value = nil
end
end
value
end
def valid?(value=self.value, check_empty: true)
value = normalize(value)
return false if empty_required_value?(value)
return super
end
end
end