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:
parent
21f29c4da9
commit
10f3531bbb
|
@ -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
|
||||
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue