inspec 1.0.0 → 1.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +933 -101
- data/Gemfile +8 -17
- data/MAINTAINERS.md +2 -1
- data/MAINTAINERS.toml +9 -4
- data/README.md +49 -28
- data/Rakefile +54 -39
- data/bin/inspec +1 -1
- data/docs/dsl_inspec.md +17 -4
- data/docs/dsl_resource.md +1 -1
- data/docs/habitat.md +192 -0
- data/docs/inspec_and_friends.md +4 -2
- data/docs/matchers.md +11 -0
- data/docs/migration.md +293 -0
- data/docs/profiles.md +124 -76
- data/docs/resources/aide_conf.md.erb +81 -0
- data/docs/resources/apache_conf.md.erb +10 -10
- data/docs/resources/apt.md.erb +13 -13
- data/docs/resources/audit_policy.md.erb +10 -10
- data/docs/resources/auditd_conf.md.erb +10 -10
- data/docs/resources/auditd_rules.md.erb +11 -11
- data/docs/resources/bash.md.erb +12 -12
- data/docs/resources/bond.md.erb +15 -15
- data/docs/resources/bridge.md.erb +11 -11
- data/docs/resources/bsd_service.md.erb +11 -11
- data/docs/resources/command.md.erb +23 -23
- data/docs/resources/crontab.md.erb +84 -0
- data/docs/resources/csv.md.erb +10 -10
- data/docs/resources/dh_params.md +191 -0
- data/docs/resources/directory.md.erb +8 -8
- data/docs/resources/docker.md.erb +160 -0
- data/docs/resources/docker_container.md.erb +89 -0
- data/docs/resources/docker_image.md.erb +86 -0
- data/docs/resources/etc_group.md.erb +16 -16
- data/docs/resources/etc_hosts.md.erb +62 -0
- data/docs/resources/file.md.erb +80 -58
- data/docs/resources/gem.md.erb +32 -13
- data/docs/resources/group.md.erb +12 -12
- data/docs/resources/grub_conf.md.erb +11 -11
- data/docs/resources/host.md.erb +27 -18
- data/docs/resources/http.md.erb +104 -0
- data/docs/resources/iis_app.md.erb +126 -0
- data/docs/resources/iis_site.md.erb +17 -17
- data/docs/resources/inetd_conf.md.erb +10 -10
- data/docs/resources/ini.md.erb +9 -9
- data/docs/resources/interface.md.erb +13 -13
- data/docs/resources/iptables.md.erb +21 -14
- data/docs/resources/json.md.erb +11 -11
- data/docs/resources/kernel_module.md.erb +73 -12
- data/docs/resources/kernel_parameter.md.erb +12 -12
- data/docs/resources/key_rsa.md.erb +70 -0
- data/docs/resources/launchd_service.md.erb +11 -11
- data/docs/resources/limits_conf.md.erb +10 -10
- data/docs/resources/login_def.md.erb +12 -12
- data/docs/resources/mount.md.erb +14 -14
- data/docs/resources/mssql_session.md.erb +62 -0
- data/docs/resources/mysql_conf.md.erb +14 -14
- data/docs/resources/mysql_session.md.erb +22 -10
- data/docs/resources/npm.md.erb +13 -13
- data/docs/resources/ntp_conf.md.erb +9 -9
- data/docs/resources/oneget.md.erb +11 -11
- data/docs/resources/oracledb_session.md.erb +53 -0
- data/docs/resources/os.md.erb +17 -17
- data/docs/resources/os_env.md.erb +12 -12
- data/docs/resources/package.md.erb +29 -16
- data/docs/resources/parse_config.md.erb +18 -18
- data/docs/resources/parse_config_file.md.erb +29 -23
- data/docs/resources/{etc_passwd.md.erb → passwd.md.erb} +17 -17
- data/docs/resources/pip.md.erb +15 -15
- data/docs/resources/port.md.erb +23 -23
- data/docs/resources/postgres_conf.md.erb +15 -13
- data/docs/resources/postgres_hba_conf.md.erb +104 -0
- data/docs/resources/postgres_ident_conf.md.erb +87 -0
- data/docs/resources/postgres_session.md.erb +28 -21
- data/docs/resources/powershell.md.erb +14 -14
- data/docs/resources/processes.md.erb +123 -0
- data/docs/resources/rabbitmq_config.md.erb +55 -0
- data/docs/resources/registry_key.md.erb +44 -21
- data/docs/resources/runit_service.md.erb +11 -11
- data/docs/resources/security_policy.md.erb +10 -10
- data/docs/resources/service.md.erb +18 -18
- data/docs/resources/{etc_shadow.md.erb → shadow.md.erb} +19 -19
- data/docs/resources/ssh_config.md.erb +13 -13
- data/docs/resources/sshd_config.md.erb +15 -15
- data/docs/resources/ssl.md.erb +13 -13
- data/docs/resources/sys_info.md.erb +10 -10
- data/docs/resources/systemd_service.md.erb +11 -11
- data/docs/resources/sysv_service.md.erb +11 -11
- data/docs/resources/upstart_service.md.erb +11 -11
- data/docs/resources/user.md.erb +20 -20
- data/docs/resources/users.md.erb +19 -19
- data/docs/resources/vbscript.md.erb +13 -13
- data/docs/resources/virtualization.md.erb +71 -0
- data/docs/resources/windows_feature.md.erb +10 -10
- data/docs/resources/windows_task.md.erb +103 -0
- data/docs/resources/wmi.md.erb +10 -10
- data/docs/resources/x509_certificate.md.erb +146 -0
- data/docs/resources/xinetd_conf.md.erb +17 -17
- data/docs/resources/xml.md.erb +75 -0
- data/docs/resources/yaml.md.erb +25 -11
- data/docs/resources/yum.md.erb +24 -16
- data/docs/resources/zfs_dataset.md.erb +63 -0
- data/docs/resources/zfs_pool.md.erb +57 -0
- data/docs/ruby_usage.md +50 -0
- data/docs/shared/matcher_cmp.md.erb +4 -6
- data/examples/inheritance/README.md +49 -3
- data/examples/inheritance/controls/example.rb +4 -1
- data/examples/inheritance/inspec.yml +3 -1
- data/examples/meta-profile/README.md +29 -3
- data/examples/meta-profile/controls/example.rb +10 -5
- data/examples/meta-profile/inspec.yml +4 -8
- data/examples/profile/README.md +1 -1
- data/examples/profile/controls/example.rb +0 -1
- data/examples/profile/controls/gordon.rb +0 -1
- data/examples/profile/inspec.yml +1 -1
- data/examples/profile-attribute/inspec.yml +1 -1
- data/examples/profile-sensitive/README.md +29 -0
- data/examples/profile-sensitive/controls/sensitive-failures.rb +9 -0
- data/examples/profile-sensitive/controls/sensitive.rb +9 -0
- data/examples/profile-sensitive/inspec.yml +8 -0
- data/inspec.gemspec +10 -2
- data/lib/bundles/inspec-artifact/README.md +1 -0
- data/lib/bundles/inspec-artifact/cli.rb +284 -0
- data/lib/bundles/inspec-artifact.rb +7 -0
- data/lib/bundles/inspec-compliance/README.md +44 -15
- data/lib/bundles/inspec-compliance/api.rb +135 -29
- data/lib/bundles/inspec-compliance/cli.rb +128 -21
- data/lib/bundles/inspec-compliance/configuration.rb +8 -0
- data/lib/bundles/inspec-compliance/http.rb +26 -19
- data/lib/bundles/inspec-compliance/target.rb +50 -25
- data/lib/bundles/inspec-habitat/cli.rb +31 -0
- data/lib/bundles/inspec-habitat/log.rb +10 -0
- data/lib/bundles/inspec-habitat/profile.rb +372 -0
- data/lib/bundles/inspec-habitat.rb +12 -0
- data/lib/bundles/inspec-init/templates/profile/controls/example.rb +0 -1
- data/lib/bundles/inspec-init/templates/profile/inspec.yml +1 -1
- data/lib/bundles/inspec-supermarket/api.rb +7 -5
- data/lib/bundles/inspec-supermarket/cli.rb +2 -2
- data/lib/fetchers/git.rb +4 -2
- data/lib/fetchers/local.rb +4 -1
- data/lib/fetchers/url.rb +64 -10
- data/lib/inspec/archive/tar.rb +1 -1
- data/lib/inspec/backend.rb +26 -3
- data/lib/inspec/base_cli.rb +44 -7
- data/lib/inspec/cached_fetcher.rb +2 -2
- data/lib/inspec/cli.rb +34 -12
- data/lib/inspec/completions/fish.sh.erb +34 -0
- data/lib/inspec/control_eval_context.rb +0 -2
- data/lib/inspec/dependencies/cache.rb +0 -1
- data/lib/inspec/dependencies/dependency_set.rb +2 -2
- data/lib/inspec/dependencies/lockfile.rb +13 -6
- data/lib/inspec/dependencies/requirement.rb +6 -6
- data/lib/inspec/dependencies/resolver.rb +4 -4
- data/lib/inspec/dsl.rb +3 -5
- data/lib/inspec/env_printer.rb +9 -1
- data/lib/inspec/exceptions.rb +8 -0
- data/lib/inspec/fetcher.rb +1 -1
- data/lib/inspec/file_provider.rb +47 -11
- data/lib/inspec/library_eval_context.rb +1 -1
- data/lib/inspec/metadata.rb +62 -18
- data/lib/inspec/method_source.rb +24 -0
- data/lib/inspec/objects/attribute.rb +21 -0
- data/lib/inspec/objects/control.rb +21 -3
- data/lib/inspec/objects/each_loop.rb +2 -1
- data/lib/inspec/objects/list.rb +1 -1
- data/lib/inspec/objects/or_test.rb +17 -2
- data/lib/inspec/objects/tag.rb +27 -0
- data/lib/inspec/objects/test.rb +9 -8
- data/lib/inspec/objects.rb +1 -0
- data/lib/inspec/plugins/fetcher.rb +4 -5
- data/lib/inspec/plugins/resource.rb +1 -2
- data/lib/inspec/plugins/source_reader.rb +3 -3
- data/lib/inspec/plugins.rb +1 -1
- data/lib/inspec/polyfill.rb +0 -1
- data/lib/inspec/profile.rb +92 -23
- data/lib/inspec/profile_context.rb +1 -1
- data/lib/inspec/profile_vendor.rb +66 -0
- data/lib/inspec/resource.rb +29 -3
- data/lib/inspec/rspec_json_formatter.rb +672 -285
- data/lib/inspec/rule.rb +12 -16
- data/lib/inspec/runner.rb +26 -15
- data/lib/inspec/runner_rspec.rb +1 -0
- data/lib/inspec/runtime_profile.rb +26 -0
- data/lib/inspec/schema.rb +185 -0
- data/lib/inspec/secrets/yaml.rb +8 -1
- data/lib/inspec/secrets.rb +1 -1
- data/lib/inspec/shell.rb +92 -22
- data/lib/inspec/source_reader.rb +1 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/inspec.rb +1 -1
- data/lib/matchers/matchers.rb +67 -17
- data/lib/resources/aide_conf.rb +162 -0
- data/lib/resources/apache.rb +0 -1
- data/lib/resources/apache_conf.rb +3 -3
- data/lib/resources/apt.rb +2 -1
- data/lib/resources/audit_policy.rb +0 -1
- data/lib/resources/auditd_conf.rb +1 -2
- data/lib/resources/auditd_rules.rb +5 -5
- data/lib/resources/bond.rb +1 -1
- data/lib/resources/bridge.rb +1 -1
- data/lib/resources/command.rb +5 -3
- data/lib/resources/crontab.rb +102 -0
- data/lib/resources/csv.rb +18 -1
- data/lib/resources/dh_params.rb +84 -0
- data/lib/resources/directory.rb +7 -3
- data/lib/resources/docker.rb +198 -0
- data/lib/resources/docker_container.rb +114 -0
- data/lib/resources/docker_image.rb +96 -0
- data/lib/resources/etc_group.rb +2 -3
- data/lib/resources/etc_hosts.rb +81 -0
- data/lib/resources/file.rb +88 -30
- data/lib/resources/gem.rb +26 -6
- data/lib/resources/groups.rb +4 -5
- data/lib/resources/grub_conf.rb +3 -4
- data/lib/resources/host.rb +175 -35
- data/lib/resources/http.rb +73 -0
- data/lib/resources/iis_app.rb +103 -0
- data/lib/resources/iis_site.rb +23 -0
- data/lib/resources/inetd_conf.rb +9 -4
- data/lib/resources/interface.rb +4 -3
- data/lib/resources/json.rb +37 -14
- data/lib/resources/kernel_module.rb +77 -10
- data/lib/resources/kernel_parameter.rb +0 -1
- data/lib/resources/key_rsa.rb +67 -0
- data/lib/resources/limits_conf.rb +3 -4
- data/lib/resources/login_def.rb +2 -3
- data/lib/resources/mount.rb +34 -4
- data/lib/resources/mssql_session.rb +81 -12
- data/lib/resources/mysql.rb +0 -1
- data/lib/resources/mysql_conf.rb +1 -2
- data/lib/resources/mysql_session.rb +18 -7
- data/lib/resources/nginx_conf.rb +95 -0
- data/lib/resources/ntp_conf.rb +2 -3
- data/lib/resources/oracledb_session.rb +138 -0
- data/lib/resources/os_env.rb +7 -5
- data/lib/resources/package.rb +70 -13
- data/lib/resources/packages.rb +111 -0
- data/lib/resources/parse_config.rb +3 -4
- data/lib/resources/passwd.rb +4 -5
- data/lib/resources/pip.rb +29 -21
- data/lib/resources/port.rb +133 -14
- data/lib/resources/postgres.rb +53 -43
- data/lib/resources/postgres_conf.rb +40 -13
- data/lib/resources/postgres_hba_conf.rb +101 -0
- data/lib/resources/postgres_ident_conf.rb +79 -0
- data/lib/resources/postgres_session.rb +28 -20
- data/lib/resources/powershell.rb +2 -2
- data/lib/resources/processes.rb +61 -26
- data/lib/resources/rabbitmq_conf.rb +53 -0
- data/lib/resources/registry_key.rb +34 -11
- data/lib/resources/security_policy.rb +2 -2
- data/lib/resources/service.rb +17 -7
- data/lib/resources/ssh_conf.rb +17 -6
- data/lib/resources/ssl.rb +3 -4
- data/lib/resources/sys_info.rb +1 -1
- data/lib/resources/toml.rb +26 -0
- data/lib/resources/users.rb +41 -41
- data/lib/resources/virtualization.rb +252 -0
- data/lib/resources/windows_task.rb +106 -0
- data/lib/resources/x509_certificate.rb +143 -0
- data/lib/resources/xinetd.rb +18 -2
- data/lib/resources/xml.rb +27 -0
- data/lib/resources/yaml.rb +10 -2
- data/lib/resources/yum.rb +25 -7
- data/lib/resources/zfs_dataset.rb +60 -0
- data/lib/resources/zfs_pool.rb +49 -0
- data/lib/source_readers/flat.rb +2 -1
- data/lib/source_readers/inspec.rb +30 -11
- data/lib/utils/command_wrapper.rb +3 -3
- data/lib/utils/database_helpers.rb +77 -0
- data/lib/utils/erlang_parser.rb +192 -0
- data/lib/utils/filter.rb +2 -1
- data/lib/utils/filter_array.rb +0 -1
- data/lib/utils/find_files.rb +1 -2
- data/lib/utils/latest_version.rb +21 -0
- data/lib/utils/nginx_parser.rb +76 -0
- data/lib/utils/object_traversal.rb +5 -4
- data/lib/utils/parser.rb +23 -4
- data/lib/utils/plugin_registry.rb +3 -3
- data/lib/utils/simpleconfig.rb +25 -8
- data/lib/utils/spdx.rb +13 -0
- data/lib/utils/spdx.txt +344 -0
- metadata +168 -22
- data/docs/cli.md +0 -342
- data/docs/resources/process.md.erb +0 -73
- /data/docs/{plugin_kitchen_inspec.html.md → plugin_kitchen_inspec.md} +0 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the docker Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# docker
|
|
6
|
+
|
|
7
|
+
Use the `docker` InSpec audit resource to test configuration data for docker daemon. It is a very comprehensive resource. Please have a look at [docker_container](docker_container) and [docker_image](docker_image), too.
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
A `docker` resource block declares allows you to write test for many containers:
|
|
12
|
+
|
|
13
|
+
describe docker.containers do
|
|
14
|
+
its('images') { should_not include 'u12:latest' }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
or:
|
|
18
|
+
|
|
19
|
+
describe docker.containers.where { name == 'flamboyant_colden' } do
|
|
20
|
+
it { should be_running }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
where
|
|
24
|
+
|
|
25
|
+
* `.where()` may specify a specific item and value, to which the matchers are compared
|
|
26
|
+
* `commands`, `ids`, `images`, `labels`, `local_volumes`, `mounts`, `names`, `networks`, `ports`, `sizes` and `'status'` are valid matchers for `containers`
|
|
27
|
+
|
|
28
|
+
The `docker` resource block also declares allows you to write test for many images:
|
|
29
|
+
|
|
30
|
+
describe docker.images do
|
|
31
|
+
its('repositories') { should_not include 'inssecure_image' }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
or if you want to query specific images:
|
|
35
|
+
|
|
36
|
+
describe docker.images.where { repository == 'ubuntu' && tag == '12.04' } do
|
|
37
|
+
it { should_not exist }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
where
|
|
41
|
+
|
|
42
|
+
* `.where()` may specify a specific item and value, to which the matchers are compared
|
|
43
|
+
* `commands`, `ids`, `images`, `labels`, `local_volumes`, `mounts`, `names`, `networks`, `ports`, `sizes` and `'status'` are valid matchers for `containers`
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Matchers
|
|
48
|
+
|
|
49
|
+
This InSpec audit resource has the following matchers:
|
|
50
|
+
|
|
51
|
+
### containers
|
|
52
|
+
|
|
53
|
+
`containers` returns information about containers as returned by [docker ps -a](https://docs.docker.com/engine/reference/commandline/ps/). You can determine specific information about
|
|
54
|
+
|
|
55
|
+
describe docker.containers do
|
|
56
|
+
its('ids') { should include 'sha:71b5df59...442b' }
|
|
57
|
+
its('commands') { should_not include '/bin/sh' }
|
|
58
|
+
its('images') { should_not include 'u12:latest' }
|
|
59
|
+
its('ports') { should include '0.0.0.0:1234->1234/tcp' }
|
|
60
|
+
its('labels') { should include 'License=GPLv2,Vendor=CentOS' }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### images
|
|
65
|
+
|
|
66
|
+
`images` returns information about docker image as returned by [docker images](https://docs.docker.com/engine/reference/commandline/images/). You can determine specific information about
|
|
67
|
+
|
|
68
|
+
describe docker.images do
|
|
69
|
+
its('ids') { should include 'sha:12b5df59...442b' }
|
|
70
|
+
its('repositories') { should_not include 'my_image' }
|
|
71
|
+
its('tags') { should_not include 'unwanted_tag' }
|
|
72
|
+
its('sizes') { should_not include "1.41 GB" }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
### version
|
|
76
|
+
|
|
77
|
+
`info` returns the parsed result of [docker version](https://docs.docker.com/engine/reference/commandline/version/)
|
|
78
|
+
|
|
79
|
+
describe docker.version do
|
|
80
|
+
its('Server.Version') { should cmp >= '1.12'}
|
|
81
|
+
its('Client.Version') { should cmp >= '1.12'}
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### info
|
|
86
|
+
|
|
87
|
+
`info` returns the parsed result of [docker info](https://docs.docker.com/engine/reference/commandline/info/)
|
|
88
|
+
|
|
89
|
+
describe docker.info do
|
|
90
|
+
its('Configuration.Path') { should eq 'value' }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
### object('id')
|
|
95
|
+
|
|
96
|
+
`object` returns low-level information about docker objects. It is calling [docker inspect](https://docs.docker.com/engine/reference/commandline/info/) under the hood.
|
|
97
|
+
|
|
98
|
+
describe docker.object(id) do
|
|
99
|
+
its('Configuration.Path') { should eq 'value' }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
## Examples
|
|
104
|
+
|
|
105
|
+
The following examples show how to use this InSpec audit resource.
|
|
106
|
+
|
|
107
|
+
### Return all running containers
|
|
108
|
+
|
|
109
|
+
docker.containers.running?.ids.each do |id|
|
|
110
|
+
describe docker.object(id) do
|
|
111
|
+
its('State.Health.Status') { should eq 'healthy' }
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
### Verify a Docker Server and Client version
|
|
116
|
+
|
|
117
|
+
describe docker.version do
|
|
118
|
+
its('Server.Version') { should cmp >= '1.12'}
|
|
119
|
+
its('Client.Version') { should cmp >= '1.12'}
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
### Iterate over all containers to verify host coniguration
|
|
123
|
+
|
|
124
|
+
docker.containers.ids.each do |id|
|
|
125
|
+
# call docker inspect for a specific container id
|
|
126
|
+
describe docker.object(id) do
|
|
127
|
+
its(%w(HostConfig Privileged)) { should cmp false }
|
|
128
|
+
its(%w(HostConfig Privileged)) { should_not cmp true }
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
### Iterate over all images to verify the container was built without ADD instruction
|
|
133
|
+
|
|
134
|
+
docker.images.ids.each do |id|
|
|
135
|
+
describe command("docker history #{id}| grep 'ADD'") do
|
|
136
|
+
its('stdout') { should eq '' }
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
### Verify that health-checks are enabled for a container
|
|
141
|
+
|
|
142
|
+
describe docker.object('71b5df59442b') do
|
|
143
|
+
its(%w(Config Healthcheck)) { should_not eq nil }
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
### Run the DevSec docker baseline profile
|
|
147
|
+
|
|
148
|
+
There are two ways to run the `docker-baseline` profile to test Docker via the `docker` resource.
|
|
149
|
+
|
|
150
|
+
Clone the profile:
|
|
151
|
+
|
|
152
|
+
$ git clone https://github.com/dev-sec/cis-docker-benchmark.git
|
|
153
|
+
|
|
154
|
+
and then run:
|
|
155
|
+
|
|
156
|
+
$ inspec exec cis-docker-benchmark
|
|
157
|
+
|
|
158
|
+
Or execute the profile directly via URL:
|
|
159
|
+
|
|
160
|
+
$ inspec exec https://github.com/dev-sec/cis-docker-benchmark
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the docker_container Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# docker_container
|
|
6
|
+
|
|
7
|
+
Use the `docker_container` InSpec audit resource to test a docker container.
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
A `docker_container` resource block declares the configuration data to be tested:
|
|
12
|
+
|
|
13
|
+
describe docker_container('container') do
|
|
14
|
+
it { should exist }
|
|
15
|
+
it { should be_running }
|
|
16
|
+
its('id') { should_not eq '' }
|
|
17
|
+
its('image') { should eq 'busybox:latest' }
|
|
18
|
+
its('repo') { should eq 'busybox' }
|
|
19
|
+
its('tag') { should eq 'latest' }
|
|
20
|
+
its('ports') { should eq [] }
|
|
21
|
+
its('command') { should eq 'nc -ll -p 1234 -e /bin/cat' }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
The container name can also be passed with the `name` argument:
|
|
25
|
+
|
|
26
|
+
describe docker_container(name: 'an-echo-server') do
|
|
27
|
+
it { should exist }
|
|
28
|
+
it { should be_running }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Alternatively, you can pass in the container id:
|
|
32
|
+
|
|
33
|
+
describe docker_container(id: '71b5df59442b') do
|
|
34
|
+
it { should exist }
|
|
35
|
+
it { should be_running }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Matchers
|
|
40
|
+
|
|
41
|
+
This InSpec audit resource has the following matchers:
|
|
42
|
+
|
|
43
|
+
### id
|
|
44
|
+
|
|
45
|
+
The `id` matcher tests the container id:
|
|
46
|
+
|
|
47
|
+
its('id') { should eq 'sha:71b5df59...442b' }
|
|
48
|
+
|
|
49
|
+
### repo
|
|
50
|
+
|
|
51
|
+
The `repo` matcher tests the value of the image repository:
|
|
52
|
+
|
|
53
|
+
its('repo') { should eq 'busybox' }
|
|
54
|
+
|
|
55
|
+
### tag
|
|
56
|
+
|
|
57
|
+
The `tag` matcher tests the value of the image tag:
|
|
58
|
+
|
|
59
|
+
its('tag') { should eq 'latest' }
|
|
60
|
+
|
|
61
|
+
### ports
|
|
62
|
+
|
|
63
|
+
The `ports` matcher tests the value the docker ports:
|
|
64
|
+
|
|
65
|
+
its('ports') { should eq '0.0.0.0:1234->1234/tcp' }
|
|
66
|
+
|
|
67
|
+
### command
|
|
68
|
+
|
|
69
|
+
The `command` matcher tests the value of the container run command:
|
|
70
|
+
|
|
71
|
+
its('command') { should eq 'nc -ll -p 1234 -e /bin/cat' }
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
The following examples show how to use this InSpec resource.
|
|
77
|
+
|
|
78
|
+
### Verify an running container:
|
|
79
|
+
|
|
80
|
+
describe docker_container('an-echo-server') do
|
|
81
|
+
it { should exist }
|
|
82
|
+
it { should be_running }
|
|
83
|
+
its('id') { should_not eq '' }
|
|
84
|
+
its('image') { should eq 'busybox:latest' }
|
|
85
|
+
its('repo') { should eq 'busybox' }
|
|
86
|
+
its('tag') { should eq 'latest' }
|
|
87
|
+
its('ports') { should eq [] }
|
|
88
|
+
its('command') { should eq 'nc -ll -p 1234 -e /bin/cat' }
|
|
89
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the docker_image Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# docker_image
|
|
6
|
+
|
|
7
|
+
Use the `docker_image` InSpec audit resource to verify a docker image.
|
|
8
|
+
|
|
9
|
+
## Syntax
|
|
10
|
+
|
|
11
|
+
A `docker_image` resource block declares the image:
|
|
12
|
+
|
|
13
|
+
describe docker_image('alpine:latest') do
|
|
14
|
+
it { should exist }
|
|
15
|
+
its('id') { should eq 'sha256:4a415e...a526' }
|
|
16
|
+
its('repo') { should eq 'alpine' }
|
|
17
|
+
its('tag') { should eq 'latest' }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
The resource allows you to pass in an image id:
|
|
21
|
+
|
|
22
|
+
describe docker_image(id: alpine_id) do
|
|
23
|
+
...
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
If the tag is missing for an image, `latest` is assumed as default:
|
|
27
|
+
|
|
28
|
+
describe docker_image('alpine') do
|
|
29
|
+
...
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
You can also pass in repository and tag as separate values
|
|
33
|
+
|
|
34
|
+
describe docker_image(repo: 'alpine', tag: 'latest') do
|
|
35
|
+
...
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Matchers
|
|
40
|
+
|
|
41
|
+
This InSpec audit resource has the following matchers:
|
|
42
|
+
|
|
43
|
+
### exist
|
|
44
|
+
|
|
45
|
+
The `exist` matcher tests if the image is available on the node:
|
|
46
|
+
|
|
47
|
+
it { should exist }
|
|
48
|
+
|
|
49
|
+
### id
|
|
50
|
+
|
|
51
|
+
The `id` matcher returns the full image id:
|
|
52
|
+
|
|
53
|
+
its('id') { should eq 'sha256:4a415e3663882fbc554ee830889c68a33b3585503892cc718a4698e91ef2a526' }
|
|
54
|
+
|
|
55
|
+
### image
|
|
56
|
+
|
|
57
|
+
The `image` matcher tests the value of the image. It is a combination of `repository/tag`:
|
|
58
|
+
|
|
59
|
+
its('image') { should eq 'alpine:latest' }
|
|
60
|
+
|
|
61
|
+
### repo
|
|
62
|
+
|
|
63
|
+
The `repo` matcher tests the value of the repository name:
|
|
64
|
+
|
|
65
|
+
its('repo') { should eq 'alpine' }
|
|
66
|
+
|
|
67
|
+
### tag
|
|
68
|
+
|
|
69
|
+
The `tag` matcher tests the value of image tag:
|
|
70
|
+
|
|
71
|
+
its('tag') { should eq 'latest' }
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
The following examples show how to use this InSpec `docker_image` resource.
|
|
77
|
+
|
|
78
|
+
### Test a docker image
|
|
79
|
+
|
|
80
|
+
describe docker_image('alpine:latest') do
|
|
81
|
+
it { should exist }
|
|
82
|
+
its('id') { should eq 'sha256:4a415e...a526' }
|
|
83
|
+
its('image') { should eq 'alpine:latest' }
|
|
84
|
+
its('repo') { should eq 'alpine' }
|
|
85
|
+
its('tag') { should eq 'latest' }
|
|
86
|
+
end
|
|
@@ -6,7 +6,7 @@ title: About the etc_group Resource
|
|
|
6
6
|
|
|
7
7
|
Use the `etc_group` InSpec audit resource to test groups that are defined on Linux and Unix platforms. The `/etc/group` file stores details about each group---group name, password, group identifier, along with a comma-separate list of users that belong to the group.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Syntax
|
|
10
10
|
|
|
11
11
|
A `etc_group` resource block declares a collection of properties to be tested:
|
|
12
12
|
|
|
@@ -28,49 +28,49 @@ where
|
|
|
28
28
|
* `.where()` may specify a specific item and value, to which the matchers are compared
|
|
29
29
|
* `'gids'`, `'groups'`, and `'users'` are valid matchers for this resource
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
## Matchers
|
|
32
32
|
|
|
33
33
|
This InSpec audit resource has the following matchers:
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
### be
|
|
36
36
|
|
|
37
37
|
<%= partial "/shared/matcher_be" %>
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
### cmp
|
|
40
40
|
|
|
41
41
|
<%= partial "/shared/matcher_cmp" %>
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
### eq
|
|
44
44
|
|
|
45
45
|
<%= partial "/shared/matcher_eq" %>
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
### gids
|
|
48
48
|
|
|
49
49
|
The `gids` matcher tests if the named group identifier is present or if it contains duplicates:
|
|
50
50
|
|
|
51
51
|
its('gids') { should_not contain_duplicates }
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
### groups
|
|
54
54
|
|
|
55
55
|
The `groups` matcher tests all groups for the named user:
|
|
56
56
|
|
|
57
57
|
its('groups') { should include 'my_group' }
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
### include
|
|
60
60
|
|
|
61
61
|
<%= partial "/shared/matcher_include" %>
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
### match
|
|
64
64
|
|
|
65
65
|
<%= partial "/shared/matcher_match" %>
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
### users
|
|
68
68
|
|
|
69
69
|
The `users` matcher tests all groups for the named user:
|
|
70
70
|
|
|
71
71
|
its('users') { should include 'my_user' }
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
### where
|
|
74
74
|
|
|
75
75
|
The `where` matcher allows the test to be focused to one (or more) specific items:
|
|
76
76
|
|
|
@@ -87,29 +87,29 @@ where `item` may be one (or more) of:
|
|
|
87
87
|
* `members: 'member_name'`
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
## Examples
|
|
91
91
|
|
|
92
92
|
The following examples show how to use this InSpec audit resource.
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
### Test group identifiers (GIDs) for duplicates
|
|
95
95
|
|
|
96
96
|
describe etc_group do
|
|
97
97
|
its('gids') { should_not contain_duplicates }
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
### Test all groups to see if a specific user belongs to one (or more) groups
|
|
101
101
|
|
|
102
102
|
describe etc_group do
|
|
103
103
|
its('groups') { should include 'my_group' }
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
### Test all groups for a specific user name
|
|
107
107
|
|
|
108
108
|
describe etc_group do
|
|
109
109
|
its('users') { should include 'my_user' }
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
### Filter a list of groups for a specific user
|
|
113
113
|
|
|
114
114
|
describe etc_group.where(name: 'my_group') do
|
|
115
115
|
its('users') { should include 'my_user' }
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the etc_hosts Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# etc_hosts
|
|
6
|
+
|
|
7
|
+
Use the `etc_hosts` InSpec audit resource to test rules set to match IP addresses with hostnames.
|
|
8
|
+
## Syntax
|
|
9
|
+
|
|
10
|
+
An etc/hosts rule specifies an IP address and what its hostname is along with optional aliases it can have.
|
|
11
|
+
|
|
12
|
+
## Syntax
|
|
13
|
+
|
|
14
|
+
Use the where clause to match a property to one or more rules in the hosts file.
|
|
15
|
+
|
|
16
|
+
describe etc_hosts.where { ip_address == 'value' } do
|
|
17
|
+
its('primary_name') { should cmp 'hostname' }
|
|
18
|
+
its('all_host_names') { should cmp 'list' }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Use the optional constructor parameter to give an alternative path to hosts file
|
|
22
|
+
|
|
23
|
+
describe etc_hosts('path/to/hosts').where { ip_address == 'value' } do
|
|
24
|
+
its('primary_name') { should cmp 'hostname' }
|
|
25
|
+
its('all_host_names') { should cmp 'list' }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
where
|
|
29
|
+
|
|
30
|
+
* `ip_address` is the ip address of the hostname in either ipv4 or ipv6 format.
|
|
31
|
+
* `primary_name` is the name associated with the ip address.
|
|
32
|
+
* `all_host_names` is a list including the primary_name as the first entry followed by any aliase names the host has.
|
|
33
|
+
|
|
34
|
+
## Supported Properties
|
|
35
|
+
|
|
36
|
+
'ip_address', 'primary_name', 'all_host_names'
|
|
37
|
+
|
|
38
|
+
## Property Examples and Return Types
|
|
39
|
+
|
|
40
|
+
### ip_address
|
|
41
|
+
|
|
42
|
+
`ip_address` returns a string array of ip addresses specified in the etc/hosts file.
|
|
43
|
+
|
|
44
|
+
describe etc_hosts.where { primary_name == 'localhost' } do
|
|
45
|
+
its('ip_address') { should cmp '127.0.1.154' }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
### primary_name
|
|
49
|
+
|
|
50
|
+
`primary_name` returns a string array of primary_names specified in the etc/hosts file.
|
|
51
|
+
|
|
52
|
+
describe etc_hosts.where { ip_address == '::1' } do
|
|
53
|
+
its('primary_name') { should cmp 'localhost' }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
### all_host_names
|
|
57
|
+
|
|
58
|
+
`all_host_names` returns a two dimensional string array where each entry has the primary_name first followed by any aliases.
|
|
59
|
+
|
|
60
|
+
describe etc_hosts.where { ip_address == '127.0.1.154' } do
|
|
61
|
+
its('all_host_names') { should eq [['localhost', 'localhost.localdomain', 'localhost4', 'localhost4.localdomain4'], ['localhost', 'localhost.localdomain', 'localhost6', 'localhost6.localdomain6']] }
|
|
62
|
+
end
|