Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider human-readable, re-usable assertions #2

Open
brucellino opened this issue Apr 10, 2018 · 0 comments
Open

Consider human-readable, re-usable assertions #2

brucellino opened this issue Apr 10, 2018 · 0 comments

Comments

@brucellino
Copy link
Contributor

Hello !

Nice work on Secant ! I would like to make a suggestion to make it easier for people to check their applications before pushing to the AppDB. You could use TestInfra or even better InSpec.

For example implement the SSH assertion as follows :

With TestInfra (:snake:)

def ssh_password_test(host): 
  f = host.file('{{ sshd_config_path }}/{{ sshd_config }}`)

    assert sshd_config_file.exists
    assert not sshd_config_file.contains('PasswordAuthentication no')

Similarly with InSpec (:gem:)

title 'SSHD configuration'

# you add controls here
control 'ssh_config' do                        # A unique ID for this control
  impact 0.7                                # The criticality, if this control fails.
  title 'SSH password authentication'             # A human-readable title
  desc 'SSH server should be configured to not use password authentication'
  describe file('/etc/ssh') do                  # The actual test
    it { should be_directory }
  end
  
  describe file('/etc/ssh/sshd_config') do
    it { should be_file }
  end

  describe sshd_config('/etc/ssh/sshd_config') do
    its('PasswordAuthentication') { should be_in ["no", nil] }
  end
end

Would you be amenable to a PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant