add exectuable validator

like the filepath validator but also checks
to see if the file is exectuable by the current
users.
This commit is contained in:
David Maloney 2014-06-14 18:01:24 -05:00
parent 21f29c4da9
commit 10f3531bbb
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,16 @@
module Metasploit
module Framework
# This is a ActiveModel custom validator that assumes the attribute
# is supposed to be the path to a regular file. It checks whether the
# file exists and whether or not it is a regular file.
class ExecutablePathValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless ::File.executable? value
record.errors[attribute] << (options[:message] || "is not a valid path to an executable file")
end
end
end
end
end

View File

@ -48,6 +48,8 @@ module Metasploit
validates :hash_path, :'Metasploit::Framework::File_path' => true, if: 'hash_path.present?'
validates :john_path, :'Metasploit::Framework::Executable_path' => true, if: 'john_path.present?'
validates :pot, :'Metasploit::Framework::File_path' => true, if: 'pot.present?'
validates :max_runtime,