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
|
@@ -6,7 +6,7 @@ title: About the os_env Resource
|
|
|
6
6
|
|
|
7
7
|
Use the `os_env` InSpec audit resource to test the environment variables for the platform on which the system is running.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Syntax
|
|
10
10
|
|
|
11
11
|
A `os_env` resource block declares an environment variable, and then declares its value:
|
|
12
12
|
|
|
@@ -20,37 +20,37 @@ where
|
|
|
20
20
|
* `matcher` is a valid matcher for this resource
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## Matchers
|
|
24
24
|
|
|
25
25
|
This InSpec audit resource has the following matchers:
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
### be
|
|
28
28
|
|
|
29
29
|
<%= partial "/shared/matcher_be" %>
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
### cmp
|
|
32
32
|
|
|
33
33
|
<%= partial "/shared/matcher_cmp" %>
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
### content
|
|
36
36
|
|
|
37
37
|
The `content` matcher return the value of the environment variable:
|
|
38
38
|
|
|
39
39
|
its('content') { should eq '/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin' }
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
### eq
|
|
42
42
|
|
|
43
43
|
<%= partial "/shared/matcher_eq" %>
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
### include
|
|
46
46
|
|
|
47
47
|
<%= partial "/shared/matcher_include" %>
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
### match
|
|
50
50
|
|
|
51
51
|
<%= partial "/shared/matcher_match" %>
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
### split
|
|
54
54
|
|
|
55
55
|
The `split` splits the content with the `:` deliminator:
|
|
56
56
|
|
|
@@ -64,18 +64,18 @@ Use `-1` to test for cases where there is a trailing colon (`:`), such as `dir1:
|
|
|
64
64
|
|
|
65
65
|
its('split') { should include ('-1') }
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
## Examples
|
|
68
68
|
|
|
69
69
|
The following examples show how to use this InSpec audit resource.
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
### Test the PATH environment variable
|
|
72
72
|
|
|
73
73
|
describe os_env('PATH') do
|
|
74
74
|
its('split') { should_not include('') }
|
|
75
75
|
its('split') { should_not include('.') }
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
### Test Habitat environment variables
|
|
79
79
|
|
|
80
80
|
Habitat uses the `os_env` resource to test environment variables. The environment variables are first defined in a whitespace array, after which each environment variable is tested:
|
|
81
81
|
|
|
@@ -7,7 +7,7 @@ title: About the package Resource
|
|
|
7
7
|
Use the `package` InSpec audit resource to test if the named package and/or package version is installed on the system.
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Syntax
|
|
11
11
|
|
|
12
12
|
A `package` resource block declares a package and (optionally) a package version:
|
|
13
13
|
|
|
@@ -20,60 +20,67 @@ where
|
|
|
20
20
|
* `('name')` must specify the name of a package, such as `'nginx'`
|
|
21
21
|
* `be_installed` is a valid matcher for this resource
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## Matchers
|
|
24
24
|
|
|
25
25
|
This InSpec audit resource has the following matchers:
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
### be
|
|
28
28
|
|
|
29
29
|
<%= partial "/shared/matcher_be" %>
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
### be_held
|
|
32
|
+
|
|
33
|
+
The `be_held` matcher tests if the named package is "held". On dpkg platforms, a "held" package
|
|
34
|
+
will not be upgraded to a later version.
|
|
35
|
+
|
|
36
|
+
it { should be_held }
|
|
37
|
+
|
|
38
|
+
### be_installed
|
|
32
39
|
|
|
33
40
|
The `be_installed` matcher tests if the named package is installed on the system:
|
|
34
41
|
|
|
35
42
|
it { should be_installed }
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
### cmp
|
|
38
45
|
|
|
39
46
|
<%= partial "/shared/matcher_cmp" %>
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
### eq
|
|
42
49
|
|
|
43
50
|
<%= partial "/shared/matcher_eq" %>
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
### include
|
|
46
53
|
|
|
47
54
|
<%= partial "/shared/matcher_include" %>
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
### match
|
|
50
57
|
|
|
51
58
|
<%= partial "/shared/matcher_match" %>
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
### version
|
|
54
61
|
|
|
55
62
|
The `version` matcher tests if the named package version is on the system:
|
|
56
63
|
|
|
57
64
|
its('version') { should eq '1.2.3' }
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
## Examples
|
|
60
67
|
|
|
61
68
|
The following examples show how to use this InSpec audit resource.
|
|
62
69
|
|
|
63
|
-
|
|
70
|
+
### Test if nginx version 1.9.5 is installed
|
|
64
71
|
|
|
65
72
|
describe package('nginx') do
|
|
66
73
|
it { should be_installed }
|
|
67
|
-
its('version') { should eq 1.9.5 }
|
|
74
|
+
its('version') { should eq '1.9.5' }
|
|
68
75
|
end
|
|
69
76
|
|
|
70
|
-
|
|
77
|
+
### Test that a package is not installed
|
|
71
78
|
|
|
72
79
|
describe package('some_package') do
|
|
73
80
|
it { should_not be_installed }
|
|
74
81
|
end
|
|
75
82
|
|
|
76
|
-
|
|
83
|
+
### Test if telnet is installed
|
|
77
84
|
|
|
78
85
|
describe package('telnetd') do
|
|
79
86
|
it { should_not be_installed }
|
|
@@ -83,7 +90,7 @@ The following examples show how to use this InSpec audit resource.
|
|
|
83
90
|
its('telnet') { should eq nil }
|
|
84
91
|
end
|
|
85
92
|
|
|
86
|
-
|
|
93
|
+
### Test if ClamAV (an antivirus engine) is installed and running
|
|
87
94
|
|
|
88
95
|
describe package('clamav') do
|
|
89
96
|
it { should be_installed }
|
|
@@ -96,7 +103,13 @@ The following examples show how to use this InSpec audit resource.
|
|
|
96
103
|
it { should_not be_running }
|
|
97
104
|
end
|
|
98
105
|
|
|
99
|
-
|
|
106
|
+
### Verify if some_package is installed according to my_rpmdb
|
|
107
|
+
|
|
108
|
+
describe package('some_package', rpm_dbpath: '/var/lib/my_rpmdb') do
|
|
109
|
+
it { should be_installed }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
### Verify if Memcached is installed, enabled, and running
|
|
100
113
|
|
|
101
114
|
Memcached is an in-memory key-value store that helps improve the performance of database-driven websites and can be installed, maintained, and tested using the `memcached` cookbook (maintained by Chef). The following example is from the `memcached` cookbook and shows how to use a combination of the `package`, `service`, and `port` InSpec audit resources to test if Memcached is installed, enabled, and running:
|
|
102
115
|
|
|
@@ -6,7 +6,7 @@ title: About the parse_config Resource
|
|
|
6
6
|
|
|
7
7
|
Use the `parse_config` InSpec audit resource to test arbitrary configuration files.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Syntax
|
|
10
10
|
|
|
11
11
|
A `parse_config` resource block declares the location of the configuration setting to be tested, and then what value is to be tested. Because this resource relies on arbitrary configuration files, the test itself is often arbitrary and relies on custom Ruby code:
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ or:
|
|
|
20
20
|
|
|
21
21
|
audit = command('/sbin/auditctl -l').stdout
|
|
22
22
|
options = {
|
|
23
|
-
|
|
23
|
+
assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
|
|
24
24
|
multiple_values: true
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -35,57 +35,57 @@ where each test
|
|
|
35
35
|
* May run a command to `stdout`, and then run the test against that output
|
|
36
36
|
* May use options to define how configuration data is to be parsed
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
## Matchers
|
|
39
39
|
|
|
40
40
|
This InSpec audit resource has the following matchers:
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
### assignment_regex
|
|
43
43
|
|
|
44
|
-
Use `
|
|
44
|
+
Use `assignment_regex` to test a key value using a regular expression:
|
|
45
45
|
|
|
46
46
|
'key = value'
|
|
47
47
|
|
|
48
48
|
may be tested using the following regular expression, which determines assignment from key to value:
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
assignment_regex: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
### be
|
|
53
53
|
|
|
54
54
|
<%= partial "/shared/matcher_be" %>
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
### cmp
|
|
57
57
|
|
|
58
58
|
<%= partial "/shared/matcher_cmp" %>
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
### comment_char
|
|
61
61
|
|
|
62
62
|
Use `comment_char` to test for comments in a configuration file:
|
|
63
63
|
|
|
64
64
|
comment_char: '#'
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
### eq
|
|
67
67
|
|
|
68
68
|
<%= partial "/shared/matcher_eq" %>
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
### include
|
|
71
71
|
|
|
72
72
|
<%= partial "/shared/matcher_include" %>
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
### key_values
|
|
75
75
|
|
|
76
|
-
Use `
|
|
76
|
+
Use `key_values` to test how many values a key contains:
|
|
77
77
|
|
|
78
78
|
key = a b c
|
|
79
79
|
|
|
80
80
|
contains three values. To test that value to ensure it only contains one, use:
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
key_values: 1
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
### match
|
|
85
85
|
|
|
86
86
|
<%= partial "/shared/matcher_match" %>
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
### multiple_values
|
|
89
89
|
|
|
90
90
|
Use `multiple_values` if the source file uses the same key multiple times. All values will be aggregated in an array:
|
|
91
91
|
|
|
@@ -105,7 +105,7 @@ To use plain key value mapping, use `multiple_values: false`:
|
|
|
105
105
|
params['key'] = 'b'
|
|
106
106
|
params['key2'] = 'c'
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
### standalone_comments
|
|
109
109
|
|
|
110
110
|
Use `standalone_comments` to parse comments as a line, otherwise inline comments are allowed:
|
|
111
111
|
|
|
@@ -117,6 +117,6 @@ Use `standalone_comments: false`, to parse the following:
|
|
|
117
117
|
'key = value # comment'
|
|
118
118
|
params['key'] = 'value'
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
## Examples
|
|
121
121
|
|
|
122
122
|
None.
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
title: About the parse_config_file Resource
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# parse\_config\_file
|
|
6
6
|
|
|
7
7
|
Use the `parse_config_file` InSpec audit resource to test arbitrary configuration files. It works in the same way as `parse_config`. Instead of using a command output, this resource works with files.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Syntax
|
|
10
10
|
|
|
11
11
|
A `parse_config_file` InSpec audit resource block declares the location of the configuration file to be tested, and then which settings in that file are to be tested.
|
|
12
12
|
|
|
@@ -17,7 +17,7 @@ A `parse_config_file` InSpec audit resource block declares the location of the c
|
|
|
17
17
|
or:
|
|
18
18
|
|
|
19
19
|
options = {
|
|
20
|
-
|
|
20
|
+
assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
|
|
21
21
|
multiple_values: true
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -32,69 +32,69 @@ where each test
|
|
|
32
32
|
* May run a command to `stdout`, and then run the test against that output
|
|
33
33
|
* May use options to define how configuration data is to be parsed
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
## Options
|
|
36
36
|
|
|
37
37
|
This resource supports the following options for parsing configuration data. Use them in an `options` block stated outside of (and immediately before) the actual test:
|
|
38
38
|
|
|
39
39
|
options = {
|
|
40
|
-
|
|
40
|
+
assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
|
|
41
41
|
multiple_values: true
|
|
42
42
|
}
|
|
43
43
|
describe parse_config_file('path/to/file', options) do
|
|
44
44
|
its('setting') { should eq 1 }
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
## Matchers
|
|
48
48
|
|
|
49
49
|
This InSpec audit resource has the following matchers:
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
### assignment_regex
|
|
52
52
|
|
|
53
|
-
Use `
|
|
53
|
+
Use `assignment_regex` to test a key value using a regular expression:
|
|
54
54
|
|
|
55
55
|
'key = value'
|
|
56
56
|
|
|
57
57
|
may be tested using the following regular expression, which determines assignment from key to value:
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
assignment_regex: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
### be
|
|
62
62
|
|
|
63
63
|
<%= partial "/shared/matcher_be" %>
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
### cmp
|
|
66
66
|
|
|
67
67
|
<%= partial "/shared/matcher_cmp" %>
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
### comment_char
|
|
70
70
|
|
|
71
71
|
Use `comment_char` to test for comments in a configuration file:
|
|
72
72
|
|
|
73
73
|
comment_char: '#'
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
### eq
|
|
76
76
|
|
|
77
77
|
<%= partial "/shared/matcher_eq" %>
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
### include
|
|
80
80
|
|
|
81
81
|
<%= partial "/shared/matcher_include" %>
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
### key_values
|
|
84
84
|
|
|
85
|
-
Use `
|
|
85
|
+
Use `key_values` to test how many values a key contains:
|
|
86
86
|
|
|
87
87
|
key = a b c
|
|
88
88
|
|
|
89
89
|
contains three values. To test that value to ensure it only contains one, use:
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
key_values: 1
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
### match
|
|
94
94
|
|
|
95
95
|
<%= partial "/shared/matcher_match" %>
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
### multiple_values
|
|
98
98
|
|
|
99
99
|
Use `multiple_values` if the source file uses the same key multiple times. All values will be aggregated in an array:
|
|
100
100
|
|
|
@@ -114,7 +114,7 @@ To use plain key value mapping, use `multiple_values: false`:
|
|
|
114
114
|
params['key'] = 'b'
|
|
115
115
|
params['key2'] = 'c'
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
### standalone_comments
|
|
118
118
|
|
|
119
119
|
Use `standalone_comments` to parse comments as a line, otherwise inline comments are allowed:
|
|
120
120
|
|
|
@@ -126,18 +126,24 @@ Use `standalone_comments: false`, to parse the following:
|
|
|
126
126
|
'key = value # comment'
|
|
127
127
|
params['key'] = 'value'
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
## Examples
|
|
130
130
|
|
|
131
131
|
The following examples show how to use this InSpec audit resource.
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
### Test a configuration setting
|
|
134
134
|
|
|
135
135
|
describe parse_config_file('/path/to/file.conf') do
|
|
136
136
|
its('PARAM_X') { should eq 'Y' }
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
### Use options, and then test a configuration setting
|
|
140
140
|
|
|
141
141
|
describe parse_config_file('/path/to/file.conf', { multiple_values: true }) do
|
|
142
142
|
its('PARAM_X') { should include 'Y' }
|
|
143
143
|
end
|
|
144
|
+
|
|
145
|
+
## Test a file with an ini-like structure (such as a yum.conf)
|
|
146
|
+
|
|
147
|
+
describe parse_config_file('/path/to/yum.conf') do
|
|
148
|
+
its('main') { should include('gpgcheck' => '1') }
|
|
149
|
+
end
|
|
@@ -18,7 +18,7 @@ These entries are defined as a colon-delimited row in the file, one row per user
|
|
|
18
18
|
|
|
19
19
|
root:x:1234:5678:additional_info:/home/dir/:/bin/bash
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
## Syntax
|
|
22
22
|
|
|
23
23
|
A `passwd` resource block declares one (or more) users and associated user information to be tested:
|
|
24
24
|
|
|
@@ -38,40 +38,40 @@ where
|
|
|
38
38
|
* `filter` may take any of the following arguments: `count` (retrieves the number of entries), `lines` (provides raw `passwd` lines), and `params` (returns an array of maps for all entries)
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
## Matchers
|
|
42
42
|
|
|
43
43
|
This InSpec audit resource has the following matchers:
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
### be
|
|
46
46
|
|
|
47
47
|
<%= partial "/shared/matcher_be" %>
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
### cmp
|
|
50
50
|
|
|
51
51
|
<%= partial "/shared/matcher_cmp" %>
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
### eq
|
|
54
54
|
|
|
55
55
|
<%= partial "/shared/matcher_eq" %>
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
### gids
|
|
58
58
|
|
|
59
59
|
The `gids` matcher tests if the group indentifiers in the test match group identifiers in `/etc/passwd`:
|
|
60
60
|
|
|
61
61
|
its('gids') { should include 1234 }
|
|
62
62
|
its('gids') { should cmp 0 }
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
### homes
|
|
65
65
|
|
|
66
66
|
The `homes` matcher tests the absolute path to a user's home directory:
|
|
67
67
|
|
|
68
68
|
its('home') { should eq '/' }
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
### include
|
|
71
71
|
|
|
72
72
|
<%= partial "/shared/matcher_include" %>
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
### length
|
|
75
75
|
|
|
76
76
|
The `length` matcher tests the length of a password that appears in `/etc/passwd`:
|
|
77
77
|
|
|
@@ -83,11 +83,11 @@ This matcher is best used in conjunction with filters. For example:
|
|
|
83
83
|
its('length') { should_not be < 16 }
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
### match
|
|
87
87
|
|
|
88
88
|
<%= partial "/shared/matcher_match" %>
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
### passwords
|
|
91
91
|
|
|
92
92
|
The `passwords` matcher tests if passwords are
|
|
93
93
|
|
|
@@ -100,7 +100,7 @@ For example:
|
|
|
100
100
|
its('passwords') { should eq ['x'] }
|
|
101
101
|
its('passwords') { should cmp '*' }
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
### shells
|
|
104
104
|
|
|
105
105
|
The `shells` matcher tests the absolute path of a shell (or command) to which a user has access:
|
|
106
106
|
|
|
@@ -112,7 +112,7 @@ or to find all users with the nologin shell:
|
|
|
112
112
|
its('users') { should_not include 'my_login_user' }
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
### uids
|
|
116
116
|
|
|
117
117
|
The `uids` matcher tests if the user indentifiers in the test match user identifiers in `/etc/passwd`:
|
|
118
118
|
|
|
@@ -125,24 +125,24 @@ or:
|
|
|
125
125
|
its('count') { should eq 1 }
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
### users
|
|
129
129
|
|
|
130
130
|
The `users` matcher tests if the user names in the test match user names in `/etc/passwd`:
|
|
131
131
|
|
|
132
132
|
its('users') { should eq ['root', 'www-data'] }
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
## Examples
|
|
135
135
|
|
|
136
136
|
The following examples show how to use this InSpec audit resource.
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
### Test usernames and UIDs
|
|
139
139
|
|
|
140
140
|
describe passwd do
|
|
141
141
|
its('users') { should eq ['root', 'www-data'] }
|
|
142
142
|
its('uids') { should eq [0, 33] }
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
### Select one user and test for multiple occurrences
|
|
146
146
|
|
|
147
147
|
describe passwd.uids(0) do
|
|
148
148
|
its('users') { should cmp 'root' }
|
data/docs/resources/pip.md.erb
CHANGED
|
@@ -6,67 +6,67 @@ title: About the pip Resource
|
|
|
6
6
|
|
|
7
7
|
Use the `pip` InSpec audit resource to test packages that are installed using the Python PIP installer.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Syntax
|
|
10
10
|
|
|
11
11
|
A `pip` resource block declares a package and (optionally) a package version:
|
|
12
12
|
|
|
13
|
-
describe pip('
|
|
13
|
+
describe pip('package_name') do
|
|
14
14
|
it { should be_installed }
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
where
|
|
18
18
|
|
|
19
|
-
* `'
|
|
20
|
-
* `be_installed` tests to see if the
|
|
19
|
+
* `'package_name'` is the name of the package, such as `'Jinja2'`
|
|
20
|
+
* `be_installed` tests to see if the package described above is installed
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## Matchers
|
|
24
24
|
|
|
25
25
|
This InSpec audit resource has the following matchers:
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
### be
|
|
28
28
|
|
|
29
29
|
<%= partial "/shared/matcher_be" %>
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
### be_installed
|
|
32
32
|
|
|
33
33
|
The `be_installed` matcher tests if the named package is installed on the system:
|
|
34
34
|
|
|
35
35
|
it { should be_installed }
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
### cmp
|
|
38
38
|
|
|
39
39
|
<%= partial "/shared/matcher_cmp" %>
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
### eq
|
|
42
42
|
|
|
43
43
|
<%= partial "/shared/matcher_eq" %>
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
### include
|
|
46
46
|
|
|
47
47
|
<%= partial "/shared/matcher_include" %>
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
### match
|
|
50
50
|
|
|
51
51
|
<%= partial "/shared/matcher_match" %>
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
### version
|
|
54
54
|
|
|
55
55
|
The `version` matcher tests if the named package version is on the system:
|
|
56
56
|
|
|
57
57
|
its('version') { should eq '1.2.3' }
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
## Examples
|
|
60
60
|
|
|
61
61
|
The following examples show how to use this InSpec audit resource.
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
### Test if Jinja2 is installed on the system
|
|
64
64
|
|
|
65
65
|
describe pip('Jinja2') do
|
|
66
66
|
it { should be_installed }
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
### Test if Jinja2 2.8 is installed on the system
|
|
70
70
|
|
|
71
71
|
describe pip('Jinja2') do
|
|
72
72
|
it { should be_installed }
|