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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -13
- data/etc/plugin_filters.json +25 -0
- data/inspec-core.gemspec +1 -1
- data/lib/bundles/inspec-compliance/api.rb +3 -0
- data/lib/bundles/inspec-compliance/configuration.rb +3 -0
- data/lib/bundles/inspec-compliance/http.rb +3 -0
- data/lib/bundles/inspec-compliance/support.rb +3 -0
- data/lib/bundles/inspec-compliance/target.rb +3 -0
- data/lib/inspec/objects/attribute.rb +3 -0
- data/lib/inspec/plugin/v2.rb +3 -0
- data/lib/inspec/plugin/v2/filter.rb +62 -0
- data/lib/inspec/plugin/v2/installer.rb +21 -1
- data/lib/inspec/plugin/v2/loader.rb +4 -0
- data/lib/inspec/profile.rb +3 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +25 -3
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb +65 -11
- data/lib/plugins/inspec-plugin-manager-cli/test/unit/cli_args_test.rb +5 -1
- data/lib/resources/package.rb +1 -1
- metadata +4 -197
- data/docs/.gitignore +0 -2
- data/docs/README.md +0 -41
- data/docs/dev/control-eval.md +0 -62
- data/docs/dev/filtertable-internals.md +0 -353
- data/docs/dev/filtertable-usage.md +0 -533
- data/docs/dev/integration-testing.md +0 -31
- data/docs/dev/plugins.md +0 -323
- data/docs/dsl_inspec.md +0 -354
- data/docs/dsl_resource.md +0 -100
- data/docs/glossary.md +0 -381
- data/docs/habitat.md +0 -193
- data/docs/inspec_and_friends.md +0 -114
- data/docs/matchers.md +0 -161
- data/docs/migration.md +0 -293
- data/docs/platforms.md +0 -119
- data/docs/plugin_kitchen_inspec.md +0 -60
- data/docs/plugins.md +0 -57
- data/docs/profiles.md +0 -576
- data/docs/reporters.md +0 -170
- data/docs/resources/aide_conf.md.erb +0 -86
- data/docs/resources/apache.md.erb +0 -77
- data/docs/resources/apache_conf.md.erb +0 -78
- data/docs/resources/apt.md.erb +0 -81
- data/docs/resources/audit_policy.md.erb +0 -57
- data/docs/resources/auditd.md.erb +0 -89
- data/docs/resources/auditd_conf.md.erb +0 -78
- data/docs/resources/bash.md.erb +0 -85
- data/docs/resources/bond.md.erb +0 -100
- data/docs/resources/bridge.md.erb +0 -67
- data/docs/resources/bsd_service.md.erb +0 -77
- data/docs/resources/chocolatey_package.md.erb +0 -68
- data/docs/resources/command.md.erb +0 -176
- data/docs/resources/cpan.md.erb +0 -89
- data/docs/resources/cran.md.erb +0 -74
- data/docs/resources/crontab.md.erb +0 -103
- data/docs/resources/csv.md.erb +0 -64
- data/docs/resources/dh_params.md.erb +0 -221
- data/docs/resources/directory.md.erb +0 -40
- data/docs/resources/docker.md.erb +0 -240
- data/docs/resources/docker_container.md.erb +0 -113
- data/docs/resources/docker_image.md.erb +0 -104
- data/docs/resources/docker_plugin.md.erb +0 -80
- data/docs/resources/docker_service.md.erb +0 -124
- data/docs/resources/elasticsearch.md.erb +0 -252
- data/docs/resources/etc_fstab.md.erb +0 -135
- data/docs/resources/etc_group.md.erb +0 -85
- data/docs/resources/etc_hosts.md.erb +0 -88
- data/docs/resources/etc_hosts_allow.md.erb +0 -84
- data/docs/resources/etc_hosts_deny.md.erb +0 -84
- data/docs/resources/file.md.erb +0 -543
- data/docs/resources/filesystem.md.erb +0 -51
- data/docs/resources/firewalld.md.erb +0 -117
- data/docs/resources/gem.md.erb +0 -108
- data/docs/resources/group.md.erb +0 -71
- data/docs/resources/grub_conf.md.erb +0 -111
- data/docs/resources/host.md.erb +0 -96
- data/docs/resources/http.md.erb +0 -207
- data/docs/resources/iis_app.md.erb +0 -132
- data/docs/resources/iis_site.md.erb +0 -145
- data/docs/resources/inetd_conf.md.erb +0 -104
- data/docs/resources/ini.md.erb +0 -86
- data/docs/resources/interface.md.erb +0 -68
- data/docs/resources/iptables.md.erb +0 -74
- data/docs/resources/json.md.erb +0 -73
- data/docs/resources/kernel_module.md.erb +0 -130
- data/docs/resources/kernel_parameter.md.erb +0 -63
- data/docs/resources/key_rsa.md.erb +0 -95
- data/docs/resources/launchd_service.md.erb +0 -67
- data/docs/resources/limits_conf.md.erb +0 -85
- data/docs/resources/login_defs.md.erb +0 -81
- data/docs/resources/mount.md.erb +0 -79
- data/docs/resources/mssql_session.md.erb +0 -78
- data/docs/resources/mysql_conf.md.erb +0 -109
- data/docs/resources/mysql_session.md.erb +0 -84
- data/docs/resources/nginx.md.erb +0 -89
- data/docs/resources/nginx_conf.md.erb +0 -148
- data/docs/resources/npm.md.erb +0 -78
- data/docs/resources/ntp_conf.md.erb +0 -70
- data/docs/resources/oneget.md.erb +0 -63
- data/docs/resources/oracledb_session.md.erb +0 -103
- data/docs/resources/os.md.erb +0 -153
- data/docs/resources/os_env.md.erb +0 -101
- data/docs/resources/package.md.erb +0 -130
- data/docs/resources/packages.md.erb +0 -77
- data/docs/resources/parse_config.md.erb +0 -113
- data/docs/resources/parse_config_file.md.erb +0 -148
- data/docs/resources/passwd.md.erb +0 -151
- data/docs/resources/pip.md.erb +0 -77
- data/docs/resources/port.md.erb +0 -147
- data/docs/resources/postgres_conf.md.erb +0 -89
- data/docs/resources/postgres_hba_conf.md.erb +0 -103
- data/docs/resources/postgres_ident_conf.md.erb +0 -86
- data/docs/resources/postgres_session.md.erb +0 -79
- data/docs/resources/powershell.md.erb +0 -112
- data/docs/resources/processes.md.erb +0 -119
- data/docs/resources/rabbitmq_config.md.erb +0 -51
- data/docs/resources/registry_key.md.erb +0 -197
- data/docs/resources/runit_service.md.erb +0 -67
- data/docs/resources/security_policy.md.erb +0 -57
- data/docs/resources/service.md.erb +0 -131
- data/docs/resources/shadow.md.erb +0 -267
- data/docs/resources/ssh_config.md.erb +0 -83
- data/docs/resources/sshd_config.md.erb +0 -93
- data/docs/resources/ssl.md.erb +0 -129
- data/docs/resources/sys_info.md.erb +0 -52
- data/docs/resources/systemd_service.md.erb +0 -67
- data/docs/resources/sysv_service.md.erb +0 -67
- data/docs/resources/upstart_service.md.erb +0 -67
- data/docs/resources/user.md.erb +0 -150
- data/docs/resources/users.md.erb +0 -137
- data/docs/resources/vbscript.md.erb +0 -65
- data/docs/resources/virtualization.md.erb +0 -67
- data/docs/resources/windows_feature.md.erb +0 -69
- data/docs/resources/windows_hotfix.md.erb +0 -63
- data/docs/resources/windows_task.md.erb +0 -95
- data/docs/resources/wmi.md.erb +0 -91
- data/docs/resources/x509_certificate.md.erb +0 -161
- data/docs/resources/xinetd_conf.md.erb +0 -166
- data/docs/resources/xml.md.erb +0 -95
- data/docs/resources/yaml.md.erb +0 -79
- data/docs/resources/yum.md.erb +0 -108
- data/docs/resources/zfs_dataset.md.erb +0 -63
- data/docs/resources/zfs_pool.md.erb +0 -57
- data/docs/shared/matcher_be.md.erb +0 -1
- data/docs/shared/matcher_cmp.md.erb +0 -43
- data/docs/shared/matcher_eq.md.erb +0 -3
- data/docs/shared/matcher_include.md.erb +0 -1
- data/docs/shared/matcher_match.md.erb +0 -1
- data/docs/shell.md +0 -217
- data/docs/style.md +0 -178
- data/examples/README.md +0 -8
- data/examples/custom-resource/README.md +0 -3
- data/examples/custom-resource/controls/example.rb +0 -7
- data/examples/custom-resource/inspec.yml +0 -8
- data/examples/custom-resource/libraries/batsignal.rb +0 -20
- data/examples/custom-resource/libraries/gordon.rb +0 -21
- data/examples/inheritance/README.md +0 -65
- data/examples/inheritance/controls/example.rb +0 -14
- data/examples/inheritance/inspec.yml +0 -16
- data/examples/kitchen-ansible/.kitchen.yml +0 -25
- data/examples/kitchen-ansible/Gemfile +0 -19
- data/examples/kitchen-ansible/README.md +0 -53
- data/examples/kitchen-ansible/files/nginx.repo +0 -6
- data/examples/kitchen-ansible/tasks/main.yml +0 -16
- data/examples/kitchen-ansible/test/integration/default/default.yml +0 -5
- data/examples/kitchen-ansible/test/integration/default/web_spec.rb +0 -28
- data/examples/kitchen-chef/.kitchen.yml +0 -20
- data/examples/kitchen-chef/Berksfile +0 -3
- data/examples/kitchen-chef/Gemfile +0 -19
- data/examples/kitchen-chef/README.md +0 -27
- data/examples/kitchen-chef/metadata.rb +0 -7
- data/examples/kitchen-chef/recipes/default.rb +0 -6
- data/examples/kitchen-chef/recipes/nginx.rb +0 -30
- data/examples/kitchen-chef/test/integration/default/web_spec.rb +0 -28
- data/examples/kitchen-puppet/.kitchen.yml +0 -23
- data/examples/kitchen-puppet/Gemfile +0 -20
- data/examples/kitchen-puppet/Puppetfile +0 -25
- data/examples/kitchen-puppet/README.md +0 -53
- data/examples/kitchen-puppet/manifests/site.pp +0 -33
- data/examples/kitchen-puppet/metadata.json +0 -11
- data/examples/kitchen-puppet/modules/.gitkeep +0 -0
- data/examples/kitchen-puppet/test/integration/default/web_spec.rb +0 -28
- data/examples/meta-profile/README.md +0 -37
- data/examples/meta-profile/controls/example.rb +0 -13
- data/examples/meta-profile/inspec.yml +0 -13
- data/examples/plugins/inspec-resource-lister/Gemfile +0 -12
- data/examples/plugins/inspec-resource-lister/LICENSE +0 -13
- data/examples/plugins/inspec-resource-lister/README.md +0 -62
- data/examples/plugins/inspec-resource-lister/Rakefile +0 -40
- data/examples/plugins/inspec-resource-lister/inspec-resource-lister.gemspec +0 -45
- data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister.rb +0 -16
- data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister/cli_command.rb +0 -70
- data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister/plugin.rb +0 -55
- data/examples/plugins/inspec-resource-lister/lib/inspec-resource-lister/version.rb +0 -10
- data/examples/plugins/inspec-resource-lister/test/fixtures/README.md +0 -24
- data/examples/plugins/inspec-resource-lister/test/functional/README.md +0 -18
- data/examples/plugins/inspec-resource-lister/test/functional/inspec_resource_lister_test.rb +0 -110
- data/examples/plugins/inspec-resource-lister/test/helper.rb +0 -26
- data/examples/plugins/inspec-resource-lister/test/unit/README.md +0 -17
- data/examples/plugins/inspec-resource-lister/test/unit/cli_args_test.rb +0 -64
- data/examples/plugins/inspec-resource-lister/test/unit/plugin_def_test.rb +0 -51
- data/examples/profile-attribute.yml +0 -2
- data/examples/profile-attribute/README.md +0 -14
- data/examples/profile-attribute/controls/example.rb +0 -11
- data/examples/profile-attribute/inspec.yml +0 -8
- data/examples/profile-sensitive/README.md +0 -29
- data/examples/profile-sensitive/controls/sensitive-failures.rb +0 -9
- data/examples/profile-sensitive/controls/sensitive.rb +0 -9
- data/examples/profile-sensitive/inspec.yml +0 -8
- data/examples/profile/README.md +0 -48
- data/examples/profile/controls/example.rb +0 -24
- data/examples/profile/controls/gordon.rb +0 -36
- data/examples/profile/controls/meta.rb +0 -36
- data/examples/profile/inspec.yml +0 -11
- data/examples/profile/libraries/gordon_config.rb +0 -59
@@ -1,31 +0,0 @@
|
|
1
|
-
# Integration Testing with InSpec
|
2
|
-
|
3
|
-
## Introduction
|
4
|
-
|
5
|
-
Inspec uses Test Kitchen for its integration testing. Our current testing uses Docker as our backend. You should install and have Docker running befor you run any tests.
|
6
|
-
|
7
|
-
### How to run specific integrations
|
8
|
-
|
9
|
-
To run a specific integration test use the following:
|
10
|
-
|
11
|
-
```bash
|
12
|
-
bundle exec rake test:integration[OS_NAME]
|
13
|
-
```
|
14
|
-
|
15
|
-
Example:
|
16
|
-
```bash
|
17
|
-
bundle exec rake test:integration[default-ubuntu-1604]
|
18
|
-
```
|
19
|
-
|
20
|
-
# Inspec Integrations
|
21
|
-
|
22
|
-
### Test Kitchen
|
23
|
-
|
24
|
-
We run the test/integration/default profile at the end of each integration test in the verify stage. This confirms that our current code is compatible with test kitchen.
|
25
|
-
|
26
|
-
### Audit Testing
|
27
|
-
|
28
|
-
For Audit cookbook testing InSpec sets up some special hooks. The integration rake command will bundle up the current checkout into a gem which is passed along to test kitchen in the os_prepare cookbook. When this cookbook is ran it will install the local inspec gem. Audit will then use this gem accordingly when running in the post chef-client validators. The .kitchen.yml is setup to export the audit report to a json file which we look for and confirm the structure in the test/integration/default/controls/audit_spec.rb file.
|
29
|
-
|
30
|
-
In the validation file we confirm that the file was created from audit and that the structure looks correct. We also validate that the inspec ran with audit is the same that the current branch is using. This validates that audit did not use a older version for some reason.
|
31
|
-
|
data/docs/dev/plugins.md
DELETED
@@ -1,323 +0,0 @@
|
|
1
|
-
# Developing InSpec Plugins for the v2 plugin API
|
2
|
-
|
3
|
-
## Introduction
|
4
|
-
|
5
|
-
### Inspiration
|
6
|
-
|
7
|
-
The software design of the InSpec Plugin v2 API is deeply inspired by the Vagrant plugin v2 system. While the InSpec Plugin v2 system is an independent implementation, acknowledgements are due to the Hashicorp team for such a well-thought-out design.
|
8
|
-
|
9
|
-
### Note About versions
|
10
|
-
|
11
|
-
"v2" refers to the second major version of the Plugin API. It doesn't refer to the InSpec release number.
|
12
|
-
|
13
|
-
### Design Goals
|
14
|
-
|
15
|
-
* Load-on-demand. Improve `inspec` startup time by making plugins load heavy libraries only if they are being used.
|
16
|
-
* Independent velocity. Enable passionate community members to contribute at their own pace by shifting core development into plugin development
|
17
|
-
* Increase dogfooding. Convert internal components into plugins to reduce core complexity and allow testing in isolation
|
18
|
-
|
19
|
-
### Design Anti-goals
|
20
|
-
|
21
|
-
* Don't implement resources in plugins; use resource packs for that.
|
22
|
-
|
23
|
-
## How Plugins are Located and Loaded
|
24
|
-
|
25
|
-
### Plugins are usually gems
|
26
|
-
|
27
|
-
The normal distribution and installation method is via gems, handled by the `inspec plugin` command.
|
28
|
-
|
29
|
-
`inspec plugin install inspec-myplugin` will fetch `inspec-myplugin` from rubygems.org, and install it and its gemspec dependencies under the user's `.inspec` directory. You may also provide a local gemfile. For local development, however, path-to-source is usually most convenient.
|
30
|
-
|
31
|
-
For more on the `plugin` CLI command, run `inspec plugin help`.
|
32
|
-
|
33
|
-
### Plugins may also be found by path to a source tree
|
34
|
-
|
35
|
-
For local development or site-specific installations, you can also 'install' a plugin by path using `inspec plugin`, or edit `~/.inspec/plugins.json` directly to add a plugin.
|
36
|
-
|
37
|
-
### The plugins.json file
|
38
|
-
|
39
|
-
InSpec stores its list of known plugins in a file, `~/.inspec/plugins.json`. The purpose of this file is avoid having to do a gem path filesystem scan to locate plugins. When you install, update, or uninstall a plugin using `inspec plugin`, InSpec updates this file.
|
40
|
-
|
41
|
-
You can tell inspec to use a different config directory using the INSPEC_CONFIG_DIR environment variable.
|
42
|
-
|
43
|
-
Top-level entries in the JSON file:
|
44
|
-
|
45
|
-
* `plugins_config_version` - must have the value "1.0.0". Reserved for future format changes.
|
46
|
-
* `plugins` - an Array of Hashes, each containing information about plugins that are expected to be installed
|
47
|
-
|
48
|
-
Each plugin entry may have the following keys:
|
49
|
-
|
50
|
-
* `name` - Required. String name of the plugin. Internal machine name of the plugin. Must match `plugin_name` DSL call (see Plugin class below).
|
51
|
-
* `installation_type` - Optional, default "gem". Selects a loading mechanism, may be either "path" or "gem"
|
52
|
-
* `installation_path` - Required if installation_type is "path". A `require` will be attempted against this path. It may be absolute or relative; InSpec adds both the process current working directory as well as the InSpec installation root to the load path.
|
53
|
-
|
54
|
-
TODO: keys for gem installations
|
55
|
-
|
56
|
-
Putting this all together, here is a plugins.json file from the InSpec test suite:
|
57
|
-
|
58
|
-
```json
|
59
|
-
{
|
60
|
-
"plugins_config_version" : "1.0.0",
|
61
|
-
"plugins": [
|
62
|
-
{
|
63
|
-
"name": "inspec-meaning-of-life",
|
64
|
-
"installation_type": "path",
|
65
|
-
"installation_path": "test/unit/mock/plugins/meaning_of_life_path_mode/inspec-meaning-of-life"
|
66
|
-
}
|
67
|
-
]
|
68
|
-
}
|
69
|
-
```
|
70
|
-
|
71
|
-
## Plugin Parts
|
72
|
-
|
73
|
-
### A Typical Plugin File Layout
|
74
|
-
|
75
|
-
```
|
76
|
-
inspec-my-plugin.gemspec
|
77
|
-
lib/
|
78
|
-
inspec-my-plugin.rb # Entry point
|
79
|
-
inspec-my-plugin/
|
80
|
-
cli.rb # An implementation file
|
81
|
-
plugin.rb # Plugin definition file
|
82
|
-
heavyweight.rb # A support file
|
83
|
-
```
|
84
|
-
|
85
|
-
Generally, except for the entry point, you may name these files anything you like; however, the above example is the typical convention.
|
86
|
-
|
87
|
-
### Gemspec and Plugin Dependencies
|
88
|
-
|
89
|
-
This is a normal Gem specification file. When you release your plugin as a gem, you can declare dependencies here, and InSpec will automatically install them along with your plugin.
|
90
|
-
|
91
|
-
If you are using a path-based install, InSpec will not manage your dependencies.
|
92
|
-
|
93
|
-
### Entry Point
|
94
|
-
|
95
|
-
The entry point is the file that will be `require`d at load time (*not* activation time; see Plugin Lifecycle, below). You should load the bare minimum here - only the plugin definition file. Do not load any plugin dependencies in this file.
|
96
|
-
|
97
|
-
```ruby
|
98
|
-
# lib/inspec-my-plugin.rb
|
99
|
-
require_relative 'inspec-my-plugin/plugin'
|
100
|
-
```
|
101
|
-
|
102
|
-
### Plugin Definition File
|
103
|
-
|
104
|
-
The plugin definition file uses the plugin DSL to declare a small amount of metadata, followed by as many activation hooks as your plugin needs.
|
105
|
-
|
106
|
-
While you may use any valid Ruby module name, we encourage you to namespace your plugin under `InspecPlugins::YOUR_PLUGIN`.
|
107
|
-
|
108
|
-
```ruby
|
109
|
-
# lib/inspec-my-plugin/plugin.rb
|
110
|
-
module InspecPlugins
|
111
|
-
module MyPlugin
|
112
|
-
# Class name doesn't matter, but this is a reasonable default name
|
113
|
-
class PluginDefinition < Inspec.plugin(2)
|
114
|
-
|
115
|
-
# Metadata
|
116
|
-
# Must match entry in plugins.json
|
117
|
-
plugin_name :'inspec-my-plugin'
|
118
|
-
|
119
|
-
# Activation hooks (CliCommand as an example)
|
120
|
-
cli_command :'my-command' do
|
121
|
-
require_relative 'cli'
|
122
|
-
InspecPlugins::MyPlugin::CliCommand
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
```
|
129
|
-
|
130
|
-
Note that the block passed to `cli_command` is not executed when the plugin definition is loaded. It will only be executed if inspec decides it needs to activate that plugin component.
|
131
|
-
|
132
|
-
Every activation hook is expected to return a `Class` which will be used in post-activation or execution phases. The behavior, duck typing, and superclass of that Class vary depending on the plugin type; see below for details.
|
133
|
-
|
134
|
-
### Implementation Files
|
135
|
-
|
136
|
-
Inside the implementation files, you should be sure to do three things:
|
137
|
-
|
138
|
-
1. Load any heavyweight libraries your plugin needs
|
139
|
-
2. Create a class (which you will return from the activator hook)
|
140
|
-
3. Within the class, implement your functionality, as dictated by the plugin type API
|
141
|
-
|
142
|
-
```ruby
|
143
|
-
# lib/inspec-my-plugin/cli.rb
|
144
|
-
|
145
|
-
# Load enormous dependencies
|
146
|
-
require_relative 'heavyweight'
|
147
|
-
|
148
|
-
module InspecPlugin::MyPlugin
|
149
|
-
# Class name doesn't matter, but this is a reasonable default name
|
150
|
-
class CliCommand < Inspec.plugin(2, :cli_command) # Note two-arg form
|
151
|
-
# Implement API or use DSL as dictated by cli_command plugin type
|
152
|
-
# ...
|
153
|
-
end
|
154
|
-
end
|
155
|
-
```
|
156
|
-
|
157
|
-
## Plugin Lifecycle
|
158
|
-
|
159
|
-
All queries regarding plugin state should be directed to `Inspec::Plugin::V2::Registry.instance`, a singleton object.
|
160
|
-
|
161
|
-
```ruby
|
162
|
-
registry = Inspec::Plugin::V2::Registry.instance
|
163
|
-
plugin_status = registry[:'inspec-meaning-of-life']
|
164
|
-
```
|
165
|
-
|
166
|
-
### Discovery (Known Plugins)
|
167
|
-
|
168
|
-
If a plugin is mentioned in `plugins.json` or is a plugin distributed with InSpec itself, it is *known*. You can get its status, a `Inspec::Plugin::V2::Status` object.
|
169
|
-
|
170
|
-
Reading the plugins.json file is handled by the Loader when Loader.new is called; at that point the registry should know about plugins.
|
171
|
-
|
172
|
-
### Loading
|
173
|
-
|
174
|
-
Next, we load plugins. Loading means that we `require` the entry point determined from the plugins.json. Your plugin definition file will thus execute.
|
175
|
-
|
176
|
-
If things go right, the Status now has a bunch of Activators, each with a block that has not yet executed.
|
177
|
-
|
178
|
-
If things go wrong, have a look at `status.load_exception`.
|
179
|
-
|
180
|
-
### Activation and Execution
|
181
|
-
|
182
|
-
Depending on the plugin type, activation may be triggered by a number of different events. For example, CliCommand plugin types are activated when their activation name is mentioned in the command line arguments.
|
183
|
-
|
184
|
-
After activation, code for that aspect of the plugin is loaded and ready to execute. Execution may be triggered by a number of different events. For example, the CliCommand plugin types are implicitly executed by Thor when `Inspec::CLI` calls `start()`.
|
185
|
-
|
186
|
-
Refer to the sections below for details about activation and execution timing.
|
187
|
-
|
188
|
-
## Implementing a CLI Command Plugin
|
189
|
-
|
190
|
-
The CliCommand plugin_type allows you to extend the InSpec command line interface by adding a namespace of new commands. InSpec is based on [Thor](http://whatisthor.com/) ([docs](https://www.rubydoc.info/github/wycats/thor/Thor)), and the plugin system exposes Thor directly.
|
191
|
-
|
192
|
-
CliCommand can do things like:
|
193
|
-
|
194
|
-
```bash
|
195
|
-
# A namespaced custom command with options
|
196
|
-
you@machine$ inspec sweeten add --kind sugar --teaspoons 2
|
197
|
-
# A namespaced custom command with short options
|
198
|
-
you@machine$ inspec sweeten add -k agave
|
199
|
-
# Mix global and namespace options
|
200
|
-
you@machine$ inspec --debug sweeten add -k aspartame
|
201
|
-
# Namespace included in help
|
202
|
-
you@machine$ inspec help
|
203
|
-
Commands:
|
204
|
-
inspec archive PATH # archive a profile to tar.gz (default) or zip
|
205
|
-
inspec sweeten ... # Add spoonfuls til the medicine goes down
|
206
|
-
# Detailed help
|
207
|
-
[cwolfe@lodi inspec-plugins]$ inspec help sweeten
|
208
|
-
Commands:
|
209
|
-
inspec sweeten add [opts] # Adds sweetener to your beverage
|
210
|
-
inspec sweeten count # Reports on teaspoons in your beverage, always bad news
|
211
|
-
```
|
212
|
-
|
213
|
-
Currently, it cannot create a direct (non-namespaced) command, such as `inspec mycommand` with no subcommands.
|
214
|
-
|
215
|
-
### Declare your plugin activators
|
216
|
-
|
217
|
-
In your `plugin.rb`, include one or more `cli_command` activation blocks. The activation block name will be matched against the command line arguments; if the name is present, your activator will fire (in which case it should load any needed libraries) and should return your implementation class.
|
218
|
-
|
219
|
-
#### CliCommand Activator Example
|
220
|
-
|
221
|
-
```ruby
|
222
|
-
|
223
|
-
# In plugin.rb
|
224
|
-
module InspecPlugins::Sweeten
|
225
|
-
class Plugin < Inspec.plugin(2)
|
226
|
-
# ... other plugin stuff
|
227
|
-
|
228
|
-
cli_command :sweeten do
|
229
|
-
require_relative 'cli.rb'
|
230
|
-
InspecPlugins::Sweeten::CliCommand
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
234
|
-
```
|
235
|
-
|
236
|
-
Like any activator, the block above will only be called if needed. For CliCommand plugins, the plugin system naively scans through ARGV, looking for the activation name as a whole element. Multiple CliCommand activations may occur if several different names match, though each activation will only occur once.
|
237
|
-
|
238
|
-
```bash
|
239
|
-
you@machine $ inspec sweeten ... # Your CliCommand implementation is activated and executed
|
240
|
-
you@machine $ inspec exec ... # Your CliCommand implementation is not activated
|
241
|
-
```
|
242
|
-
|
243
|
-
Execution occurs implicitly via `Thor.start()`, which is handled by `bin/inspec`. Keep reading.
|
244
|
-
|
245
|
-
You should also be aware of one other activation event: if the CLI is invoked as `inspec help`, *all* CliCommand plugins will activate (but will not be executed). This is so that each plugin's help information can be registered with Thor.
|
246
|
-
|
247
|
-
### Implementation class for CLI Commands
|
248
|
-
|
249
|
-
In your `cli.rb`, you should begin by requesting the superclass from `Inspec.plugin`:
|
250
|
-
|
251
|
-
```ruby
|
252
|
-
module InspecPlugins::Sweeten
|
253
|
-
class CliCommand < Inspec.plugin(2, :cli_command)
|
254
|
-
# ...
|
255
|
-
end
|
256
|
-
end
|
257
|
-
```
|
258
|
-
|
259
|
-
The Inspec plugin v2 system promises the following:
|
260
|
-
|
261
|
-
* The superclass will be an (indirect) subclass of Thor
|
262
|
-
* The plugin system will handle registering the subcommand with Thor for you
|
263
|
-
* The plugin system will handle setup of the subcommand help message for you
|
264
|
-
|
265
|
-
### Implementing your command
|
266
|
-
|
267
|
-
Within your `cli.rb`, you need to do two things:
|
268
|
-
|
269
|
-
* Inform Inspec of your subcommand's usage and description, so the `help` commands will work properly
|
270
|
-
* Implement your subcommands and options using the Thor DSL
|
271
|
-
|
272
|
-
See also: [Thor homepage](http://whatisthor.com/) and [Thor docs](https://www.rubydoc.info/github/wycats/thor/Thor).
|
273
|
-
|
274
|
-
#### Call subcommand_desc
|
275
|
-
|
276
|
-
Within your implementation, make a call like this:
|
277
|
-
|
278
|
-
```ruby
|
279
|
-
# Class declaration as above
|
280
|
-
subcommand_desc 'sweeten ...', 'Add spoonfuls til the medicine goes down'
|
281
|
-
```
|
282
|
-
|
283
|
-
The first argument is the usage message; it will be displayed whenever you execute `inspec help`, or when Thor tries to parse a malformed `inspec sweeten ...` command.
|
284
|
-
|
285
|
-
The second is the command groups description, and is displayed with `inspec help`.
|
286
|
-
|
287
|
-
Both arguments are free-form Strings intended for humans; the usage message should begin with your subcommand name to prevent user confusion.
|
288
|
-
|
289
|
-
If you neglect to call this DSL method, Thor will not register your command.
|
290
|
-
|
291
|
-
#### Adding Subcommands
|
292
|
-
|
293
|
-
The minimum needed for a command is a call to `desc` to set the help message, and a method definition named after the command.
|
294
|
-
|
295
|
-
```ruby
|
296
|
-
desc 'Reports on teaspoons in your beverage, always bad news'
|
297
|
-
def count
|
298
|
-
# Someone has executed `inspec sweeten count` - do whatever that entails
|
299
|
-
case beverage_type
|
300
|
-
when :soda
|
301
|
-
puts 12
|
302
|
-
when :tea_two_lumps
|
303
|
-
puts 2
|
304
|
-
end
|
305
|
-
end
|
306
|
-
```
|
307
|
-
|
308
|
-
There is a great deal more you can do with Thor, especially concerning handling options. Refer to the Thor docs for more examples and details.
|
309
|
-
|
310
|
-
#### Using no_command
|
311
|
-
|
312
|
-
One common surprise seen with Thor is that every public instance method of your CliCommand implementation class is expected to be a CLI command definition. Thor will issue a warning if it encounters a public method definition without a `desc` call preceding it. Two ways around this include:
|
313
|
-
|
314
|
-
* Make your helper methods private
|
315
|
-
* Enclose your non-command methods in a no_command block (a feature of Thor just for this circumstance)
|
316
|
-
|
317
|
-
```ruby
|
318
|
-
no_command do
|
319
|
-
def beverage_type
|
320
|
-
@bevvy
|
321
|
-
end
|
322
|
-
end
|
323
|
-
```
|
data/docs/dsl_inspec.md
DELETED
@@ -1,354 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: InSpec DSL
|
3
|
-
---
|
4
|
-
|
5
|
-
# InSpec DSL
|
6
|
-
|
7
|
-
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|.
|
8
|
-
|
9
|
-
The InSpec DSL is a Ruby DSL for writing audit controls, which includes audit resources that you can invoke.
|
10
|
-
|
11
|
-
The following sections describe the syntax and show some simple examples of using the InSpec resources.
|
12
|
-
|
13
|
-
## Syntax
|
14
|
-
|
15
|
-
The following resource tests |ssh| server configuration. For example, a simple control may described as:
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
describe sshd_config do
|
19
|
-
its('Port') { should cmp 22 }
|
20
|
-
end
|
21
|
-
```
|
22
|
-
|
23
|
-
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:
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
control 'sshd-8' do
|
27
|
-
impact 0.6
|
28
|
-
title 'Server: Configure the service port'
|
29
|
-
desc 'Always specify which port the SSH server should listen.'
|
30
|
-
desc 'rationale', 'This ensures that there are no unexpected settings'
|
31
|
-
tag 'ssh','sshd','openssh-server'
|
32
|
-
tag cce: 'CCE-27072-8'
|
33
|
-
ref 'NSA-RH6-STIG - Section 3.5.2.1', url: 'https://www.nsa.gov/ia/_files/os/redhat/rhel5-guide-i731.pdf'
|
34
|
-
|
35
|
-
describe sshd_config do
|
36
|
-
its('Port') { should cmp 22 }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
```
|
40
|
-
|
41
|
-
where
|
42
|
-
|
43
|
-
* `'sshd-8'` is the name of the control
|
44
|
-
* `impact`, `title`, and `desc` define metadata that fully describes the importance of the control, its purpose, with a succinct and complete description
|
45
|
-
* `desc` when given only one argument it sets the default description. When given 2 arguments (see: `'rationale'`) it will use the first argument as a header when rendering in Automate
|
46
|
-
* `impact` is an float that measures the importance of the compliance results and must be a value between `0.0` and `1.0`. The value ranges are:
|
47
|
-
* `0.0 to <0.4` these are controls with minor criticality
|
48
|
-
* `0.4 to <0.7` these are controls with major criticality
|
49
|
-
* `0.7 to 1.0` these are critical controls
|
50
|
-
* `tag` is optional meta-information with with key or key-value pairs
|
51
|
-
* `ref` is a reference to an external document
|
52
|
-
* `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
|
53
|
-
* `sshd_config` is an InSpec resource. For the full list of InSpec resources, see InSpec resource documentation
|
54
|
-
* `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
|
55
|
-
|
56
|
-
## Advanced concepts
|
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
|
-
```ruby
|
61
|
-
describe.one do
|
62
|
-
describe ConfigurationA do
|
63
|
-
its('setting_1') { should eq true }
|
64
|
-
end
|
65
|
-
|
66
|
-
describe ConfigurationB do
|
67
|
-
its('setting_2') { should eq true }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
```
|
71
|
-
|
72
|
-
### Sensitive resources
|
73
|
-
|
74
|
-
In some scenarios, you may be writing checks involving resources with sensitive content (e.g. a file resource). In the case of failures, it may be desired to suppress output. This can be done by adding the `:sensitive` flag to the resource definition
|
75
|
-
|
76
|
-
```ruby
|
77
|
-
describe file('/tmp/mysecretfile'), :sensitive do
|
78
|
-
its('content') { should match /secret_info/ }
|
79
|
-
end
|
80
|
-
```
|
81
|
-
|
82
|
-
## Examples
|
83
|
-
|
84
|
-
The following examples show simple compliance tests using a single `control` block.
|
85
|
-
|
86
|
-
## Test System Event Log
|
87
|
-
|
88
|
-
The following test shows how to audit machines running Windows 2012 R2 that password complexity is enabled:
|
89
|
-
|
90
|
-
```ruby
|
91
|
-
control 'windows-account-102' do
|
92
|
-
impact 1.0
|
93
|
-
title 'Windows Password Complexity is Enabled'
|
94
|
-
desc 'Password must meet complexity requirement'
|
95
|
-
describe security_policy do
|
96
|
-
its('PasswordComplexity') { should cmp 1 }
|
97
|
-
end
|
98
|
-
end
|
99
|
-
```
|
100
|
-
|
101
|
-
## Test if PostgreSQL passwords are empty
|
102
|
-
|
103
|
-
The following test shows how to audit machines running PostgreSQL to ensure that passwords are not empty.
|
104
|
-
|
105
|
-
```ruby
|
106
|
-
control 'postgres-7' do
|
107
|
-
impact 1.0
|
108
|
-
title "Don't allow empty passwords"
|
109
|
-
describe postgres_session('user', 'pass').query("SELECT * FROM pg_shadow WHERE passwd IS NULL;") do
|
110
|
-
its('output') { should cmp '' }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
```
|
114
|
-
|
115
|
-
## Test if MySQL passwords are in ENV
|
116
|
-
|
117
|
-
The following test shows how to audit machines running MySQL to ensure that passwords are not stored in `ENV`:
|
118
|
-
|
119
|
-
```ruby
|
120
|
-
control 'mysql-3' do
|
121
|
-
impact 1.0
|
122
|
-
title 'Do not store your MySQL password in your ENV'
|
123
|
-
desc '
|
124
|
-
Storing credentials in your ENV may easily expose
|
125
|
-
them to an attacker. Prevent this at all costs.
|
126
|
-
'
|
127
|
-
describe command('env') do
|
128
|
-
its('stdout') { should_not match /^MYSQL_PWD=/ }
|
129
|
-
end
|
130
|
-
end
|
131
|
-
```
|
132
|
-
|
133
|
-
## Test if `/etc/ssh` is a Directory
|
134
|
-
|
135
|
-
The following test shows how to audit machines to ensure that `/etc/ssh` is a directory:
|
136
|
-
|
137
|
-
```ruby
|
138
|
-
control 'basic-1' do
|
139
|
-
impact 1.0
|
140
|
-
title '/etc/ssh should be a directory'
|
141
|
-
desc '
|
142
|
-
In order for OpenSSH to function correctly, its
|
143
|
-
configuration path must be a folder.
|
144
|
-
'
|
145
|
-
describe file('/etc/ssh') do
|
146
|
-
it { should be_directory }
|
147
|
-
end
|
148
|
-
end
|
149
|
-
```
|
150
|
-
|
151
|
-
## Test if Apache running
|
152
|
-
|
153
|
-
The following test shows how to audit machines to ensure that Apache is enabled and running:
|
154
|
-
|
155
|
-
```ruby
|
156
|
-
control 'apache-1' do
|
157
|
-
impact 0.3
|
158
|
-
title 'Apache2 should be configured and running'
|
159
|
-
describe service(apache.service) do
|
160
|
-
it { should be_enabled }
|
161
|
-
it { should be_running }
|
162
|
-
end
|
163
|
-
end
|
164
|
-
```
|
165
|
-
|
166
|
-
## Test if insecure packages are installed
|
167
|
-
|
168
|
-
The following test shows how to audit machines for insecure packages:
|
169
|
-
|
170
|
-
```ruby
|
171
|
-
control 'cis-os-services-5.1.3' do
|
172
|
-
impact 0.7
|
173
|
-
title '5.1.3 Ensure rsh client is not installed'
|
174
|
-
describe package('rsh') do
|
175
|
-
it { should_not be_installed }
|
176
|
-
end
|
177
|
-
describe package('rsh-redone-client') do
|
178
|
-
it { should_not be_installed }
|
179
|
-
end
|
180
|
-
end
|
181
|
-
```
|
182
|
-
|
183
|
-
## Test Windows Registry Keys
|
184
|
-
|
185
|
-
The following test shows how to audit machines to ensure Safe DLL Search Mode is enabled:
|
186
|
-
|
187
|
-
```ruby
|
188
|
-
control 'windows-base-101' do
|
189
|
-
impact 1.0
|
190
|
-
title 'Safe DLL Search Mode is Enabled'
|
191
|
-
desc '
|
192
|
-
@link: https://msdn.microsoft.com/en-us/library/ms682586(v=vs.85).aspx
|
193
|
-
'
|
194
|
-
describe registry_key('HKLM\\System\\CurrentControlSet\\Control\\Session Manager') do
|
195
|
-
it { should exist }
|
196
|
-
it { should_not have_property_value('SafeDllSearchMode', :type_dword, '0') }
|
197
|
-
end
|
198
|
-
end
|
199
|
-
```
|
200
|
-
|
201
|
-
## Exclude specific test
|
202
|
-
|
203
|
-
This shows how to allow skipping certain tests if conditions are not met, by using `only_if`.
|
204
|
-
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.
|
205
|
-
|
206
|
-
```ruby
|
207
|
-
control 'nutcracker-connect-redis-001' do
|
208
|
-
impact 1.0
|
209
|
-
title 'Check if nutcracker can pass commands to redis'
|
210
|
-
desc 'execute redis-cli set key command, to check connectivity of the service'
|
211
|
-
|
212
|
-
only_if { command('redis-cli').exist? }
|
213
|
-
|
214
|
-
describe command('redis-cli SET test_inspec "HELLO"') do
|
215
|
-
its('stdout') { should match /OK/ }
|
216
|
-
end
|
217
|
-
end
|
218
|
-
```
|
219
|
-
|
220
|
-
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.
|
221
|
-
|
222
|
-
## Additional metadata for controls
|
223
|
-
|
224
|
-
The following example illustrates various ways to add tags and references to `control`
|
225
|
-
|
226
|
-
```ruby
|
227
|
-
control 'ssh-1' do
|
228
|
-
impact 1.0
|
229
|
-
|
230
|
-
title 'Allow only SSH Protocol 2'
|
231
|
-
desc '
|
232
|
-
Only SSH protocol version 2 connections should be permitted.
|
233
|
-
The default setting in /etc/ssh/sshd_config is correct, and can be
|
234
|
-
verified by ensuring that the following line appears: Protocol 2
|
235
|
-
'
|
236
|
-
|
237
|
-
tag 'production','development'
|
238
|
-
tag 'ssh','sshd','openssh-server'
|
239
|
-
|
240
|
-
tag cce: 'CCE-27072-8'
|
241
|
-
tag disa: 'RHEL-06-000227'
|
242
|
-
|
243
|
-
tag remediation: 'stig_rhel6/recipes/sshd-config.rb'
|
244
|
-
tag remediation: 'https://supermarket.chef.io/cookbooks/ssh-hardening'
|
245
|
-
|
246
|
-
ref 'NSA-RH6-STIG - Section 3.5.2.1', url: 'https://www.nsa.gov/ia/_files/os/redhat/rhel5-guide-i731.pdf'
|
247
|
-
ref 'http://people.redhat.com/swells/scap-security-guide/RHEL/6/output/ssg-centos6-guide-C2S.html'
|
248
|
-
|
249
|
-
describe ssh_config do
|
250
|
-
its('Protocol') { should cmp 2 }
|
251
|
-
end
|
252
|
-
end
|
253
|
-
```
|
254
|
-
|
255
|
-
# Using Ruby in InSpec
|
256
|
-
|
257
|
-
The InSpec DSL is a Ruby based language. This allows you to be flexible with
|
258
|
-
Ruby code in controls:
|
259
|
-
|
260
|
-
```ruby
|
261
|
-
json_obj = json('/file.json')
|
262
|
-
json_obj['keys'].each do |value|
|
263
|
-
..
|
264
|
-
end
|
265
|
-
```
|
266
|
-
|
267
|
-
Ruby allows a lot of freedoms, but should be limited in controls so that they
|
268
|
-
remain portable and easy to understand. Please see our [profile style guide](./style).
|
269
|
-
|
270
|
-
Core and custom resources are written as regular Ruby classes which inherit from
|
271
|
-
`Inspec.resource`.
|
272
|
-
|
273
|
-
|
274
|
-
## Interactive Debugging with Pry
|
275
|
-
|
276
|
-
Here's a sample InSpec control that users Ruby variables to instantiate
|
277
|
-
an InSpec resource once and use the content in multiple tests.
|
278
|
-
|
279
|
-
```ruby
|
280
|
-
control 'check-perl' do
|
281
|
-
impact 0.3
|
282
|
-
title 'Check perl compiled options and permissions'
|
283
|
-
perl_out = command('perl -V')
|
284
|
-
#require 'pry'; binding.pry;
|
285
|
-
describe perl_out do
|
286
|
-
its('exit_status') { should eq 0 }
|
287
|
-
its('stdout') { should match /USE_64_BIT_ALL/ }
|
288
|
-
its('stdout') { should match /useposix=true/ }
|
289
|
-
its('stdout') { should match /-fstack-protector/ }
|
290
|
-
end
|
291
|
-
|
292
|
-
# extract an array of include directories
|
293
|
-
perl_inc = perl_out.stdout.partition('@INC:').last.strip.split("\n")
|
294
|
-
# ensure include directories are only writable by 'owner'
|
295
|
-
perl_inc.each do |path|
|
296
|
-
describe directory(path.strip) do
|
297
|
-
it { should_not be_writable.by 'group' }
|
298
|
-
it { should_not be_writable.by 'other' }
|
299
|
-
end
|
300
|
-
end
|
301
|
-
end
|
302
|
-
```
|
303
|
-
|
304
|
-
An **advanced** but very useful Ruby tip. In the previous example, I
|
305
|
-
commented out the `require 'pry'; binding.pry;` line. If you remove the
|
306
|
-
`#` prefix and run the control, the execution will stop at that line and
|
307
|
-
give you a `pry` shell. Use that to troubleshoot, print variables, see
|
308
|
-
methods available, etc. For the above example:
|
309
|
-
|
310
|
-
```ruby
|
311
|
-
[1] pry> perl_out.exit_status
|
312
|
-
=> 0
|
313
|
-
[2] pry> perl_out.stderr
|
314
|
-
=> ""
|
315
|
-
[3] pry> ls perl_out
|
316
|
-
Inspec::Plugins::Resource#methods: inspect
|
317
|
-
Inspec::Resources::Cmd#methods: command exist? exit_status result stderr stdout to_s
|
318
|
-
Inspec::Resource::Registry::Command#methods: inspec
|
319
|
-
instance variables: @__backend_runner__ @__resource_name__ @command @result
|
320
|
-
[4] pry> perl_out.stdout.partition('@INC:').last.strip.split("\n")
|
321
|
-
=> ["/Library/Perl/5.18/darwin-thread-multi-2level",
|
322
|
-
" /Library/Perl/5.18",
|
323
|
-
...REDACTED...
|
324
|
-
[5] pry> exit # or abort
|
325
|
-
```
|
326
|
-
|
327
|
-
You can use `pry` inside both the controls DSL and resources. Similarly,
|
328
|
-
for dev and test, you can use `inspec shell` which is based on `pry`,
|
329
|
-
for example:
|
330
|
-
|
331
|
-
```ruby
|
332
|
-
$ inspec shell
|
333
|
-
Welcome to the interactive InSpec Shell
|
334
|
-
To find out how to use it, type: help
|
335
|
-
|
336
|
-
inspec> command('ls /home/gordon/git/inspec/docs').stdout
|
337
|
-
=> "ctl_inspec.rst\ndsl_inspec.rst\ndsl_resource.rst\n"
|
338
|
-
inspec> command('ls').stdout.split("\n")
|
339
|
-
=> ["ctl_inspec.rst", "dsl_inspec.rst", "dsl_resource.rst"]
|
340
|
-
|
341
|
-
inspec> help command
|
342
|
-
Name: command
|
343
|
-
|
344
|
-
Description:
|
345
|
-
Use the command InSpec audit resource to test an arbitrary command that is run on the system.
|
346
|
-
|
347
|
-
Example:
|
348
|
-
describe command('ls -al /') do
|
349
|
-
it { should exist }
|
350
|
-
its('stdout') { should match /bin/ }
|
351
|
-
its('stderr') { should eq '' }
|
352
|
-
its('exit_status') { should eq 0 }
|
353
|
-
end
|
354
|
-
```
|