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.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +323 -6
  3. data/Gemfile +10 -0
  4. data/README.md +1 -1
  5. data/Rakefile +4 -55
  6. data/docs/.gitignore +2 -0
  7. data/docs/README.md +40 -0
  8. data/docs/cli.md +342 -0
  9. data/docs/dsl_inspec.md +245 -0
  10. data/docs/dsl_resource.md +93 -0
  11. data/docs/inspec_and_friends.md +105 -0
  12. data/docs/matchers.md +136 -0
  13. data/docs/plugin_kitchen_inspec.html.md +55 -0
  14. data/docs/profiles.md +285 -0
  15. data/docs/resources/apache_conf.md.erb +75 -0
  16. data/docs/resources/apt.md.erb +84 -0
  17. data/docs/resources/audit_policy.md.erb +61 -0
  18. data/docs/resources/auditd_conf.md.erb +79 -0
  19. data/docs/resources/auditd_rules.md.erb +132 -0
  20. data/docs/resources/bash.md.erb +84 -0
  21. data/docs/resources/bond.md.erb +97 -0
  22. data/docs/resources/bridge.md.erb +67 -0
  23. data/docs/resources/bsd_service.md.erb +76 -0
  24. data/docs/resources/command.md.erb +151 -0
  25. data/docs/resources/csv.md.erb +62 -0
  26. data/docs/resources/directory.md.erb +43 -0
  27. data/docs/resources/etc_group.md.erb +116 -0
  28. data/docs/resources/etc_passwd.md.erb +155 -0
  29. data/docs/resources/etc_shadow.md.erb +149 -0
  30. data/docs/resources/file.md.erb +460 -0
  31. data/docs/resources/gem.md.erb +73 -0
  32. data/docs/resources/group.md.erb +74 -0
  33. data/docs/resources/grub_conf.md.erb +115 -0
  34. data/docs/resources/host.md.erb +85 -0
  35. data/docs/resources/iis_site.md.erb +142 -0
  36. data/docs/resources/inetd_conf.md.erb +99 -0
  37. data/docs/resources/ini.md.erb +69 -0
  38. data/docs/resources/interface.md.erb +66 -0
  39. data/docs/resources/iptables.md.erb +70 -0
  40. data/docs/resources/json.md.erb +76 -0
  41. data/docs/resources/kernel_module.md.erb +60 -0
  42. data/docs/resources/kernel_parameter.md.erb +72 -0
  43. data/docs/resources/launchd_service.md.erb +76 -0
  44. data/docs/resources/limits_conf.md.erb +80 -0
  45. data/docs/resources/login_def.md.erb +77 -0
  46. data/docs/resources/mount.md.erb +83 -0
  47. data/docs/resources/mysql_conf.md.erb +102 -0
  48. data/docs/resources/mysql_session.md.erb +63 -0
  49. data/docs/resources/npm.md.erb +75 -0
  50. data/docs/resources/ntp_conf.md.erb +76 -0
  51. data/docs/resources/oneget.md.erb +67 -0
  52. data/docs/resources/os.md.erb +154 -0
  53. data/docs/resources/os_env.md.erb +98 -0
  54. data/docs/resources/package.md.erb +115 -0
  55. data/docs/resources/parse_config.md.erb +122 -0
  56. data/docs/resources/parse_config_file.md.erb +143 -0
  57. data/docs/resources/pip.md.erb +74 -0
  58. data/docs/resources/port.md.erb +150 -0
  59. data/docs/resources/postgres_conf.md.erb +90 -0
  60. data/docs/resources/postgres_session.md.erb +75 -0
  61. data/docs/resources/powershell.md.erb +116 -0
  62. data/docs/resources/process.md.erb +73 -0
  63. data/docs/resources/registry_key.md.erb +149 -0
  64. data/docs/resources/runit_service.md.erb +76 -0
  65. data/docs/resources/security_policy.md.erb +61 -0
  66. data/docs/resources/service.md.erb +135 -0
  67. data/docs/resources/ssh_config.md.erb +94 -0
  68. data/docs/resources/sshd_config.md.erb +97 -0
  69. data/docs/resources/ssl.md.erb +133 -0
  70. data/docs/resources/sys_info.md.erb +55 -0
  71. data/docs/resources/systemd_service.md.erb +76 -0
  72. data/docs/resources/sysv_service.md.erb +76 -0
  73. data/docs/resources/upstart_service.md.erb +76 -0
  74. data/docs/resources/user.md.erb +154 -0
  75. data/docs/resources/users.md.erb +140 -0
  76. data/docs/resources/vbscript.md.erb +69 -0
  77. data/docs/resources/windows_feature.md.erb +61 -0
  78. data/docs/resources/wmi.md.erb +95 -0
  79. data/docs/resources/xinetd_conf.md.erb +170 -0
  80. data/docs/resources/yaml.md.erb +69 -0
  81. data/docs/resources/yum.md.erb +103 -0
  82. data/docs/ruby_usage.md +154 -0
  83. data/docs/shared/matcher_be.md.erb +1 -0
  84. data/docs/shared/matcher_cmp.md.erb +45 -0
  85. data/docs/shared/matcher_eq.md.erb +3 -0
  86. data/docs/shared/matcher_include.md.erb +1 -0
  87. data/docs/shared/matcher_match.md.erb +1 -0
  88. data/docs/shell.md +150 -0
  89. data/examples/meta-profile/inspec.yml +2 -4
  90. data/inspec.gemspec +1 -1
  91. data/lib/bundles/inspec-compliance/api.rb +28 -18
  92. data/lib/bundles/inspec-compliance/cli.rb +19 -27
  93. data/lib/bundles/inspec-compliance/target.rb +15 -2
  94. data/lib/fetchers/git.rb +4 -0
  95. data/lib/fetchers/local.rb +16 -1
  96. data/lib/fetchers/mock.rb +4 -0
  97. data/lib/fetchers/url.rb +46 -20
  98. data/lib/inspec/base_cli.rb +14 -0
  99. data/lib/inspec/cached_fetcher.rb +67 -0
  100. data/lib/inspec/cli.rb +22 -8
  101. data/lib/inspec/control_eval_context.rb +12 -2
  102. data/lib/inspec/dependencies/{vendor_index.rb → cache.rb} +5 -4
  103. data/lib/inspec/dependencies/dependency_set.rb +8 -14
  104. data/lib/inspec/dependencies/lockfile.rb +5 -13
  105. data/lib/inspec/dependencies/requirement.rb +31 -41
  106. data/lib/inspec/dependencies/resolver.rb +3 -3
  107. data/lib/inspec/dsl.rb +16 -4
  108. data/lib/inspec/errors.rb +1 -0
  109. data/lib/inspec/fetcher.rb +25 -1
  110. data/lib/inspec/objects/each_loop.rb +5 -2
  111. data/lib/inspec/objects/test.rb +8 -2
  112. data/lib/inspec/plugins/fetcher.rb +13 -12
  113. data/lib/inspec/plugins/resource.rb +3 -0
  114. data/lib/inspec/profile.rb +62 -26
  115. data/lib/inspec/profile_context.rb +44 -8
  116. data/lib/inspec/resource.rb +18 -3
  117. data/lib/inspec/rspec_json_formatter.rb +91 -40
  118. data/lib/inspec/rule.rb +45 -2
  119. data/lib/inspec/runner.rb +51 -39
  120. data/lib/inspec/shell.rb +5 -16
  121. data/lib/inspec/version.rb +1 -1
  122. data/lib/resources/apache_conf.rb +1 -1
  123. data/lib/resources/gem.rb +1 -0
  124. data/lib/resources/groups.rb +190 -0
  125. data/lib/resources/oneget.rb +1 -0
  126. data/lib/resources/os.rb +1 -1
  127. data/lib/resources/package.rb +3 -1
  128. data/lib/resources/parse_config.rb +18 -1
  129. data/lib/resources/pip.rb +1 -1
  130. data/lib/resources/security_policy.rb +54 -0
  131. data/lib/resources/ssl.rb +9 -11
  132. data/lib/resources/sys_info.rb +1 -1
  133. data/lib/resources/users.rb +81 -64
  134. metadata +91 -17
  135. data/docs/cli.rst +0 -442
  136. data/docs/dsl_inspec.rst +0 -259
  137. data/docs/dsl_resource.rst +0 -90
  138. data/docs/inspec_and_friends.rst +0 -85
  139. data/docs/matchers.rst +0 -137
  140. data/docs/profiles.rst +0 -169
  141. data/docs/readme.rst +0 -105
  142. data/docs/resources.rst +0 -4836
  143. data/docs/ruby_usage.rst +0 -145
  144. data/docs/shell.rst +0 -130
  145. data/docs/template.rst +0 -51
  146. data/lib/resources/group.rb +0 -137
data/docs/dsl_inspec.rst DELETED
@@ -1,259 +0,0 @@
1
- =====================================================
2
- InSpec DSL
3
- =====================================================
4
-
5
- |inspec| is a run-time framework and rule language used to specify compliance, security, and policy requirements. It includes a collection of resources that help you write auditing controls quickly and easily. The syntax used by both open source and |chef compliance| auditing is the same. The open source |inspec resource| framework is compatible with |chef compliance|.
6
-
7
- The InSpec DSL is a Ruby DSL for writing audit controls, which includes audit resources that you can invoke.
8
-
9
- The following sections describe the syntax and show some simple examples of using the |inspec resources| to define
10
-
11
- Syntax
12
- =====================================================
13
-
14
- The following resource tests |ssh| server configuration. For example, a simple control may described as:
15
-
16
- .. code-block:: ruby
17
-
18
- describe sshd_config do
19
- its('Port') { should eq('22') }
20
- end
21
-
22
- In various use cases like implementing IT compliance across different departments, it becomes handy to extend the control with metadata. Each control may define an additional ``impact``, ``title`` or ``desc``. An example looks like:
23
-
24
- .. code-block:: ruby
25
-
26
- control 'sshd-8' do
27
- impact 0.6
28
- title 'Server: Configure the service port'
29
- desc '
30
- Always specify which port the SSH server should listen to.
31
- Prevent unexpected settings.
32
- '
33
- tag 'ssh','sshd','openssh-server'
34
- tag cce: 'CCE-27072-8'
35
- ref 'NSA-RH6-STIG - Section 3.5.2.1', url: 'https://www.nsa.gov/ia/_files/os/redhat/rhel5-guide-i731.pdf'
36
-
37
- describe sshd_config do
38
- its('Port') { should eq('22') }
39
- end
40
- end
41
-
42
-
43
- where
44
-
45
- * ``'sshd-8'`` is the name of the control
46
- * ``impact``, ``title``, and ``desc`` define metadata that fully describes the importance of the control, its purpose, with a succinct and complete description
47
- * ``impact`` is an float that measures the importance of the compliance results and must be a value between ``0.0`` and ``1.0``.
48
- * ``tag`` is optional meta-information with with key or key-value pairs
49
- * ``ref`` is a reference to an external document
50
- * ``describe`` is a block that contains at least one test. A ``control`` block must contain at least one ``describe`` block, but may contain as many as required
51
- * ``sshd_config`` is an |inspec| resource. For the full list of InSpec resources, see |inspec| resource documentation
52
- * ``its('Port')`` is the matcher; ``{ should eq('22') }`` is the test. A ``describe`` block must contain at least one matcher, but may contain as many as required
53
-
54
-
55
- Advanced concepts
56
- =====================================================
57
-
58
- With inspec it is possible to check if at least one of a collection of checks is true. For example: If a setting is configured in two different locations, you may want to test if either configuration A or configuration B have been set. This is accomplished via ``describe.one``. It defines a block of tests with at least one valid check.
59
-
60
- .. code-block:: ruby
61
-
62
- describe.one do
63
- describe ConfigurationA do
64
- its('setting_1') { should eq true }
65
- end
66
-
67
- describe ConfigurationB do
68
- its('setting_2') { should eq true }
69
- end
70
- end
71
-
72
- Examples
73
- =====================================================
74
- The following examples show simple compliance tests using a single ``control`` block.
75
-
76
- Test System Event Log
77
- -----------------------------------------------------
78
- The following test shows how to audit machines running |windows| 2012 R2 that pwassword complexity is enabled:
79
-
80
- .. code-block:: ruby
81
-
82
- control 'windows-account-102' do
83
- impact 1.0
84
- title 'Windows Password Complexity is Enabled'
85
- desc 'Password must meet complexity requirement'
86
- describe security_policy do
87
- its('PasswordComplexity') { should eq 1 }
88
- end
89
- end
90
-
91
- Are PosgtreSQL passwords empty?
92
- -----------------------------------------------------
93
- The following test shows how to audit machines running |postgresql| to ensure that passwords are not empty.
94
-
95
- .. code-block:: ruby
96
-
97
- control 'postgres-7' do
98
- impact 1.0
99
- title 'Don't allow empty passwords'
100
- describe postgres_session('user', 'pass').query("SELECT * FROM pg_shadow WHERE passwd IS NULL;") do
101
- its('output') { should eq('') }
102
- end
103
- end
104
-
105
-
106
- Are MySQL passwords in ENV?
107
- -----------------------------------------------------
108
- The following test shows how to audit machines running |mysql| to ensure that passwords are not stored in ``ENV``:
109
-
110
- .. code-block:: ruby
111
-
112
- control 'mysql-3' do
113
- impact 1.0
114
- title 'Do not store your MySQL password in your ENV'
115
- desc '
116
- Storing credentials in your ENV may easily expose
117
- them to an attacker. Prevent this at all costs.
118
- '
119
- describe command('env') do
120
- its('stdout') { should_not match(/^MYSQL_PWD=/) }
121
- end
122
- end
123
-
124
- Is /etc/ssh a Directory?
125
- -----------------------------------------------------
126
- The following test shows how to audit machines to ensure that ``/etc/ssh`` is a directory:
127
-
128
- .. code-block:: ruby
129
-
130
- control 'basic-1' do
131
- impact 1.0
132
- title '/etc/ssh should be a directory'
133
- desc '
134
- In order for OpenSSH to function correctly, its
135
- configuration path must be a folder.
136
- '
137
- describe file('/etc/ssh') do
138
- it { should be_directory }
139
- end
140
- end
141
-
142
- Is Apache running?
143
- -----------------------------------------------------
144
- The following test shows how to audit machines to ensure that |apache| is enabled and running:
145
-
146
- .. code-block:: ruby
147
-
148
- control 'apache-1' do
149
- impact 0.3
150
- title 'Apache2 should be configured and running'
151
- describe service(apache.service) do
152
- it { should be_enabled }
153
- it { should be_running }
154
- end
155
- end
156
-
157
- Are insecure packages installed ?
158
- -----------------------------------------------------
159
- The following test shows how to audit machines for insecure packages:
160
-
161
- .. code-block:: ruby
162
-
163
- control 'cis-os-services-5.1.3' do
164
- impact 0.7
165
- title '5.1.3 Ensure rsh client is not installed'
166
-
167
- describe package('rsh') do
168
- it { should_not be_installed }
169
- end
170
-
171
- describe package('rsh-redone-client') do
172
- it { should_not be_installed }
173
- end
174
- end
175
-
176
-
177
- Test Windows Registry Keys
178
- -----------------------------------------------------
179
- The following test shows how to audit machines to ensure Safe DLL Seach Mode is enabled:
180
-
181
- .. code-block:: ruby
182
-
183
- control 'windows-base-101' do
184
- impact 1.0
185
- title 'Safe DLL Search Mode is Enabled'
186
- desc '
187
- @link: https://msdn.microsoft.com/en-us/library/ms682586(v=vs.85).aspx
188
- '
189
- describe registry_key('HKLM\\System\\CurrentControlSet\\Control\\Session Manager') do
190
- it { should exist }
191
- it { should_not have_property_value('SafeDllSearchMode', :type_dword, '0') }
192
- end
193
- end
194
-
195
- Exclude specific test
196
- -----------------------------------------------------
197
- This shows how to allow skipping certain tests if conditions are not met, by using ``only_if``.
198
- In this example the test will not be performed if ``redis-cli`` command does not exist, because for example package on remote host was not installed.
199
-
200
- .. code-block:: ruby
201
-
202
- control 'nutcracker-connect-redis-001' do
203
- impact 1.0
204
- title 'Check if nutcracker can pass commands to redis'
205
- desc 'execute redis-cli set key command, to check connectivity of the service'
206
-
207
- only_if do
208
- command('redis-cli').exist?
209
- end
210
-
211
- describe command('redis-cli SET test_inspec "HELLO"') do
212
- its(:stdout) { should match(/OK/) }
213
- end
214
- end
215
-
216
- Mixing this with other conditionals (like checking existence of the files etc.) can help to test different test paths using inspec. This way you can skip certain tests which would 100% fail due to the way servers are prepared, but you know that the same test suites are reused later in different circumstances by different teams.
217
-
218
- Additional metadata for controls
219
- -----------------------------------------------------
220
-
221
- The following example illustrates various ways to add tags and references to `control`
222
-
223
- .. code-block:: ruby
224
-
225
- control 'ssh-1' do
226
- impact 1.0
227
-
228
- title 'Allow only SSH Protocol 2'
229
- desc 'Only SSH protocol version 2 connections should be permitted.
230
- The default setting in /etc/ssh/sshd_config is correct, and can be
231
- verified by ensuring that the following line appears: Protocol 2'
232
-
233
- tag 'production','development'
234
- tag 'ssh','sshd','openssh-server'
235
-
236
- tag cce: 'CCE-27072-8'
237
- tag disa: 'RHEL-06-000227'
238
-
239
- tag remediation: 'stig_rhel6/recipes/sshd-config.rb'
240
- tag remediation: 'https://supermarket.chef.io/cookbooks/ssh-hardening'
241
-
242
- ref 'NSA-RH6-STIG - Section 3.5.2.1', url: 'https://www.nsa.gov/ia/_files/os/redhat/rhel5-guide-i731.pdf'
243
- ref 'http://people.redhat.com/swells/scap-security-guide/RHEL/6/output/ssg-centos6-guide-C2S.html'
244
-
245
- describe ssh_config do
246
- its ('Protocol') { should eq '2'}
247
- end
248
- end`
249
-
250
-
251
-
252
- .. |inspec| replace:: InSpec
253
- .. |inspec resource| replace:: InSpec Resource
254
- .. |chef compliance| replace:: Chef Compliance
255
- .. |ruby| replace:: Ruby
256
- .. |ssh| replace:: SSH
257
- .. |windows| replace:: Microsoft Windows
258
- .. |postgresql| replace:: PostgreSQL
259
- .. |apache| replace:: Apache
@@ -1,90 +0,0 @@
1
- =====================================================
2
- Resource DSL
3
- =====================================================
4
-
5
- InSpec provides a mechanism for defining custom resources. These become available with their respective names and provide easy functionality to profiles.
6
-
7
- Resource location
8
- -----------------------------------------------------
9
-
10
- Resources may be added to profiles in the `libraries` folder:
11
-
12
- .. code-block:: bash
13
-
14
- $ tree examples/profile
15
- examples/profile
16
- ...
17
- ├── libraries
18
- │   └── gordon_config.rb
19
-
20
-
21
- Resource structure
22
- -----------------------------------------------------
23
-
24
- The smallest possible resource takes this form:
25
-
26
- .. code-block:: ruby
27
-
28
- class Tiny < Inspec.resource(1)
29
- name 'tiny'
30
- end
31
-
32
- Resources are written as a regular Ruby `class` which inherits from `Inspec.resource`. The number (`1`) specifies the version this resource plugin targets. As InSpec evolves, this interface may change and may require a higher version.
33
-
34
- The following attributes can be configured:
35
-
36
- * `name` - Identifier of the resource (required)
37
- * `desc` - Description of the resource (optional)
38
- * `example` - Example usage of the resource (optional)
39
-
40
- The following methods are available to the resource:
41
-
42
- * `inspec` - Contains a registry of all other resources to interact with the operating system or target in general.
43
- * `skip_resource` - A resource may call this method to indicate, that requirements aren't met. All tests that use this resource will be marked as `skipped`.
44
-
45
- The following example shows a full resource using attributes and methods to provide simple access to a configuration file:
46
-
47
- .. code-block:: ruby
48
-
49
- class GordonConfig < Inspec.resource(1)
50
- name 'gordon_config'
51
-
52
- desc '
53
- Resource description ...
54
- '
55
-
56
- example '
57
- describe gordon_config do
58
- its("signal") { should eq "on" }
59
- end
60
- '
61
-
62
- # Load the configuration file on initialization
63
- def initialize(path = nil)
64
- @path = path || '/etc/gordon.conf'
65
- @params = SimpleConfig.new( read_content )
66
- end
67
-
68
- # Expose all parameters of the configuration file.
69
- def method_missing(name)
70
- @params[name]
71
- end
72
-
73
- private
74
-
75
- def read_content
76
- f = inspec.file(@path)
77
- # Test if the path exist and that it's a file
78
- if f.file?
79
- # Retrieve the file's contents
80
- f.content
81
- else
82
- # If the file doesn't exist, skip all tests that use gordon_config
83
- skip_resource "Can't read config from #{@path}."
84
- end
85
- end
86
- end
87
-
88
- For a full example, see our `example resource`_.
89
-
90
- .. _example resource: ../examples/profile/libraries/gordon_config.rb
@@ -1,85 +0,0 @@
1
- =====================================================
2
- InSpec and friends
3
- =====================================================
4
-
5
- RSpec
6
- =====================================================
7
-
8
- RSpec is an awesome framework that is widely used to test Ruby code. It enables test-driven development (TDD) and helps developers to write better code every day.
9
-
10
- InSpec is built on top of RSpec and uses it as the underlying foundation to execute tests. It uses the key strengths of RSpec, easily execute tests and a DSL to write tests, but extends the functionality for use as compliance audits. InSpec ships with custom audit resources that make it easy to write audit checks and with the ability to run those checks on remote servers. These audit resources provided know the differences between operating systems and help you abstract from the local operating system, similar to other resources you might use in your Chef recipes.
11
-
12
- A complete InSpec rule looks like:
13
-
14
- .. code-block:: ruby
15
-
16
- control "sshd-11" do
17
- impact 1.0
18
- title "Server: Set protocol version to SSHv2"
19
- desc "Set the SSH protocol version to 2. Don't use legacy
20
- insecure SSHv1 connections anymore."
21
- tag security: "level-1"
22
- tag "openssh-server"
23
- ref "Server Security Guide v.1.0", url: "http://..."
24
-
25
- describe sshd_config do
26
- its('Protocol') { should eq('2') }
27
- end
28
- end
29
-
30
-
31
-
32
- Serverspec
33
- =====================================================
34
-
35
- Serverspec can be credited as the first extension of RSpec that enabled users to run RSpec tests on servers to verify deployed artifacts. It was created in March 2013 by Gosuke Miyashita and has been widely adopted. It is also one of the core test frameworks within test-kitchen and has been widely used within the Chef ecosystem. InSpec takes lessons learned implementing and using Serverspec and builds on them to make auditing and compliance easier.
36
-
37
- Lessons learned from Serverspec include:
38
-
39
- * IT, compliance, and security professional require metadata beyond what Serverspec offers, such as criticality, to fully describe controls.
40
-
41
- * Setting up and running the same tests across multiple machines must be easy.
42
-
43
- * It must be easy to locate, debug, and extend operating system-dependent code.
44
-
45
- * It must be easy to extend the language and create custom resources.
46
-
47
- * It must run multiple tests simultaneously.
48
-
49
- * Support for Windows is a first-class requirement.
50
-
51
- * A command line interface (CLI) is required for faster iteration of test code.
52
-
53
-
54
- How is InSpec different than Serverspec
55
- -----------------------------------------------------
56
-
57
- One of the key differences is that InSpec targets more user groups. It is optimized for DevOps, Security, and Compliance professionals. Additional metadata, such as impact, title, and description, make it easier to fully describe the controls which makes it easier to share the controls with other departments. This enables Security departments to prioritize rules. DevOps teams use this information to focus on the most critical issues to remediate.
58
-
59
- .. code-block:: ruby
60
-
61
- control "sshd-11" do
62
- impact 1.0
63
- title "Server: Set protocol version to SSHv2"
64
- desc "Set the SSH protocol version to 2. Don't use legacy
65
- insecure SSHv1 connections anymore."
66
- tag security: "level-1"
67
- tag "openssh-server"
68
- ref "Server Security Guide v.1.0" url: "http://..."
69
-
70
- describe sshd_config do
71
- its('Protocol') { should cmp 2 }
72
- end
73
- end
74
-
75
- **Why not fork Serverspec?**
76
-
77
- InSpec started as an extension of Serverspec. As the extension grew, it became clear that a new library was required. Creating and maintaining a fork was not practical so a new project was born.
78
-
79
- **Will InSpec only work on machines managed by Chef?**
80
-
81
- No, InSpec can be used on any machine. It doesn’t matter if that machine was configured by Chef or configured lovingly by the hands of your local System Administrator.
82
-
83
- **Is InSpec a replacement of Serverspec?**
84
-
85
- InSpec is intended to be a drop-in replacement of Serverspec. Popular Serverspec resources have been ported to InSpec. It changed some behaviour as documented in our migration guide.
data/docs/matchers.rst DELETED
@@ -1,137 +0,0 @@
1
- =====================================================
2
- InSpec Matchers Reference
3
- =====================================================
4
-
5
-
6
- Inspec uses matchers to help compare resource values to expectations. The following matchers are available:
7
-
8
- * `be`
9
- * `cmp`
10
- * `eq`
11
- * `include`
12
- * `match`
13
-
14
-
15
- be
16
- =====================================================
17
-
18
- This matcher can be followed by many different comparison operators. Always make sure to use numbers, not strings, for these comparisons.
19
-
20
- .. code-block:: ruby
21
-
22
- describe file('/proc/cpuinfo') do
23
- its('size') { should be >= 10 }
24
- its('size') { should be < 1000 }
25
- end
26
-
27
- cmp
28
- =====================================================
29
-
30
- Unlike ``eq``, cmp is a matcher for less-restrictive comparisons. It will try to fit the actual value to the type you are comparing it to. This is meant to relieve the user from having to write type-casts and resolutions.
31
-
32
- .. code-block:: ruby
33
-
34
- describe sshd_config do
35
- its('Protocol') { should cmp 2 }
36
- end
37
-
38
- describe passwd.uid(0) do
39
- its('users') { should cmp 'root' }
40
- end
41
-
42
- ``cmp`` behaves in the following way:
43
-
44
- * Compare strings to numbers
45
-
46
- .. code-block:: ruby
47
-
48
- describe sshd_config do
49
- its('Protocol') { should eq '2' }
50
-
51
- its('Protocol') { should cmp '2' }
52
- its('Protocol') { should cmp 2 }
53
- end
54
-
55
- * String comparisons are not case-sensitive
56
-
57
- .. code-block:: ruby
58
-
59
- describe auditd_conf do
60
- its('log_format') { should cmp 'raw' }
61
- its('log_format') { should cmp 'RAW' }
62
- end
63
-
64
- * Compare arrays with only one entry to a value
65
-
66
- .. code-block:: ruby
67
-
68
- describe passwd.uids(0) do
69
- its('users') { should cmp 'root' }
70
- its('users') { should cmp ['root'] }
71
- end
72
-
73
- * Single-value arrays of strings may also be compared to a regex
74
-
75
- .. code-block:: ruby
76
-
77
- describe auditd_conf do
78
- its('log_format') { should cmp /raw/i }
79
- end
80
-
81
- * Improved printing of octal comparisons
82
-
83
- .. code-block:: ruby
84
-
85
- describe file('/proc/cpuinfo') do
86
- its('mode') { should cmp '0345' }
87
- end
88
-
89
- expected: 0345
90
- got: 0444
91
-
92
- eq
93
- =====================================================
94
-
95
- Test for exact equality of two values.
96
-
97
- .. code-block:: ruby
98
-
99
- describe sshd_config do
100
- its('RSAAuthentication') { should_not eq 'no' }
101
- its('Protocol') { should eq '2' }
102
- end
103
-
104
- It fails if types don't match. Please keep this in mind, when comparing configuration
105
- entries that are numbers:
106
-
107
- .. code-block:: ruby
108
-
109
- its('Port') { should eq '22' } # ok
110
-
111
- its('Port') { should eq 22 }
112
- # fails: '2' != 2 (string vs int)
113
-
114
- For less restrictive comparisons, please use ``cmp``.
115
-
116
- include
117
- =====================================================
118
-
119
- Verifies if a value is included in a list.
120
-
121
- .. code-block:: ruby
122
-
123
- describe passwd do
124
- its('users') { should include 'my_user' }
125
- end
126
-
127
-
128
- match
129
- =====================================================
130
-
131
- Check if a string matches a regular expression.
132
-
133
- .. code-block:: ruby
134
-
135
- describe sshd_config do
136
- its('Ciphers') { should_not match /cbc/ }
137
- end