set good defaults

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

View File

@ -1,48 +1,45 @@
# -*- coding: binary -*-
module Msf
###
#
# Enum option.
#
###
class OptEnum < OptBase
def type
return 'enum'
end
def valid?(value=self.value, check_empty: true)
return false if check_empty && empty_required_value?(value)
return true if value.nil? and !required?
(value and self.enums.include?(value.to_s))
end
def normalize(value=self.value)
return nil if not self.valid?(value)
return value.to_s
end
def desc=(value)
self.desc_string = value
self.desc
end
def desc
if self.enums
str = self.enums.join(', ')
###
#
# Enum option.
#
###
class OptEnum < OptBase
def type
return 'enum'
end
"#{self.desc_string || ''} (Accepted: #{str})"
# This overrides required default from 'false' to 'true'
def initialize(in_name, attrs = [],
required: true, desc: nil, default: nil, enums: [], aliases: [])
super
end
def valid?(value = self.value, check_empty: true)
return false if check_empty && empty_required_value?(value)
return true if value.nil? && !required?
(value && enums.include?(value.to_s))
end
def normalize(value = self.value)
!valid?(value) ? nil : value.to_s
end
def desc=(value)
self.desc_string = value
desc
end
def desc
str = enums.join(', ') if enums
"#{desc_string || ''} (Accepted: #{str})"
end
protected
attr_accessor :desc_string # :nodoc:
end
protected
attr_accessor :desc_string # :nodoc:
end
end