inspec 0.34.1 → 1.0.0
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 +323 -6
- data/Gemfile +10 -0
- data/README.md +1 -1
- data/Rakefile +4 -55
- data/docs/.gitignore +2 -0
- data/docs/README.md +40 -0
- data/docs/cli.md +342 -0
- data/docs/dsl_inspec.md +245 -0
- data/docs/dsl_resource.md +93 -0
- data/docs/inspec_and_friends.md +105 -0
- data/docs/matchers.md +136 -0
- data/docs/plugin_kitchen_inspec.html.md +55 -0
- data/docs/profiles.md +285 -0
- data/docs/resources/apache_conf.md.erb +75 -0
- data/docs/resources/apt.md.erb +84 -0
- data/docs/resources/audit_policy.md.erb +61 -0
- data/docs/resources/auditd_conf.md.erb +79 -0
- data/docs/resources/auditd_rules.md.erb +132 -0
- data/docs/resources/bash.md.erb +84 -0
- data/docs/resources/bond.md.erb +97 -0
- data/docs/resources/bridge.md.erb +67 -0
- data/docs/resources/bsd_service.md.erb +76 -0
- data/docs/resources/command.md.erb +151 -0
- data/docs/resources/csv.md.erb +62 -0
- data/docs/resources/directory.md.erb +43 -0
- data/docs/resources/etc_group.md.erb +116 -0
- data/docs/resources/etc_passwd.md.erb +155 -0
- data/docs/resources/etc_shadow.md.erb +149 -0
- data/docs/resources/file.md.erb +460 -0
- data/docs/resources/gem.md.erb +73 -0
- data/docs/resources/group.md.erb +74 -0
- data/docs/resources/grub_conf.md.erb +115 -0
- data/docs/resources/host.md.erb +85 -0
- data/docs/resources/iis_site.md.erb +142 -0
- data/docs/resources/inetd_conf.md.erb +99 -0
- data/docs/resources/ini.md.erb +69 -0
- data/docs/resources/interface.md.erb +66 -0
- data/docs/resources/iptables.md.erb +70 -0
- data/docs/resources/json.md.erb +76 -0
- data/docs/resources/kernel_module.md.erb +60 -0
- data/docs/resources/kernel_parameter.md.erb +72 -0
- data/docs/resources/launchd_service.md.erb +76 -0
- data/docs/resources/limits_conf.md.erb +80 -0
- data/docs/resources/login_def.md.erb +77 -0
- data/docs/resources/mount.md.erb +83 -0
- data/docs/resources/mysql_conf.md.erb +102 -0
- data/docs/resources/mysql_session.md.erb +63 -0
- data/docs/resources/npm.md.erb +75 -0
- data/docs/resources/ntp_conf.md.erb +76 -0
- data/docs/resources/oneget.md.erb +67 -0
- data/docs/resources/os.md.erb +154 -0
- data/docs/resources/os_env.md.erb +98 -0
- data/docs/resources/package.md.erb +115 -0
- data/docs/resources/parse_config.md.erb +122 -0
- data/docs/resources/parse_config_file.md.erb +143 -0
- data/docs/resources/pip.md.erb +74 -0
- data/docs/resources/port.md.erb +150 -0
- data/docs/resources/postgres_conf.md.erb +90 -0
- data/docs/resources/postgres_session.md.erb +75 -0
- data/docs/resources/powershell.md.erb +116 -0
- data/docs/resources/process.md.erb +73 -0
- data/docs/resources/registry_key.md.erb +149 -0
- data/docs/resources/runit_service.md.erb +76 -0
- data/docs/resources/security_policy.md.erb +61 -0
- data/docs/resources/service.md.erb +135 -0
- data/docs/resources/ssh_config.md.erb +94 -0
- data/docs/resources/sshd_config.md.erb +97 -0
- data/docs/resources/ssl.md.erb +133 -0
- data/docs/resources/sys_info.md.erb +55 -0
- data/docs/resources/systemd_service.md.erb +76 -0
- data/docs/resources/sysv_service.md.erb +76 -0
- data/docs/resources/upstart_service.md.erb +76 -0
- data/docs/resources/user.md.erb +154 -0
- data/docs/resources/users.md.erb +140 -0
- data/docs/resources/vbscript.md.erb +69 -0
- data/docs/resources/windows_feature.md.erb +61 -0
- data/docs/resources/wmi.md.erb +95 -0
- data/docs/resources/xinetd_conf.md.erb +170 -0
- data/docs/resources/yaml.md.erb +69 -0
- data/docs/resources/yum.md.erb +103 -0
- data/docs/ruby_usage.md +154 -0
- data/docs/shared/matcher_be.md.erb +1 -0
- data/docs/shared/matcher_cmp.md.erb +45 -0
- data/docs/shared/matcher_eq.md.erb +3 -0
- data/docs/shared/matcher_include.md.erb +1 -0
- data/docs/shared/matcher_match.md.erb +1 -0
- data/docs/shell.md +150 -0
- data/examples/meta-profile/inspec.yml +2 -4
- data/inspec.gemspec +1 -1
- data/lib/bundles/inspec-compliance/api.rb +28 -18
- data/lib/bundles/inspec-compliance/cli.rb +19 -27
- data/lib/bundles/inspec-compliance/target.rb +15 -2
- data/lib/fetchers/git.rb +4 -0
- data/lib/fetchers/local.rb +16 -1
- data/lib/fetchers/mock.rb +4 -0
- data/lib/fetchers/url.rb +46 -20
- data/lib/inspec/base_cli.rb +14 -0
- data/lib/inspec/cached_fetcher.rb +67 -0
- data/lib/inspec/cli.rb +22 -8
- data/lib/inspec/control_eval_context.rb +12 -2
- data/lib/inspec/dependencies/{vendor_index.rb → cache.rb} +5 -4
- data/lib/inspec/dependencies/dependency_set.rb +8 -14
- data/lib/inspec/dependencies/lockfile.rb +5 -13
- data/lib/inspec/dependencies/requirement.rb +31 -41
- data/lib/inspec/dependencies/resolver.rb +3 -3
- data/lib/inspec/dsl.rb +16 -4
- data/lib/inspec/errors.rb +1 -0
- data/lib/inspec/fetcher.rb +25 -1
- data/lib/inspec/objects/each_loop.rb +5 -2
- data/lib/inspec/objects/test.rb +8 -2
- data/lib/inspec/plugins/fetcher.rb +13 -12
- data/lib/inspec/plugins/resource.rb +3 -0
- data/lib/inspec/profile.rb +62 -26
- data/lib/inspec/profile_context.rb +44 -8
- data/lib/inspec/resource.rb +18 -3
- data/lib/inspec/rspec_json_formatter.rb +91 -40
- data/lib/inspec/rule.rb +45 -2
- data/lib/inspec/runner.rb +51 -39
- data/lib/inspec/shell.rb +5 -16
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/apache_conf.rb +1 -1
- data/lib/resources/gem.rb +1 -0
- data/lib/resources/groups.rb +190 -0
- data/lib/resources/oneget.rb +1 -0
- data/lib/resources/os.rb +1 -1
- data/lib/resources/package.rb +3 -1
- data/lib/resources/parse_config.rb +18 -1
- data/lib/resources/pip.rb +1 -1
- data/lib/resources/security_policy.rb +54 -0
- data/lib/resources/ssl.rb +9 -11
- data/lib/resources/sys_info.rb +1 -1
- data/lib/resources/users.rb +81 -64
- metadata +91 -17
- data/docs/cli.rst +0 -442
- data/docs/dsl_inspec.rst +0 -259
- data/docs/dsl_resource.rst +0 -90
- data/docs/inspec_and_friends.rst +0 -85
- data/docs/matchers.rst +0 -137
- data/docs/profiles.rst +0 -169
- data/docs/readme.rst +0 -105
- data/docs/resources.rst +0 -4836
- data/docs/ruby_usage.rst +0 -145
- data/docs/shell.rst +0 -130
- data/docs/template.rst +0 -51
- data/lib/resources/group.rb +0 -137
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the vbscript Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# vbscript
|
|
6
|
+
|
|
7
|
+
Use the `vbscript` InSpec audit resource to test a VBScript on the Windows platform.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
A `vbscript` resource block tests the output of a VBScript on the Windows platform:
|
|
12
|
+
|
|
13
|
+
describe vbscript('script_name') do
|
|
14
|
+
its('stdout') { should eq 'output' }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
where
|
|
18
|
+
|
|
19
|
+
* `'script_name'` is the name of the VBScript to test
|
|
20
|
+
* `('output')` is the expected output of the VBScript
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Matchers
|
|
24
|
+
|
|
25
|
+
This InSpec audit resource has the following matchers:
|
|
26
|
+
|
|
27
|
+
## be
|
|
28
|
+
|
|
29
|
+
<%= partial "/shared/matcher_be" %>
|
|
30
|
+
|
|
31
|
+
## cmp
|
|
32
|
+
|
|
33
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
34
|
+
|
|
35
|
+
## eq
|
|
36
|
+
|
|
37
|
+
<%= partial "/shared/matcher_eq" %>
|
|
38
|
+
|
|
39
|
+
## include
|
|
40
|
+
|
|
41
|
+
<%= partial "/shared/matcher_include" %>
|
|
42
|
+
|
|
43
|
+
## match
|
|
44
|
+
|
|
45
|
+
<%= partial "/shared/matcher_match" %>
|
|
46
|
+
|
|
47
|
+
# Examples
|
|
48
|
+
|
|
49
|
+
The following examples show how to use this InSpec audit resource.
|
|
50
|
+
|
|
51
|
+
## Test a VBScript
|
|
52
|
+
|
|
53
|
+
A VBScript file similar to:
|
|
54
|
+
|
|
55
|
+
vbscript = <<-EOH
|
|
56
|
+
WScript.Echo "hello"
|
|
57
|
+
EOH
|
|
58
|
+
|
|
59
|
+
may be tested for multiple lines:
|
|
60
|
+
|
|
61
|
+
describe vbscript(vbscript) do
|
|
62
|
+
its('stdout') { should eq "hello\r\n" }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
and tested for whitespace removal from standard output:
|
|
66
|
+
|
|
67
|
+
describe vbscript(vbscript) do
|
|
68
|
+
its('strip') { should eq "hello" }
|
|
69
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the windows_feature Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# windows_feature
|
|
6
|
+
|
|
7
|
+
Use the `windows_feature` InSpec audit resource to test features on Windows via the `Get-WindowsFeature` cmdlet.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
A `windows_feature` resource block declares the name of the Windows feature, tests if that feature is installed, and then returns information about that feature:
|
|
12
|
+
|
|
13
|
+
describe windows_feature('feature_name') do
|
|
14
|
+
it { should be_installed }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
where
|
|
18
|
+
|
|
19
|
+
* `('feature_name')` must specify a Windows feature name, such as `DHCP Server` or `IIS-Webserver`
|
|
20
|
+
* `be_installed` is a valid matcher for this resource
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Matchers
|
|
24
|
+
|
|
25
|
+
This InSpec audit resource has the following matchers:
|
|
26
|
+
|
|
27
|
+
## be
|
|
28
|
+
|
|
29
|
+
<%= partial "/shared/matcher_be" %>
|
|
30
|
+
|
|
31
|
+
## be_installed
|
|
32
|
+
|
|
33
|
+
The `be_installed` matcher tests if the named Windows feature is installed:
|
|
34
|
+
|
|
35
|
+
it { should be_installed }
|
|
36
|
+
|
|
37
|
+
## cmp
|
|
38
|
+
|
|
39
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
40
|
+
|
|
41
|
+
## eq
|
|
42
|
+
|
|
43
|
+
<%= partial "/shared/matcher_eq" %>
|
|
44
|
+
|
|
45
|
+
## include
|
|
46
|
+
|
|
47
|
+
<%= partial "/shared/matcher_include" %>
|
|
48
|
+
|
|
49
|
+
## match
|
|
50
|
+
|
|
51
|
+
<%= partial "/shared/matcher_match" %>
|
|
52
|
+
|
|
53
|
+
# Examples
|
|
54
|
+
|
|
55
|
+
The following examples show how to use this InSpec audit resource.
|
|
56
|
+
|
|
57
|
+
## Test the DHCP Server feature
|
|
58
|
+
|
|
59
|
+
describe windows_feature('DHCP Server') do
|
|
60
|
+
it{ should be_installed }
|
|
61
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the wmi Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# wmi
|
|
6
|
+
|
|
7
|
+
Use the `wmi` InSpec audit resource to test WMI settings on the Windows platform.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
A `wmi` resource block tests WMI settings on the Windows platform:
|
|
12
|
+
|
|
13
|
+
describe wmi({
|
|
14
|
+
class: 'class_name'
|
|
15
|
+
namespace: 'path\\to\\setting'
|
|
16
|
+
filter: 'filter'
|
|
17
|
+
query: 'query'
|
|
18
|
+
}) do
|
|
19
|
+
its('setting_name') { should eq '' }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
where
|
|
23
|
+
|
|
24
|
+
* `class`, `namespace`, `filter`, and `query` comprise a Ruby Hash of the WMI object
|
|
25
|
+
* `('class')` is the WMI class to which the setting belongs, such as `win32_service`
|
|
26
|
+
* `('namespace')` is path to that object, such as `root\\cimv2`
|
|
27
|
+
* Use `('filter')` fine-tune the information defined by the WMI class, such as to find a specific service (`filter: "name like '%winrm%'")`, to find a specific setting (`filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1'`), and so on
|
|
28
|
+
* Use `('query')` to run a query that returns data to be tested, such as `"SELECT Setting FROM RSOP_SecuritySettingBoolean WHERE KeyName='LSAAnonymousNameLookup' AND Precedence=1"`
|
|
29
|
+
* `('setting_name')` is a setting in the WMI object to be tested, and then `should eq ''` is the expected value for that setting
|
|
30
|
+
|
|
31
|
+
For example, both of the following tests will verify if WinRM is present on the target node. The first tests if WinRM belongs to the list of services running under the `win32_service` class:
|
|
32
|
+
|
|
33
|
+
describe wmi({class: 'win32_service'}) do
|
|
34
|
+
its('DisplayName') { should include 'Windows Remote Management (WS-Management)'}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
and the second uses a filter in the Ruby Hash to first identify WinRM, and then perform additional tests:
|
|
38
|
+
|
|
39
|
+
describe wmi({
|
|
40
|
+
class: 'win32_service',
|
|
41
|
+
filter: "name like '%winrm%'"
|
|
42
|
+
}) do
|
|
43
|
+
its('Status') { should cmp 'ok' }
|
|
44
|
+
its('State') { should cmp 'Running' }
|
|
45
|
+
its('ExitCode') { should cmp 0 }
|
|
46
|
+
its('DisplayName') { should eq 'Windows Remote Management (WS-Management)'}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# Matchers
|
|
51
|
+
|
|
52
|
+
This InSpec audit resource has the following matchers:
|
|
53
|
+
|
|
54
|
+
## be
|
|
55
|
+
|
|
56
|
+
<%= partial "/shared/matcher_be" %>
|
|
57
|
+
|
|
58
|
+
## cmp
|
|
59
|
+
|
|
60
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
61
|
+
|
|
62
|
+
## eq
|
|
63
|
+
|
|
64
|
+
<%= partial "/shared/matcher_eq" %>
|
|
65
|
+
|
|
66
|
+
## include
|
|
67
|
+
|
|
68
|
+
<%= partial "/shared/matcher_include" %>
|
|
69
|
+
|
|
70
|
+
## match
|
|
71
|
+
|
|
72
|
+
<%= partial "/shared/matcher_match" %>
|
|
73
|
+
|
|
74
|
+
# Examples
|
|
75
|
+
|
|
76
|
+
The following examples show how to use this InSpec audit resource.
|
|
77
|
+
|
|
78
|
+
## Test a password expiration policy
|
|
79
|
+
|
|
80
|
+
describe wmi({
|
|
81
|
+
class: 'RSOP_SecuritySettingNumeric',
|
|
82
|
+
namespace: 'root\\rsop\\computer',
|
|
83
|
+
filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1'
|
|
84
|
+
}) do
|
|
85
|
+
its('Setting') { should eq 1 }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
## Test if an anonymous user can query the Local Security Authority (LSA)
|
|
89
|
+
|
|
90
|
+
describe wmi({
|
|
91
|
+
namespace: 'root\rsop\computer',
|
|
92
|
+
query: "SELECT Setting FROM RSOP_SecuritySettingBoolean WHERE KeyName='LSAAnonymousNameLookup' AND Precedence=1"
|
|
93
|
+
}) do
|
|
94
|
+
its('Setting') { should eq false }
|
|
95
|
+
end
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the xinetd_conf Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# xinetd_conf
|
|
6
|
+
|
|
7
|
+
Use the `xinetd_conf` InSpec audit resource to test services under `/etc/xinet.d` on Linux and Unix platforms. xinetd---the extended Internet service daemon---listens on all ports, and then loads the appropriate program based on a request. The `xinetd.conf` file is typically located at `/etc/xinetd.conf` and contains a list of Internet services associated to the ports on which that service will listen. Only enabled services may handle a request; only services that are required by the system should be enabled.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
An `xinetd_conf` resource block declares settings found in a `xinetd.conf` file for the named service:
|
|
12
|
+
|
|
13
|
+
describe xinetd_conf('service_name') do
|
|
14
|
+
it { should be_enabled } # or be_disabled
|
|
15
|
+
its('setting') { should eq 'value' }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
where
|
|
19
|
+
|
|
20
|
+
* `'service_name'` is a service located under `/etc/xinet.d`
|
|
21
|
+
* `('setting')` is a setting in the `xinetd.conf` file
|
|
22
|
+
* `should eq 'value'` is the value that is expected
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Matchers
|
|
26
|
+
|
|
27
|
+
This InSpec audit resource has the following matchers:
|
|
28
|
+
|
|
29
|
+
## be
|
|
30
|
+
|
|
31
|
+
<%= partial "/shared/matcher_be" %>
|
|
32
|
+
|
|
33
|
+
## be_enabed
|
|
34
|
+
|
|
35
|
+
The `be_enabled` matcher tests if a service listed under `/etc/xinet.d` is enabled:
|
|
36
|
+
|
|
37
|
+
it { should be_enabled }
|
|
38
|
+
|
|
39
|
+
## cmp
|
|
40
|
+
|
|
41
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
42
|
+
|
|
43
|
+
## eq
|
|
44
|
+
|
|
45
|
+
<%= partial "/shared/matcher_eq" %>
|
|
46
|
+
|
|
47
|
+
## ids
|
|
48
|
+
|
|
49
|
+
The `ids` matcher tests if the named service is located under `/etc/xinet.d`:
|
|
50
|
+
|
|
51
|
+
its('ids') { should include 'service_name' }
|
|
52
|
+
|
|
53
|
+
For example:
|
|
54
|
+
|
|
55
|
+
its('ids') { should include 'chargen-stream chargen-dgram'}
|
|
56
|
+
|
|
57
|
+
## include
|
|
58
|
+
|
|
59
|
+
<%= partial "/shared/matcher_include" %>
|
|
60
|
+
|
|
61
|
+
## match
|
|
62
|
+
|
|
63
|
+
<%= partial "/shared/matcher_match" %>
|
|
64
|
+
|
|
65
|
+
## services
|
|
66
|
+
|
|
67
|
+
The `services` matcher tests if the named service is listed under `/etc/xinet.d`:
|
|
68
|
+
|
|
69
|
+
its('services') { should include 'service_name' }
|
|
70
|
+
|
|
71
|
+
## socket_types
|
|
72
|
+
|
|
73
|
+
The `socket_types` matcher tests if a service listed under `/etc/xinet.d` is configured to use the named socket type:
|
|
74
|
+
|
|
75
|
+
its('socket_types') { should eq 'socket' }
|
|
76
|
+
|
|
77
|
+
where `socket` is one of `dgram`, `raw`, or `stream`. For a UDP-based service:
|
|
78
|
+
|
|
79
|
+
its('socket_types') { should eq 'dgram' }
|
|
80
|
+
|
|
81
|
+
For a raw socket (such as a service using a non-standard protocol or a service that requires direct access to IP):
|
|
82
|
+
|
|
83
|
+
its('socket_types') { should eq 'raw' }
|
|
84
|
+
|
|
85
|
+
For a TCP-based service:
|
|
86
|
+
|
|
87
|
+
its('socket_types') { should eq 'stream' }
|
|
88
|
+
|
|
89
|
+
## types
|
|
90
|
+
|
|
91
|
+
The `types` matcher tests the service type:
|
|
92
|
+
|
|
93
|
+
its('type') { should eq 'TYPE' }
|
|
94
|
+
|
|
95
|
+
where `'TYPE'` is `INTERNAL` (for a service provided by xinetd), `RPC` (for a service based on remote procedure call), or `UNLISTED` (for services not under `/etc/services` or `/etc/rpc`).
|
|
96
|
+
|
|
97
|
+
## wait
|
|
98
|
+
|
|
99
|
+
The `wait` matcher tests how a service handles incoming connections.
|
|
100
|
+
|
|
101
|
+
For UDP (`dgram`) socket types the `wait` matcher should test for `yes`:
|
|
102
|
+
|
|
103
|
+
its('socket_types') { should eq 'dgram' }
|
|
104
|
+
its('wait') { should eq 'yes' }
|
|
105
|
+
|
|
106
|
+
For TCP (`stream`) socket types the `wait` matcher should test for `no`:
|
|
107
|
+
|
|
108
|
+
its('socket_types') { should eq 'stream' }
|
|
109
|
+
its('wait') { should eq 'no' }
|
|
110
|
+
|
|
111
|
+
# Examples
|
|
112
|
+
|
|
113
|
+
The following examples show how to use this InSpec audit resource.
|
|
114
|
+
|
|
115
|
+
## Test a socket_type
|
|
116
|
+
|
|
117
|
+
The network socket type: `dgram` (a datagram-based service), `raw` (a service that requires direct access to an IP address), `stream` (a stream-based service), or `seqpacket` (a service that requires a sequenced packet).
|
|
118
|
+
|
|
119
|
+
describe xinetd_conf.services('service_name') do
|
|
120
|
+
its('socket_types') { should include 'dgram' }
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
## Test a service type
|
|
124
|
+
|
|
125
|
+
The type of service: `INTERNAL` (a service provided by xinetd), `RPC` (an RPC-based service), `TCPMUX` (a service that is started on a well-known TPCMUX port), or `UNLISTED` (a service that is not listed in a standard system file location).
|
|
126
|
+
|
|
127
|
+
describe xinetd_conf.services('service_name') do
|
|
128
|
+
its('type') { should include 'RPC' }
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
## Test the telnet service
|
|
132
|
+
|
|
133
|
+
For example, a `telnet` file under `/etc/xinet.d` contains the following settings:
|
|
134
|
+
|
|
135
|
+
service telnet
|
|
136
|
+
{
|
|
137
|
+
disable = yes
|
|
138
|
+
flags = REUSE
|
|
139
|
+
socket_type = stream
|
|
140
|
+
wait = no
|
|
141
|
+
user = root
|
|
142
|
+
server = /usr/sbin/in.telnetd
|
|
143
|
+
log_on_failure += USERID
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
Some examples of tests that can be run against that file include:
|
|
147
|
+
|
|
148
|
+
describe xinetd_conf.services('telnet') do
|
|
149
|
+
it { should be_disabled }
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
and
|
|
153
|
+
|
|
154
|
+
describe xinetd_conf.services('telnet') do
|
|
155
|
+
its('socket_type') { should include 'stream' }
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
and
|
|
159
|
+
|
|
160
|
+
describe xinetd_conf.services('telnet') do
|
|
161
|
+
its('wait') { should eq 'no' }
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
All three settings can be tested in the same block as well:
|
|
165
|
+
|
|
166
|
+
describe xinetd_conf.services('telnet') do
|
|
167
|
+
it { should be_disabled }
|
|
168
|
+
its('socket_type') { should include 'stream' }
|
|
169
|
+
its('wait') { should eq 'no' }
|
|
170
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the yaml Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# yaml
|
|
6
|
+
|
|
7
|
+
Use the `yaml` InSpec audit resource to test configuration data in a Yaml file.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
A `yaml` resource block declares the configuration data to be tested. Assume the following Yaml file:
|
|
12
|
+
|
|
13
|
+
name: foo
|
|
14
|
+
array:
|
|
15
|
+
- zero
|
|
16
|
+
- one
|
|
17
|
+
|
|
18
|
+
This file can be queried using:
|
|
19
|
+
|
|
20
|
+
describe yaml do
|
|
21
|
+
its('name') { should eq 'foo' }
|
|
22
|
+
its(['array', 1]) { should eq 'one' }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
where
|
|
26
|
+
|
|
27
|
+
* `name` is a configuration setting in a Yaml file
|
|
28
|
+
* `should eq 'foo'` tests a value of `name` as read from a Yaml file versus the value declared in the test
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Matchers
|
|
32
|
+
|
|
33
|
+
This InSpec audit resource has the following matchers:
|
|
34
|
+
|
|
35
|
+
## be
|
|
36
|
+
|
|
37
|
+
<%= partial "/shared/matcher_be" %>
|
|
38
|
+
|
|
39
|
+
## cmp
|
|
40
|
+
|
|
41
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
42
|
+
|
|
43
|
+
## eq
|
|
44
|
+
|
|
45
|
+
<%= partial "/shared/matcher_eq" %>
|
|
46
|
+
|
|
47
|
+
## include
|
|
48
|
+
|
|
49
|
+
<%= partial "/shared/matcher_include" %>
|
|
50
|
+
|
|
51
|
+
## match
|
|
52
|
+
|
|
53
|
+
<%= partial "/shared/matcher_match" %>
|
|
54
|
+
|
|
55
|
+
## name
|
|
56
|
+
|
|
57
|
+
The `name` matcher tests the value of `name` as read from a Yaml file versus the value declared in the test:
|
|
58
|
+
|
|
59
|
+
its('name') { should eq 'foo' }
|
|
60
|
+
|
|
61
|
+
# Examples
|
|
62
|
+
|
|
63
|
+
The following examples show how to use this InSpec audit resource.
|
|
64
|
+
|
|
65
|
+
## Test a kitchen.yml file driver
|
|
66
|
+
|
|
67
|
+
describe yaml('.kitchen.yaml') do
|
|
68
|
+
its('driver.name') { should eq('vagrant') }
|
|
69
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the yum Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# yum
|
|
6
|
+
|
|
7
|
+
Use the `yum` InSpec audit resource to test packages in the Yum repository.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
A `yum` resource block declares a package repo, tests if the package repository is present, and if it that package repository is a valid package source (i.e. "is enabled"):
|
|
12
|
+
|
|
13
|
+
describe yum.repo('name') do
|
|
14
|
+
it { should exist }
|
|
15
|
+
it { should be_enabled }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
where
|
|
19
|
+
|
|
20
|
+
* `repo('name')` is the (optional) name of a package repo, using either a full identifier (`'updates/7/x86_64'`) or a short identifier (`'updates'`)
|
|
21
|
+
|
|
22
|
+
# Matchers
|
|
23
|
+
|
|
24
|
+
This InSpec audit resource has the following matchers:
|
|
25
|
+
|
|
26
|
+
## be
|
|
27
|
+
|
|
28
|
+
<%= partial "/shared/matcher_be" %>
|
|
29
|
+
|
|
30
|
+
## be_enabled
|
|
31
|
+
|
|
32
|
+
The `be_enabled` matcher tests if the package repository is a valid package source:
|
|
33
|
+
|
|
34
|
+
it { should be_enabled }
|
|
35
|
+
|
|
36
|
+
## cmp
|
|
37
|
+
|
|
38
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
39
|
+
|
|
40
|
+
## eq
|
|
41
|
+
|
|
42
|
+
<%= partial "/shared/matcher_eq" %>
|
|
43
|
+
|
|
44
|
+
## exist
|
|
45
|
+
|
|
46
|
+
The `exist` matcher tests if the package repository exists:
|
|
47
|
+
|
|
48
|
+
it { should exist }
|
|
49
|
+
|
|
50
|
+
## include
|
|
51
|
+
|
|
52
|
+
<%= partial "/shared/matcher_include" %>
|
|
53
|
+
|
|
54
|
+
## match
|
|
55
|
+
|
|
56
|
+
<%= partial "/shared/matcher_match" %>
|
|
57
|
+
|
|
58
|
+
## repo('name')
|
|
59
|
+
|
|
60
|
+
The `repo('name')` matcher names a specific package repository:
|
|
61
|
+
|
|
62
|
+
describe yum.repo('epel') do
|
|
63
|
+
...
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
## repos
|
|
67
|
+
|
|
68
|
+
The `repos` matcher tests if a named repo, using either a full identifier (`'updates/7/x86_64'`) or a short identifier (`'updates'`), is included in the Yum repo:
|
|
69
|
+
|
|
70
|
+
its('repos') { should include 'some_repo' }
|
|
71
|
+
|
|
72
|
+
## shortname
|
|
73
|
+
|
|
74
|
+
The `shortname` matcher names a specific package repository's group identifier. For example, if a repository's group name is "Directory Server", the corresponding group idenfier is typically "directory-server":
|
|
75
|
+
|
|
76
|
+
describe yum.repo('Directory Server') do
|
|
77
|
+
its('shortname') { should eq 'directory-server' }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Examples
|
|
81
|
+
|
|
82
|
+
The following examples show how to use this InSpec audit resource.
|
|
83
|
+
|
|
84
|
+
## Test if the yum repo exists
|
|
85
|
+
|
|
86
|
+
describe yum do
|
|
87
|
+
its('repos') { should exist }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
## Test if the 'base/7/x86_64' repo exists and is enabled
|
|
91
|
+
|
|
92
|
+
describe yum do
|
|
93
|
+
its('repos') { should include 'base/7/x86_64' }
|
|
94
|
+
its('epel') { should exist }
|
|
95
|
+
its('epel') { should be_enabled }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
## Test if a specific yum repo exists
|
|
99
|
+
|
|
100
|
+
describe yum.repo('epel') do
|
|
101
|
+
it { should exist }
|
|
102
|
+
it { should be_enabled }
|
|
103
|
+
end
|