Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/ssh_crypto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def valid_algorithms # rubocop:disable Metrics/CyclomaticComplexity

# returns the hostkeys value based on valid_algorithms
def valid_hostkeys
hostkeys = valid_algorithms.map { |alg| "#{sshd_custom_path}/ssh_host_#{alg}_key" }
hostkeys = valid_algorithms.map { |alg| "#{inspec.input('sshd_custom_path')}/ssh_host_#{alg}_key" }
Copy link
Member

@chris-rock chris-rock May 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since only one test is affected we should probably move that logic directly to the control:

control 'sshd-14' do
impact 1.0
title 'Server: Specify SSH HostKeys'
desc 'Specify HostKey for protection against Man-In-The-Middle Attacks'
describe sshd_config(sshd_custom_path + '/sshd_config') do
its('HostKey') { should cmp ssh_crypto.valid_hostkeys }
end
end

It will also be easier for the reader of the control to understand what the control is actually doing

# its('HostKey') provides a string for a single-element value.
# we have to return a string if we have a single-element
# https://github.com/chef/inspec/issues/1434
Expand Down