inspec 1.40.0 → 1.41.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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -9
  3. data/docs/matchers.md +18 -0
  4. data/docs/plugin_kitchen_inspec.md +18 -24
  5. data/docs/profiles.md +39 -2
  6. data/docs/resources/aide_conf.md.erb +18 -28
  7. data/docs/resources/apache_conf.md.erb +19 -33
  8. data/docs/resources/apt.md.erb +22 -36
  9. data/docs/resources/audit_policy.md.erb +9 -24
  10. data/docs/resources/auditd.md.erb +9 -24
  11. data/docs/resources/auditd_conf.md.erb +20 -34
  12. data/docs/resources/auditd_rules.md.erb +8 -24
  13. data/docs/resources/bash.md.erb +4 -26
  14. data/docs/resources/bond.md.erb +25 -40
  15. data/docs/resources/bridge.md.erb +5 -25
  16. data/docs/resources/bsd_service.md.erb +5 -25
  17. data/docs/resources/command.md.erb +35 -50
  18. data/docs/resources/crontab.md.erb +9 -23
  19. data/docs/resources/csv.md.erb +12 -27
  20. data/docs/resources/dh_params.md +1 -0
  21. data/docs/resources/directory.md.erb +5 -25
  22. data/docs/resources/docker.md.erb +60 -57
  23. data/docs/resources/docker_container.md.erb +23 -19
  24. data/docs/resources/docker_image.md.erb +20 -16
  25. data/docs/resources/etc_fstab.md.erb +5 -2
  26. data/docs/resources/etc_group.md.erb +29 -45
  27. data/docs/resources/etc_hosts.md.erb +6 -0
  28. data/docs/resources/etc_hosts_allow.md.erb +6 -2
  29. data/docs/resources/etc_hosts_deny.md.erb +6 -2
  30. data/docs/resources/file.md.erb +198 -212
  31. data/docs/resources/firewalld.md.erb +7 -1
  32. data/docs/resources/gem.md.erb +21 -35
  33. data/docs/resources/group.md.erb +16 -30
  34. data/docs/resources/grub_conf.md.erb +9 -24
  35. data/docs/resources/host.md.erb +32 -49
  36. data/docs/resources/http.md.erb +38 -44
  37. data/docs/resources/iis_app.md.erb +25 -35
  38. data/docs/resources/iis_site.md.erb +26 -40
  39. data/docs/resources/inetd_conf.md.erb +27 -42
  40. data/docs/resources/ini.md.erb +9 -23
  41. data/docs/resources/interface.md.erb +5 -25
  42. data/docs/resources/iptables.md.erb +15 -29
  43. data/docs/resources/json.md.erb +12 -27
  44. data/docs/resources/kernel_module.md.erb +47 -61
  45. data/docs/resources/kernel_parameter.md.erb +15 -29
  46. data/docs/resources/key_rsa.md.erb +3 -0
  47. data/docs/resources/launchd_service.md.erb +5 -25
  48. data/docs/resources/limits_conf.md.erb +15 -29
  49. data/docs/resources/login_def.md.erb +15 -30
  50. data/docs/resources/mount.md.erb +18 -33
  51. data/docs/resources/mssql_session.md.erb +9 -12
  52. data/docs/resources/mysql_conf.md.erb +17 -32
  53. data/docs/resources/mysql_session.md.erb +15 -29
  54. data/docs/resources/nginx.md.erb +6 -0
  55. data/docs/resources/nginx_conf.md.erb +25 -20
  56. data/docs/resources/npm.md.erb +19 -35
  57. data/docs/resources/ntp_conf.md.erb +20 -37
  58. data/docs/resources/oneget.md.erb +15 -30
  59. data/docs/resources/oracledb_session.md.erb +9 -11
  60. data/docs/resources/os.md.erb +29 -43
  61. data/docs/resources/os_env.md.erb +29 -44
  62. data/docs/resources/package.md.erb +33 -42
  63. data/docs/resources/parse_config.md.erb +5 -25
  64. data/docs/resources/parse_config_file.md.erb +31 -43
  65. data/docs/resources/passwd.md.erb +24 -39
  66. data/docs/resources/pip.md.erb +20 -35
  67. data/docs/resources/port.md.erb +43 -57
  68. data/docs/resources/postgres_conf.md.erb +17 -31
  69. data/docs/resources/postgres_hba_conf.md.erb +26 -38
  70. data/docs/resources/postgres_ident_conf.md.erb +25 -37
  71. data/docs/resources/postgres_session.md.erb +15 -29
  72. data/docs/resources/powershell.md.erb +27 -42
  73. data/docs/resources/processes.md.erb +17 -33
  74. data/docs/resources/rabbitmq_config.md.erb +9 -24
  75. data/docs/resources/registry_key.md.erb +27 -42
  76. data/docs/resources/runit_service.md.erb +5 -25
  77. data/docs/resources/security_policy.md.erb +12 -27
  78. data/docs/resources/service.md.erb +27 -42
  79. data/docs/resources/shadow.md.erb +20 -35
  80. data/docs/resources/ssh_config.md.erb +19 -34
  81. data/docs/resources/sshd_config.md.erb +19 -34
  82. data/docs/resources/ssl.md.erb +39 -54
  83. data/docs/resources/sys_info.md.erb +12 -26
  84. data/docs/resources/systemd_service.md.erb +5 -25
  85. data/docs/resources/sysv_service.md.erb +5 -25
  86. data/docs/resources/upstart_service.md.erb +5 -25
  87. data/docs/resources/user.md.erb +29 -44
  88. data/docs/resources/users.md.erb +12 -26
  89. data/docs/resources/vbscript.md.erb +9 -24
  90. data/docs/resources/virtualization.md.erb +8 -23
  91. data/docs/resources/windows_feature.md.erb +15 -30
  92. data/docs/resources/windows_hotfix.md.erb +15 -9
  93. data/docs/resources/windows_task.md.erb +12 -26
  94. data/docs/resources/wmi.md.erb +9 -24
  95. data/docs/resources/x509_certificate.md.erb +4 -0
  96. data/docs/resources/xinetd_conf.md.erb +65 -80
  97. data/docs/resources/xml.md.erb +12 -26
  98. data/docs/resources/yaml.md.erb +12 -27
  99. data/docs/resources/yum.md.erb +37 -51
  100. data/docs/resources/zfs_dataset.md.erb +15 -26
  101. data/docs/resources/zfs_pool.md.erb +9 -20
  102. data/lib/inspec/backend.rb +8 -0
  103. data/lib/inspec/profile.rb +9 -1
  104. data/lib/inspec/shell.rb +13 -13
  105. data/lib/inspec/version.rb +1 -1
  106. data/lib/matchers/matchers.rb +2 -0
  107. data/lib/resources/etc_hosts.rb +1 -1
  108. data/lib/resources/host.rb +4 -1
  109. data/lib/resources/http.rb +173 -23
  110. data/lib/resources/processes.rb +106 -20
  111. data/lib/resources/ssh_conf.rb +1 -1
  112. data/lib/resources/ssl.rb +4 -3
  113. data/lib/utils/object_traversal.rb +35 -10
  114. metadata +2 -2
@@ -19,6 +19,8 @@ These entries are defined as a colon-delimited row in the file, one row per user
19
19
 
20
20
  dannos:Gb7crrO5CDF.:10063:0:99999:7:::
21
21
 
22
+ <br>
23
+
22
24
  ## Syntax
23
25
 
24
26
  A `shadow` resource block declares one (or more) users and associated user information to be tested:
@@ -39,18 +41,30 @@ where
39
41
  * `homes`, `gids`, `passwords`, `shells`, `uids`, and `users` are valid accessors for `passwd`
40
42
  * `filter` one (or more) arguments, for example: `passwd.users(/name/)` used to define filtering; `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)
41
43
 
44
+ <br>
42
45
 
43
- ## Matchers
46
+ ## Examples
47
+
48
+ The following examples show how to use this InSpec audit resource.
49
+
50
+ ### Test for a forbidden user
51
+
52
+ describe shadow do
53
+ its('users') { should_not include 'forbidden_user' }
54
+ end
44
55
 
45
- This InSpec audit resource has the following matchers:
56
+ ### Test that a user appears one time
46
57
 
47
- ### be
58
+ describe shadow.users('bin') do
59
+ its('passwords') { should cmp 'x' }
60
+ its('count') { should eq 1 }
61
+ end
48
62
 
49
- <%= partial "/shared/matcher_be" %>
63
+ <br>
50
64
 
51
- ### cmp
65
+ ## Matchers
52
66
 
53
- <%= partial "/shared/matcher_cmp" %>
67
+ 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/).
54
68
 
55
69
  ### count
56
70
 
@@ -64,10 +78,6 @@ TThis matcher is best used in conjunction with filters. For example:
64
78
  its('count') { should eq 1 }
65
79
  end
66
80
 
67
- ### eq
68
-
69
- <%= partial "/shared/matcher_eq" %>
70
-
71
81
  ### expiry_dates
72
82
 
73
83
  The `expiry_dates` matcher tests the number of days a user account has been disabled:
@@ -80,20 +90,12 @@ The `inactive_days` matcher tests the number of days a user must be inactive bef
80
90
 
81
91
  its('inactive_days') { should eq '' }
82
92
 
83
- ### include
84
-
85
- <%= partial "/shared/matcher_include" %>
86
-
87
93
  ### last_changes
88
94
 
89
95
  The `last_changes` matcher tests the last time a password was changed:
90
96
 
91
97
  its('last_changes') { should eq '' }
92
98
 
93
- ### match
94
-
95
- <%= partial "/shared/matcher_match" %>
96
-
97
99
  ### max_days
98
100
 
99
101
  The `max_days` matcher tests the maximum number of days after which a password must be changed:
@@ -130,20 +132,3 @@ The `users` matcher tests if the user name exists `/etc/shadow`:
130
132
  The `warn_days` matcher tests the number of days a user is warned about an expiring password:
131
133
 
132
134
  its('warn_days') { should eq 7 }
133
-
134
- ## Examples
135
-
136
- The following examples show how to use this InSpec audit resource.
137
-
138
- ### Test for a forbidden user
139
-
140
- describe shadow do
141
- its('users') { should_not include 'forbidden_user' }
142
- end
143
-
144
- ### Test that a user appears one time
145
-
146
- describe shadow.users('bin') do
147
- its('passwords') { should cmp 'x' }
148
- its('count') { should eq 1 }
149
- end
@@ -6,6 +6,8 @@ title: About the ssh_config Resource
6
6
 
7
7
  Use the `ssh_config` InSpec audit resource to test OpenSSH client configuration data located at `/etc/ssh/ssh_config` on Linux and Unix platforms.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  An `ssh_config` resource block declares the client OpenSSH configuration data to be tested:
@@ -20,40 +22,7 @@ where
20
22
  * `('path')` is the non-default `/path/to/ssh_config`
21
23
  * `{ should include('foo') }` tests the value of `name` as read from `ssh_config` versus the value declared in the test
22
24
 
23
-
24
- ## Matchers
25
-
26
- This InSpec audit resource has the following matchers:
27
-
28
- ### be
29
-
30
- <%= partial "/shared/matcher_be" %>
31
-
32
- ### cmp
33
-
34
- <%= partial "/shared/matcher_cmp" %>
35
-
36
- ### eq
37
-
38
- <%= partial "/shared/matcher_eq" %>
39
-
40
- ### include
41
-
42
- <%= partial "/shared/matcher_include" %>
43
-
44
- ### match
45
-
46
- <%= partial "/shared/matcher_match" %>
47
-
48
- ### name
49
-
50
- The `name` matcher tests the value of `name` as read from `ssh_config` versus the value declared in the test:
51
-
52
- its('name') { should eq 'foo' }
53
-
54
- or:
55
-
56
- its('name') { should include('bar') }
25
+ <br>
57
26
 
58
27
  ## Examples
59
28
 
@@ -92,3 +61,19 @@ The following examples show how to use this InSpec audit resource.
92
61
  its('SendEnv') { should eq 'LANG LC_*' }
93
62
  its('HashKnownHosts') { should eq 'yes' }
94
63
  end
64
+
65
+ <br>
66
+
67
+ ## Matchers
68
+
69
+ 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/).
70
+
71
+ ### name
72
+
73
+ The `name` matcher tests the value of `name` as read from `ssh_config` versus the value declared in the test:
74
+
75
+ its('name') { should eq 'foo' }
76
+
77
+ or:
78
+
79
+ its('name') { should include('bar') }
@@ -6,6 +6,8 @@ title: About the sshd_config Resource
6
6
 
7
7
  Use the `sshd_config` InSpec audit resource to test configuration data for the OpenSSH daemon located at `/etc/ssh/sshd_config` on Linux and Unix platforms. sshd---the OpenSSH daemon---listens on dedicated ports, starts a daemon for each incoming connection, and then handles encryption, authentication, key exchanges, command execution, and data exchanges.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  An `sshd_config` resource block declares the client OpenSSH configuration data to be tested:
@@ -20,40 +22,7 @@ where
20
22
  * `('path')` is the non-default `/path/to/sshd_config`
21
23
  * `{ should include('foo') }` tests the value of `name` as read from `sshd_config` versus the value declared in the test
22
24
 
23
-
24
- ## Matchers
25
-
26
- This InSpec audit resource has the following matchers:
27
-
28
- ### be
29
-
30
- <%= partial "/shared/matcher_be" %>
31
-
32
- ### cmp
33
-
34
- <%= partial "/shared/matcher_cmp" %>
35
-
36
- ### eq
37
-
38
- <%= partial "/shared/matcher_eq" %>
39
-
40
- ### include
41
-
42
- <%= partial "/shared/matcher_include" %>
43
-
44
- ### match
45
-
46
- <%= partial "/shared/matcher_match" %>
47
-
48
- ### name
49
-
50
- The `name` matcher tests the value of `name` as read from `sshd_config` versus the value declared in the test:
51
-
52
- its('name') { should cmp 'foo' }
53
-
54
- or:
55
-
56
- its('name') {should include('bar') }
25
+ <br>
57
26
 
58
27
  ## Examples
59
28
 
@@ -95,3 +64,19 @@ The following examples show how to use this InSpec audit resource.
95
64
  '/etc/ssh/ssh_host_ecdsa_key',
96
65
  ] }
97
66
  end
67
+
68
+ <br>
69
+
70
+ ## Matchers
71
+
72
+ 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/).
73
+
74
+ ### name
75
+
76
+ The `name` matcher tests the value of `name` as read from `sshd_config` versus the value declared in the test:
77
+
78
+ its('name') { should cmp 'foo' }
79
+
80
+ or:
81
+
82
+ its('name') {should include('bar') }
@@ -6,6 +6,8 @@ title: About the ssl Resource
6
6
 
7
7
  Use the `ssl` InSpec audit resource to test SSL settings for the named port.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  An `ssl` resource block declares an SSL port, and then other properties of the test like cipher and/or protocol:
@@ -25,60 +27,7 @@ where
25
27
  * `ssl(port: #)` is the port number, such as `ssl(port: 443)`
26
28
  * `filter` may take any of the following arguments: `ciphers`, `protocols`, and `handshake`
27
29
 
28
-
29
- ## Matchers
30
-
31
- This InSpec audit resource has the following matchers:
32
-
33
- ### be
34
-
35
- <%= partial "/shared/matcher_be" %>
36
-
37
- ### be_enabled
38
-
39
- The `be_enabled` matcher tests if SSL is enabled:
40
-
41
- it { should be_enabled }
42
-
43
- ### ciphers
44
-
45
- The `ciphers` matcher tests the named cipher:
46
-
47
- its('ciphers') { should_not eq '/rc4/i' }
48
-
49
- or:
50
-
51
- describe ssl(port: 443).ciphers(/rc4/i) do
52
- it { should_not be_enabled }
53
- end
54
-
55
- ### cmp
56
-
57
- <%= partial "/shared/matcher_cmp" %>
58
-
59
- ### eq
60
-
61
- <%= partial "/shared/matcher_eq" %>
62
-
63
- ### include
64
-
65
- <%= partial "/shared/matcher_include" %>
66
-
67
- ### match
68
-
69
- <%= partial "/shared/matcher_match" %>
70
-
71
- ### protocols
72
-
73
- The `protocols` matcher tests what protocol versions (SSLv3, TLSv1.1, etc) are enabled:
74
-
75
- its('protocols') { should eq 'ssl2' }
76
-
77
- or:
78
-
79
- describe ssl(port: 443).protocols('ssl2') do
80
- it { should_not be_enabled }
81
- end
30
+ <br>
82
31
 
83
32
  ## Examples
84
33
 
@@ -131,3 +80,39 @@ and then run:
131
80
  Or execute the profile directly via URL:
132
81
 
133
82
  $ inspec exec https://github.com/dev-sec/ssl-benchmark
83
+
84
+ <br>
85
+
86
+ ## Matchers
87
+
88
+ 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/).
89
+
90
+ ### be_enabled
91
+
92
+ The `be_enabled` matcher tests if SSL is enabled:
93
+
94
+ it { should be_enabled }
95
+
96
+ ### ciphers
97
+
98
+ The `ciphers` matcher tests the named cipher:
99
+
100
+ its('ciphers') { should_not eq '/rc4/i' }
101
+
102
+ or:
103
+
104
+ describe ssl(port: 443).ciphers(/rc4/i) do
105
+ it { should_not be_enabled }
106
+ end
107
+
108
+ ### protocols
109
+
110
+ The `protocols` matcher tests what protocol versions (SSLv3, TLSv1.1, etc) are enabled:
111
+
112
+ its('protocols') { should eq 'ssl2' }
113
+
114
+ or:
115
+
116
+ describe ssl(port: 443).protocols('ssl2') do
117
+ it { should_not be_enabled }
118
+ end
@@ -6,6 +6,8 @@ title: About the sys_info Resource
6
6
 
7
7
  Use the `sys_info` InSpec audit resource to test for operating system properties for the named host, and then returns that info as standard output.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  An `sys_info` resource block declares the hostname to be tested:
@@ -14,42 +16,26 @@ An `sys_info` resource block declares the hostname to be tested:
14
16
  its('hostname') { should eq 'value' }
15
17
  end
16
18
 
17
- ## Matchers
19
+ <br>
18
20
 
19
- This InSpec audit resource has the following matchers:
21
+ ## Examples
20
22
 
21
- ### be
23
+ The following examples show how to use this InSpec audit resource.
22
24
 
23
- <%= partial "/shared/matcher_be" %>
25
+ ### Get system information for example.com
24
26
 
25
- ### cmp
27
+ describe sys_info do
28
+ its('hostname') { should eq 'example.com' }
29
+ end
26
30
 
27
- <%= partial "/shared/matcher_cmp" %>
31
+ <br>
28
32
 
29
- ### eq
33
+ ## Matchers
30
34
 
31
- <%= partial "/shared/matcher_eq" %>
35
+ 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/).
32
36
 
33
37
  ### hostname
34
38
 
35
39
  The `hostname` matcher tests the host for which standard output is returned:
36
40
 
37
41
  its('hostname') { should eq 'value' }
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
- ### Get system information for example.com
52
-
53
- describe sys_info do
54
- its('hostname') { should eq 'example.com' }
55
- end
@@ -6,6 +6,8 @@ title: About the systemd_service Resource
6
6
 
7
7
  Use the `systemd_service` InSpec audit resource to test a service using SystemD.
8
8
 
9
+ <br>
10
+
9
11
  ## Syntax
10
12
 
11
13
  A `systemd_service` resource block declares the name of a service and then one (or more) matchers to test the state of the service:
@@ -29,13 +31,11 @@ The path to the service manager's control may be specified for situations where
29
31
  it { should be_running }
30
32
  end
31
33
 
32
- ## Matchers
33
-
34
- This InSpec audit resource has the following matchers:
34
+ <br>
35
35
 
36
- ### be
36
+ ## Matchers
37
37
 
38
- <%= partial "/shared/matcher_be" %>
38
+ 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/).
39
39
 
40
40
  ### be_enabled
41
41
 
@@ -54,23 +54,3 @@ The `be_installed` matcher tests if the named service is installed:
54
54
  The `be_running` matcher tests if the named service is running:
55
55
 
56
56
  it { should be_running }
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
- None.