From 645eef51b7735d49f0bf6740b69f23fb503f4646 Mon Sep 17 00:00:00 2001 From: David Maloney Date: Tue, 22 Apr 2014 10:25:36 -0500 Subject: [PATCH] Rename CredDetail to Credential it was felt this was better naming for the class. Refactored all occurence --- lib/metasploit/framework/login_scanner.rb | 2 +- .../{cred_detail.rb => credential.rb} | 2 +- lib/metasploit/framework/login_scanner/ssh.rb | 4 +- .../login_scanner/cred_detail_spec.rb | 71 ------------------- .../framework/login_scanner/ssh_spec.rb | 10 +-- 5 files changed, 9 insertions(+), 80 deletions(-) rename lib/metasploit/framework/login_scanner/{cred_detail.rb => credential.rb} (98%) delete mode 100644 spec/lib/metasploit/framework/login_scanner/cred_detail_spec.rb diff --git a/lib/metasploit/framework/login_scanner.rb b/lib/metasploit/framework/login_scanner.rb index 8574e11451..1909d8befd 100644 --- a/lib/metasploit/framework/login_scanner.rb +++ b/lib/metasploit/framework/login_scanner.rb @@ -1,6 +1,6 @@ require 'metasploit/framework/login_scanner/invalid' 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' module Metasploit diff --git a/lib/metasploit/framework/login_scanner/cred_detail.rb b/lib/metasploit/framework/login_scanner/credential.rb similarity index 98% rename from lib/metasploit/framework/login_scanner/cred_detail.rb rename to lib/metasploit/framework/login_scanner/credential.rb index d16e0effa7..7828345ee0 100644 --- a/lib/metasploit/framework/login_scanner/cred_detail.rb +++ b/lib/metasploit/framework/login_scanner/credential.rb @@ -1,7 +1,7 @@ module Metasploit module Framework module LoginScanner - class CredDetail + class Credential include ActiveModel::Validations # @!attribute paired diff --git a/lib/metasploit/framework/login_scanner/ssh.rb b/lib/metasploit/framework/login_scanner/ssh.rb index f81e309e08..b03827086a 100644 --- a/lib/metasploit/framework/login_scanner/ssh.rb +++ b/lib/metasploit/framework/login_scanner/ssh.rb @@ -12,7 +12,7 @@ module Metasploit # @return [Fixnum] The timeout in seconds for a single SSH connection attr_accessor :connection_timeout # @!attribute cred_details - # @return [Array] An array of CredDetail objects + # @return [Array] An array of Credential objects attr_accessor :cred_details # @!attribute successes # @return [Array] Array of of result objects that failed @@ -195,7 +195,7 @@ module Metasploit def validate_cred_details if cred_details.kind_of? Array 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}") next end diff --git a/spec/lib/metasploit/framework/login_scanner/cred_detail_spec.rb b/spec/lib/metasploit/framework/login_scanner/cred_detail_spec.rb deleted file mode 100644 index 4a14f988f2..0000000000 --- a/spec/lib/metasploit/framework/login_scanner/cred_detail_spec.rb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb b/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb index 5447c1dd03..decbcf718c 100644 --- a/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb @@ -6,7 +6,7 @@ describe Metasploit::Framework::LoginScanner::SSH do let(:private) { 'toor' } let(:pub_blank) { - Metasploit::Framework::LoginScanner::CredDetail.new( + Metasploit::Framework::LoginScanner::Credential.new( paired: true, public: public, private: '' @@ -14,7 +14,7 @@ describe Metasploit::Framework::LoginScanner::SSH do } let(:pub_pub) { - Metasploit::Framework::LoginScanner::CredDetail.new( + Metasploit::Framework::LoginScanner::Credential.new( paired: true, public: public, private: public @@ -22,7 +22,7 @@ describe Metasploit::Framework::LoginScanner::SSH do } let(:pub_pri) { - Metasploit::Framework::LoginScanner::CredDetail.new( + Metasploit::Framework::LoginScanner::Credential.new( paired: true, public: public, private: private @@ -30,7 +30,7 @@ describe Metasploit::Framework::LoginScanner::SSH do } let(:invalid_detail) { - Metasploit::Framework::LoginScanner::CredDetail.new( + Metasploit::Framework::LoginScanner::Credential.new( paired: true, public: 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" 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] expect(ssh_scanner).to_not be_valid expect(ssh_scanner.errors[:cred_details]).to include "has invalid element 1"