Rename CredDetail to Credential

it was felt this was better naming
for the class. Refactored all occurence
bug/bundler_fix
David Maloney 2014-04-22 10:25:36 -05:00
parent 7d05de935e
commit 645eef51b7
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
5 changed files with 9 additions and 80 deletions

View File

@ -1,6 +1,6 @@
require 'metasploit/framework/login_scanner/invalid' require 'metasploit/framework/login_scanner/invalid'
require 'metasploit/framework/login_scanner/result' require 'metasploit/framework/login_scanner/result'
require 'metasploit/framework/login_scanner/cred_detail' require 'metasploit/framework/login_scanner/credential'
require 'metasploit/framework/login_scanner/ssh' require 'metasploit/framework/login_scanner/ssh'
module Metasploit module Metasploit

View File

@ -1,7 +1,7 @@
module Metasploit module Metasploit
module Framework module Framework
module LoginScanner module LoginScanner
class CredDetail class Credential
include ActiveModel::Validations include ActiveModel::Validations
# @!attribute paired # @!attribute paired

View File

@ -12,7 +12,7 @@ module Metasploit
# @return [Fixnum] The timeout in seconds for a single SSH connection # @return [Fixnum] The timeout in seconds for a single SSH connection
attr_accessor :connection_timeout attr_accessor :connection_timeout
# @!attribute cred_details # @!attribute cred_details
# @return [Array] An array of CredDetail objects # @return [Array] An array of Credential objects
attr_accessor :cred_details attr_accessor :cred_details
# @!attribute successes # @!attribute successes
# @return [Array] Array of of result objects that failed # @return [Array] Array of of result objects that failed
@ -195,7 +195,7 @@ module Metasploit
def validate_cred_details def validate_cred_details
if cred_details.kind_of? Array if cred_details.kind_of? Array
cred_details.each do |detail| cred_details.each do |detail|
unless detail.kind_of? Metasploit::Framework::LoginScanner::CredDetail unless detail.kind_of? Metasploit::Framework::LoginScanner::Credential
errors.add(:cred_details, "has invalid element #{detail.inspect}") errors.add(:cred_details, "has invalid element #{detail.inspect}")
next next
end end

View File

@ -1,71 +0,0 @@
require 'spec_helper'
require 'metasploit/framework/login_scanner'
describe Metasploit::Framework::LoginScanner::CredDetail do
subject(:cred_detail) {
described_class.new
}
it { should respond_to :paired }
it { should respond_to :private }
it { should respond_to :public }
it { should respond_to :realm }
context 'validations' do
it 'is not valid without paired being set' do
expect(cred_detail).to_not be_valid
end
context 'when not paired' do
before(:each) do
cred_detail.paired = false
end
it 'is invalid without at least a public or a private' do
expect(cred_detail).to_not be_valid
end
it 'is valid with just a public' do
cred_detail.public = 'root'
expect(cred_detail).to be_valid
end
it 'is valid with just a private' do
cred_detail.private = 'toor'
expect(cred_detail).to be_valid
end
end
context 'when paired' do
before(:each) do
cred_detail.paired = true
end
it 'is invalid with only a public' do
cred_detail.public = 'root'
expect(cred_detail).to_not be_valid
end
it 'is invalid with only a private' do
cred_detail.private = 'toor'
expect(cred_detail).to_not be_valid
end
it 'is invalid with empty string for public' do
cred_detail.public = ''
cred_detail.private = 'toor'
expect(cred_detail).to_not be_valid
end
it 'is valid with empty string for private' do
cred_detail.public = 'root'
cred_detail.private = ''
expect(cred_detail).to be_valid
end
end
end
end

View File

@ -6,7 +6,7 @@ describe Metasploit::Framework::LoginScanner::SSH do
let(:private) { 'toor' } let(:private) { 'toor' }
let(:pub_blank) { let(:pub_blank) {
Metasploit::Framework::LoginScanner::CredDetail.new( Metasploit::Framework::LoginScanner::Credential.new(
paired: true, paired: true,
public: public, public: public,
private: '' private: ''
@ -14,7 +14,7 @@ describe Metasploit::Framework::LoginScanner::SSH do
} }
let(:pub_pub) { let(:pub_pub) {
Metasploit::Framework::LoginScanner::CredDetail.new( Metasploit::Framework::LoginScanner::Credential.new(
paired: true, paired: true,
public: public, public: public,
private: public private: public
@ -22,7 +22,7 @@ describe Metasploit::Framework::LoginScanner::SSH do
} }
let(:pub_pri) { let(:pub_pri) {
Metasploit::Framework::LoginScanner::CredDetail.new( Metasploit::Framework::LoginScanner::Credential.new(
paired: true, paired: true,
public: public, public: public,
private: private private: private
@ -30,7 +30,7 @@ describe Metasploit::Framework::LoginScanner::SSH do
} }
let(:invalid_detail) { let(:invalid_detail) {
Metasploit::Framework::LoginScanner::CredDetail.new( Metasploit::Framework::LoginScanner::Credential.new(
paired: true, paired: true,
public: nil, public: nil,
private: nil private: nil
@ -159,7 +159,7 @@ describe Metasploit::Framework::LoginScanner::SSH do
expect(ssh_scanner.errors[:cred_details]).to include "must be an array" expect(ssh_scanner.errors[:cred_details]).to include "must be an array"
end end
it 'is not valid if any of the elements are not a CredDetail' do it 'is not valid if any of the elements are not a Credential' do
ssh_scanner.cred_details = [1,2] ssh_scanner.cred_details = [1,2]
expect(ssh_scanner).to_not be_valid expect(ssh_scanner).to_not be_valid
expect(ssh_scanner.errors[:cred_details]).to include "has invalid element 1" expect(ssh_scanner.errors[:cred_details]).to include "has invalid element 1"