Files
metasploit-gs/lib/msf/core/opt_int.rb
T

29 lines
521 B
Ruby
Raw Normal View History

# -*- coding: binary -*-
module Msf
2017-08-05 02:22:04 -05:00
###
#
# Integer option.
#
###
class OptInt < OptBase
def type
'integer'
end
2017-08-05 02:22:04 -05:00
def normalize(value)
if value.to_s.match(/^0x[a-fA-F\d]+$/)
2017-08-05 02:22:04 -05:00
value.to_i(16)
elsif value.present?
value.to_i
end
end
2017-08-05 02:22:04 -05:00
def valid?(value, check_empty: true)
return false if check_empty && empty_required_value?(value)
return false if value.present? && !value.to_s.match(/^0x[0-9a-fA-F]+$|^-?\d+$/)
2017-08-05 02:22:04 -05:00
super
end
end
end