wordlist validators

added custom fielpath vaidator and
added validations to the wordlist class
bug/bundler_fix
David Maloney 2014-06-14 17:49:47 -05:00
parent 466576d03f
commit 1dd69a5228
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
3 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1 @@
require 'metasploit/framework/file_path_validator'

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 FilePathValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless ::File.file? value
record.errors[attribute] << (options[:message] || "is not a valid path to a regular file")
end
end
end
end
end

View File

@ -1,3 +1,4 @@
require 'metasploit/framework/jtr/invalid_wordlist'
module Metasploit
module Framework
@ -48,6 +49,8 @@ module Metasploit
# @return [FalseClass] if you do not want to seed the wordlist with existing hostnames from the database
attr_accessor :use_hostnames
validates :custom_wordlist, :'Metasploit::Framework::File_path' => true
validates :mutate,
inclusion: { in: [true, false] }