diff --git a/app/validators/metasploit/framework/executable_path_validator.rb b/app/validators/metasploit/framework/executable_path_validator.rb new file mode 100644 index 0000000000..b2ca74b926 --- /dev/null +++ b/app/validators/metasploit/framework/executable_path_validator.rb @@ -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 + diff --git a/lib/metasploit/framework/jtr/cracker.rb b/lib/metasploit/framework/jtr/cracker.rb index 0b226a7ed3..f02d85db20 100644 --- a/lib/metasploit/framework/jtr/cracker.rb +++ b/lib/metasploit/framework/jtr/cracker.rb @@ -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,