Skip to content

Commit 2c91ecd

Browse files
authored
Merge pull request #26 from dev-sec/chris-rock/refactor
split up control files into components
2 parents 8baf8c9 + 1ca0490 commit 2c91ecd

File tree

7 files changed

+1365
-1282
lines changed

7 files changed

+1365
-1282
lines changed

controls/container_images.rb

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# encoding: utf-8
2+
# frozen_string_literal: true
3+
#
4+
# Copyright 2016, Patrick Muench
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# author: Christoph Hartmann
19+
# author: Dominik Richter
20+
# author: Patrick Muench
21+
22+
title 'Container Images and Build File'
23+
24+
# attributes
25+
CONTAINER_USER = attribute(
26+
'container_user',
27+
description: 'define user within containers. cis-docker-benchmark-4.1',
28+
default: 'ubuntu'
29+
)
30+
31+
# check if docker exists
32+
only_if do
33+
command('docker').exist?
34+
end
35+
36+
control 'cis-docker-benchmark-4.1' do
37+
impact 1.0
38+
title 'Create a user for the container'
39+
desc 'Create a non-root user for the container in the Dockerfile for the container image.'
40+
41+
tag 'daemon'
42+
tag cis: 'docker:4.1'
43+
tag level: 1
44+
ref url: 'https://github.com/docker/docker/issues/2918'
45+
ref url: 'https://github.com/docker/docker/pull/4572'
46+
ref url: 'https://github.com/docker/docker/issues/7906'
47+
ref url: 'https://www.altiscale.com/blog/making-docker-work-yarn/'
48+
49+
docker.ps.each do |id|
50+
describe docker.inspect(id) do
51+
its(%w(Config User)) { should eq CONTAINER_USER }
52+
its(%w(Config User)) { should_not eq nil }
53+
end
54+
end
55+
end
56+
57+
control 'cis-docker-benchmark-4.2' do
58+
impact 1.0
59+
title 'Use trusted base images for containers'
60+
desc 'Ensure that the container image is written either from scratch or is based on another established and trusted base image downloaded over a secure channel.'
61+
62+
tag 'daemon'
63+
tag cis: 'docker:4.2'
64+
tag level: 1
65+
ref url: 'https://titanous.com/posts/docker-insecurity'
66+
ref url: 'https://hub.docker.com/'
67+
ref url: 'https://blog.docker.com/2014/10/docker-1-3-signed-images-process-injection-security-options-mac-shared-directories/'
68+
ref url: 'https://github.com/docker/docker/issues/8093'
69+
ref url: 'https://docs.docker.com/engine/reference/commandline/cli/#pull'
70+
ref url: 'https://github.com/docker/docker/pull/11109'
71+
ref url: 'https://blog.docker.com/2015/11/docker-trusted-registry-1-4/'
72+
end
73+
74+
control 'cis-docker-benchmark-4.3' do
75+
impact 1.0
76+
title 'Do not install unnecessary packages in the container'
77+
desc 'Containers tend to be minimal and slim down versions of the Operating System. Do not install anything that does not justify the purpose of container.'
78+
79+
tag 'daemon'
80+
tag cis: 'docker:4.3'
81+
tag level: 1
82+
ref url: 'https://docs.docker.com/engine/userguide/containers/dockerimages/'
83+
ref url: 'http://www.livewyer.com/blog/2015/02/24/slimming-down-your-docker-containers-alpine-linux'
84+
ref url: 'https://github.com/progrium/busybox'
85+
end
86+
87+
control 'cis-docker-benchmark-4.4' do
88+
impact 1.0
89+
title 'Rebuild the images to include security patches'
90+
desc 'Instead of patching your containers and images, rebuild the images from scratch and instantiate new containers from it.'
91+
92+
tag 'daemon'
93+
tag cis: 'docker:4.4'
94+
tag level: 1
95+
ref url: 'https://docs.docker.com/engine/userguide/containers/dockerimages/'
96+
end
97+
98+
control 'cis-docker-benchmark-4.5' do
99+
impact 1.0
100+
title 'Enable Content trust for Docker'
101+
desc 'Content trust provides the ability to use digital signatures for data sent to and received from remote Docker registries. These signatures allow client-side verification of the integrity and publisher of specific image tags. This ensures provenance of container images. Content trust is disabled by default. You should enable it.'
102+
103+
tag 'daemon'
104+
tag cis: 'docker:4.5'
105+
tag level: 2
106+
ref 'https://docs.docker.com/engine/reference/commandline/cli/#notary'
107+
ref 'https://docs.docker.com/engine/reference/commandline/cli/#environment-variables'
108+
ref 'https://docs.docker.com/engine/security/trust/content_trust/'
109+
110+
describe os_env('DOCKER_CONTENT_TRUST') do
111+
its('content') { should eq '1' }
112+
end
113+
end

0 commit comments

Comments
 (0)