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
@@ -0,0 +1,105 @@
1
+ ---
2
+ title: InSpec and friends
3
+ ---
4
+
5
+ # InSpec and friends
6
+
7
+ This page looks at projects that are similar to InSpec to explain how they
8
+ relate to each other.
9
+
10
+ ## RSpec
11
+
12
+ RSpec is an awesome framework that is widely used to test Ruby code. It
13
+ enables test-driven development (TDD) and helps developers to write
14
+ better code every day.
15
+
16
+ InSpec is built on top of RSpec and uses it as the underlying foundation
17
+ to execute tests. It uses the key strengths of RSpec, easily execute
18
+ tests and a DSL to write tests, but extends the functionality for use as
19
+ compliance audits. InSpec ships with custom audit resources that make it
20
+ easy to write audit checks and with the ability to run those checks on
21
+ remote servers. These audit resources provided know the differences
22
+ between operating systems and help you abstract from the local operating
23
+ system, similar to other resources you might use in your Chef recipes.
24
+
25
+ A complete InSpec rule looks like:
26
+
27
+ ```ruby
28
+ control "sshd-11" do
29
+ impact 1.0
30
+ title "Server: Set protocol version to SSHv2"
31
+ desc "Set the SSH protocol version to 2. Don't use legacy
32
+ insecure SSHv1 connections anymore."
33
+ tag security: "level-1"
34
+ tag "openssh-server"
35
+ ref "Server Security Guide v.1.0", url: "http://..."
36
+
37
+ describe sshd_config do
38
+ its('Protocol') { should eq('2') }
39
+ end
40
+ end
41
+ ```
42
+
43
+ ## Serverspec
44
+
45
+ Serverspec can be credited as the first extension of RSpec that enabled
46
+ users to run RSpec tests on servers to verify deployed artifacts. It was
47
+ created in March 2013 by Gosuke Miyashita and has been widely adopted.
48
+ It is also one of the core test frameworks within test-kitchen and has
49
+ been widely used within the Chef ecosystem. InSpec takes lessons learned
50
+ implementing and using Serverspec and builds on them to make auditing
51
+ and compliance easier.
52
+
53
+ Lessons learned from Serverspec include:
54
+
55
+ * IT, compliance, and security professional require metadata beyond what Serverspec offers, such as criticality, to fully describe controls.
56
+ * Setting up and running the same tests across multiple machines must be easy.
57
+ * It must be easy to locate, debug, and extend operating system-dependent code.
58
+ * It must be easy to extend the language and create custom resources.
59
+ * It must run multiple tests simultaneously.
60
+ * Support for Windows is a first-class requirement.
61
+ * A command line interface (CLI) is required for faster iteration of test code.
62
+
63
+ ### How is InSpec different than Serverspec
64
+
65
+ One of the key differences is that InSpec targets more user groups. It
66
+ is optimized for DevOps, Security, and Compliance professionals.
67
+ Additional metadata, such as impact, title, and description, make it
68
+ easier to fully describe the controls which makes it easier to share the
69
+ controls with other departments. This enables Security departments to
70
+ prioritize rules. DevOps teams use this information to focus on the most
71
+ critical issues to remediate.
72
+
73
+ ```ruby
74
+ control "sshd-11" do
75
+ impact 1.0
76
+ title "Server: Set protocol version to SSHv2"
77
+ desc "Set the SSH protocol version to 2. Don't use legacy
78
+ insecure SSHv1 connections anymore."
79
+ tag security: "level-1"
80
+ tag "openssh-server"
81
+ ref "Server Security Guide v.1.0" url: "http://..."
82
+
83
+ describe sshd_config do
84
+ its('Protocol') { should cmp 2 }
85
+ end
86
+ end
87
+ ```
88
+
89
+ **Why not fork Serverspec?**
90
+
91
+ InSpec started as an extension of Serverspec. As the extension grew, it
92
+ became clear that a new library was required. Creating and maintaining a
93
+ fork was not practical so a new project was born.
94
+
95
+ **Will InSpec only work on machines managed by Chef?**
96
+
97
+ No, InSpec can be used on any machine. It doesn’t matter if that machine
98
+ was configured by Chef or configured lovingly by the hands of your local
99
+ System Administrator.
100
+
101
+ **Is InSpec a replacement of Serverspec?**
102
+
103
+ InSpec is intended to be a drop-in replacement of Serverspec. Popular
104
+ Serverspec resources have been ported to InSpec. It changed some
105
+ behaviour as documented in our migration guide.
data/docs/matchers.md ADDED
@@ -0,0 +1,136 @@
1
+ ---
2
+ title: InSpec Matchers Reference
3
+ ---
4
+
5
+ # InSpec Matchers Reference
6
+
7
+ Inspec uses matchers to help compare resource values to expectations.
8
+ The following matchers are available:
9
+
10
+ * `be`
11
+ * `cmp`
12
+ * `eq`
13
+ * `include`
14
+ * `match`
15
+
16
+ ## be
17
+
18
+ This matcher can be followed by many different comparison operators.
19
+ Always make sure to use numbers, not strings, for these comparisons.
20
+
21
+ ```ruby
22
+ describe file('/proc/cpuinfo') do
23
+ its('size') { should be >= 10 }
24
+ its('size') { should be < 1000 }
25
+ end
26
+ ```
27
+
28
+ ## cmp
29
+
30
+ Unlike `eq`, cmp is a matcher for less-restrictive comparisons. It will
31
+ try to fit the actual value to the type you are comparing it to. This is
32
+ meant to relieve the user from having to write type-casts and
33
+ resolutions.
34
+
35
+ ```ruby
36
+ describe sshd_config do
37
+ its('Protocol') { should cmp 2 }
38
+ end
39
+
40
+ describe passwd.uid(0) do
41
+ its('users') { should cmp 'root' }
42
+ end
43
+ ```
44
+
45
+ `cmp` behaves in the following way:
46
+
47
+ * Compare strings to numbers
48
+
49
+ ```ruby
50
+ describe sshd_config do
51
+ its('Protocol') { should eq '2' }
52
+
53
+ its('Protocol') { should cmp '2' }
54
+ its('Protocol') { should cmp 2 }
55
+ end
56
+ ```
57
+
58
+ * String comparisons are not case-sensitive
59
+
60
+ ```ruby
61
+ describe auditd_conf do
62
+ its('log_format') { should cmp 'raw' }
63
+ its('log_format') { should cmp 'RAW' }
64
+ end
65
+ ```
66
+
67
+ * Compare arrays with only one entry to a value
68
+
69
+ ```ruby
70
+ describe passwd.uids(0) do
71
+ its('users') { should cmp 'root' }
72
+ its('users') { should cmp ['root'] }
73
+ end
74
+ ```
75
+
76
+ * Single-value arrays of strings may also be compared to a regex
77
+
78
+ ```ruby
79
+ describe auditd_conf do
80
+ its('log_format') { should cmp /raw/i }
81
+ end
82
+ ```
83
+
84
+ * Improved printing of octal comparisons
85
+
86
+ ```ruby
87
+ describe file('/proc/cpuinfo') do
88
+ its('mode') { should cmp '0345' }
89
+ end
90
+
91
+ expected: 0345
92
+ got: 0444
93
+ ```
94
+
95
+ ## eq
96
+
97
+ Test for exact equality of two values.
98
+
99
+ ```ruby
100
+ describe sshd_config do
101
+ its('RSAAuthentication') { should_not eq 'no' }
102
+ its('Protocol') { should eq '2' }
103
+ end
104
+ ```
105
+
106
+ It fails if types don't match. Please keep this in mind, when comparing
107
+ configuration entries that are numbers:
108
+
109
+ ```ruby
110
+ its('Port') { should eq '22' } # ok
111
+
112
+ its('Port') { should eq 22 }
113
+ # fails: '2' != 2 (string vs int)
114
+ ```
115
+
116
+ For less restrictive comparisons, please use `cmp`.
117
+
118
+ ## include
119
+
120
+ Verifies if a value is included in a list.
121
+
122
+ ```ruby
123
+ describe passwd do
124
+ its('users') { should include 'my_user' }
125
+ end
126
+ ```
127
+
128
+ ## match
129
+
130
+ Check if a string matches a regular expression.
131
+
132
+ ```ruby
133
+ describe sshd_config do
134
+ its('Ciphers') { should_not match /cbc/ }
135
+ end
136
+ ```
@@ -0,0 +1,55 @@
1
+ ---
2
+ title: About kitchen-inspec
3
+ ---
4
+
5
+ # kitchen-inspec
6
+
7
+ The `kitchen-inspec` driver enables InSpec to be used as a verifier within Kitchen.
8
+
9
+ To use InSpec as a verifier, add it to the kitchen.yml file:
10
+
11
+ verifier:
12
+ name: inspec
13
+
14
+ To define a suite that pulls its run-list from the Chef Compliance server:
15
+
16
+ suites:
17
+ - name: compliance
18
+ run_list:
19
+ - recipe[ssh-hardening]
20
+ verifier:
21
+ inspec_tests:
22
+ - compliance://base/ssh
23
+
24
+ and then run the following command:
25
+
26
+ $ inspec compliance login https://compliance.test --user admin --insecure --token ''
27
+
28
+ where `--insecure` is required when using self-signed certificates.
29
+
30
+ To define a suite that pulls its run-list from the Chef Supermarket:
31
+
32
+ suites:
33
+ - name: supermarket
34
+ run_list:
35
+ - recipe[ssh-hardening]
36
+ verifier:
37
+ inspec_tests:
38
+ - supermarket://hardening/ssh-hardening
39
+
40
+ The `kitchen-inspec` driver expects tests to be located in the `test/integration` directory in a cookbook. For example::
41
+
42
+ .
43
+ ├── Berksfile
44
+ ├── Gemfile
45
+ ├── README.md
46
+ ├── metadata.rb
47
+ ├── recipes
48
+ │ ├── default.rb
49
+ │ └── nginx.rb
50
+ └── test
51
+ └── integration
52
+ └── default
53
+ ├── controls
54
+ ├── inspec.yml
55
+ └── libraries
data/docs/profiles.md ADDED
@@ -0,0 +1,285 @@
1
+ ---
2
+ title: About InSpec Profiles
3
+ ---
4
+
5
+ # InSpec Profiles
6
+
7
+ InSpec supports the creation of complex test and compliance profiles, which organize controls to support dependency management and code reuse. Each profile is a standalone structure with its own distribution and execution flow.
8
+
9
+ # Profile Structure
10
+
11
+ A profile should have the following structure::
12
+
13
+ examples/profile
14
+ ├── README.md
15
+ ├── controls
16
+ │ ├── example.rb
17
+ │ └── control_etc.rb
18
+ ├── libraries
19
+ │ └── extension.rb
20
+ └── inspec.yml
21
+
22
+ where:
23
+
24
+ * `inspec.yml` includes the profile description (required)
25
+ * `controls` is the directory in which all tests are located (required)
26
+ * `libraries` is the directory in which all InSpec resource extensions are located (optional)
27
+ * `README.md` should be used to explain the profile, its scope, and usage
28
+
29
+ See a complete example profile in the InSpec open source repository: https://github.com/chef/inspec/tree/master/examples/profile
30
+
31
+ ## inspec.yml
32
+
33
+ Each profile must have an `inspec.yml` file that defines the following information:
34
+
35
+ * Use `name` to specify a unique name for the profile. Required.
36
+ * Use `title` to specify a human-readable name for the profile.
37
+ * Use `maintainer` to specify the profile maintainer.
38
+ * Use `copyright` to specify the copyright holder.
39
+ * Use `copyright_email` to specify support contact information for the profile, typically an email address.
40
+ * Use `license` to specify the license for the profile.
41
+ * Use `summary` to specify a one line summary for the profile.
42
+ * Use `description` to specify a multiple line description of the profile.
43
+ * Use `version` to specify the profile version.
44
+ * Use `supports` to specify a list of supported platform targets.
45
+ * Use `depends` to define a list of profiles on which this profile depends.
46
+
47
+ `name` is required; all other profile settings are optional. For example:
48
+
49
+ name: ssh
50
+ title: Basic SSH
51
+ maintainer: Chef Software, Inc.
52
+ copyright: Chef Software, Inc.
53
+ copyright_email: support@chef.io
54
+ license: Proprietary, All rights reserved
55
+ summary: Verify that SSH Server and SSH Client are configured securely
56
+ version: 1.0.0
57
+ supports:
58
+ - os-family: linux
59
+ depends:
60
+ - name: profile
61
+ path: ../path/to/profile
62
+
63
+ ## Verify Profiles
64
+
65
+ Use the `inspec check` command to verify the implementation of a profile:
66
+
67
+ $ inspec check examples/profile
68
+
69
+ # Platform Support
70
+
71
+ Use the `supports` setting in the `inspec.yml` file to specify one (or more) platforms for which a profile is targeting. The list of supported platforms may contain simple names, names and versions, or detailed flags, and may be combined arbitrarily. For example, to target anything running Debian Linux:
72
+
73
+ name: ssh
74
+ supports:
75
+ - os-name: debian
76
+
77
+ and to target only Ubuntu version 14.04
78
+
79
+ name: ssh
80
+ supports:
81
+ - os-name: ubuntu
82
+ release: 14.04
83
+
84
+ and to target the entire RedHat platform (including CentOS and Oracle Linux):
85
+
86
+ name: ssh
87
+ supports:
88
+ - os-family: redhat
89
+
90
+ and to target anything running on Amazon AWS:
91
+
92
+ name: ssh
93
+ supports:
94
+ - platform: aws
95
+
96
+ and to target all of these examples in a single `inspec.yml` file:
97
+
98
+ name: ssh
99
+ supports:
100
+ - os-name: debian
101
+ supports:
102
+ - os-name: ubuntu
103
+ release: 14.04
104
+ supports:
105
+ - os-family: redhat
106
+ supports:
107
+ - platform: aws
108
+
109
+
110
+ # Profile Dependencies
111
+
112
+ Use the `depends` setting in the `inspec.yml` file to specify one (or more) profiles on which this profile depends. A profile dependency may be sourced from a path, URL, a git repo, a cookbook located on Chef Supermarket or on GitHub, or a profile located on the Chef Compliance server.
113
+
114
+ ## Path
115
+
116
+ The `path` setting defines a profile that is located on disk. This setting is typically used during development of profiles and when debugging profiles. This setting does not support version constraints. If the location of the profile does not exist, an error is returned.
117
+
118
+ For example:
119
+
120
+ depends:
121
+ - name: my-profile
122
+ path: /absolute/path
123
+ - name: another
124
+ path: ../relative/path
125
+
126
+ ## URL
127
+
128
+ The `url` setting specifies a profile that is located at an HTTP- or HTTPS-based URL. The profile must be accessible via a HTTP GET operation and must be a valid profile archive (zip, tar, tar.gz format). If the download fails, the profile is inaccessible, or not in the correct format, an error is returned.
129
+
130
+ For example:
131
+
132
+ depends:
133
+ - name: my-profile
134
+ url: https://my.domain/path/to/profile.tgz
135
+
136
+ ## git
137
+
138
+ A `git` setting specifies a profile that is located in a git repository, with optional settings for branch, tag, commit, and version. The source location is translated into a URL upon resolution. This type of dependency supports version indexing via semantic versioning as git tags.
139
+
140
+ For example:
141
+
142
+ depends:
143
+ - name: git-profile
144
+ git: http://url/to/repo
145
+ branch: desired_branch
146
+ tag: desired_version
147
+ commit: pinned_commit
148
+ version: semver_via_tags
149
+
150
+ ## Chef Supermarket
151
+
152
+ A `supermarket` setting specifies a profile that is located in a cookbook hosted on Chef Supermarket, with optional settings for branch, tag, commit, and version. The source location is translated into a URL upon resolution. This type of dependency supports version indexing via semantic versioning as git tags.
153
+
154
+ For example:
155
+
156
+ depends:
157
+ - name: supermarket-profile
158
+ git: username/profile
159
+ branch: desired_branch
160
+ tag: desired_version
161
+ commit: pinned_commit
162
+ version: semver_via_tags
163
+
164
+ ## GitHub
165
+
166
+ A `github` setting specifies a profile that is located in a repository hosted on GitHub, with optional settings for branch, tag, commit, and version. The source location is translated into a URL upon resolution. This type of dependency supports version indexing via semantic versioning as git tags.
167
+
168
+ For example:
169
+
170
+ depends:
171
+ - name: gh-profile
172
+ git: username/project
173
+ branch: desired_branch
174
+ tag: desired_version
175
+ commit: pinned_commit
176
+ version: semver_via_tags
177
+
178
+ ## Chef Compliance
179
+
180
+ A `compliance` setting specifies a profile that is located on the Chef Compliance server.
181
+
182
+ For example:
183
+
184
+ depends:
185
+ - name: linux
186
+ compliance: base/linux
187
+
188
+
189
+ ## Define in inspec.yml
190
+
191
+ Use the `depends` setting in the `inspec.yml` file to define any combination of profile dependencies. For example:
192
+
193
+ depends:
194
+ - name: ssh-hardening
195
+ supermarket: hardening/ssh-hardening
196
+ - name: os-hardening
197
+ url: https://github.com/dev-sec/tests-os-hardening/archive/master.zip
198
+ - name: ssl-benchmark
199
+ git: https://github.com/dev-sec/ssl-benchmark.git
200
+ - name: windows-patch-benchmark
201
+ git: https://github.com/chris-rock/windows-patch-benchmark.git
202
+ - name: linux
203
+ compliance: base/linux
204
+
205
+ # Profile Inheritance
206
+
207
+ When a profile is run, it may include controls that are defined in other profiles. Controls may also be required.
208
+
209
+ ## include_controls
210
+
211
+ The `include_controls` keyword may be used in a profile to import all rules from the named profile.
212
+
213
+ For example, to include controls from the `cis-level-1` profile when running the `cis-fs-2.7` profile:
214
+
215
+ include_controls 'cis-level-1' do
216
+
217
+ control "cis-fs-2.7" do
218
+ impact 1.0
219
+ ...
220
+
221
+ end
222
+
223
+ To include controls from the `cis-level-1` profile, but skipping two controls within that profile:
224
+
225
+ include_controls 'cis-level-1' do
226
+
227
+ skip_control "cis-fs-2.1"
228
+ skip_control "cis-fs-2.2"
229
+
230
+ end
231
+
232
+ ## require_controls
233
+
234
+ The `require_controls` keyword may be used to load only specific controls from the named profile.
235
+
236
+ For example, to require that controls `cis-fs-2.1` and `cis-fs-2.2` be loaded from the `cis-level-1` profile:
237
+
238
+ require_controls 'cis-level-1' do
239
+
240
+ control "cis-fs-2.1"
241
+ control "cis-fs-2.2"
242
+
243
+ end
244
+
245
+
246
+ ## require_resource
247
+
248
+ By default, all of the resources from a listed dependency are available
249
+ for use in your profile. If two of your dependencies provide a resource with
250
+ the same name, you can use the `require_resource` DSL function to
251
+ disambiguate the two:
252
+
253
+ require_resource(profile: 'my_dep', resource: 'my_res',
254
+ as: 'my_res2')
255
+
256
+ This will allow you to reference the resource `my_res` from the
257
+ profile `my_dep` using the name `my_res2`.
258
+
259
+ # Profile Attributes
260
+
261
+ Attributes may be used in profiles to define secrets, such as user names and passwords, that should not otherwise be stored in plain-text in a cookbook. First specify a variable in the control for each secret, then add the secret to a Yaml file located on the local machine, and then run `inspec exec` and specify the path to that Yaml file using the `--attrs` attribute.
262
+
263
+ For example, a control:
264
+
265
+ val_user = attribute('user', default: 'alice', description: 'An identification for the user')
266
+ val_password = attribute('password', description: 'A value for the password')
267
+
268
+ describe val_user do
269
+ it { should eq 'bob' }
270
+ end
271
+
272
+ describe val_password do
273
+ it { should eq 'secret' }
274
+ end
275
+
276
+ And a Yaml file named `profile-attribute.yml`:
277
+
278
+ user: bob
279
+ password: secret
280
+
281
+ The following command runs the tests and applies the secrets specified in `profile-attribute.yml`:
282
+
283
+ $ inspec exec examples/profile-attribute --attrs examples/profile-attribute.yml
284
+
285
+ See the full example in the InSpec open source repository: https://github.com/chef/inspec/tree/master/examples/profile-attribute
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: About the apache_conf Resource
3
+ ---
4
+
5
+ # apache_conf
6
+
7
+ Use the `apache_conf` InSpec audit resource to test the configuration settings for Apache. This file is typically located under `/etc/apache2` on the Debian and Ubuntu platforms and under `/etc/httpd` on the Fedora, CentOS, RedHat Enterprise Linux, and ArchLinux platforms. The configuration settings may vary significantly from platform to platform.
8
+
9
+ # Syntax
10
+
11
+ An `apache_conf` InSpec audit resource block declares configuration settings that should be tested:
12
+
13
+ describe apache_conf('path') do
14
+ its('setting_name') { should eq 'value' }
15
+ end
16
+
17
+ where
18
+
19
+ * `'setting_name'` is a configuration setting defined in the Apache configuration file
20
+ * `('path')` is the non-default path to the Apache configuration file
21
+ * `{ should eq 'value' }` is the value that is expected
22
+
23
+ # Matchers
24
+
25
+ This InSpec audit resource matches any service that is listed in the Apache configuration file:
26
+
27
+ its('PidFile') { should_not eq '/var/run/httpd.pid' }
28
+
29
+ or:
30
+
31
+ its('Timeout') { should eq 300 }
32
+
33
+ For example:
34
+
35
+ describe apache_conf do
36
+ its('MaxClients') { should eq 100 }
37
+ its('Listen') { should eq '443'}
38
+ end
39
+
40
+
41
+ ## be
42
+
43
+ <%= partial "/shared/matcher_be" %>
44
+
45
+ ## cmp
46
+
47
+ <%= partial "/shared/matcher_cmp" %>
48
+
49
+ ## eq
50
+
51
+ <%= partial "/shared/matcher_eq" %>
52
+
53
+ ## include
54
+
55
+ <%= partial "/shared/matcher_include" %>
56
+
57
+ ## match
58
+
59
+ <%= partial "/shared/matcher_match" %>
60
+
61
+ # Examples
62
+
63
+ The following examples show how to use this InSpec audit resource.
64
+
65
+ ## Test for blocking .htaccess files on CentOS
66
+
67
+ describe apache_conf do
68
+ its('AllowOverride') { should eq 'None' }
69
+ end
70
+
71
+ ## Test ports for SSL
72
+
73
+ describe apache_conf do
74
+ its('Listen') { should eq '443'}
75
+ end