Skip to content

Commit 0347b17

Browse files
committed
Fix OptInt's valid?() function
[FixRM rapid7#7539] - The valid?() function will first normalize() the user-supplied input before validation. The problem is that the normalize() function will ALWAYS convert data to integer, therefore whatever you validate, you will always get true. For example: when I do "yomama".to_i, that returns 0, and of course will pass integer validation.
1 parent 6471a70 commit 0347b17

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/msf/core/option_container.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def normalize(value)
441441
def valid?(value)
442442
return false if empty_required_value?(value)
443443

444-
if value and not normalize(value).to_s.match(/^\d+$/)
444+
if value and not value.to_s.match(/^\d+$/)
445445
return false
446446
end
447447

0 commit comments

Comments
 (0)