set a good default, remove unused methods, speed up checks

MS-2855/keylogger-mettle-extension
Brent Cook 2017-09-20 21:17:03 -05:00
parent ffa6d74a23
commit 65c58c3d55
1 changed files with 21 additions and 38 deletions

View File

@ -1,48 +1,31 @@
# -*- coding: binary -*-
module Msf
# Boolean option type
class OptBool < OptBase
TRUE_REGEX = /^(y|yes|t|1|true)$/i
ANY_REGEX = /^(y|yes|n|no|t|f|0|1|true|false)$/i
###
#
# Boolean option.
#
###
class OptBool < OptBase
TrueRegex = /^(y|yes|t|1|true)$/i
def type
return 'bool'
end
def valid?(value, check_empty: true)
return false if empty_required_value?(value)
if ((value != nil and
(value.to_s.empty? == false) and
(value.to_s.match(/^(y|yes|n|no|t|f|0|1|true|false)$/i) == nil)))
return false
# This overrides default from 'nil' to 'false'
def initialize(in_name, attrs = [],
required: true, desc: nil, default: false, aliases: [])
super
end
true
end
def type
return 'bool'
end
def normalize(value)
if(value.nil? or value.to_s.match(TrueRegex).nil?)
false
else
true
def valid?(value, check_empty: true)
return false if check_empty && empty_required_value?(value)
!(value.nil? ||
value.to_s.empty? ||
value.to_s.match(ANY_REGEX).nil?)
end
def normalize(value)
!(value.nil? ||
value.to_s.match(TRUE_REGEX).nil?)
end
end
def is_true?(value)
return normalize(value)
end
def is_false?(value)
return !is_true?(value)
end
end
end