Skip to content

Commit ce6575a

Browse files
use input instead of attribute (#201)
* use input instead of attribute In the last versions of Inspec and cinc-auditor, attribute is deprecated and input should be used. https://docs.chef.io/workstation/cookstyle/inspec_deprecations_attributehelper/ Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com> * Update sshd_spec.rb Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com> * Update inspec.yml Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com> * Update Rakefile Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>
1 parent 8df0c50 commit ce6575a

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

Rakefile

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env rake
21
# frozen_string_literal: true
32

43
require 'rake/testtask'
@@ -26,24 +25,3 @@ namespace :test do
2625
pp profile.check
2726
end
2827
end
29-
30-
task :changelog do
31-
# Automatically generate a changelog for this project. Only loaded if
32-
# the necessary gem is installed. By default its picking up the version from
33-
# inspec.yml. You can override that behavior with `rake changelog to=1.2.0`
34-
35-
require 'yaml'
36-
metadata = YAML.load_file('inspec.yml')
37-
v = ENV['to'] || metadata['version']
38-
puts " * Generating changelog for version #{v}"
39-
require 'github_changelog_generator/task'
40-
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
41-
config.future_release = v
42-
config.user = 'dev-sec'
43-
config.project = 'ssh-baseline'
44-
end
45-
Rake::Task[:changelog].execute
46-
rescue LoadError
47-
puts '>>>>> GitHub Changelog Generator not loaded, omitting tasks'
48-
49-
end

controls/ssh_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
command('ssh').exist?
2525
end
2626

27-
ssh_custom_user = attribute('ssh_custom_user', value: 'root', description: 'The SSH user is not always root. It must be an unprivileged user in a container')
28-
ssh_custom_path = attribute('ssh_custom_path', value: '/etc/ssh', description: 'Sometimes ssh configuration files are present in another location and ssh use them with the -f flag')
27+
ssh_custom_user = input('ssh_custom_user', value: 'root', description: 'The SSH user is not always root. It must be an unprivileged user in a container')
28+
ssh_custom_path = input('ssh_custom_path', value: '/etc/ssh', description: 'Sometimes ssh configuration files are present in another location and ssh use them with the -f flag')
2929

3030
control 'ssh-01' do
3131
impact 1.0

controls/sshd_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@
2020

2121
title 'SSH server config'
2222

23-
sshd_valid_ciphers = attribute('sshd_valid_ciphers', value: ssh_crypto.valid_ciphers, description: 'Expected value for sshd_config ciphers')
24-
sshd_valid_kexs = attribute('sshd_valid_kexs', value: ssh_crypto.valid_kexs, description: 'Expected value for sshd_config kexs')
25-
sshd_valid_macs = attribute('sshd_valid_macs', value: ssh_crypto.valid_macs, description: 'Expected value for sshd_config macs')
26-
sshd_permittunnel = attribute('sshd_permittunnel', value: 'no', description: 'Expected value for sshd_config PermitTunnel')
27-
sshd_tcpforwarding = attribute('sshd_tcpforwarding', value: 'no', description: 'Expected value for sshd_config TcpForwarding')
28-
sshd_agentforwarding = attribute('sshd_agentforwarding', value: 'no', description: 'Expected value for sshd_config AgentForwarding')
29-
sshd_gatewayports = attribute('sshd_gatewayports', value: 'no', description: 'Expected value for sshd_config GatewayPorts')
30-
sshd_x11forwarding = attribute('sshd_x11forwarding', value: 'no', description: 'Expected value for sshd_config X11Forwarding')
31-
sshd_banner = attribute('sshd_banner', value: 'none', description: 'Expected value for sshd_config Banner')
32-
sshd_max_auth_tries = attribute('sshd_max_auth_tries', value: 2, description: 'Expected value for max_auth_retries')
33-
sshd_custom_user = attribute('sshd_custom_user', value: 'root', description: 'The SSH user is not always root. It must be an unprivileged user in a container')
34-
sshd_custom_path = attribute('sshd_custom_path', value: '/etc/ssh', description: 'Sometimes ssh configuration files are present in another location and ssh use them with the -f flag')
35-
sshd_custom_port = attribute('sshd_custom_port', value: '22', description: 'Sometimes the ssh port is not 22. For instance, in a container as another user, 22 is forbidden')
36-
sshd_custom_hostkeys_path = attribute('sshd_custom_hostkeys_path', value: '/etc/ssh', description: 'Sometimes ssh host keys must be in a particular path, in a clustered environment for instance')
23+
sshd_valid_ciphers = input('sshd_valid_ciphers', value: ssh_crypto.valid_ciphers, description: 'Expected value for sshd_config ciphers')
24+
sshd_valid_kexs = input('sshd_valid_kexs', value: ssh_crypto.valid_kexs, description: 'Expected value for sshd_config kexs')
25+
sshd_valid_macs = input('sshd_valid_macs', value: ssh_crypto.valid_macs, description: 'Expected value for sshd_config macs')
26+
sshd_permittunnel = input('sshd_permittunnel', value: 'no', description: 'Expected value for sshd_config PermitTunnel')
27+
sshd_tcpforwarding = input('sshd_tcpforwarding', value: 'no', description: 'Expected value for sshd_config TcpForwarding')
28+
sshd_agentforwarding = input('sshd_agentforwarding', value: 'no', description: 'Expected value for sshd_config AgentForwarding')
29+
sshd_gatewayports = input('sshd_gatewayports', value: 'no', description: 'Expected value for sshd_config GatewayPorts')
30+
sshd_x11forwarding = input('sshd_x11forwarding', value: 'no', description: 'Expected value for sshd_config X11Forwarding')
31+
sshd_banner = input('sshd_banner', value: 'none', description: 'Expected value for sshd_config Banner')
32+
sshd_max_auth_tries = input('sshd_max_auth_tries', value: 2, description: 'Expected value for max_auth_retries')
33+
sshd_custom_user = input('sshd_custom_user', value: 'root', description: 'The SSH user is not always root. It must be an unprivileged user in a container')
34+
sshd_custom_path = input('sshd_custom_path', value: '/etc/ssh', description: 'Sometimes ssh configuration files are present in another location and ssh use them with the -f flag')
35+
sshd_custom_port = input('sshd_custom_port', value: '22', description: 'Sometimes the ssh port is not 22. For instance, in a container as another user, 22 is forbidden')
36+
sshd_custom_hostkeys_path = input('sshd_custom_hostkeys_path', value: '/etc/ssh', description: 'Sometimes ssh host keys must be in a particular path, in a clustered environment for instance')
3737

3838
sshd_valid_privseparation = if sshd_custom_user != 'root'
3939
'no'

inspec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ copyright: DevSec Hardening Framework Team
66
copyright_email: hello@dev-sec.io
77
license: Apache-2.0
88
summary: Test-suite for best-practice SSH hardening
9+
inspec_version: '>= 4.6.3'
910
version: 2.7.0
1011
supports:
1112
- os-family: unix

0 commit comments

Comments
 (0)