inspec 0.34.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +323 -6
  3. data/Gemfile +10 -0
  4. data/README.md +1 -1
  5. data/Rakefile +4 -55
  6. data/docs/.gitignore +2 -0
  7. data/docs/README.md +40 -0
  8. data/docs/cli.md +342 -0
  9. data/docs/dsl_inspec.md +245 -0
  10. data/docs/dsl_resource.md +93 -0
  11. data/docs/inspec_and_friends.md +105 -0
  12. data/docs/matchers.md +136 -0
  13. data/docs/plugin_kitchen_inspec.html.md +55 -0
  14. data/docs/profiles.md +285 -0
  15. data/docs/resources/apache_conf.md.erb +75 -0
  16. data/docs/resources/apt.md.erb +84 -0
  17. data/docs/resources/audit_policy.md.erb +61 -0
  18. data/docs/resources/auditd_conf.md.erb +79 -0
  19. data/docs/resources/auditd_rules.md.erb +132 -0
  20. data/docs/resources/bash.md.erb +84 -0
  21. data/docs/resources/bond.md.erb +97 -0
  22. data/docs/resources/bridge.md.erb +67 -0
  23. data/docs/resources/bsd_service.md.erb +76 -0
  24. data/docs/resources/command.md.erb +151 -0
  25. data/docs/resources/csv.md.erb +62 -0
  26. data/docs/resources/directory.md.erb +43 -0
  27. data/docs/resources/etc_group.md.erb +116 -0
  28. data/docs/resources/etc_passwd.md.erb +155 -0
  29. data/docs/resources/etc_shadow.md.erb +149 -0
  30. data/docs/resources/file.md.erb +460 -0
  31. data/docs/resources/gem.md.erb +73 -0
  32. data/docs/resources/group.md.erb +74 -0
  33. data/docs/resources/grub_conf.md.erb +115 -0
  34. data/docs/resources/host.md.erb +85 -0
  35. data/docs/resources/iis_site.md.erb +142 -0
  36. data/docs/resources/inetd_conf.md.erb +99 -0
  37. data/docs/resources/ini.md.erb +69 -0
  38. data/docs/resources/interface.md.erb +66 -0
  39. data/docs/resources/iptables.md.erb +70 -0
  40. data/docs/resources/json.md.erb +76 -0
  41. data/docs/resources/kernel_module.md.erb +60 -0
  42. data/docs/resources/kernel_parameter.md.erb +72 -0
  43. data/docs/resources/launchd_service.md.erb +76 -0
  44. data/docs/resources/limits_conf.md.erb +80 -0
  45. data/docs/resources/login_def.md.erb +77 -0
  46. data/docs/resources/mount.md.erb +83 -0
  47. data/docs/resources/mysql_conf.md.erb +102 -0
  48. data/docs/resources/mysql_session.md.erb +63 -0
  49. data/docs/resources/npm.md.erb +75 -0
  50. data/docs/resources/ntp_conf.md.erb +76 -0
  51. data/docs/resources/oneget.md.erb +67 -0
  52. data/docs/resources/os.md.erb +154 -0
  53. data/docs/resources/os_env.md.erb +98 -0
  54. data/docs/resources/package.md.erb +115 -0
  55. data/docs/resources/parse_config.md.erb +122 -0
  56. data/docs/resources/parse_config_file.md.erb +143 -0
  57. data/docs/resources/pip.md.erb +74 -0
  58. data/docs/resources/port.md.erb +150 -0
  59. data/docs/resources/postgres_conf.md.erb +90 -0
  60. data/docs/resources/postgres_session.md.erb +75 -0
  61. data/docs/resources/powershell.md.erb +116 -0
  62. data/docs/resources/process.md.erb +73 -0
  63. data/docs/resources/registry_key.md.erb +149 -0
  64. data/docs/resources/runit_service.md.erb +76 -0
  65. data/docs/resources/security_policy.md.erb +61 -0
  66. data/docs/resources/service.md.erb +135 -0
  67. data/docs/resources/ssh_config.md.erb +94 -0
  68. data/docs/resources/sshd_config.md.erb +97 -0
  69. data/docs/resources/ssl.md.erb +133 -0
  70. data/docs/resources/sys_info.md.erb +55 -0
  71. data/docs/resources/systemd_service.md.erb +76 -0
  72. data/docs/resources/sysv_service.md.erb +76 -0
  73. data/docs/resources/upstart_service.md.erb +76 -0
  74. data/docs/resources/user.md.erb +154 -0
  75. data/docs/resources/users.md.erb +140 -0
  76. data/docs/resources/vbscript.md.erb +69 -0
  77. data/docs/resources/windows_feature.md.erb +61 -0
  78. data/docs/resources/wmi.md.erb +95 -0
  79. data/docs/resources/xinetd_conf.md.erb +170 -0
  80. data/docs/resources/yaml.md.erb +69 -0
  81. data/docs/resources/yum.md.erb +103 -0
  82. data/docs/ruby_usage.md +154 -0
  83. data/docs/shared/matcher_be.md.erb +1 -0
  84. data/docs/shared/matcher_cmp.md.erb +45 -0
  85. data/docs/shared/matcher_eq.md.erb +3 -0
  86. data/docs/shared/matcher_include.md.erb +1 -0
  87. data/docs/shared/matcher_match.md.erb +1 -0
  88. data/docs/shell.md +150 -0
  89. data/examples/meta-profile/inspec.yml +2 -4
  90. data/inspec.gemspec +1 -1
  91. data/lib/bundles/inspec-compliance/api.rb +28 -18
  92. data/lib/bundles/inspec-compliance/cli.rb +19 -27
  93. data/lib/bundles/inspec-compliance/target.rb +15 -2
  94. data/lib/fetchers/git.rb +4 -0
  95. data/lib/fetchers/local.rb +16 -1
  96. data/lib/fetchers/mock.rb +4 -0
  97. data/lib/fetchers/url.rb +46 -20
  98. data/lib/inspec/base_cli.rb +14 -0
  99. data/lib/inspec/cached_fetcher.rb +67 -0
  100. data/lib/inspec/cli.rb +22 -8
  101. data/lib/inspec/control_eval_context.rb +12 -2
  102. data/lib/inspec/dependencies/{vendor_index.rb → cache.rb} +5 -4
  103. data/lib/inspec/dependencies/dependency_set.rb +8 -14
  104. data/lib/inspec/dependencies/lockfile.rb +5 -13
  105. data/lib/inspec/dependencies/requirement.rb +31 -41
  106. data/lib/inspec/dependencies/resolver.rb +3 -3
  107. data/lib/inspec/dsl.rb +16 -4
  108. data/lib/inspec/errors.rb +1 -0
  109. data/lib/inspec/fetcher.rb +25 -1
  110. data/lib/inspec/objects/each_loop.rb +5 -2
  111. data/lib/inspec/objects/test.rb +8 -2
  112. data/lib/inspec/plugins/fetcher.rb +13 -12
  113. data/lib/inspec/plugins/resource.rb +3 -0
  114. data/lib/inspec/profile.rb +62 -26
  115. data/lib/inspec/profile_context.rb +44 -8
  116. data/lib/inspec/resource.rb +18 -3
  117. data/lib/inspec/rspec_json_formatter.rb +91 -40
  118. data/lib/inspec/rule.rb +45 -2
  119. data/lib/inspec/runner.rb +51 -39
  120. data/lib/inspec/shell.rb +5 -16
  121. data/lib/inspec/version.rb +1 -1
  122. data/lib/resources/apache_conf.rb +1 -1
  123. data/lib/resources/gem.rb +1 -0
  124. data/lib/resources/groups.rb +190 -0
  125. data/lib/resources/oneget.rb +1 -0
  126. data/lib/resources/os.rb +1 -1
  127. data/lib/resources/package.rb +3 -1
  128. data/lib/resources/parse_config.rb +18 -1
  129. data/lib/resources/pip.rb +1 -1
  130. data/lib/resources/security_policy.rb +54 -0
  131. data/lib/resources/ssl.rb +9 -11
  132. data/lib/resources/sys_info.rb +1 -1
  133. data/lib/resources/users.rb +81 -64
  134. metadata +91 -17
  135. data/docs/cli.rst +0 -442
  136. data/docs/dsl_inspec.rst +0 -259
  137. data/docs/dsl_resource.rst +0 -90
  138. data/docs/inspec_and_friends.rst +0 -85
  139. data/docs/matchers.rst +0 -137
  140. data/docs/profiles.rst +0 -169
  141. data/docs/readme.rst +0 -105
  142. data/docs/resources.rst +0 -4836
  143. data/docs/ruby_usage.rst +0 -145
  144. data/docs/shell.rst +0 -130
  145. data/docs/template.rst +0 -51
  146. data/lib/resources/group.rb +0 -137
data/docs/profiles.rst DELETED
@@ -1,169 +0,0 @@
1
- =====================================================
2
- InSpec Profiles
3
- =====================================================
4
-
5
- InSpec supports the creation of complex test and compliance profiles, which organize controls to support dependency management and code re-use. These profiles are standalone structures with their own distribution and execution flow.
6
-
7
- InSpec profile structure
8
- -----------------------------------------------------
9
-
10
- To create a new profile just place the files according to the following structure:
11
-
12
- .. code-block:: bash
13
-
14
- $ tree examples/profile
15
- examples/profile
16
- ├── README.md
17
- ├── controls
18
- │   ├── example.rb
19
- │   └── gordon.rb
20
- ├── libraries
21
- │   └── gordon_config.rb
22
- └── inspec.yml
23
-
24
-
25
- * `inspec.yml` - includes the profile description (required)
26
- * `controls` - a folder which contains all tests (required)
27
- * `libraries` - a folder which contains InSpec resource extensions (optional)
28
- * `README.md` - a best-practice readme to each explain the profile and its scope
29
-
30
- For a full example, see our `example profile`_.
31
-
32
- .. _example profile: ../examples/profile
33
-
34
- InSpec profile manifest
35
- -----------------------------------------------------
36
-
37
- Each profile has a manifest file `inspec.yml`. It looks as follows
38
-
39
- .. code-block:: yaml
40
-
41
- name: ssh
42
- title: Basic SSH
43
- maintainer: Chef Software, Inc.
44
- copyright: Chef Software, Inc.
45
- copyright_email: support@chef.io
46
- license: Proprietary, All rights reserved
47
- summary: Verify that SSH Server and SSH Client are configured securely
48
- version: 1.0.0
49
- supports:
50
- - os-family: linux
51
-
52
-
53
- A manifest description may contain the following values:
54
-
55
- * `name` - Identifier of the profile (required)
56
- * `title` - Human-readable name of the profile (optional)
57
- * `maintainer` - Name of the profile maintainer (optional)
58
- * `copyright` - Copyright holder (optional)
59
- * `copyright_email` - Support contact for profile (optional)
60
- * `license` - License of the profile (optional)
61
- * `summary` - One-line summary of the profile (optional)
62
- * `description` - Description of the profile (optional)
63
- * `version` - Version of the profile (optional)
64
- * `supports` - A list of supported targets (optional)
65
-
66
- Supported targets
67
- -----------------------------------------------------
68
-
69
- The manifest contains the `supports` flag, which specifies operating systems or even cloud systems that the profile is targeting.
70
-
71
- This list can contain simple names, names and versions, or detailed flags for the targeted system. These can freely be combined:
72
-
73
- .. code-block:: yaml
74
-
75
- name: ssh
76
- supports:
77
- // Runs on any version of Debian Linux
78
- - os-name: debian
79
-
80
- // Only runs on Ubuntu 14.04
81
- - os-name: ubuntu
82
- release: 14.04
83
-
84
- // Targets RedHat, CentOS, Oracle Linux ...
85
- - os-family: redhat
86
-
87
- // Or even broader
88
- - platform: aws
89
-
90
-
91
- InSpec profile verification
92
- -----------------------------------------------------
93
-
94
- InSpec ships with a verification command that verifies the implementation of a profile:
95
-
96
- .. code-block:: bash
97
-
98
- $ inspec check examples/profile
99
-
100
-
101
- InSpec profile archive
102
- -----------------------------------------------------
103
-
104
- Profiles are composed of multiple files. This hinders easy distribution of a profile. InSpec solves the problem by offering to collect all files in one archive.
105
-
106
- The InSpec profile archive format aims for flexibility and reuse of standard and common technologies:
107
-
108
- * tar and gzip (default)
109
- * zip
110
- * HTTP
111
-
112
- This should enable third-parties to easily build InSpec profile archives:
113
-
114
- * InSpec archives MUST be named with the stanard suffix
115
- * InSpec archives MUST be a tar.gz or zip formatted file
116
- * InSpec archives MUST have no duplicate entries
117
- * InSpec archives MAY be compressed with gzip, bzip2, or xz.
118
-
119
- InSpec is able to create profile archive for you. By default it generates a tar-file on Unix and zip on Windows or Mac.
120
-
121
- .. code-block:: bash
122
-
123
- # will generate a example-profile.tar.gz
124
- $ inspec archive examples/profile
125
-
126
- # will generate a example-profile.zip
127
- $ inspec archive examples/profile --zip
128
-
129
-
130
- Profile inheritance
131
- -----------------------------------------------------
132
-
133
- **Include controls of existing profile**
134
-
135
- The `include_controls` keyword allows you to import all rules from an existing profile. This can be easily extended with additional rules.
136
-
137
- .. code-block:: bash
138
-
139
- include_controls 'cis-level-1' do
140
-
141
- control "cis-fs-2.7" do
142
- impact 1.0
143
- ...
144
-
145
- end
146
-
147
- **Inherit from a profile, but skip some rules**
148
-
149
- Sometimes, not all requirements can be fulfilled for a legacy application. To manage the derivation, you can skip certain controls with `skip_control`.
150
-
151
- .. code-block:: bash
152
-
153
- include_controls 'cis-level-1' do
154
-
155
- skip_control "cis-fs-2.1"
156
- skip_control "cis-fs-2.2"
157
-
158
- end
159
-
160
- **Load specific controls from another profile**
161
-
162
- .. code-block:: bash
163
-
164
- require_controls 'cis-level-1' do
165
-
166
- control "cis-fs-2.1"
167
- control "cis-fs-2.2"
168
-
169
- end
data/docs/readme.rst DELETED
@@ -1,105 +0,0 @@
1
- =====================================================
2
- InSpec Documentation
3
- =====================================================
4
-
5
- InSpec a collection of resources and matchers to test the compliance of your nodes. This documentation provides an introduction to this mechanism and shows how to write custom tests.
6
-
7
- Introduction
8
- -----------------------------------------------------
9
-
10
- At first, we add our tests to the ``test`` folder. Each test file must end with ``_spec.rb``:
11
-
12
- .. code-block:: bash
13
-
14
- mkdir test
15
- touch test/example_spec.rb
16
-
17
- We add a control to this file, to check the ``/tmp`` path in our system:
18
-
19
- .. code-block:: ruby
20
-
21
- # encoding: utf-8
22
-
23
- control "cis-fs-2.1" do # A unique ID for this control
24
- impact 0.7 # The criticality, if this control fails.
25
- title "Create separate /tmp partition" # A human-readable title
26
- desc "An optional description..."
27
- tag mygroup: "tag" # A tag can be a simple value or
28
- tag "tag" # can have a more complex key/value pair.
29
- ref "name", url: "http://..." # A reference to a document, uri: is optional
30
- describe file('/tmp') do # The actual test
31
- it { should be_mounted }
32
- end
33
- end
34
-
35
-
36
- Let's add another spec for checking the SSH server configuration:
37
-
38
- .. code-block:: bash
39
-
40
- touch test/sshd_spec.rb
41
-
42
- It will contain:
43
-
44
- .. code-block:: ruby
45
-
46
- # encoding: utf-8
47
-
48
- # Skip all controls, if SSH doesn't exist on the system
49
- only_if do
50
- command('sshd').exist?
51
- end
52
-
53
- control "sshd-11" do
54
- impact 1.0
55
- title "Server: Set protocol version to SSHv2"
56
- desc "Set the SSH protocol version to 2. Don't use legacy
57
- insecure SSHv1 connections anymore."
58
- tag security: "openssh-server"
59
- ref "Document A-12"
60
-
61
- describe sshd_config do
62
- its('Protocol') { should eq('2') }
63
- end
64
- end
65
-
66
- control "sshd-7" do
67
- impact 1.0
68
- title "Server: Do not permit root-based login with password."
69
- desc "To reduce the potential to gain full privileges
70
- of a system in the course of an attack (by either misconfiguration
71
- or vulnerabilities), do not allow login as root with password"
72
- tag security: "openssh-server"
73
- ref "Document A-12"
74
-
75
- describe sshd_config do
76
- its('PermitRootLogin') { should match(/no|without-password/) }
77
- end
78
- end
79
-
80
-
81
- Now, we are ready to run the tests locally:
82
-
83
- bundle exec bin/inspec exec demo/test/example_spec.rb
84
-
85
- .. code-block:: bash
86
-
87
- # run tests individually
88
- $ inspec exec test/example_spec.rb
89
- $ inspec exec test/sshd_spec.rb
90
-
91
- # if you want to run all test located within the directory
92
- $ inspec exec ./test
93
-
94
-
95
- Stability Index
96
- -----------------------------------------------------
97
-
98
- Every available InSpec resource will indicate its stability. As InSpec matures, certain parts are more reliable than others. Brand new features are likely to be redesigned and marked as such.
99
-
100
- The stability indices are as follows:
101
-
102
- * ``Stability: Deprecated`` - This features will be removed in future versions, because its known for being problematic. Do not rely on it.
103
- * ``Stability: Experimental`` - New features may change or are removed in future versions
104
- * ``Stability: Stable`` - API is well established and proofed. Maintaining compatibility is a high priority
105
- * ``Stability: Locked`` - Only security and performance fixes are allowed