inspec-core 2.3.10 → 2.3.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -13
  3. data/etc/plugin_filters.json +25 -0
  4. data/inspec-core.gemspec +1 -1
  5. data/lib/bundles/inspec-compliance/api.rb +3 -0
  6. data/lib/bundles/inspec-compliance/configuration.rb +3 -0
  7. data/lib/bundles/inspec-compliance/http.rb +3 -0
  8. data/lib/bundles/inspec-compliance/support.rb +3 -0
  9. data/lib/bundles/inspec-compliance/target.rb +3 -0
  10. data/lib/inspec/objects/attribute.rb +3 -0
  11. data/lib/inspec/plugin/v2.rb +3 -0
  12. data/lib/inspec/plugin/v2/filter.rb +62 -0
  13. data/lib/inspec/plugin/v2/installer.rb +21 -1
  14. data/lib/inspec/plugin/v2/loader.rb +4 -0
  15. data/lib/inspec/profile.rb +3 -1
  16. data/lib/inspec/version.rb +1 -1
  17. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +25 -3
  18. data/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb +65 -11
  19. data/lib/plugins/inspec-plugin-manager-cli/test/unit/cli_args_test.rb +5 -1
  20. data/lib/resources/package.rb +1 -1
  21. metadata +4 -197
  22. data/docs/.gitignore +0 -2
  23. data/docs/README.md +0 -41
  24. data/docs/dev/control-eval.md +0 -62
  25. data/docs/dev/filtertable-internals.md +0 -353
  26. data/docs/dev/filtertable-usage.md +0 -533
  27. data/docs/dev/integration-testing.md +0 -31
  28. data/docs/dev/plugins.md +0 -323
  29. data/docs/dsl_inspec.md +0 -354
  30. data/docs/dsl_resource.md +0 -100
  31. data/docs/glossary.md +0 -381
  32. data/docs/habitat.md +0 -193
  33. data/docs/inspec_and_friends.md +0 -114
  34. data/docs/matchers.md +0 -161
  35. data/docs/migration.md +0 -293
  36. data/docs/platforms.md +0 -119
  37. data/docs/plugin_kitchen_inspec.md +0 -60
  38. data/docs/plugins.md +0 -57
  39. data/docs/profiles.md +0 -576
  40. data/docs/reporters.md +0 -170
  41. data/docs/resources/aide_conf.md.erb +0 -86
  42. data/docs/resources/apache.md.erb +0 -77
  43. data/docs/resources/apache_conf.md.erb +0 -78
  44. data/docs/resources/apt.md.erb +0 -81
  45. data/docs/resources/audit_policy.md.erb +0 -57
  46. data/docs/resources/auditd.md.erb +0 -89
  47. data/docs/resources/auditd_conf.md.erb +0 -78
  48. data/docs/resources/bash.md.erb +0 -85
  49. data/docs/resources/bond.md.erb +0 -100
  50. data/docs/resources/bridge.md.erb +0 -67
  51. data/docs/resources/bsd_service.md.erb +0 -77
  52. data/docs/resources/chocolatey_package.md.erb +0 -68
  53. data/docs/resources/command.md.erb +0 -176
  54. data/docs/resources/cpan.md.erb +0 -89
  55. data/docs/resources/cran.md.erb +0 -74
  56. data/docs/resources/crontab.md.erb +0 -103
  57. data/docs/resources/csv.md.erb +0 -64
  58. data/docs/resources/dh_params.md.erb +0 -221
  59. data/docs/resources/directory.md.erb +0 -40
  60. data/docs/resources/docker.md.erb +0 -240
  61. data/docs/resources/docker_container.md.erb +0 -113
  62. data/docs/resources/docker_image.md.erb +0 -104
  63. data/docs/resources/docker_plugin.md.erb +0 -80
  64. data/docs/resources/docker_service.md.erb +0 -124
  65. data/docs/resources/elasticsearch.md.erb +0 -252
  66. data/docs/resources/etc_fstab.md.erb +0 -135
  67. data/docs/resources/etc_group.md.erb +0 -85
  68. data/docs/resources/etc_hosts.md.erb +0 -88
  69. data/docs/resources/etc_hosts_allow.md.erb +0 -84
  70. data/docs/resources/etc_hosts_deny.md.erb +0 -84
  71. data/docs/resources/file.md.erb +0 -543
  72. data/docs/resources/filesystem.md.erb +0 -51
  73. data/docs/resources/firewalld.md.erb +0 -117
  74. data/docs/resources/gem.md.erb +0 -108
  75. data/docs/resources/group.md.erb +0 -71
  76. data/docs/resources/grub_conf.md.erb +0 -111
  77. data/docs/resources/host.md.erb +0 -96
  78. data/docs/resources/http.md.erb +0 -207
  79. data/docs/resources/iis_app.md.erb +0 -132
  80. data/docs/resources/iis_site.md.erb +0 -145
  81. data/docs/resources/inetd_conf.md.erb +0 -104
  82. data/docs/resources/ini.md.erb +0 -86
  83. data/docs/resources/interface.md.erb +0 -68
  84. data/docs/resources/iptables.md.erb +0 -74
  85. data/docs/resources/json.md.erb +0 -73
  86. data/docs/resources/kernel_module.md.erb +0 -130
  87. data/docs/resources/kernel_parameter.md.erb +0 -63
  88. data/docs/resources/key_rsa.md.erb +0 -95
  89. data/docs/resources/launchd_service.md.erb +0 -67
  90. data/docs/resources/limits_conf.md.erb +0 -85
  91. data/docs/resources/login_defs.md.erb +0 -81
  92. data/docs/resources/mount.md.erb +0 -79
  93. data/docs/resources/mssql_session.md.erb +0 -78
  94. data/docs/resources/mysql_conf.md.erb +0 -109
  95. data/docs/resources/mysql_session.md.erb +0 -84
  96. data/docs/resources/nginx.md.erb +0 -89
  97. data/docs/resources/nginx_conf.md.erb +0 -148
  98. data/docs/resources/npm.md.erb +0 -78
  99. data/docs/resources/ntp_conf.md.erb +0 -70
  100. data/docs/resources/oneget.md.erb +0 -63
  101. data/docs/resources/oracledb_session.md.erb +0 -103
  102. data/docs/resources/os.md.erb +0 -153
  103. data/docs/resources/os_env.md.erb +0 -101
  104. data/docs/resources/package.md.erb +0 -130
  105. data/docs/resources/packages.md.erb +0 -77
  106. data/docs/resources/parse_config.md.erb +0 -113
  107. data/docs/resources/parse_config_file.md.erb +0 -148
  108. data/docs/resources/passwd.md.erb +0 -151
  109. data/docs/resources/pip.md.erb +0 -77
  110. data/docs/resources/port.md.erb +0 -147
  111. data/docs/resources/postgres_conf.md.erb +0 -89
  112. data/docs/resources/postgres_hba_conf.md.erb +0 -103
  113. data/docs/resources/postgres_ident_conf.md.erb +0 -86
  114. data/docs/resources/postgres_session.md.erb +0 -79
  115. data/docs/resources/powershell.md.erb +0 -112
  116. data/docs/resources/processes.md.erb +0 -119
  117. data/docs/resources/rabbitmq_config.md.erb +0 -51
  118. data/docs/resources/registry_key.md.erb +0 -197
  119. data/docs/resources/runit_service.md.erb +0 -67
  120. data/docs/resources/security_policy.md.erb +0 -57
  121. data/docs/resources/service.md.erb +0 -131
  122. data/docs/resources/shadow.md.erb +0 -267
  123. data/docs/resources/ssh_config.md.erb +0 -83
  124. data/docs/resources/sshd_config.md.erb +0 -93
  125. data/docs/resources/ssl.md.erb +0 -129
  126. data/docs/resources/sys_info.md.erb +0 -52
  127. data/docs/resources/systemd_service.md.erb +0 -67
  128. data/docs/resources/sysv_service.md.erb +0 -67
  129. data/docs/resources/upstart_service.md.erb +0 -67
  130. data/docs/resources/user.md.erb +0 -150
  131. data/docs/resources/users.md.erb +0 -137
  132. data/docs/resources/vbscript.md.erb +0 -65
  133. data/docs/resources/virtualization.md.erb +0 -67
  134. data/docs/resources/windows_feature.md.erb +0 -69
  135. data/docs/resources/windows_hotfix.md.erb +0 -63
  136. data/docs/resources/windows_task.md.erb +0 -95
  137. data/docs/resources/wmi.md.erb +0 -91
  138. data/docs/resources/x509_certificate.md.erb +0 -161
  139. data/docs/resources/xinetd_conf.md.erb +0 -166
  140. data/docs/resources/xml.md.erb +0 -95
  141. data/docs/resources/yaml.md.erb +0 -79
  142. data/docs/resources/yum.md.erb +0 -108
  143. data/docs/resources/zfs_dataset.md.erb +0 -63
  144. data/docs/resources/zfs_pool.md.erb +0 -57
  145. data/docs/shared/matcher_be.md.erb +0 -1
  146. data/docs/shared/matcher_cmp.md.erb +0 -43
  147. data/docs/shared/matcher_eq.md.erb +0 -3
  148. data/docs/shared/matcher_include.md.erb +0 -1
  149. data/docs/shared/matcher_match.md.erb +0 -1
  150. data/docs/shell.md +0 -217
  151. data/docs/style.md +0 -178
  152. data/examples/README.md +0 -8
  153. data/examples/custom-resource/README.md +0 -3
  154. data/examples/custom-resource/controls/example.rb +0 -7
  155. data/examples/custom-resource/inspec.yml +0 -8
  156. data/examples/custom-resource/libraries/batsignal.rb +0 -20
  157. data/examples/custom-resource/libraries/gordon.rb +0 -21
  158. data/examples/inheritance/README.md +0 -65
  159. data/examples/inheritance/controls/example.rb +0 -14
  160. data/examples/inheritance/inspec.yml +0 -16
  161. data/examples/kitchen-ansible/.kitchen.yml +0 -25
  162. data/examples/kitchen-ansible/Gemfile +0 -19
  163. data/examples/kitchen-ansible/README.md +0 -53
  164. data/examples/kitchen-ansible/files/nginx.repo +0 -6
  165. data/examples/kitchen-ansible/tasks/main.yml +0 -16
  166. data/examples/kitchen-ansible/test/integration/default/default.yml +0 -5
  167. data/examples/kitchen-ansible/test/integration/default/web_spec.rb +0 -28
  168. data/examples/kitchen-chef/.kitchen.yml +0 -20
  169. data/examples/kitchen-chef/Berksfile +0 -3
  170. data/examples/kitchen-chef/Gemfile +0 -19
  171. data/examples/kitchen-chef/README.md +0 -27
  172. data/examples/kitchen-chef/metadata.rb +0 -7
  173. data/examples/kitchen-chef/recipes/default.rb +0 -6
  174. data/examples/kitchen-chef/recipes/nginx.rb +0 -30
  175. data/examples/kitchen-chef/test/integration/default/web_spec.rb +0 -28
  176. data/examples/kitchen-puppet/.kitchen.yml +0 -23
  177. data/examples/kitchen-puppet/Gemfile +0 -20
  178. data/examples/kitchen-puppet/Puppetfile +0 -25
  179. data/examples/kitchen-puppet/README.md +0 -53
  180. data/examples/kitchen-puppet/manifests/site.pp +0 -33
  181. data/examples/kitchen-puppet/metadata.json +0 -11
  182. data/examples/kitchen-puppet/modules/.gitkeep +0 -0
  183. data/examples/kitchen-puppet/test/integration/default/web_spec.rb +0 -28
  184. data/examples/meta-profile/README.md +0 -37
  185. data/examples/meta-profile/controls/example.rb +0 -13
  186. data/examples/meta-profile/inspec.yml +0 -13
  187. data/examples/plugins/inspec-resource-lister/Gemfile +0 -12
  188. data/examples/plugins/inspec-resource-lister/LICENSE +0 -13
  189. data/examples/plugins/inspec-resource-lister/README.md +0 -62
  190. data/examples/plugins/inspec-resource-lister/Rakefile +0 -40
  191. data/examples/plugins/inspec-resource-lister/inspec-resource-lister.gemspec +0 -45
  192. data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister.rb +0 -16
  193. data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister/cli_command.rb +0 -70
  194. data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister/plugin.rb +0 -55
  195. data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister/version.rb +0 -10
  196. data/examples/plugins/inspec-resource-lister/test/fixtures/README.md +0 -24
  197. data/examples/plugins/inspec-resource-lister/test/functional/README.md +0 -18
  198. data/examples/plugins/inspec-resource-lister/test/functional/inspec_resource_lister_test.rb +0 -110
  199. data/examples/plugins/inspec-resource-lister/test/helper.rb +0 -26
  200. data/examples/plugins/inspec-resource-lister/test/unit/README.md +0 -17
  201. data/examples/plugins/inspec-resource-lister/test/unit/cli_args_test.rb +0 -64
  202. data/examples/plugins/inspec-resource-lister/test/unit/plugin_def_test.rb +0 -51
  203. data/examples/profile-attribute.yml +0 -2
  204. data/examples/profile-attribute/README.md +0 -14
  205. data/examples/profile-attribute/controls/example.rb +0 -11
  206. data/examples/profile-attribute/inspec.yml +0 -8
  207. data/examples/profile-sensitive/README.md +0 -29
  208. data/examples/profile-sensitive/controls/sensitive-failures.rb +0 -9
  209. data/examples/profile-sensitive/controls/sensitive.rb +0 -9
  210. data/examples/profile-sensitive/inspec.yml +0 -8
  211. data/examples/profile/README.md +0 -48
  212. data/examples/profile/controls/example.rb +0 -24
  213. data/examples/profile/controls/gordon.rb +0 -36
  214. data/examples/profile/controls/meta.rb +0 -36
  215. data/examples/profile/inspec.yml +0 -11
  216. data/examples/profile/libraries/gordon_config.rb +0 -59
data/docs/dsl_resource.md DELETED
@@ -1,100 +0,0 @@
1
- ---
2
- title: Resource DSL
3
- ---
4
-
5
- # Resource DSL
6
-
7
- InSpec provides a mechanism for defining custom resources. These become
8
- available with their respective names and provide easy functionality to
9
- profiles.
10
-
11
- ## Resource location
12
-
13
- Resources may be added to profiles in the libraries folder:
14
-
15
- ```bash
16
- $ tree examples/profile
17
- examples/profile
18
- ...
19
- ├── libraries
20
- │   └── gordon_config.rb
21
- ```
22
-
23
- ## Resource structure
24
-
25
- The smallest possible resource takes this form:
26
-
27
- ```ruby
28
- class Tiny < Inspec.resource(1)
29
- name 'tiny'
30
- end
31
- ```
32
-
33
- Resources are written as a regular Ruby class which inherits from
34
- Inspec.resource. The number (1) specifies the version this resource
35
- plugin targets. As InSpec evolves, this interface may change and may
36
- require a higher version.
37
-
38
- The following attributes can be configured:
39
-
40
- - name - Identifier of the resource (required)
41
- - desc - Description of the resource (optional)
42
- - example - Example usage of the resource (optional)
43
- - supports - (InSpec 2.0+) Platform restrictions of the resource (optional)
44
-
45
- The following methods are available to the resource:
46
-
47
- - inspec - Contains a registry of all other resources to interact with the operating system or target in general.
48
- - 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.
49
-
50
- The following example shows a full resource using attributes and methods
51
- to provide simple access to a configuration file:
52
-
53
- ```ruby
54
- class GordonConfig < Inspec.resource(1)
55
- name 'gordon_config'
56
-
57
- # Restrict to only run on the below platforms (if none were given, all OS's supported)
58
- supports platform_family: 'fedora'
59
- supports platform: 'centos', release: '6.9'
60
- # Supports `*` for wildcard matcher in the release
61
- supports platform: 'centos', release: '7.*'
62
-
63
- desc '
64
- Resource description ...
65
- '
66
-
67
- example '
68
- describe gordon_config do
69
- its("signal") { should eq "on" }
70
- end
71
- '
72
-
73
- # Load the configuration file on initialization
74
- def initialize(path = nil)
75
- @path = path || '/etc/gordon.conf'
76
- @params = SimpleConfig.new( read_content )
77
- end
78
-
79
- # Expose all parameters of the configuration file.
80
- def method_missing(name)
81
- @params[name]
82
- end
83
-
84
- private
85
-
86
- def read_content
87
- f = inspec.file(@path)
88
- # Test if the path exist and that it's a file
89
- if f.file?
90
- # Retrieve the file's contents
91
- f.content
92
- else
93
- # If the file doesn't exist, skip all tests that use gordon_config
94
- raise Inspec::Exceptions::ResourceSkipped, "Can't read config at #{@path}"
95
- end
96
- end
97
- end
98
- ```
99
-
100
- For a full example, see our [example resource](https://github.com/chef/inspec/blob/master/examples/profile/libraries/gordon_config.rb).
data/docs/glossary.md DELETED
@@ -1,381 +0,0 @@
1
- # InSpec Glossary
2
-
3
- This document should help you become familiar with some of the terminology used by the InSpec project.
4
-
5
- There are two ways to use it:
6
-
7
- * A [text glossary](#text_glossary). Learn the meaning of a word you have encountered.
8
- * A [visual glossary](#visual_glossary). Look at examples and see how the parts are labelled. You can then use the text glossary to read details of each concept.
9
-
10
- ## Visual Glossary
11
-
12
- ### Motivating Example
13
-
14
- Suppose we are interested in auditing cars. Let's suppose we have two InSpec resources for auditing: `cars`, which searches for and filters groups of cars, and `car`, which performs detailed auditing of a single car.
15
-
16
- ### Basic Syntax
17
-
18
- Let's look at some simple examples.
19
-
20
- ### Singular Resource Example
21
-
22
- ```inspec
23
- describe car(owner: 'Tony Clifton') do
24
- it { should exist }
25
- its('license_plate') { should cmp 'MOONMAN' }
26
- it { should be_classy }
27
- it { should_not have_check_engine_light_on }
28
- end
29
- ```
30
-
31
- #### describe car(owner: 'Tony Clifton') do
32
-
33
- _car_ is a [resource](#resource). Since we are talking about only one car, it is a [singular resource](#singular_resource).
34
-
35
- #### describe car(_owner: 'Tony Clifton'_)
36
-
37
- _owner_ is a [resource parameter](#resource_parameter) and _'Tony Clifton'_ is a resource parameter value.
38
-
39
- #### _it { should exist }_
40
-
41
- Each line within the resource block beginning with `it` or `its` is a [test](#test). Use [it](#it) to access [resource-specific matchers](#resource_specific_matcher), and use [its](#its) to access [properties](#property) of the [resource](#resource), which are in turn used with [universal matchers](#universal_matcher).
42
-
43
- #### its('_license\_plate_') { should cmp 'MOONMAN' }
44
-
45
- _license\_plate_ is a [property](#property) belonging to the [resource](#resource). Properties expose testable information about the resource. Some properties are numbers, some (like this one) are text, some are lists, and some are more complex objects. Properties are always used with [universal matchers](#universal_matcher).
46
-
47
- #### its('license\_plate') { should _cmp_ 'MOONMAN' }
48
-
49
- _cmp_ is a [universal matcher](#universal_matcher). `cmp` is a very flexible, loosely typed equality operator; here it checks to see if the license plate text is the same as the text 'MOONMAN'. Notice that the test operates on the license plate text (the property value) and not on the resource. You can find the full list of supported universal matchers on the [Universal Matcher page](https://www.inspec.io/docs/reference/matchers/).
50
-
51
- #### its('license\_plate') { should cmp _'MOONMAN'_ }
52
-
53
- _'MOONMAN'_ is an [expected result](#expected_result). Some matchers take an expected result; others do not.
54
-
55
- #### it { should _be\_classy_ }
56
-
57
- _be\_classy_ is a [resource-specific matcher](#resource_specific_matcher). It returns a yes-or-no value, based on whether Tony's car is classy or not. (It is. Tony is a classy guy.)
58
-
59
- #### it { _should\_not_ have\_check\_engine\_light\_on }
60
-
61
- _should\_not_ indicates this is a negated test. So, this test passes if the matcher says "no".
62
-
63
- ### Plural Resource Example
64
-
65
- ```inspec
66
- describe cars.where(color: /^b/) do
67
- it { should exist }
68
- its('manufacturers') { should include 'Cadillac' }
69
- its('count') { should be >= 10 }
70
- end
71
- ```
72
-
73
- #### describe _cars_.where(color: /^b/) do
74
-
75
- _cars_ is a [resource](#resource). Since we are potentially talking about many cars, it is a [plural resource](#plural_resource).
76
-
77
- #### describe cars._where(color: /^b/)_ do
78
-
79
- _where(color: /^b/)_ is a [filter statement](#filter_statement). Without a filter statement, `cars` simply selects all the cars in the world.
80
-
81
- #### describe cars.where(_color: /^b/_) do
82
-
83
- _color_ is a [filter criterion](#filter_criteria) along with its filter value, _/^b/_. Here, the criterion expresses that we want to select all cars whose colors begin with the letter 'b' - blue, brown, burgundy, etc.
84
-
85
- #### _it { should exist }_
86
-
87
- Each line within the resource block beginning with `it` or `its` is a [test](#test). Use [it](#it) to access [resource-specific matchers](#resource_specific_matcher), and use [its](#its) to access [properties](#property) of the [resource](#resource), which are in turn used with [universal matchers](#universal_matcher).
88
-
89
- With plural resources, `exist` has a special meaning: did the filter match anything?
90
-
91
- #### its('_manufacturers_') { should include 'Cadillac' }
92
-
93
- _manufacturers_ is a [property](#property) of the [resource](#resource). Properties expose testable information about the resource. On plural resources, properties are almost always names in the plural, and almost always return a list of values. Here, the test returns a list of the car manufacturer names. Some list properties are de-duplicated; for example, you might have 10 cars, but if they are all Subarus and Cadillacs, it returns only two entries in the `manufacturers` property. Be sure to check the documentation for your resource.
94
-
95
- #### its('manufacturers') { should _include_ 'Cadillac' }
96
-
97
- _include_ is a [universal matcher](#universal_matcher). `include` works with lists, and checks to see if an expected result is present. Here, it checks to see if the list of manufacturers contains an entry with the text 'Cadillac'. Notice it operates on the manufacturers list (the property value) and not on the resource. You can find the full list of supported universal matchers on the [Universal Matcher page](https://www.inspec.io/docs/reference/matchers/).
98
-
99
- #### its('manufacturers') { should include '_Cadillac_' }
100
-
101
- _'Cadillac'_ is an [expected result](#expected_result). Some matchers take an expected result; others do not.
102
-
103
- #### its('count') { should _be >=_ 10 }
104
-
105
- _be >=_ is an [operator matcher](#operator matcher). It allows you to perform numeric comparisons. All plural resources have a `count` property.
106
-
107
- ## Text Glossary
108
-
109
- ### attribute
110
-
111
- An _attribute_ is a parameter that InSpec reads from a YAML file provided on the command line. You can use this feature either to change a [profile's](#profile) behavior by passing different attribute files or to store secrets that should not be directly present in a profile. InSpec attributes are unrelated to Chef attributes.
112
-
113
- The CLI syntax for attributes is documented under the [`inspec exec`](https://www.inspec.io/docs/reference/cli/#exec) command.
114
-
115
- The syntax for accessing attributes within a profile is documented in the [profiles documentation](https://www.inspec.io/docs/reference/profiles/#profile-attributes).
116
-
117
- ### control
118
-
119
- ### control block
120
-
121
- The _`control`_ keyword is used to declare a _`control block`_. Here, the word 'control' means a 'regulatory control, recommendation, or requirement' - not a software engineering construct. A `control block` has a name (which usually refers to the assigned ID of the regulatory recommendation it implements), metadata such as descriptions, references, and tags, and finally groups together related [describe blocks](#describe_block) to implement the checks.
122
-
123
- ### core resource
124
-
125
- A [resource](#resource) that is included with InSpec; you are not required to install additional [plugins](#plugin) or depend on a [resource pack](#resource pack) to use the resource.
126
-
127
- ### custom resource
128
-
129
- A [resource](#resource) that is _not_ included with InSpec. It may be a resource of your own creation, or one you obtain by depending on a [resource pack](#resource pack).
130
-
131
- ### describe
132
-
133
- ### describe block
134
-
135
- The _`describe`_ keyword is used with a _`describe block`_ to refer to an InSpec resource. You use the `describe` keyword along with the name of a [resource](#resource) to enclose related [tests](#test) that apply to the resource. Multiple describe blocks are usually grouped together in a [control](#control), but you can also use them outside of a control.
136
-
137
- ```Ruby
138
- control 'Rule 1.1 - Color restrictions' do
139
- # Count only blue cars
140
- describe cars.where(color: 'blue') do
141
- its('count') { should eq 20 }
142
- end
143
- end
144
- ```
145
-
146
- ### DSL
147
-
148
- _DSL_ is an acronym for _Domain Specific Language_. It refers to the language extensions InSpec provides to make authoring resources and controls easier. While InSpec control files are use Ruby, the _Control DSL_ makes it easy to write controls without knowledge of Ruby by providing DSL keywords such as [describe](#describe), [control](#control), [it](#it) and [its](#its). See the [InSpec DSL page](https://www.inspec.io/docs/reference/dsl_inspec/) for details about keywords available to control authors.
149
-
150
- For [custom resource](#custom_resource) authors, an additional DSL is available - see the [Resource DSL page](https://www.inspec.io/docs/reference/dsl_resource/).
151
-
152
- ### expected result
153
-
154
- When using a [matcher](#matcher), the _`expected result`_ is the value the matcher will compare against the [property](#property) being accessed.
155
-
156
- In this example, the [`cmp`](https://www.inspec.io/docs/reference/matchers/#cmp) matcher is being used to compare the `color` property to the expected result 'black'.
157
-
158
- ```Ruby
159
- describe car(owner: 'Bruce Wayne') do
160
- its('color') { should cmp 'black' }
161
- end
162
- ```
163
-
164
- ### filter statement
165
-
166
- When using a [plural resource](#plural_resource), a _`filter statement`_ is used to select individual test subjects using [filter criteria](#filter_criteria). A filter statement almost always is indicated by the keyword `where`, and may be repeated using method chaining.
167
-
168
- A filter statement may use method call syntax (which allows basic criteria operations, such as equality, regex matching, and ruby `===` comparison) or block syntax (which allows arbitrary code).
169
-
170
- In this example, `where(...)` is the filter statement.
171
-
172
- ```Ruby
173
- # Count only blue cars
174
- describe cars.where(color: 'blue') do
175
- its('count') { should eq 20 }
176
- end
177
- ```
178
-
179
- ### filter criterion
180
-
181
- ### filter criteria
182
-
183
- When using a [plural resource](#plural_resource), a _`filter criterion`_ is used to select individual test subjects within a [filter statement](#filter_statement). You may use multiple _`filter criteria`_ in a single filter statement.
184
-
185
- When method-call syntax is used with the filter statement, you provide filter criteria as a Hash, with filter criteria names as keys, and conditions as the Hash values. You may provide test, true/false, or numbers, in which case the comparison is equality; or you may provide a regular expression, in which case a match is performed.
186
-
187
- Here, `(color: blue)` is a single filter criterion being used with a filter statement in method-call syntax.
188
-
189
- ```Ruby
190
- # Count only blue cars
191
- describe cars.where(color: 'blue') do
192
- its('count') { should eq 20 }
193
- end
194
- ```
195
-
196
- When block-method syntax is used with the filter statement, you provide a block. The block may contain arbitrary code, and each filter criteria will be available as an accessor. The block will be evaluated once per row, and each block that evaluates to a truthy value will pass the filter.
197
-
198
- Here, `{ engine_cylinders >= 6 }` is a block-syntax filter statement referring to one filter criterion.
199
-
200
- ```Ruby
201
- # Vroom!
202
- describe cars.where { engine_cylinders >= 6 } do
203
- its('city_mpg_ratings') { should_not include '4-star' }
204
- end
205
- ```
206
-
207
- ### it
208
-
209
- Within a [describe block](#describe), _`it`_ declares an individual [test](#test) directly against the [resource](#resource) (as opposed to testing against one of the resource's [properties](#property), as [its](#its) does). Though it is possible to use [universal matchers](#universal_matcher) with `it`, it is much more typical to use [resource-specific matchers](#resource_specific_matchers).
210
-
211
- `it` may be used with `should`, or negated using `should_not`.
212
-
213
- Here, `it { should ... }` declares a test, calling the `classy?` matcher on Tony Clifton's car.
214
-
215
- ```Ruby
216
- describe car(owner: 'Tony Clifton') do
217
- it { should be_classy }
218
- end
219
- ```
220
-
221
- ### its
222
-
223
- Within a [describe block](#describe), _`its`_ declares an individual [test](#test) against a property of the [resource](#resource) (as opposed to testing directly against the resource itself, as [it](#it) does). You must use [universal matchers](#universal_matcher) with `its`; you cannot use [resource-specific matchers](#resource_specific_matchers).
224
-
225
- `its` may be used with `should`, or negated using `should_not`.
226
-
227
- The property to access is passed as a single string argument to `its`. As an advanced usage, if the property has methods you are interested in, you can call them using '`.`' within the string; even more advanced calling patterns are possible - see [the rspec-its documentation](https://github.com/rspec/rspec-its#usage).
228
-
229
- Here, `its('fuzzy_dice') { should ... }` declares a test, testing against the `fuzzy_dice` property of Tony Clifton's car. Let's assume - Tony being Tony - that `fuzzy_dice` will return an Array.
230
-
231
- ```Ruby
232
- describe car(owner: 'Tony Clifton') do
233
- its('fuzzy_dice') { should_not be_empty }
234
- its('fuzzy_dice.count') { should be >= 2 }
235
- its('fuzzy_dice.first.fuzziness') { should cmp 'outlandishly so' }
236
- end
237
- ```
238
-
239
- ### matcher
240
-
241
- A _`matcher`_ performs the actual assertions against [resources](#resource) or the [properties](#property) of resources. Matchers always return a true/false value. Matchers fall into two camps:
242
-
243
- * [resource-specific matchers](#resource_specific_matchers), which operate directly on the resource, are used with [it](#it), and tend to be highly customized to the auditing needs of the resource
244
- * [universal matchers](#universal_matchers), which operate on the properties of the resource, are used with [its](#its), and tend to be very generic, operating on text, numbers, and lists
245
-
246
- Some matchers accept parameters, called [expected results](#expected_results).
247
-
248
- For information on how RSpec matchers are related o InSpec matchers, see [InSpec and RSpec](https://www.inspec.io/docs/reference/inspec_and_friends/#rspec).
249
-
250
- Here, `be_classy` is a resource-specific matcher operating directly on the `car`, while `cmp` is a universal matcher operating on the `manufacturer` property.
251
-
252
- ```Ruby
253
- describe car(owner: 'Tony Clifton') do
254
- it { should be_classy }
255
- its('manufacturer') { should cmp 'Cadillac' }
256
- end
257
- ```
258
-
259
- ### plural resource
260
-
261
- A _`plural resource`_ is a [resource](#resource) that specializes in performing searches and represents multiple occurrences of the resource on the [target](#target) platform. Plural resources are used to audit counts, inspect group properties, and have the unique ability to enforce negative tests ("nothing like this should exist") often required by compliance standards. Plural resources are not intended to perform in-depth auditing of an individual; use [singular resources](#singular_resource) for that.
262
-
263
- Plural resources nearly always have a name that ends in 's': `processes`, `aws_security_groups`, `cars`. Plural resources generally do not have [resource-specific matchers](#resource_specific_matcher). If they have properties, they are almost always list properties, meaning that they return a list of values, which may or may not be de-duplicated.
264
-
265
- Plural resources support [filter statements](#filter_statement). See the [resource documentation](https://www.inspec.io/docs/reference/resources/) for details regarding which [filter criteria](#filter_criteria) are supported on each resource.
266
-
267
- Here, `cars` is a plural resource.
268
-
269
- ```Ruby
270
- describe cars.where(color: 'blue') do
271
- its('count') { should eq 20 }
272
- its('license_plates') { should include 'AUTOAZUL' }
273
-
274
- # License plates are unique, should have 20
275
- its('license_plates.count') { should cmp 20 }
276
-
277
- # Manufacturers are de-duplicated
278
- its('manufacturers') { should include 'Subaru' }
279
- its('manufacturers.count') { should be < 10 }
280
- end
281
- ```
282
-
283
- ### profile
284
-
285
- A _`profile`_ is a set of related [controls](#control) in a distributable form. You might have a locally-developed profile that your organization uses to define baseline security on all machines, or you might use a pre-defined profile that implements the requirements of a specific compliance standard. For full details about the capabilities of a profile, see the [profile documentation](https://www.inspec.io/docs/reference/profiles/).
286
-
287
- Profiles may be distributed locally as a directory tree, as a tarball or zipfile at a URL, as a git repo, and several other ways. Profiles contain metadata, including versioning, and can setup dependency relationships with other profiles.
288
-
289
- Aside from controls, profiles can also contain [custom resources](#custom_resource). If the profile contains only custom resources and no controls, we call it a [resource pack](#resource_pack).
290
-
291
- ### property
292
-
293
- A fact about a [resource](#resource). Typically, you use the [its](#its) keyword to access the property and write a [test](#test) within a [describe block](#describe_block), and then use a [universal matcher](#universal_matcher) to make assertions about the value of the property.
294
-
295
- Each resource has different properties. See the [resource documentation](https://www.inspec.io/docs/reference/resources/) for details.
296
-
297
- Here, `manufacturer` is a property of the `car` resource.
298
-
299
- ```Ruby
300
- describe car(owner: 'Tony Clifton') do
301
- its('manufacturer') { should cmp 'Cadillac' }
302
- end
303
- ```
304
-
305
- ### reporter
306
-
307
- An output format for the `inspec exec` command line. Several reporters are available, including JSON and JUnit; see the [inspec exec documentation](https://www.inspec.io/docs/reference/cli/#exec).
308
-
309
- ### resource
310
-
311
- A _`resource`_ represents a category of things on the [target](#target) you wish to examine. For example, to check for the existence and permissions of a file, you would use the [`file`](https://www.inspec.io/docs/reference/resources/file/) resource. InSpec offers dozens of different resources, from the highly specialized (such as `aws_security_group`, which examines firewall rules in AWS) to the very general (such as `command`, which runs a command and lets you examine its output).
312
-
313
- Resources are generally categorized as either [singular](#singular_resource) or [plural](#plural_resource), though there are some irregular resources that cannot be cleanly considered one or the other.
314
-
315
- Resources are used within a [describe block](#describe_block) to perform [tests](#test).
316
-
317
- Here, `car` is a resource.
318
-
319
- ```Ruby
320
- describe car(owner: 'Tony Clifton') do
321
- it { should be_classy }
322
- end
323
- ```
324
-
325
- ### resource pack
326
-
327
- A _resource pack_ is a type of [profile](#profile) that is used to distribute [custom resources](#custom_resource). This specialized type of profile contains no [controls](#control), but it does contain a `libraries` directory within which Ruby files define custom resources.
328
-
329
- ### resource parameter
330
-
331
- _`resource parameters`_ are information passed to the resource when they are declared. Typically, resource parameters provide identifying information or connectivity information. Resource parameters are not the same as a [filter statement](#filter_statement).
332
-
333
- Resource parameters vary from resource to resource; refer to the [resource documentation](https://www.inspec.io/docs/reference/resources/) for details.
334
-
335
- Here, `owner: 'Tony Clifton'` is a resource parameter.
336
-
337
- ```Ruby
338
- describe car(owner: 'Tony Clifton') do
339
- it { should be_classy }
340
- end
341
- ```
342
-
343
- ### resource-specific matcher
344
-
345
- A [matcher](#matcher) that operates directly on the [resource](#resource), as opposed to operating on a property as a [universal matcher](#universal matcher) does.
346
-
347
- Resource-specific matchers often provide highly customized behavior. Check the [resource documentation](#https://www.inspec.io/docs/reference/resources/) to discover which resource-specific matchers are available for your resource.
348
-
349
- For example, the hypothetical `car` resource defines a `classy?` method, which is exposed as the `be_classy` matcher in InSpec tests.
350
-
351
- ```Ruby
352
- describe car(owner: 'Tony Clifton') do
353
- it { should be_classy }
354
- end
355
- ```
356
-
357
- ### singular resource
358
-
359
- A [resource](#resource) intended to uniquely identify a single object on the [target](#target). Singular resources specialize in providing richer auditing capabilities via resource-specific matchers. Compare to [plural resources](#plural_resource).
360
-
361
- ### target
362
-
363
- The _`target`_ is the OS or API on which InSpec is performing audits. In InSpec 1.x, this was always an operating system target (a bare metal machine, VM, or container). In InSpec 2.x and later, this can be an OS target, or an API target, including cloud providers such as AWS. InSpec is agentless, meaning that the InSpec code and profiles remain on your workstation, and the target is remotely interrogated without installing anything.
364
-
365
- ### test
366
-
367
- A _`test`_ is an individual assertion about the state of the [resource](#resource) or one of its [properties](#property). All tests begin with the keyword [it](#it) or [its](#its). Tests are grouped within a [describe block](#describe_block).
368
-
369
- ### universal matcher
370
-
371
- A _universal matcher_ is a [matcher](#matcher) that can be used on the [properties](#property) of any type of [resource](#resource). For example, you can use the `cmp` matcher to check the value of properties without having to worry about Ruby type-casting. Universal matchers are almost always used with the [its](#its) keyword.
372
-
373
- Universal matchers are documented on the [Universal Matchers](https://www.inspec.io/docs/reference/matchers/) page.
374
-
375
- Here, we access the 'color' property, then use the `cmp` universal matcher to compare the property to the 'black' [expected result](#expected_result).
376
-
377
- ```Ruby
378
- describe car(owner: 'Bruce Wayne') do
379
- its('color') { should cmp 'black' }
380
- end
381
- ```