From 6da66e885aeafc82cd06478dd04f2daaec109c98 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 21 Sep 2017 02:33:37 -0500 Subject: [PATCH] fix enum default logic for bools that default to false --- lib/msf/core/opt_base.rb | 6 +++++- lib/msf/core/opt_enum.rb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/msf/core/opt_base.rb b/lib/msf/core/opt_base.rb index a8ce71f4b4..9c780c6789 100644 --- a/lib/msf/core/opt_base.rb +++ b/lib/msf/core/opt_base.rb @@ -36,7 +36,11 @@ module Msf self.required = required self.desc = attrs.is_a?(String) ? attrs : desc self.enums = [ *(enums) ].map { |x| x.to_s } - self.default = default || enums[0] + if default.nil? && enums.length > 0 + self.default = enums[0] + else + self.default = default + end regex_temp = regex else self.required = attrs[0] || required diff --git a/lib/msf/core/opt_enum.rb b/lib/msf/core/opt_enum.rb index 722fe113cf..3b05709b64 100644 --- a/lib/msf/core/opt_enum.rb +++ b/lib/msf/core/opt_enum.rb @@ -25,7 +25,11 @@ module Msf end def normalize(value = self.value) - !valid?(value) ? nil : value.to_s + if valid?(value) + value.to_s + else + nil + end end def desc=(value)