inspec 1.31.0 → 1.45.9
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/.rubocop.yml +3 -0
- data/CHANGELOG.md +2599 -1
- data/Gemfile +0 -1
- data/README.md +24 -34
- data/Rakefile +0 -31
- data/docs/dsl_inspec.md +10 -0
- data/docs/matchers.md +29 -0
- data/docs/plugin_kitchen_inspec.md +18 -24
- data/docs/profiles.md +101 -81
- data/docs/resources/aide_conf.md.erb +71 -0
- data/docs/resources/apache_conf.md.erb +19 -33
- data/docs/resources/apt.md.erb +22 -36
- data/docs/resources/audit_policy.md.erb +9 -24
- data/docs/resources/auditd.md.erb +78 -0
- data/docs/resources/auditd_conf.md.erb +20 -34
- data/docs/resources/auditd_rules.md.erb +8 -24
- data/docs/resources/bash.md.erb +4 -26
- data/docs/resources/bond.md.erb +25 -40
- data/docs/resources/bridge.md.erb +5 -25
- data/docs/resources/bsd_service.md.erb +5 -25
- data/docs/resources/command.md.erb +35 -50
- data/docs/resources/cpan.md.erb +62 -0
- data/docs/resources/cran.md.erb +54 -0
- data/docs/resources/crontab.md.erb +9 -23
- data/docs/resources/csv.md.erb +12 -27
- data/docs/resources/dh_params.md +1 -0
- data/docs/resources/directory.md.erb +5 -25
- data/docs/resources/docker.md.erb +61 -58
- data/docs/resources/docker_container.md.erb +23 -19
- data/docs/resources/docker_image.md.erb +20 -16
- data/docs/resources/elasticsearch.md.erb +245 -0
- data/docs/resources/etc_fstab.md.erb +120 -0
- data/docs/resources/etc_group.md.erb +29 -45
- data/docs/resources/etc_hosts.md.erb +68 -0
- data/docs/resources/etc_hosts_allow.md.erb +68 -0
- data/docs/resources/etc_hosts_deny.md.erb +68 -0
- data/docs/resources/file.md.erb +227 -216
- data/docs/resources/firewalld.md.erb +104 -0
- data/docs/resources/gem.md.erb +21 -35
- data/docs/resources/group.md.erb +16 -30
- data/docs/resources/grub_conf.md.erb +9 -24
- data/docs/resources/host.md.erb +32 -49
- data/docs/resources/http.md.erb +38 -44
- data/docs/resources/iis_app.md.erb +25 -35
- data/docs/resources/iis_site.md.erb +26 -40
- data/docs/resources/inetd_conf.md.erb +27 -42
- data/docs/resources/ini.md.erb +9 -23
- data/docs/resources/interface.md.erb +5 -25
- data/docs/resources/iptables.md.erb +15 -29
- data/docs/resources/json.md.erb +12 -27
- data/docs/resources/kernel_module.md.erb +47 -61
- data/docs/resources/kernel_parameter.md.erb +15 -29
- data/docs/resources/key_rsa.md.erb +3 -0
- data/docs/resources/launchd_service.md.erb +5 -25
- data/docs/resources/limits_conf.md.erb +15 -29
- data/docs/resources/login_def.md.erb +15 -30
- data/docs/resources/mount.md.erb +18 -33
- data/docs/resources/mssql_session.md.erb +9 -12
- data/docs/resources/mysql_conf.md.erb +28 -32
- data/docs/resources/mysql_session.md.erb +15 -29
- data/docs/resources/nginx.md.erb +78 -0
- data/docs/resources/nginx_conf.md.erb +127 -0
- data/docs/resources/npm.md.erb +19 -35
- data/docs/resources/ntp_conf.md.erb +20 -37
- data/docs/resources/oneget.md.erb +15 -30
- data/docs/resources/oracledb_session.md.erb +9 -11
- data/docs/resources/os.md.erb +29 -43
- data/docs/resources/os_env.md.erb +23 -44
- data/docs/resources/package.md.erb +34 -36
- data/docs/resources/parse_config.md.erb +5 -25
- data/docs/resources/parse_config_file.md.erb +31 -43
- data/docs/resources/{etc_passwd.md.erb → passwd.md.erb} +24 -39
- data/docs/resources/pip.md.erb +20 -35
- data/docs/resources/port.md.erb +43 -57
- data/docs/resources/postgres_conf.md.erb +17 -31
- data/docs/resources/postgres_hba_conf.md.erb +26 -38
- data/docs/resources/postgres_ident_conf.md.erb +25 -37
- data/docs/resources/postgres_session.md.erb +15 -29
- data/docs/resources/powershell.md.erb +27 -42
- data/docs/resources/processes.md.erb +17 -33
- data/docs/resources/rabbitmq_config.md.erb +9 -24
- data/docs/resources/registry_key.md.erb +27 -42
- data/docs/resources/runit_service.md.erb +5 -25
- data/docs/resources/security_policy.md.erb +12 -27
- data/docs/resources/service.md.erb +27 -42
- data/docs/resources/{etc_shadow.md.erb → shadow.md.erb} +41 -47
- data/docs/resources/ssh_config.md.erb +19 -34
- data/docs/resources/sshd_config.md.erb +19 -34
- data/docs/resources/ssl.md.erb +39 -54
- data/docs/resources/sys_info.md.erb +12 -26
- data/docs/resources/systemd_service.md.erb +5 -25
- data/docs/resources/sysv_service.md.erb +5 -25
- data/docs/resources/upstart_service.md.erb +5 -25
- data/docs/resources/user.md.erb +29 -44
- data/docs/resources/users.md.erb +12 -26
- data/docs/resources/vbscript.md.erb +9 -24
- data/docs/resources/virtualization.md.erb +8 -23
- data/docs/resources/windows_feature.md.erb +15 -30
- data/docs/resources/windows_hotfix.md.erb +50 -0
- data/docs/resources/windows_task.md.erb +12 -26
- data/docs/resources/wmi.md.erb +9 -24
- data/docs/resources/x509_certificate.md.erb +4 -0
- data/docs/resources/xinetd_conf.md.erb +65 -80
- data/docs/resources/xml.md.erb +61 -0
- data/docs/resources/yaml.md.erb +12 -27
- data/docs/resources/yum.md.erb +37 -51
- data/docs/resources/zfs_dataset.md.erb +15 -26
- data/docs/resources/zfs_pool.md.erb +9 -20
- data/docs/ruby_usage.md +0 -1
- data/examples/meta-profile/README.md +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 +3 -3
- data/lib/bundles/inspec-artifact/cli.rb +5 -5
- data/lib/bundles/inspec-compliance/README.md +24 -22
- data/lib/bundles/inspec-compliance/api/login.rb +152 -0
- data/lib/bundles/inspec-compliance/api.rb +46 -16
- data/lib/bundles/inspec-compliance/cli.rb +58 -165
- data/lib/bundles/inspec-compliance/target.rb +2 -3
- data/lib/bundles/inspec-habitat/cli.rb +7 -2
- data/lib/bundles/inspec-habitat/profile.rb +44 -20
- data/lib/bundles/inspec-init/templates/profile/README.md +1 -1
- data/lib/bundles/inspec-init/templates/profile/controls/example.rb +1 -1
- data/lib/bundles/inspec-supermarket/api.rb +1 -1
- data/lib/inspec/backend.rb +8 -0
- data/lib/inspec/cli.rb +1 -1
- data/lib/inspec/control_eval_context.rb +16 -6
- data/lib/inspec/dependencies/requirement.rb +22 -8
- data/lib/inspec/dependencies/resolver.rb +1 -1
- data/lib/inspec/exceptions.rb +4 -0
- data/lib/inspec/file_provider.rb +38 -9
- data/lib/inspec/metadata.rb +17 -3
- data/lib/inspec/objects/attribute.rb +16 -7
- data/lib/inspec/objects/control.rb +10 -2
- data/lib/inspec/plugins/resource.rb +34 -5
- data/lib/inspec/profile.rb +10 -1
- data/lib/inspec/profile_context.rb +3 -1
- data/lib/inspec/resource.rb +17 -5
- data/lib/inspec/rspec_json_formatter.rb +48 -14
- data/lib/inspec/rule.rb +4 -0
- data/lib/inspec/runner.rb +72 -30
- data/lib/inspec/shell.rb +24 -19
- data/lib/inspec/version.rb +1 -1
- data/lib/matchers/matchers.rb +40 -0
- data/lib/resources/aide_conf.rb +162 -0
- data/lib/resources/auditd.rb +231 -0
- data/lib/resources/auditd_rules.rb +3 -1
- data/lib/resources/command.rb +1 -1
- data/lib/resources/cpan.rb +60 -0
- data/lib/resources/cran.rb +66 -0
- data/lib/resources/docker.rb +8 -1
- data/lib/resources/docker_container.rb +19 -2
- data/lib/resources/elasticsearch.rb +172 -0
- data/lib/resources/etc_fstab.rb +102 -0
- data/lib/resources/etc_group.rb +1 -1
- data/lib/resources/etc_hosts.rb +81 -0
- data/lib/resources/etc_hosts_allow_deny.rb +122 -0
- data/lib/resources/file.rb +87 -10
- data/lib/resources/firewalld.rb +144 -0
- data/lib/resources/groups.rb +0 -1
- data/lib/resources/host.rb +30 -15
- data/lib/resources/http.rb +178 -22
- data/lib/resources/mssql_session.rb +3 -3
- data/lib/resources/mysql_conf.rb +10 -0
- data/lib/resources/mysql_session.rb +1 -1
- data/lib/resources/nginx.rb +97 -0
- data/lib/resources/nginx_conf.rb +134 -1
- data/lib/resources/oracledb_session.rb +9 -8
- data/lib/resources/os_env.rb +7 -4
- data/lib/resources/package.rb +14 -2
- data/lib/resources/packages.rb +1 -1
- data/lib/resources/pip.rb +28 -20
- data/lib/resources/port.rb +251 -3
- data/lib/resources/postgres.rb +1 -1
- data/lib/resources/postgres_session.rb +1 -1
- data/lib/resources/processes.rb +106 -20
- data/lib/resources/registry_key.rb +11 -2
- data/lib/resources/service.rb +5 -24
- data/lib/resources/ssh_conf.rb +1 -1
- data/lib/resources/ssl.rb +4 -3
- data/lib/resources/toml.rb +2 -2
- data/lib/resources/windows_hotfix.rb +35 -0
- data/lib/resources/xinetd.rb +4 -6
- data/lib/resources/xml.rb +27 -0
- data/lib/source_readers/inspec.rb +3 -3
- data/lib/utils/find_files.rb +2 -1
- data/lib/utils/nginx_parser.rb +10 -1
- data/lib/utils/object_traversal.rb +35 -10
- data/lib/utils/parser.rb +21 -3
- metadata +48 -18
- data/docs/cli.md +0 -392
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -339,11 +339,10 @@ The InSpec community and maintainers are very active and helpful. This project b
|
|
|
339
339
|
|
|
340
340
|
## Testing InSpec
|
|
341
341
|
|
|
342
|
-
We perform `unit
|
|
342
|
+
We perform `unit` and `integration` tests.
|
|
343
343
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
* `integration` tests run against VMs via test-kitchen and [kitchen-inspec](https://github.com/chef/kitchen-inspec)
|
|
344
|
+
- `unit` tests ensure the intended behaviour of the implementation
|
|
345
|
+
- `integration` tests run against Docker-based VMs via test-kitchen and [kitchen-inspec](https://github.com/chef/kitchen-inspec)
|
|
347
346
|
|
|
348
347
|
### Unit tests
|
|
349
348
|
|
|
@@ -351,60 +350,51 @@ We perform `unit`, `resource` and `integration` tests.
|
|
|
351
350
|
bundle exec rake test
|
|
352
351
|
```
|
|
353
352
|
|
|
354
|
-
If you like to run only one test
|
|
353
|
+
If you like to run only one test file:
|
|
355
354
|
|
|
356
355
|
```bash
|
|
357
|
-
bundle exec
|
|
356
|
+
bundle exec m test/unit/resources/user_test.rb
|
|
358
357
|
```
|
|
359
358
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
Resource tests make sure the backend execution layer behaves as expected. These tests will take a while, as a lot of different operating systems and configurations are being tested.
|
|
363
|
-
|
|
364
|
-
You will require:
|
|
365
|
-
|
|
366
|
-
* docker
|
|
367
|
-
|
|
368
|
-
Run `resource` tests with
|
|
359
|
+
You may also run a single test within a file by line number:
|
|
369
360
|
|
|
370
361
|
```bash
|
|
371
|
-
bundle exec
|
|
372
|
-
bundle exec rake test:resources config=test/test-extra.yaml
|
|
362
|
+
bundle exec m test/unit/resources/user_test.rb -l 123
|
|
373
363
|
```
|
|
374
364
|
|
|
375
365
|
### Integration tests
|
|
376
366
|
|
|
377
367
|
These tests download various virtual machines, to ensure InSpec is working as expected across different operating systems.
|
|
378
368
|
|
|
379
|
-
|
|
369
|
+
These tests require the following gems:
|
|
370
|
+
|
|
371
|
+
- test-kitchen
|
|
372
|
+
- kitchen-dokken
|
|
373
|
+
- kitchen-inspec
|
|
380
374
|
|
|
381
|
-
|
|
382
|
-
* test-kitchen
|
|
375
|
+
These gems are provided via the `integration` group in the project's Gemfile.
|
|
383
376
|
|
|
384
|
-
|
|
377
|
+
In addition, these test require Docker to be available on your machine or a remote Docker machine configured via the standard Docker environment variables.
|
|
378
|
+
|
|
379
|
+
#### Running Integration tests
|
|
380
|
+
|
|
381
|
+
List the various test instances available:
|
|
385
382
|
|
|
386
383
|
```bash
|
|
387
|
-
|
|
384
|
+
bundle exec kitchen list`
|
|
388
385
|
```
|
|
389
386
|
|
|
390
|
-
|
|
387
|
+
The platforms and test suites are configured in the `.kitchen.yml` file. Once you know which instance you wish to test, test that instance:
|
|
391
388
|
|
|
392
389
|
```bash
|
|
393
|
-
|
|
394
|
-
export AWS_SECRET_ACCESS_KEY=enteryoursecreykey
|
|
395
|
-
export AWS_KEYPAIR_NAME=enteryoursshkeyid
|
|
396
|
-
export EC2_SSH_KEY_PATH=~/.ssh/id_aws.pem
|
|
397
|
-
KITCHEN_YAML=.kitchen.ec2.yml bundle exec kitchen test
|
|
390
|
+
bundle exec kitchen test <INSTANCE_NAME>
|
|
398
391
|
```
|
|
399
392
|
|
|
400
|
-
|
|
393
|
+
You may test all instances in parallel with:
|
|
401
394
|
|
|
395
|
+
```bash
|
|
396
|
+
bundle exec kitchen test -c
|
|
402
397
|
```
|
|
403
|
-
transport:
|
|
404
|
-
ssh_key: /Users/chartmann/aws/aws_chartmann.pem
|
|
405
|
-
username: ec2-user
|
|
406
|
-
```
|
|
407
|
-
|
|
408
398
|
|
|
409
399
|
## License
|
|
410
400
|
|
data/Rakefile
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
require 'bundler'
|
|
5
5
|
require 'bundler/gem_tasks'
|
|
6
6
|
require 'rake/testtask'
|
|
7
|
-
require_relative 'tasks/changelog'
|
|
8
7
|
require_relative 'tasks/maintainers'
|
|
9
8
|
require_relative 'tasks/spdx'
|
|
10
9
|
|
|
@@ -138,19 +137,6 @@ task :version do
|
|
|
138
137
|
inspec_version
|
|
139
138
|
end
|
|
140
139
|
|
|
141
|
-
# Update the version of this gem and create an updated
|
|
142
|
-
# changelog. It covers everything short of actually releasing
|
|
143
|
-
# the gem.
|
|
144
|
-
desc 'Bump the version of this gem'
|
|
145
|
-
task :bump_version, [:version] do |_, args|
|
|
146
|
-
v = args[:version] || ENV['to']
|
|
147
|
-
fail "You must specify a target version! rake bump_version to=1.2.3" if v.empty?
|
|
148
|
-
check_update_requirements
|
|
149
|
-
inspec_version(v)
|
|
150
|
-
Rake::Task['changelog'].invoke
|
|
151
|
-
Rake::Task['docs:cli'].invoke
|
|
152
|
-
end
|
|
153
|
-
|
|
154
140
|
desc 'Release a new docker image'
|
|
155
141
|
task :release_docker do
|
|
156
142
|
version = Inspec::VERSION
|
|
@@ -164,23 +150,6 @@ task :release_docker do
|
|
|
164
150
|
sh('sh', '-c', cmd)
|
|
165
151
|
end
|
|
166
152
|
|
|
167
|
-
desc 'Release a new Habitat package'
|
|
168
|
-
task :release_habitat do
|
|
169
|
-
version = Inspec::VERSION
|
|
170
|
-
ENV['HAB_ORIGIN'] = "chef"
|
|
171
|
-
if Dir.exist?("./results") then
|
|
172
|
-
raise "Please remove the ./results directory"
|
|
173
|
-
end
|
|
174
|
-
if ! ENV.has_key?("HAB_AUTH_TOKEN") then
|
|
175
|
-
raise "Please set the HAB_AUTH_TOKEN environment variable"
|
|
176
|
-
end
|
|
177
|
-
cmd = "echo #{version} > ./habitat/VERSION && "\
|
|
178
|
-
"hab pkg build . && " \
|
|
179
|
-
"hab pkg upload ./results/*.hart"
|
|
180
|
-
puts "--> #{cmd}"
|
|
181
|
-
sh('sh', '-c', cmd)
|
|
182
|
-
end
|
|
183
|
-
|
|
184
153
|
desc 'Release the website [deprecated]'
|
|
185
154
|
task :www do
|
|
186
155
|
puts 'The Rake tasks for releasing the website are now in the www/ directory.'
|
data/docs/dsl_inspec.md
CHANGED
|
@@ -71,6 +71,16 @@ describe.one do
|
|
|
71
71
|
end
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
#### Sensitive resources
|
|
75
|
+
|
|
76
|
+
In some scenarios, you may be writing checks involving resources with sensitive content (e.g. a file resource). In the case of failures, it may be desired to suppress output. This can be done by adding the `:sensitive` flag to the resource definition
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
describe file('/tmp/mysecretfile'), :sensitive do
|
|
80
|
+
its('content') { should contain 'secret_info' }
|
|
81
|
+
end
|
|
82
|
+
```
|
|
83
|
+
|
|
74
84
|
## Examples
|
|
75
85
|
|
|
76
86
|
The following examples show simple compliance tests using a single `control` block.
|
data/docs/matchers.md
CHANGED
|
@@ -8,11 +8,14 @@ Inspec uses matchers to help compare resource values to expectations.
|
|
|
8
8
|
The following matchers are available:
|
|
9
9
|
|
|
10
10
|
* `be`
|
|
11
|
+
* `be_in`
|
|
11
12
|
* `cmp`
|
|
12
13
|
* `eq`
|
|
13
14
|
* `include`
|
|
14
15
|
* `match`
|
|
15
16
|
|
|
17
|
+
<br>
|
|
18
|
+
|
|
16
19
|
## be
|
|
17
20
|
|
|
18
21
|
This matcher can be followed by many different comparison operators.
|
|
@@ -25,6 +28,8 @@ describe file('/proc/cpuinfo') do
|
|
|
25
28
|
end
|
|
26
29
|
```
|
|
27
30
|
|
|
31
|
+
<br>
|
|
32
|
+
|
|
28
33
|
## cmp
|
|
29
34
|
|
|
30
35
|
Unlike `eq`, cmp is a matcher for less-restrictive comparisons. It will
|
|
@@ -63,6 +68,13 @@ end
|
|
|
63
68
|
its('log_format') { should cmp 'RAW' }
|
|
64
69
|
end
|
|
65
70
|
```
|
|
71
|
+
* Recognize versions embedded in strings
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
describe package(curl) do
|
|
75
|
+
its('version') { should cmp > '7.35.0-1ubuntu2.10' }
|
|
76
|
+
end
|
|
77
|
+
```
|
|
66
78
|
|
|
67
79
|
* Compare arrays with only one entry to a value
|
|
68
80
|
|
|
@@ -91,6 +103,7 @@ end
|
|
|
91
103
|
expected: 0345
|
|
92
104
|
got: 0444
|
|
93
105
|
```
|
|
106
|
+
<br>
|
|
94
107
|
|
|
95
108
|
## eq
|
|
96
109
|
|
|
@@ -115,6 +128,8 @@ its('Port') { should eq 22 }
|
|
|
115
128
|
|
|
116
129
|
For less restrictive comparisons, please use `cmp`.
|
|
117
130
|
|
|
131
|
+
<br>
|
|
132
|
+
|
|
118
133
|
## include
|
|
119
134
|
|
|
120
135
|
Verifies if a value is included in a list.
|
|
@@ -125,6 +140,20 @@ describe passwd do
|
|
|
125
140
|
end
|
|
126
141
|
```
|
|
127
142
|
|
|
143
|
+
<br>
|
|
144
|
+
|
|
145
|
+
## be_in
|
|
146
|
+
|
|
147
|
+
Verifies that an item is included in a list.
|
|
148
|
+
|
|
149
|
+
```ruby
|
|
150
|
+
describe resource do
|
|
151
|
+
its('item') { should be_in LIST }
|
|
152
|
+
end
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
<br>
|
|
156
|
+
|
|
128
157
|
## match
|
|
129
158
|
|
|
130
159
|
Check if a string matches a regular expression.
|
|
@@ -4,19 +4,19 @@ title: About kitchen-inspec
|
|
|
4
4
|
|
|
5
5
|
# kitchen-inspec
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Use InSpec as a Kitchen verifier with `kitchen-inspec`.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Add the InSpec verifier to the `.kitchen.yml` file:
|
|
10
10
|
|
|
11
11
|
verifier:
|
|
12
12
|
name: inspec
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Use a compliance profile from the Chef Compliance server:
|
|
15
15
|
|
|
16
16
|
suites:
|
|
17
17
|
- name: compliance
|
|
18
18
|
run_list:
|
|
19
|
-
- recipe[ssh-hardening]
|
|
19
|
+
- recipe[ssh-hardening::default]
|
|
20
20
|
verifier:
|
|
21
21
|
inspec_tests:
|
|
22
22
|
- compliance://base/ssh
|
|
@@ -27,29 +27,23 @@ and then run the following command:
|
|
|
27
27
|
|
|
28
28
|
where `--insecure` is required when using self-signed certificates.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Use a compliance profile from the Chef Supermarket:
|
|
31
31
|
|
|
32
32
|
suites:
|
|
33
33
|
- name: supermarket
|
|
34
34
|
run_list:
|
|
35
|
-
- recipe[ssh-hardening]
|
|
35
|
+
- recipe[ssh-hardening::default]
|
|
36
36
|
verifier:
|
|
37
37
|
inspec_tests:
|
|
38
|
-
- supermarket://
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
└── test
|
|
51
|
-
└── integration
|
|
52
|
-
└── default
|
|
53
|
-
├── controls
|
|
54
|
-
├── inspec.yml
|
|
55
|
-
└── libraries
|
|
38
|
+
- supermarket://dev-sec/ssh-baseline
|
|
39
|
+
|
|
40
|
+
Use InSpec tests from the local file system:
|
|
41
|
+
|
|
42
|
+
suites:
|
|
43
|
+
- name: local
|
|
44
|
+
run_list:
|
|
45
|
+
- recipe[my_cookbook::default]
|
|
46
|
+
verifier:
|
|
47
|
+
inspec_tests:
|
|
48
|
+
- test/integration/default
|
|
49
|
+
|
data/docs/profiles.md
CHANGED
|
@@ -109,18 +109,23 @@ and to target all of these examples in a single `inspec.yml` file:
|
|
|
109
109
|
|
|
110
110
|
# Profile Dependencies
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
An InSpec profile can bring in the controls and custom resources from another InSpec profile. Additionally, when inheriting the controls of another profile, a profile can skip or even modify those included controls.
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
* using a custom InSpec resource defined in another profile
|
|
114
|
+
## Defining the Dependencies
|
|
116
115
|
|
|
117
|
-
|
|
116
|
+
Before a profile can use controls from another profile, the to-be-included profile needs to be specified in the including profile’s `inspec.yml` file in the `depends` section. For each profile to be included, a location for the profile from where to be fetched and a name for the profile should be included. For example:
|
|
118
117
|
|
|
119
|
-
|
|
118
|
+
depends:
|
|
119
|
+
- name: linux-baseline
|
|
120
|
+
url: https://github.com/dev-sec/linux-baseline/archive/master.tar.gz
|
|
121
|
+
- name: ssh-baseline
|
|
122
|
+
url: https://github.com/dev-sec/ssh-baseline/archive/master.tar.gz
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
InSpec supports a number of dependency sources.
|
|
122
125
|
|
|
123
|
-
|
|
126
|
+
### path
|
|
127
|
+
|
|
128
|
+
The `path` setting defines a profile that is located on disk. This setting is typically used during development of profiles and when debugging profiles.
|
|
124
129
|
|
|
125
130
|
depends:
|
|
126
131
|
- name: my-profile
|
|
@@ -128,19 +133,19 @@ For example:
|
|
|
128
133
|
- name: another
|
|
129
134
|
path: ../relative/path
|
|
130
135
|
|
|
131
|
-
|
|
136
|
+
### url
|
|
132
137
|
|
|
133
|
-
The `url` setting specifies a profile that is located at an HTTP- or HTTPS-based URL. The profile must be accessible via a HTTP GET operation and must be a valid profile archive (zip, tar, tar.gz format).
|
|
134
|
-
|
|
135
|
-
For example:
|
|
138
|
+
The `url` setting specifies a profile that is located at an HTTP- or HTTPS-based URL. The profile must be accessible via a HTTP GET operation and must be a valid profile archive (zip, tar, or tar.gz format).
|
|
136
139
|
|
|
137
140
|
depends:
|
|
138
141
|
- name: my-profile
|
|
139
142
|
url: https://my.domain/path/to/profile.tgz
|
|
143
|
+
- name: profile-via-git
|
|
144
|
+
url: https://github.com/myusername/myprofile-repo/archive/master.tar.gz
|
|
140
145
|
|
|
141
|
-
|
|
146
|
+
### git
|
|
142
147
|
|
|
143
|
-
A `git` setting specifies a profile that is located in a git repository, with optional settings for branch, tag, commit, and version. The source location is translated into a URL upon resolution. This type of dependency supports version
|
|
148
|
+
A `git` setting specifies a profile that is located in a git repository, with optional settings for branch, tag, commit, and version. The source location is translated into a URL upon resolution. This type of dependency supports version constraints via semantic versioning as git tags.
|
|
144
149
|
|
|
145
150
|
For example:
|
|
146
151
|
|
|
@@ -152,7 +157,7 @@ For example:
|
|
|
152
157
|
commit: pinned_commit
|
|
153
158
|
version: semver_via_tags
|
|
154
159
|
|
|
155
|
-
|
|
160
|
+
### supermarket
|
|
156
161
|
|
|
157
162
|
A `supermarket` setting specifies a profile that is located in a cookbook hosted on Chef Supermarket. The source location is translated into a URL upon resolution.
|
|
158
163
|
|
|
@@ -164,27 +169,9 @@ For example:
|
|
|
164
169
|
|
|
165
170
|
Available Supermarket profiles can be listed with `inspec supermarket profiles`.
|
|
166
171
|
|
|
167
|
-
|
|
172
|
+
### compliance
|
|
168
173
|
|
|
169
|
-
A `
|
|
170
|
-
|
|
171
|
-
For example:
|
|
172
|
-
|
|
173
|
-
depends:
|
|
174
|
-
- name: gh-profile
|
|
175
|
-
github: username/project
|
|
176
|
-
|
|
177
|
-
A path to a Git commit or tag on GitHub can also be used:
|
|
178
|
-
|
|
179
|
-
dev-sec/linux-baseline
|
|
180
|
-
dev-sec/linux-baseline/tree/2.0
|
|
181
|
-
dev-sec/linux-baseline/tree/48bd4388ddffde68badd83aefa654e7af3231876
|
|
182
|
-
|
|
183
|
-
would all download profiles corresponding to the GitHub URL, https://github.com/dev-sec/linux-baseline/tree/48bd4388ddffde68badd83aefa654e7af3231876, for example.
|
|
184
|
-
|
|
185
|
-
## Chef Compliance
|
|
186
|
-
|
|
187
|
-
A `compliance` setting specifies a profile that is located on the Chef Compliance server.
|
|
174
|
+
A `compliance` setting specifies a profile that is located on the Chef Automate or Chef Compliance server.
|
|
188
175
|
|
|
189
176
|
For example:
|
|
190
177
|
|
|
@@ -192,80 +179,76 @@ For example:
|
|
|
192
179
|
- name: linux
|
|
193
180
|
compliance: base/linux
|
|
194
181
|
|
|
195
|
-
|
|
182
|
+
## Vendoring Dependencies
|
|
196
183
|
|
|
197
|
-
|
|
184
|
+
When you execute a local profile, the `inspec.yml` file will be read in order to source any profile dependencies. It will then cache the dependencies locally and generate an `inspec.lock` file.
|
|
198
185
|
|
|
199
|
-
|
|
186
|
+
If you add or update dependencies in `inspec.yml`, dependencies may be re-vendored and the lockfile updated with `inspec vendor --overwrite`
|
|
200
187
|
|
|
201
|
-
|
|
202
|
-
- name: ssh-hardening
|
|
203
|
-
supermarket: hardening/ssh-hardening
|
|
204
|
-
version: '= 2.0.0'
|
|
205
|
-
- name: os-hardening
|
|
206
|
-
url: https://github.com/dev-sec/tests-os-hardening/archive/master.zip
|
|
207
|
-
- name: ssl-benchmark
|
|
208
|
-
git: https://github.com/dev-sec/ssl-benchmark.git
|
|
209
|
-
version: '< 2.0'
|
|
210
|
-
- name: windows-patch-benchmark
|
|
211
|
-
git: https://github.com/chris-rock/windows-patch-benchmark.git
|
|
212
|
-
version: '~> 0.6'
|
|
213
|
-
- name: linux
|
|
214
|
-
compliance: base/linux
|
|
188
|
+
## Using Controls from an Included Profile
|
|
215
189
|
|
|
216
|
-
|
|
190
|
+
Once defined in the `inspec.yml`, controls from the included profiles can be used! Let’s look at some examples.
|
|
217
191
|
|
|
218
|
-
|
|
192
|
+
### Including All Controls from a Profile
|
|
219
193
|
|
|
220
|
-
|
|
221
|
-
* deleting `inspec.lock` before running `inspec exec`
|
|
194
|
+
With the `include_controls` command in a profile, all controls from the named profile will be executed every time the including profile is executed.
|
|
222
195
|
|
|
223
|
-
|
|
196
|
+

|
|
224
197
|
|
|
225
|
-
|
|
198
|
+
In the example above, every time `my-app-profile` is executed, all the controls from `my-baseline` are also executed. Therefore, the following controls would be executed:
|
|
226
199
|
|
|
227
|
-
|
|
200
|
+
* myapp-1
|
|
201
|
+
* myapp-2
|
|
202
|
+
* myapp-3
|
|
203
|
+
* baseline-1
|
|
204
|
+
* baseline-2
|
|
228
205
|
|
|
229
|
-
|
|
206
|
+
This is a great reminder that having a good naming convention for your controls is helpful to avoid confusion when
|
|
207
|
+
including controls from other profiles!
|
|
230
208
|
|
|
231
|
-
|
|
209
|
+
### Skipping a Control from a Profile
|
|
232
210
|
|
|
233
|
-
|
|
211
|
+
What if one of the controls from the included profile does not apply to your environment? Luckily, it is not necessary to maintain a slightly-modified copy of the included profile just to delete a control. The `skip_control` command tells InSpec to not run a particular control.
|
|
234
212
|
|
|
235
|
-
|
|
213
|
+

|
|
236
214
|
|
|
237
|
-
|
|
238
|
-
impact 1.0
|
|
239
|
-
...
|
|
215
|
+
In the above example, all controls from `my-app-profile` and `my-baseline` profile will be executed every time `my-app-profile` is executed **except** for control `baseline-2` from the `my-baseline` profile.
|
|
240
216
|
|
|
241
|
-
|
|
217
|
+
### Modifying a Control
|
|
242
218
|
|
|
243
|
-
|
|
219
|
+
Let's say a particular control from an included profile should still be run, but the impact isn't appropriate? Perhaps the test should still run, but if it fails, it should be treated as low severity instead of high severity?
|
|
244
220
|
|
|
245
|
-
|
|
221
|
+
When a control is included, it can also be modified!
|
|
246
222
|
|
|
247
|
-
|
|
248
|
-
skip_control "cis-fs-2.2"
|
|
223
|
+

|
|
249
224
|
|
|
250
|
-
|
|
225
|
+
In the above example, all controls from `my-baseline` are executed along with all the controls from the including profile, `my-app-profile`. However, should control `baseline-1` fail, it will be raised with an impact of `0.5` instead of the originally-intended impact of `1.0`.
|
|
251
226
|
|
|
252
|
-
|
|
227
|
+
### Selectively Including Controls from a Profile
|
|
253
228
|
|
|
254
|
-
|
|
229
|
+
If there are only a handful of controls that should be executed from an included profile, it's not necessarily to skip all the unneeded controls, or worse, copy/paste those controls bit-for-bit into your profile. Instead, use the `require_controls` command.
|
|
255
230
|
|
|
256
|
-
|
|
231
|
+

|
|
257
232
|
|
|
258
|
-
|
|
233
|
+
Whenever `my-app-profile` is executed, in addition to its own controls, it will run only the controls specified in the `require_controls` block. In the case, the following controls would be executed:
|
|
259
234
|
|
|
260
|
-
|
|
261
|
-
|
|
235
|
+
* myapp-1
|
|
236
|
+
* myapp-2
|
|
237
|
+
* myapp-3
|
|
238
|
+
* baseline-2
|
|
239
|
+
* baseline-4
|
|
262
240
|
|
|
263
|
-
|
|
241
|
+
Controls `baseline-1`, `baseline-3`, and `baseline-5` would not be run, just as if they were manually skipped. This method of including specific controls ensures only the controls specified are executed; if new controls are added to a later version of `my-baseline`, they would not be run.
|
|
242
|
+
|
|
243
|
+
And, just the way its possible to modify controls when using `include_controls`, controls can be modified as well.
|
|
244
|
+
|
|
245
|
+

|
|
264
246
|
|
|
247
|
+
As with the prior example, only `baseline-2` and `baseline-4` are executed, but if `baseline-2` fails, it will report with an impact of `0.5` instead of the originally-intended `1.0` impact.
|
|
265
248
|
|
|
266
|
-
##
|
|
249
|
+
## Using Resources from an Included Profile
|
|
267
250
|
|
|
268
|
-
By default, all of the resources from a listed dependency are available
|
|
251
|
+
By default, all of the custom resources from a listed dependency are available
|
|
269
252
|
for use in your profile. If two of your dependencies provide a resource with
|
|
270
253
|
the same name, you can use the `require_resource` DSL function to
|
|
271
254
|
disambiguate the two:
|
|
@@ -340,7 +323,7 @@ The tests in `example.rb` can now access this file:
|
|
|
340
323
|
my_services = yaml(content: inspec.profile.file('services.yml')).params
|
|
341
324
|
|
|
342
325
|
my_services.each do |s|
|
|
343
|
-
describe service(s['
|
|
326
|
+
describe service(s['service_name']) do
|
|
344
327
|
it { should be_running }
|
|
345
328
|
end
|
|
346
329
|
|
|
@@ -348,3 +331,40 @@ The tests in `example.rb` can now access this file:
|
|
|
348
331
|
it { should be_listening }
|
|
349
332
|
end
|
|
350
333
|
end
|
|
334
|
+
|
|
335
|
+
# "should" vs. "expect" syntax
|
|
336
|
+
|
|
337
|
+
Users familiar with the RSpec testing framework may know that there are two ways to write test statements: `should` and `expect`. The RSpec community decided that `expect` is the preferred syntax. However, InSpec recommends the `should` syntax as it tends to read more easily to those users who are not as technical.
|
|
338
|
+
|
|
339
|
+
InSpec will continue to support both methods of writing tests. Consider this `file` test:
|
|
340
|
+
|
|
341
|
+
describe file('/tmp/test.txt') do
|
|
342
|
+
it { should be_file }
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
This can be re-written with `expect` syntax
|
|
346
|
+
|
|
347
|
+
describe file('/tmp/test.txt') do
|
|
348
|
+
it 'should be a file' do
|
|
349
|
+
expect(subject).to(be_file)
|
|
350
|
+
end
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
The output of both of the above examples looks like this:
|
|
354
|
+
|
|
355
|
+
File /tmp/test.txt
|
|
356
|
+
✔ should be a file
|
|
357
|
+
|
|
358
|
+
In addition, you can make use of the `subject` keyword to further control your output if you choose:
|
|
359
|
+
|
|
360
|
+
describe 'test file' do
|
|
361
|
+
subject { file('/tmp/test.txt') }
|
|
362
|
+
it 'should be a file' do
|
|
363
|
+
expect(subject).to(be_file)
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
... which will render the following output:
|
|
368
|
+
|
|
369
|
+
test file
|
|
370
|
+
✔ should be a file
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the aide_conf Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# aide_conf
|
|
6
|
+
|
|
7
|
+
Use the `aide_conf` InSpec audit resource to test the rules established for the file integrity tool AIDE. Controlled by the aide.conf file typically at /etc/aide.conf.
|
|
8
|
+
|
|
9
|
+
<br>
|
|
10
|
+
|
|
11
|
+
## Syntax
|
|
12
|
+
|
|
13
|
+
An `aide_conf` resource block can be used to determine if the selection lines contain one (or more) directories whose files should be added to the aide database:
|
|
14
|
+
|
|
15
|
+
describe aide_conf('path') do
|
|
16
|
+
its('selection_lines') { should include '/sbin' }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
where
|
|
20
|
+
|
|
21
|
+
* `'selection_lines'` refers to all selection lines found in the aide.conf file
|
|
22
|
+
* `('path')` is the non-default path to the `aide.conf` file (optional)
|
|
23
|
+
* `should include 'value'` is the value that is expected
|
|
24
|
+
|
|
25
|
+
Use the where clause to match a selection_line to one rule or a particular set of rules found in the aide.conf file:
|
|
26
|
+
|
|
27
|
+
describe aide_conf.where { selection_line == '/bin' } do
|
|
28
|
+
its('rules.flatten') { should include 'r' }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe aide_conf.where { selection_line == '/sbin' } do
|
|
32
|
+
its('rules') { should include ['p', 'i', 'l', 'n', 'u', 'g', 'sha512'] }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
<br>
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
The following examples show how to use this InSpec audit resource. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
|
40
|
+
|
|
41
|
+
### Test if all selection lines contain the xattr rule
|
|
42
|
+
|
|
43
|
+
describe aide_conf.all_have_rule('xattr') do
|
|
44
|
+
it { should eq true }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
### Test whether selection line for /bin contains a particular rule
|
|
48
|
+
|
|
49
|
+
describe aide_conf.where { selection_line == '/bin' } do
|
|
50
|
+
its('rules.flatten') { should include 'r' }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
### Test whether selection line for /sbin consists of a particular set of rules
|
|
54
|
+
|
|
55
|
+
describe aide_conf.where { selection_line == '/sbin' } do
|
|
56
|
+
its('rules') { should include ['r', 'sha512'] }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
<br>
|
|
60
|
+
|
|
61
|
+
## Matchers
|
|
62
|
+
|
|
63
|
+
This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
|
64
|
+
|
|
65
|
+
### all_have_rule
|
|
66
|
+
|
|
67
|
+
The usage of all_have_rule will return whether or not all selection lines in audit.conf contain a particular rule:
|
|
68
|
+
|
|
69
|
+
describe aide_conf.all_have_rule('sha512') do
|
|
70
|
+
it { should eq true }
|
|
71
|
+
end
|