From fe56166e27b97f3353e2c5f482eafe09b68ae7ac Mon Sep 17 00:00:00 2001 From: Jonathan Claudius Date: Fri, 19 Jan 2018 14:49:55 -0500 Subject: [PATCH 1/2] Bug fix for grades --- lib/ssh_scan/result.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ssh_scan/result.rb b/lib/ssh_scan/result.rb index 6b48d814..1427ded7 100644 --- a/lib/ssh_scan/result.rb +++ b/lib/ssh_scan/result.rb @@ -182,19 +182,19 @@ def set_compliance=(compliance) end def compliance_policy - @compliance[:policy] + @compliance["policy"] end def compliant? - @compliance[:compliant] + @compliance["compliant"] end def compliance_references - @compliance[:references] + @compliance["references"] end def compliance_recommendations - @compliance[:recommendations] + @compliance["recommendations"] end def set_client_attributes(client) From ceaabad172ca7db4b7986619de8beb3b723bf9b6 Mon Sep 17 00:00:00 2001 From: Jonathan Claudius Date: Fri, 19 Jan 2018 14:55:00 -0500 Subject: [PATCH 2/2] Fix bug/specs for grading --- lib/ssh_scan/result.rb | 4 ++-- spec/ssh_scan/grader_spec.rb | 36 ++++++++++++++++---------------- spec/ssh_scan/result_spec.rb | 40 ++++++++++++++++++------------------ 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib/ssh_scan/result.rb b/lib/ssh_scan/result.rb index 1427ded7..c0484598 100644 --- a/lib/ssh_scan/result.rb +++ b/lib/ssh_scan/result.rb @@ -220,11 +220,11 @@ def error end def grade=(grade) - @compliance[:grade] = grade + @compliance["grade"] = grade end def grade - @compliance[:grade] + @compliance["grade"] end def to_hash diff --git a/spec/ssh_scan/grader_spec.rb b/spec/ssh_scan/grader_spec.rb index 87ab65ba..28f2481c 100644 --- a/spec/ssh_scan/grader_spec.rb +++ b/spec/ssh_scan/grader_spec.rb @@ -6,9 +6,9 @@ it "should provide an F grade" do result = SSHScan::Result.new() result.set_compliance = { - :policy => "Test Result", - :compliant => false, - :recommendations => [ + "policy" => "Test Result", + "compliant" => false, + "recommendations" => [ "Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256", "Add these MAC Algos: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,umac-128@openssh.com", "Add these Encryption Ciphers: aes256-gcm@openssh.com,aes128-gcm@openssh.com", @@ -24,9 +24,9 @@ it "should provide an F grade" do result = SSHScan::Result.new() result.set_compliance = { - :policy => "Test Result", - :compliant => false, - :recommendations => [ + "policy" => "Test Result", + "compliant" => false, + "recommendations" => [ "Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256", "Add these MAC Algos: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,umac-128@openssh.com", "Add these Encryption Ciphers: aes256-gcm@openssh.com,aes128-gcm@openssh.com", @@ -40,9 +40,9 @@ it "should provide an D grade" do result = SSHScan::Result.new() result.set_compliance = { - :policy => "Test Result", - :compliant => false, - :recommendations => [ + "policy" => "Test Result", + "compliant" => false, + "recommendations" => [ "Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256", "Add these MAC Algos: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,umac-128@openssh.com", "Add these Encryption Ciphers: aes256-gcm@openssh.com,aes128-gcm@openssh.com", @@ -55,9 +55,9 @@ it "should provide an C grade" do result = SSHScan::Result.new() result.set_compliance = { - :policy => "Test Result", - :compliant => false, - :recommendations => [ + "policy" => "Test Result", + "compliant" => false, + "recommendations" => [ "Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256", "Add these MAC Algos: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,umac-128@openssh.com", ] @@ -69,9 +69,9 @@ it "should provide an B grade" do result = SSHScan::Result.new() result.set_compliance = { - :policy => "Test Result", - :compliant => false, - :recommendations => [ + "policy" => "Test Result", + "compliant" => false, + "recommendations" => [ "Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256", ] } @@ -82,9 +82,9 @@ it "should provide an A grade" do result = SSHScan::Result.new() result.set_compliance = { - :policy => "Test Result", - :compliant => false, - :recommendations => [ + "policy" => "Test Result", + "compliant" => false, + "recommendations" => [ ] } grader = SSHScan::Grader.new(result) diff --git a/spec/ssh_scan/result_spec.rb b/spec/ssh_scan/result_spec.rb index a7e76325..53c2824b 100644 --- a/spec/ssh_scan/result_spec.rb +++ b/spec/ssh_scan/result_spec.rb @@ -179,18 +179,18 @@ context "when setting compliance" do it "should allow setting of the compliance information" do compliance = { - :policy => "Test Policy", - :compliant => true, - :recommendations => ["do this", "do that"], - :references => ["https://reference.example.com"], + "policy" => "Test Policy", + "compliant" => true, + "recommendations" => ["do this", "do that"], + "references" => ["https://reference.example.com"], } result = SSHScan::Result.new() result.set_compliance = compliance - expect(result.compliance_policy).to eql(compliance[:policy]) - expect(result.compliant?).to eql(compliance[:compliant]) - expect(result.compliance_recommendations).to eql(compliance[:recommendations]) - expect(result.compliance_references).to eql(compliance[:references]) + expect(result.compliance_policy).to eql(compliance["policy"]) + expect(result.compliant?).to eql(compliance["compliant"]) + expect(result.compliance_recommendations).to eql(compliance["recommendations"]) + expect(result.compliance_references).to eql(compliance["references"]) expect(result.to_hash).to be_kind_of(Hash) end end @@ -198,19 +198,19 @@ context "when setting grade" do it "should allow setting of the grade information" do compliance = { - :policy => "Test Policy", - :compliant => true, - :recommendations => ["do this", "do that"], - :references => ["https://reference.example.com"], + "policy" => "Test Policy", + "compliant" => true, + "recommendations" => ["do this", "do that"], + "references" => ["https://reference.example.com"], } result = SSHScan::Result.new() result.set_compliance = compliance result.grade = "D" - expect(result.compliance_policy).to eql(compliance[:policy]) - expect(result.compliant?).to eql(compliance[:compliant]) - expect(result.compliance_recommendations).to eql(compliance[:recommendations]) - expect(result.compliance_references).to eql(compliance[:references]) + expect(result.compliance_policy).to eql(compliance["policy"]) + expect(result.compliant?).to eql(compliance["compliant"]) + expect(result.compliance_recommendations).to eql(compliance["recommendations"]) + expect(result.compliance_references).to eql(compliance["references"]) expect(result.grade).to eql("D") end end @@ -218,10 +218,10 @@ context "when dealing with errors" do it "should append errors " do compliance = { - :policy => "Test Policy", - :compliant => true, - :recommendations => ["do this", "do that"], - :references => ["https://reference.example.com"], + "policy" => "Test Policy", + "compliant" => true, + "recommendations" => ["do this", "do that"], + "references" => ["https://reference.example.com"], } result = SSHScan::Result.new() result.set_compliance = compliance