Skip to content

Commit 733182e

Browse files
authored
Merge pull request #56 from dev-sec/chris-rock/unified-attributes
unified attributes
2 parents 79cad39 + a4b7178 commit 733182e

File tree

9 files changed

+128
-122
lines changed

9 files changed

+128
-122
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
22

33
gem 'highline', '~> 1.6.0'
44

5-
gem 'inspec', '~> 2.0.0'
5+
gem 'inspec', '~> 2'
66
gem 'rack', '1.6.4'
77
gem 'rake'
88
gem 'rubocop', '~> 0.49.0'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ InSpec is an open-source run-time framework and rule language used to specify co
1212

1313
## Requirements
1414

15-
* at least [InSpec](http://inspec.io/) version 1.38.8
15+
* at least [InSpec](http://inspec.io/) version 2.3.23
1616
* Docker 1.13+
1717

1818
### Platform

controls/container_images.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@
2323
title 'Container Images and Build File'
2424

2525
# attributes
26-
CONTAINER_USER = attribute(
27-
'container_user',
28-
description: 'define user within containers.',
29-
default: 'ubuntu'
30-
)
26+
CONTAINER_USER = attribute('container_user')
3127

3228
# check if docker exists
33-
only_if do
29+
only_if('docker not found') do
3430
command('docker').exist?
3531
end
3632

controls/container_runtime.rb

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,12 @@
2323
title 'Container Runtime'
2424

2525
# attributes
26-
CONTAINER_CAPADD = attribute(
27-
'container_capadd',
28-
description: 'define needed capabilities for containers.'
29-
)
30-
31-
APP_ARMOR_PROFILE = attribute(
32-
'app_armor_profile',
33-
description: 'define apparmor profile for Docker containers.',
34-
default: 'docker-default'
35-
)
36-
37-
SELINUX_PROFILE = attribute(
38-
'selinux_profile',
39-
description: 'define SELinux profile for Docker containers.',
40-
default: /label\:level\:s0-s0\:c1023/
41-
)
26+
CONTAINER_CAPADD = attribute('container_capadd')
27+
APP_ARMOR_PROFILE = attribute('app_armor_profile')
28+
SELINUX_PROFILE = attribute('selinux_profile')
4229

4330
# check if docker exists
44-
only_if do
31+
only_if('docker not found') do
4532
command('docker').exist?
4633
end
4734

controls/docker_daemon_configuration.rb

Lines changed: 11 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -23,68 +23,19 @@
2323
title 'Docker Daemon Configuration'
2424

2525
# attributes
26-
DAEMON_TLSCACERT = attribute(
27-
'daemon_tlscacert',
28-
description: 'Trust certs signed only by this CA',
29-
default: '/etc/docker/ssl/ca.pem'
30-
)
31-
32-
DAEMON_TLSCERT = attribute(
33-
'daemon_tlscert',
34-
description: 'Path to TLS certificate file',
35-
default: '/etc/docker/ssl/server_cert.pem'
36-
)
37-
38-
DAEMON_TLSKEY = attribute(
39-
'daemon_tlskey',
40-
description: 'Path to TLS key file',
41-
default: '/etc/docker/ssl/server_key.pem'
42-
)
43-
44-
AUTHORIZATION_PLUGIN = attribute(
45-
'authorization_plugin',
46-
description: 'define authorization plugin to manage access to Docker daemon.',
47-
default: 'authz-broker'
48-
)
49-
50-
LOG_DRIVER = attribute(
51-
'log_driver',
52-
description: 'define preferable way to store logs.',
53-
default: 'syslog'
54-
)
55-
56-
LOG_OPTS = attribute(
57-
'log_opts',
58-
description: 'define Docker daemon log-opts.',
59-
default: /syslog-address/
60-
)
61-
62-
SWARM_MODE = attribute(
63-
'swarm_mode',
64-
description: 'define the swarm mode, `active` or `inactive`',
65-
default: 'inactive'
66-
)
67-
68-
SWARM_MAX_MANAGER_NODES = attribute(
69-
'swarm_max_manager_nodes',
70-
description: 'number of manager nodes in a swarm',
71-
default: 3
72-
)
73-
74-
SWARM_PORT = attribute(
75-
'swarm_port',
76-
description: 'port of the swarm node',
77-
default: 2377
78-
)
79-
80-
SECCOMP_DEFAULT_PROFILE = attribute(
81-
'seccomp_default_profile',
82-
description: 'define the default seccomp profile',
83-
default: 'default'
84-
)
26+
DAEMON_TLSCACERT = attribute('daemon_tlscacert')
27+
DAEMON_TLSCERT = attribute('daemon_tlscert')
28+
DAEMON_TLSKEY = attribute('daemon_tlskey')
29+
AUTHORIZATION_PLUGIN = attribute('authorization_plugin')
30+
LOG_DRIVER = attribute('log_driver')
31+
LOG_OPTS = attribute('log_opts')
32+
SWARM_MODE = attribute('swarm_mode')
33+
SWARM_MAX_MANAGER_NODES = attribute('swarm_max_manager_nodes')
34+
SWARM_PORT = attribute('swarm_port')
35+
SECCOMP_DEFAULT_PROFILE = attribute('seccomp_default_profile')
8536

8637
# check if docker exists
87-
only_if do
38+
only_if('docker not found') do
8839
command('docker').exist?
8940
end
9041

controls/docker_daemon_configuration_files.rb

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,12 @@
2323
title 'Docker Daemon Configuration Files'
2424

2525
# attributes
26-
REGISTRY_CERT_PATH = attribute(
27-
'registry_cert_path',
28-
description: 'directory contains various Docker registry directories.',
29-
default: '/etc/docker/certs.d'
30-
)
31-
32-
REGISTRY_NAME = attribute(
33-
'registry_name',
34-
description: 'directory contain certificate certain Docker registry.',
35-
default: '/etc/docker/certs.d/registry_hostname:port'
36-
)
37-
38-
REGISTRY_CA_FILE = attribute(
39-
'registry_ca_file',
40-
description: 'certificate file for a certain Docker registry certificate files.',
41-
default: '/etc/docker/certs.d/registry_hostname:port/ca.crt'
42-
)
26+
REGISTRY_CERT_PATH = attribute('registry_cert_path')
27+
REGISTRY_NAME = attribute('registry_name')
28+
REGISTRY_CA_FILE = attribute('registry_ca_file')
4329

4430
# check if docker exists
45-
only_if do
31+
only_if('docker not found') do
4632
command('docker').exist?
4733
end
4834

controls/docker_security_operations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
title 'Docker Security Operations'
2424

2525
# check if docker exists
26-
only_if do
26+
only_if('docker not found') do
2727
command('docker').exist?
2828
end
2929

controls/host_configuration.rb

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,12 @@
2222

2323
title 'Host Configuration'
2424

25-
TRUSTED_USER = attribute(
26-
'trusted_user',
27-
description: 'define trusted user to control Docker daemon.',
28-
default: 'vagrant'
29-
)
30-
31-
MANAGEABLE_CONTAINER_NUMBER = attribute(
32-
'managable_container_number',
33-
description: 'keep number of containers on a host to a manageable total.',
34-
default: 25
35-
)
36-
37-
BENCHMARK_VERSION = attribute(
38-
'benchmark_version',
39-
description: 'to execute also the old controls from previous benchmarks. to execute the controls, define the value as 1.12.0',
40-
default: ''
41-
)
25+
TRUSTED_USER = attribute('trusted_user')
26+
MANAGEABLE_CONTAINER_NUMBER = attribute('managable_container_number')
27+
BENCHMARK_VERSION = attribute('benchmark_version')
4228

4329
# check if docker exists
44-
only_if do
30+
only_if('docker not found') do
4531
command('docker').exist?
4632
end
4733

inspec.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,103 @@ copyright_email: [email protected]
66
license: Apache-2.0
77
summary: An InSpec Compliance Profile for the CIS Docker Benchmark
88
version: 2.1.0
9+
inspec_version: '>= 2.3.23'
10+
attributes:
11+
- name: container_user
12+
required: false
13+
description: 'define user within containers.'
14+
default: 'ubuntu'
15+
type: string
16+
- name: container_capadd
17+
required: true
18+
description: 'define needed capabilities for containers.'
19+
type: string
20+
- name: app_armor_profile
21+
required: false
22+
description: 'define apparmor profile for Docker containers.'
23+
default: 'docker-default'
24+
type: string
25+
- name: selinux_profile
26+
required: false
27+
description: 'define SELinux profile for Docker containers.'
28+
default: label:level:s0-s0:c1023
29+
type: string
30+
- name: trusted_user
31+
required: false
32+
description: 'define trusted user to control Docker daemon.'
33+
default: vagrant
34+
type: string
35+
- name: managable_container_number
36+
required: true
37+
description: 'keep number of containers on a host to a manageable total.'
38+
default: 25
39+
type: numeric
40+
- name: benchmark_version
41+
required: true
42+
description: 'to execute also the old controls from previous benchmarks. to execute the controls, define the value as 1.12.0'
43+
type: string
44+
- name: registry_cert_path
45+
required: true
46+
description: 'directory contains various Docker registry directories.'
47+
default: '/etc/docker/certs.d'
48+
type: string
49+
- name: registry_name
50+
required: true
51+
description: 'directory contain certificate certain Docker registry.'
52+
default: '/etc/docker/certs.d/registry_hostname:port'
53+
type: string
54+
- name: registry_ca_file
55+
required: false
56+
description: 'directory contain certificate certain Docker registry.'
57+
default: '/etc/docker/certs.d/registry_hostname:port/ca.crt'
58+
type: string
59+
- name: daemon_tlscacert
60+
required: false
61+
description: 'Trust certs signed only by this CA'
62+
default: '/etc/docker/ssl/ca.pem'
63+
type: string
64+
- name: daemon_tlscert
65+
required: false
66+
description: 'Path to TLS certificate file'
67+
default: '/etc/docker/ssl/server_cert.pem'
68+
type: string
69+
- name: daemon_tlskey
70+
required: false
71+
description: 'Path to TLS key file'
72+
default: '/etc/docker/ssl/server_key.pem'
73+
type: string
74+
- name: authorization_plugin
75+
required: false
76+
description: 'define authorization plugin to manage access to Docker daemon.'
77+
default: 'authz-broker'
78+
type: string
79+
- name: log_driver
80+
required: false
81+
description: 'define preferable way to store logs.'
82+
default: 'syslog'
83+
type: string
84+
- name: log_opts
85+
required: false
86+
description: 'define Docker daemon log-opts.'
87+
default: syslog-address
88+
type: string
89+
- name: swarm_mode
90+
required: false
91+
description: 'define the swarm mode, `active` or `inactive`'
92+
default: inactive
93+
type: string
94+
- name: swarm_max_manager_nodes
95+
required: false
96+
description: 'number of manager nodes in a swarm'
97+
default: 3
98+
type: numeric
99+
- name: swarm_port
100+
required: false
101+
description: 'port of the swarm node'
102+
default: 2377
103+
type: numeric
104+
- name: seccomp_default_profile
105+
required: false
106+
description: 'define the default seccomp profile'
107+
default: 'default'
108+
type: string

0 commit comments

Comments
 (0)