From 064d624322ddd4890ebd392bdffea80a61d353f8 Mon Sep 17 00:00:00 2001 From: darkbushido Date: Wed, 23 Jul 2014 16:17:09 -0500 Subject: [PATCH] changing Credential == operator it should no longer raise no method errors when comparing a credential to an object that doesnt respond to public, private, or realm --- lib/metasploit/framework/credential.rb | 4 +++- spec/lib/metasploit/framework/credential_spec.rb | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/metasploit/framework/credential.rb b/lib/metasploit/framework/credential.rb index be9cc0809b..800a526344 100644 --- a/lib/metasploit/framework/credential.rb +++ b/lib/metasploit/framework/credential.rb @@ -78,7 +78,9 @@ module Metasploit end def ==(other) - other.public == self.public && other.private == self.private && other.realm == self.realm + other.respond_to?(:public) && other.public == self.public && + other.respond_to?(:private) && other.private == self.private && + other.respond_to?(:realm) && other.realm == self.realm end def to_credential diff --git a/spec/lib/metasploit/framework/credential_spec.rb b/spec/lib/metasploit/framework/credential_spec.rb index 78f71673ac..2856966b96 100644 --- a/spec/lib/metasploit/framework/credential_spec.rb +++ b/spec/lib/metasploit/framework/credential_spec.rb @@ -132,6 +132,11 @@ describe Metasploit::Framework::Credential do expect(other).not_to eq(cred_detail) end end - + context "when comparing to a different object" do + let(:other) {'a string'} + specify do + expect(other).not_to eq(cred_detail) + end + end end end