inspec 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -2
  3. data/README.md +5 -1
  4. data/bin/os +23 -0
  5. data/examples/kitchen-ansible/.kitchen/default-centos-71.yml +6 -0
  6. data/examples/kitchen-ansible/.kitchen/default-ubuntu-1204.yml +6 -0
  7. data/examples/kitchen-ansible/.kitchen/default-ubuntu-1404.yml +6 -0
  8. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-centos-71/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  9. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-centos-71/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  10. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-centos-71/.vagrant/machines/default/virtualbox/id +1 -0
  11. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-centos-71/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  12. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-centos-71/.vagrant/machines/default/virtualbox/private_key +27 -0
  13. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-centos-71/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  14. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-centos-71/Vagrantfile +9 -0
  15. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  16. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1204/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  17. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +1 -0
  18. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  19. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +27 -0
  20. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1204/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  21. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1204/Vagrantfile +9 -0
  22. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  23. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  24. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +1 -0
  25. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  26. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +27 -0
  27. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  28. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/Vagrantfile +9 -0
  29. data/examples/kitchen-ansible/.kitchen/logs/default-centos-71.log +4 -0
  30. data/examples/kitchen-ansible/.kitchen/logs/default-ubuntu-1204.log +4 -0
  31. data/examples/kitchen-ansible/.kitchen/logs/default-ubuntu-1404.log +4 -0
  32. data/examples/kitchen-ansible/.kitchen/logs/kitchen.log +8 -0
  33. data/examples/kitchen-ansible/Gemfile.lock +154 -0
  34. data/examples/kitchen-chef/.kitchen/default-centos-71.yml +6 -0
  35. data/examples/kitchen-chef/.kitchen/default-ubuntu-1204.yml +6 -0
  36. data/examples/kitchen-chef/.kitchen/default-ubuntu-1404.yml +6 -0
  37. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  38. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  39. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/id +1 -0
  40. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  41. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/private_key +27 -0
  42. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  43. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/Vagrantfile +9 -0
  44. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  45. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  46. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +1 -0
  47. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  48. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +27 -0
  49. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  50. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/Vagrantfile +9 -0
  51. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  52. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  53. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +1 -0
  54. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  55. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +27 -0
  56. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  57. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/Vagrantfile +9 -0
  58. data/examples/kitchen-chef/.kitchen/logs/default-centos-71.log +4 -0
  59. data/examples/kitchen-chef/.kitchen/logs/default-ubuntu-1204.log +4 -0
  60. data/examples/kitchen-chef/.kitchen/logs/default-ubuntu-1404.log +4 -0
  61. data/examples/kitchen-chef/.kitchen/logs/kitchen.log +8 -0
  62. data/examples/kitchen-chef/Berksfile.lock +11 -0
  63. data/examples/kitchen-chef/Gemfile.lock +223 -0
  64. data/examples/kitchen-puppet/.bundle/config +2 -0
  65. data/examples/kitchen-puppet/.kitchen/logs/default-centos-71.log +5 -0
  66. data/examples/kitchen-puppet/.kitchen/logs/default-ubuntu-1204.log +5 -0
  67. data/examples/kitchen-puppet/.kitchen/logs/default-ubuntu-1404.log +5 -0
  68. data/examples/kitchen-puppet/.kitchen/logs/kitchen.log +5 -0
  69. data/examples/kitchen-puppet/.librarian/puppet/config +2 -0
  70. data/examples/kitchen-puppet/Gemfile.lock +174 -0
  71. data/examples/kitchen-puppet/Puppetfile.lock +2 -0
  72. data/examples/profile/libraries/.DS_Store +0 -0
  73. data/examples/test-kitchen/.kitchen/logs/default-centos-71.log +5 -0
  74. data/examples/test-kitchen/.kitchen/logs/default-ubuntu-1204.log +5 -0
  75. data/examples/test-kitchen/.kitchen/logs/default-ubuntu-1404.log +5 -0
  76. data/examples/test-kitchen/.kitchen/logs/kitchen.log +5 -0
  77. data/examples/test-kitchen/Berksfile.lock +11 -0
  78. data/examples/test-kitchen/Gemfile.lock +233 -0
  79. data/inspec.gemspec +2 -2
  80. data/lib/.DS_Store +0 -0
  81. data/lib/extras/compliance/README.md +15 -0
  82. data/lib/extras/compliance/compliance.rb +245 -0
  83. data/lib/inspec/metadata.rb +3 -1
  84. data/lib/inspec/profile.rb +2 -0
  85. data/lib/inspec/profile_context.rb +34 -63
  86. data/lib/inspec/resource.rb +23 -0
  87. data/lib/inspec/runner.rb +17 -35
  88. data/lib/inspec/runner_mock.rb +31 -0
  89. data/lib/inspec/runner_rspec.rb +94 -0
  90. data/lib/inspec/targets/dir.rb +2 -4
  91. data/lib/inspec/version.rb +1 -1
  92. data/{test/unit/mock/profiles/complete-meta/test/.gitkeep → lib/resources/certificate.rb} +0 -0
  93. data/lib/resources/command.rb +1 -1
  94. data/lib/resources/postgres_session.rb +10 -15
  95. data/{test/unit/mock/profiles/custom-resource/test/.gitkeep → lib/resources/private_key.rb} +0 -0
  96. data/lib/resources/registry_key.rb +10 -6
  97. data/lib/resources/service.rb +232 -63
  98. data/test/chefdk/.gitignore +16 -0
  99. data/test/chefdk/.kitchen.yml +27 -0
  100. data/test/chefdk/Policyfile.rb +16 -0
  101. data/test/chefdk/README.md +4 -0
  102. data/test/chefdk/chefignore +100 -0
  103. data/test/chefdk/metadata.rb +7 -0
  104. data/test/chefdk/recipes/default.rb +5 -0
  105. data/test/chefdk/spec/spec_helper.rb +2 -0
  106. data/test/chefdk/spec/unit/recipes/default_spec.rb +20 -0
  107. data/test/chefdk/test/integration/default/serverspec/default_spec.rb +9 -0
  108. data/test/chefdk/test/integration/helpers/serverspec/spec_helper.rb +8 -0
  109. data/test/docker_run.rb +5 -1
  110. data/test/docker_test.rb +1 -2
  111. data/test/helper.rb +1 -0
  112. data/test/integration/.kitchen/default-aws-linux.yml +4 -0
  113. data/test/integration/.kitchen/default-centos-7.yml +4 -0
  114. data/test/integration/.kitchen/default-debian-8.yml +4 -0
  115. data/test/integration/.kitchen/default-fedora-22.yml +4 -0
  116. data/test/integration/.kitchen/default-redhat-65.yml +4 -0
  117. data/test/integration/.kitchen/default-redhat-71.yml +4 -0
  118. data/test/integration/.kitchen/default-suse-11sp3.yml +4 -0
  119. data/test/integration/.kitchen/default-suse-12.yml +4 -0
  120. data/test/integration/.kitchen/default-ubuntu-1204.yml +3 -0
  121. data/test/integration/.kitchen/default-ubuntu-1404.yml +4 -0
  122. data/test/integration/.kitchen/default-windows-2012.yml +1 -0
  123. data/test/integration/.kitchen/default-windows-2012r2.yml +2 -0
  124. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67-i386/Vagrantfile +9 -0
  125. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  126. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  127. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/id +1 -0
  128. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  129. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/private_key +27 -0
  130. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  131. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/Vagrantfile +9 -0
  132. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  133. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  134. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/.vagrant/machines/default/virtualbox/id +1 -0
  135. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  136. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/Vagrantfile +8 -0
  137. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  138. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  139. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +1 -0
  140. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  141. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +27 -0
  142. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  143. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/Vagrantfile +9 -0
  144. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  145. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  146. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +1 -0
  147. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  148. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +27 -0
  149. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  150. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/Vagrantfile +9 -0
  151. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  152. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  153. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/.vagrant/machines/default/virtualbox/id +1 -0
  154. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  155. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/Vagrantfile +8 -0
  156. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-new-ubuntu-1404/Vagrantfile +9 -0
  157. data/test/{unit/mock/profiles/empty/metadata.rb → integration/.kitchen/logs/default-aws-linux.log} +0 -0
  158. data/test/integration/.kitchen/logs/default-centos-511-i386.log +2 -0
  159. data/test/integration/.kitchen/logs/default-centos-511.log +2 -0
  160. data/test/integration/.kitchen/logs/default-centos-67-i386.log +2 -0
  161. data/test/integration/.kitchen/logs/default-centos-67.log +2 -0
  162. data/test/integration/.kitchen/logs/default-centos-7.log +0 -0
  163. data/test/integration/.kitchen/logs/default-centos-71.log +2 -0
  164. data/test/integration/.kitchen/logs/default-debian-6010-i386.log +2 -0
  165. data/test/integration/.kitchen/logs/default-debian-6010.log +2 -0
  166. data/test/integration/.kitchen/logs/default-debian-78-i386.log +2 -0
  167. data/test/integration/.kitchen/logs/default-debian-78.log +2 -0
  168. data/test/integration/.kitchen/logs/default-debian-8.log +0 -0
  169. data/test/integration/.kitchen/logs/default-debian-81-i386.log +2 -0
  170. data/test/integration/.kitchen/logs/default-debian-81.log +2 -0
  171. data/test/integration/.kitchen/logs/default-fedora-21-i386.log +2 -0
  172. data/test/integration/.kitchen/logs/default-fedora-21.log +2 -0
  173. data/test/integration/.kitchen/logs/default-fedora-22.log +0 -0
  174. data/test/integration/.kitchen/logs/default-freebsd-102.log +2 -0
  175. data/test/integration/.kitchen/logs/default-freebsd-93.log +2 -0
  176. data/test/integration/.kitchen/logs/default-mint-172-cinnamon.log +2 -0
  177. data/test/integration/.kitchen/logs/default-modernIE-w10-edge.log +2 -0
  178. data/test/integration/.kitchen/logs/default-modernIE-w7-ie11.log +2 -0
  179. data/test/integration/.kitchen/logs/default-modernIE-w81-ie11.log +2 -0
  180. data/test/integration/.kitchen/logs/default-opensuse-132-i386.log +2 -0
  181. data/test/integration/.kitchen/logs/default-opensuse-132-x86-64.log +2 -0
  182. data/test/integration/.kitchen/logs/default-opentable-win-2008r2-standard-amd64-nocm.log +0 -0
  183. data/test/integration/.kitchen/logs/default-opentable-win-2012r2-standard-amd64-nocm.log +0 -0
  184. data/test/integration/.kitchen/logs/default-redhat-65.log +0 -0
  185. data/test/integration/.kitchen/logs/default-redhat-71.log +0 -0
  186. data/test/integration/.kitchen/logs/default-suse-11sp3.log +0 -0
  187. data/test/integration/.kitchen/logs/default-suse-12.log +0 -0
  188. data/test/integration/.kitchen/logs/default-ubuntu-1004-i386.log +2 -0
  189. data/test/integration/.kitchen/logs/default-ubuntu-1004.log +2 -0
  190. data/test/integration/.kitchen/logs/default-ubuntu-1204-i386.log +2 -0
  191. data/test/integration/.kitchen/logs/default-ubuntu-1204.log +0 -0
  192. data/test/integration/.kitchen/logs/default-ubuntu-1404-i386.log +2 -0
  193. data/test/integration/.kitchen/logs/default-ubuntu-1404.log +0 -0
  194. data/test/integration/.kitchen/logs/default-ubuntu-1510.log +0 -0
  195. data/test/integration/.kitchen/logs/default-windows-2008-opentable.log +2 -0
  196. data/test/integration/.kitchen/logs/default-windows-2008.log +0 -0
  197. data/test/integration/.kitchen/logs/default-windows-2012.log +0 -0
  198. data/test/integration/.kitchen/logs/default-windows-2012R2-matt.log +2 -0
  199. data/test/integration/.kitchen/logs/default-windows-2012r2-opentable.log +2 -0
  200. data/test/integration/.kitchen/logs/default-windows-2012r2.log +41 -0
  201. data/test/integration/.kitchen/logs/kitchen.log +0 -0
  202. data/test/integration/.kitchen/logs/new-centos-511-i386.log +0 -0
  203. data/test/integration/.kitchen/logs/new-centos-511.log +0 -0
  204. data/test/integration/.kitchen/logs/new-centos-67-i386.log +0 -0
  205. data/test/integration/.kitchen/logs/new-centos-67.log +0 -0
  206. data/test/integration/.kitchen/logs/new-centos-71.log +0 -0
  207. data/test/integration/.kitchen/logs/new-debian-6010-i386.log +0 -0
  208. data/test/integration/.kitchen/logs/new-debian-6010.log +0 -0
  209. data/test/integration/.kitchen/logs/new-debian-78-i386.log +0 -0
  210. data/test/integration/.kitchen/logs/new-debian-78.log +0 -0
  211. data/test/integration/.kitchen/logs/new-debian-81-i386.log +0 -0
  212. data/test/integration/.kitchen/logs/new-debian-81.log +0 -0
  213. data/test/integration/.kitchen/logs/new-fedora-21-i386.log +0 -0
  214. data/test/integration/.kitchen/logs/new-fedora-21.log +0 -0
  215. data/test/integration/.kitchen/logs/new-fedora-22.log +0 -0
  216. data/test/integration/.kitchen/logs/new-freebsd-102.log +0 -0
  217. data/test/integration/.kitchen/logs/new-freebsd-93.log +0 -0
  218. data/test/integration/.kitchen/logs/new-opensuse-132-i386.log +0 -0
  219. data/test/integration/.kitchen/logs/new-opensuse-132-x86-64.log +0 -0
  220. data/test/integration/.kitchen/logs/new-ubuntu-1004-i386.log +0 -0
  221. data/test/integration/.kitchen/logs/new-ubuntu-1004.log +0 -0
  222. data/test/integration/.kitchen/logs/new-ubuntu-1204-i386.log +0 -0
  223. data/test/integration/.kitchen/logs/new-ubuntu-1204.log +0 -0
  224. data/test/integration/.kitchen/logs/new-ubuntu-1404-i386.log +0 -0
  225. data/test/integration/.kitchen/logs/new-ubuntu-1404.log +3 -0
  226. data/test/integration/.kitchen/logs/test-centos-511-i386.log +0 -0
  227. data/test/integration/.kitchen/logs/test-centos-511.log +0 -0
  228. data/test/integration/.kitchen/logs/test-centos-67-i386.log +0 -0
  229. data/test/integration/.kitchen/logs/test-centos-67.log +0 -0
  230. data/test/integration/.kitchen/logs/test-centos-71.log +0 -0
  231. data/test/integration/.kitchen/logs/test-debian-6010-i386.log +0 -0
  232. data/test/integration/.kitchen/logs/test-debian-6010.log +0 -0
  233. data/test/integration/.kitchen/logs/test-debian-78-i386.log +0 -0
  234. data/test/integration/.kitchen/logs/test-debian-78.log +0 -0
  235. data/test/integration/.kitchen/logs/test-debian-81-i386.log +0 -0
  236. data/test/integration/.kitchen/logs/test-debian-81.log +0 -0
  237. data/test/integration/.kitchen/logs/test-fedora-21-i386.log +0 -0
  238. data/test/integration/.kitchen/logs/test-fedora-21.log +0 -0
  239. data/test/integration/.kitchen/logs/test-fedora-22.log +0 -0
  240. data/test/integration/.kitchen/logs/test-freebsd-102.log +0 -0
  241. data/test/integration/.kitchen/logs/test-freebsd-93.log +0 -0
  242. data/test/integration/.kitchen/logs/test-opensuse-132-i386.log +0 -0
  243. data/test/integration/.kitchen/logs/test-opensuse-132-x86-64.log +0 -0
  244. data/test/integration/.kitchen/logs/test-ubuntu-1004-i386.log +0 -0
  245. data/test/integration/.kitchen/logs/test-ubuntu-1004.log +0 -0
  246. data/test/integration/.kitchen/logs/test-ubuntu-1204-i386.log +0 -0
  247. data/test/integration/.kitchen/logs/test-ubuntu-1204.log +0 -0
  248. data/test/integration/.kitchen/logs/test-ubuntu-1404-i386.log +0 -0
  249. data/test/integration/.kitchen/logs/test-ubuntu-1404.log +0 -0
  250. data/test/integration/.kitchen/new-ubuntu-1404.yml +1 -0
  251. data/test/integration/Berksfile +1 -0
  252. data/test/integration/Berksfile.lock +27 -0
  253. data/test/integration/TODO.md +15 -0
  254. data/test/integration/cookbooks/os_prepare/files/empty.iso +0 -0
  255. data/test/integration/cookbooks/os_prepare/metadata.rb +2 -0
  256. data/test/integration/cookbooks/os_prepare/recipes/_runit_service_centos.rb +34 -0
  257. data/test/integration/cookbooks/os_prepare/recipes/default.rb +1 -0
  258. data/test/integration/cookbooks/os_prepare/recipes/mount.rb +5 -5
  259. data/test/integration/cookbooks/os_prepare/recipes/postgres.rb +12 -0
  260. data/test/integration/cookbooks/os_prepare/recipes/service.rb +6 -2
  261. data/test/integration/cookbooks/os_prepare/templates/default/sv-default-svlog-run.erb +3 -0
  262. data/test/integration/test/.DS_Store +0 -0
  263. data/test/integration/test/integration/.DS_Store +0 -0
  264. data/test/integration/test/integration/default/.DS_Store +0 -0
  265. data/test/integration/test/integration/default/certificate_spec.rb +7 -0
  266. data/test/integration/test/integration/default/file_spec.rb +2 -2
  267. data/test/integration/test/integration/default/mount_spec.rb +1 -1
  268. data/test/integration/test/integration/default/postgres_session_spec.rb +9 -0
  269. data/test/integration/test/integration/default/service_spec.rb +34 -0
  270. data/test/mac/service_spec.rb +5 -0
  271. data/test/serverspec/.kitchen.yml +18 -0
  272. data/test/serverspec/.kitchen/default-ubuntu-1404.yml +6 -0
  273. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  274. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  275. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +1 -0
  276. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  277. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +27 -0
  278. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  279. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/Vagrantfile +9 -0
  280. data/test/serverspec/.kitchen/logs/default-ubuntu-1404.log +2 -0
  281. data/test/serverspec/.kitchen/logs/kitchen.log +3 -0
  282. data/test/serverspec/Berksfile +3 -0
  283. data/test/serverspec/Berksfile.lock +5 -0
  284. data/test/serverspec/TODO.md +2 -0
  285. data/test/serverspec/test/integration/default/serverspec/os_spec.rb +25 -0
  286. data/test/serverspec/test/integration/default/serverspec/spec_helper.rb +48 -0
  287. data/test/serverspec/test/integration/default/serverspec/sysctl_spec.rb +37 -0
  288. data/test/unit/metadata_test.rb +13 -1
  289. data/test/unit/mock/profiles/complete-metadata/inspec.yml +7 -0
  290. data/test/unit/mock/profiles/empty-metadata/inspec.yml +0 -0
  291. data/test/unit/mock/profiles/{complete-meta → legacy-complete-metadata}/metadata.rb +0 -0
  292. data/test/unit/mock/profiles/legacy-complete-metadata/test/.gitkeep +0 -0
  293. data/test/unit/mock/profiles/legacy-empty-metadata/controls/.gitkeep +0 -0
  294. data/test/unit/mock/profiles/legacy-empty-metadata/metadata.rb +0 -0
  295. data/test/unit/mock/profiles/{metadata → legacy-simple-metadata}/metadata.rb +0 -0
  296. data/test/unit/mock/profiles/legacy-simple-metadata/test/.gitkeep +0 -0
  297. data/test/unit/mock/profiles/simple-metadata/inspec.yml +1 -0
  298. data/test/unit/profile_test.rb +82 -31
  299. data/test/unit/resources/service_test.rb +67 -3
  300. metadata +466 -23
  301. data/examples/resource/controls/tiny.rb +0 -3
  302. data/examples/resource/inspec.yml +0 -10
  303. data/examples/resource/libraries/tiny.rb +0 -3
  304. data/lib/inspec/targets/url.rb.orig +0 -87
  305. data/test/unit/mock/profiles/custom-resource/libraries/resource.rb +0 -3
  306. data/test/unit/mock/profiles/custom-resource/metadata.rb +0 -7
data/inspec.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Inspec::VERSION
9
9
  spec.authors = ['Dominik Richter']
10
10
  spec.email = ['dominik.richter@gmail.com']
11
- spec.summary = 'Validate Inspec compliance checks'
12
- spec.description = 'Validate Inspec compliance checks.'
11
+ spec.summary = 'Infrastructure and compliance testing.'
12
+ spec.description = 'InSpec provides a framework for creating end-to-end infrastructure tests. You can use it for integration or even compliance testing. Create fully portable test profiles and use them in your workflow to ensure stability and security. Integrate InSpec in your change lifecycle for local testing, CI/CD, and deployment verification.'
13
13
  spec.homepage = 'https://github.com/chef/inspec'
14
14
  spec.license = 'Apache 2.0'
15
15
 
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,15 @@
1
+ # InSpec Extension for Chef Compliance
2
+
3
+ This extensions offers the following features:
4
+
5
+ - list profiles available in Chef Compliance
6
+ - execute profiles from Chef Compliance
7
+ - upload a local profile to Chef Compliance
8
+
9
+ To use the CLI, this extra package adds the following commands:
10
+
11
+ * `$ inspec compliance login user password` - retieves a authentication token from Chef Compliance
12
+ * `$ inspec compliance list` - list all available profiles in Chef Compliance
13
+ * `$ inspec exec profile` - runs a profile that is stored on Chef Compliance
14
+ * `$ inspec compliance upload path/to/local/profile` - uploads a local command to Chef Compliance
15
+ * `$ inspec compliance logout` - removes the authentication token from the local cache and logs out of the Chef Compliance server
@@ -0,0 +1,245 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # author: Christoph Hartmann
4
+
5
+ require 'thor'
6
+ require 'net/http'
7
+ require 'uri'
8
+
9
+ # TODO:
10
+ # - invalidate token
11
+ # - fix file upload and genereate tar if required
12
+ # - hook into exec with a new target helper
13
+
14
+ class ComplianceCLI < Thor
15
+ namespace 'compliance'
16
+
17
+ desc 'login SERVER', 'Log in to a Chef Compliance SERVER'
18
+ options :username => :required, :password => :required
19
+ def login(server)
20
+ config = Compliance::Configuration.new
21
+ config['server'] = server
22
+ url = "#{server}/oauth/token"
23
+
24
+ data = post(url, options['username'], options['password'])
25
+ if !data.nil?
26
+ tokendata = JSON.parse(data)
27
+ if tokendata['access_token']
28
+ config['token'] = tokendata['access_token']
29
+ puts "Successfully authenticated"
30
+ else
31
+ puts 'Reponse does not include a token'
32
+ end
33
+ else
34
+ puts "Authentication failed for Server: #{url}"
35
+ end
36
+ config.store
37
+ end
38
+
39
+ desc 'list', 'list all available profiles in Chef Compliance'
40
+ def list
41
+ profiles = get_profiles
42
+ if !profiles.empty?
43
+ # iterate over profiles
44
+ puts "Available profiles: "
45
+ profiles.each { |profile|
46
+ puts " * #{profile[:org]}/#{profile[:name]}"
47
+ }
48
+ else
49
+ puts "Could not reach server #{url}"
50
+ end
51
+ end
52
+
53
+ desc 'exec PROFILE', 'executes a profile from Chef Compliance'
54
+ def exec(profile)
55
+ config = Compliance::Configuration.new
56
+ profiles = get_profiles
57
+ if !profiles.empty?
58
+ # 1. verify that the profile exists (list)
59
+ index = profiles.index { |p| "#{p[:org]}/#{p[:name]}" == profile }
60
+ if index >= 0
61
+ p = profiles[index]
62
+ # 2. execute the profile with the proper url, inject `inspec exec` with the suitable params`
63
+ url = "#{config['server']}/owners/#{p[:org]}/compliance/#{p[:name]}/tar"
64
+ puts "b bin/inspec exec #{url} --user #{config['token']}"
65
+ end
66
+ else
67
+ puts "The profile #{profile} is not available"
68
+ end
69
+ end
70
+
71
+ desc 'upload PATH', 'uploads a local profile to Chef Compliance'
72
+ def upload(path)
73
+ # 1. detect if tar or folder
74
+ # 2. archive if folder
75
+ # 3. check if tar is a compliance profile
76
+ # 4. show result and confirm upload to the user (skip with --force)
77
+ # 5. upload tar to server
78
+
79
+ # find the tar
80
+ config = Compliance::Configuration.new
81
+ tar_path = File.join(Dir.pwd, 'profile.tar.gz')
82
+
83
+ owner = 'admin'
84
+ profile = 'profile'
85
+ url = "#{config['server']}/owners/#{owner}/compliance/#{profile}/tar"
86
+
87
+ puts "Uploading to #{url}"
88
+ if post_file(url, config['token'], '', tar_path)
89
+ puts "Successfully uploaded profile"
90
+ else
91
+ puts "Error during profile upload"
92
+ end
93
+ end
94
+
95
+ desc 'version', 'displays the version of the Chef Compliance server'
96
+ def version
97
+ config = Compliance::Configuration.new
98
+ url = "#{config['server']}/version"
99
+
100
+ data = get(url, nil, nil)
101
+ if !data.nil?
102
+ info = JSON.parse(data)
103
+ puts "Chef Compliance version: #{info['version']}"
104
+ else
105
+ puts "Could not reach server #{url}"
106
+ end
107
+ end
108
+
109
+ desc 'logout', 'user logout from Chef Compliance'
110
+ def logout
111
+ config = Compliance::Configuration.new
112
+ url = "#{config['server']}/logout"
113
+ data = post(url, config['token'], nil)
114
+ if !data.nil?
115
+ puts "Successfully logged out"
116
+ else
117
+ puts "Could not log out"
118
+ end
119
+ config.destroy
120
+ end
121
+
122
+ private
123
+
124
+ def get_profiles
125
+ config = Compliance::Configuration.new
126
+
127
+ url = "#{config['server']}/user/compliance"
128
+ data = get(url, config['token'], '')
129
+
130
+ if !data.nil?
131
+ profiles = JSON.parse(data)
132
+ val = []
133
+ # iterate over profiles
134
+ profiles.each_key { |org|
135
+ profiles[org].each_key { |name|
136
+ val.push({ org: org, name: name})
137
+ }
138
+ }
139
+ val
140
+ else
141
+ []
142
+ end
143
+ end
144
+
145
+ def get(url, username, password)
146
+ uri = URI.parse(url)
147
+ req = Net::HTTP::Get.new(uri.path)
148
+ req.basic_auth username, password
149
+
150
+ send_request(uri, req)
151
+ end
152
+
153
+ def post(url, username, password)
154
+ # form request
155
+ uri = URI.parse(url)
156
+ req = Net::HTTP::Post.new(uri.path)
157
+ req.basic_auth username, password
158
+ req.form_data={}
159
+
160
+ send_request(uri, req)
161
+ end
162
+
163
+ # upload a file
164
+ def post_file(url, username, password, file_path)
165
+ uri = URI.parse(url)
166
+ http = Net::HTTP.new(uri.host, uri.port)
167
+ req = Net::HTTP::Post.new(uri.path)
168
+ req.basic_auth username, password
169
+
170
+ req.body_stream=File.open(file_path)
171
+ req["Content-Type"] = "multipart/form-data"
172
+ req.add_field('Content-Length', File.size(file_path))
173
+ req.add_field('Content-Type', 'application/x-gtar')
174
+
175
+ boundary = "INSPEC-PROFILE-UPLOAD"
176
+ req.add_field('session', boundary)
177
+ res=http.request(req)
178
+
179
+ # puts "Response #{response.code} #{response.message}"
180
+ # puts "#{response.body}"
181
+ # puts "Headers: #{response.to_hash.inspect}"
182
+
183
+ res.is_a?(Net::HTTPSuccess)
184
+ end
185
+
186
+ def send_request(uri, req)
187
+ # send request
188
+ res = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') {|http|
189
+ http.request(req)
190
+ }
191
+ if res.is_a?(Net::HTTPSuccess)
192
+ res.body
193
+ else
194
+ nil
195
+ end
196
+ end
197
+ end
198
+
199
+ module Compliance
200
+ class Configuration
201
+
202
+ def initialize
203
+ @config_path = File.join(ENV['HOME'], '/.inspec')
204
+ # ensure the directory is available
205
+ unless File.directory?(@config_path)
206
+ FileUtils.mkdir_p(@config_path)
207
+ end
208
+ # set config file pasth
209
+ @config_file = File.join(@config_path, '/config.json')
210
+ @config = {}
211
+
212
+ # load the data
213
+ get
214
+ end
215
+
216
+ # direct access to config
217
+ def [](key)
218
+ @config[key]
219
+ end
220
+
221
+ def []=(key, value)
222
+ @config[key] = value
223
+ end
224
+
225
+ # return the json data
226
+ def get
227
+ if File.exists?(@config_file)
228
+ file = File.read(@config_file)
229
+ @config = JSON.parse(file)
230
+ end
231
+ @config
232
+ end
233
+
234
+ # stores a hash to json
235
+ def store
236
+ File.open(@config_file,"w") do |f|
237
+ f.write(@config.to_json)
238
+ end
239
+ end
240
+
241
+ def destroy
242
+ File.delete(@config_file)
243
+ end
244
+ end
245
+ end
@@ -73,7 +73,9 @@ module Inspec
73
73
  family = try_support[:'os-family']
74
74
  release = try_support[:release]
75
75
  elsif entry.is_a?(String)
76
- @logger.warn("Using deprecated `supports` syntax: using `#{entry}` as OS family")
76
+ @logger.warn(
77
+ "Do not use deprecated `supports: #{entry}` syntax. Instead use "\
78
+ "`supports: {os-family: #{entry}}`.")
77
79
  family = entry
78
80
  end
79
81
 
@@ -33,11 +33,13 @@ module Inspec
33
33
  @params = @metadata.params
34
34
  # use the id from parameter, name or fallback to nil
35
35
  @profile_id = options[:id] || params[:name] || nil
36
+ @params[:name] = @profile_id
36
37
 
37
38
  @params[:rules] = rules = {}
38
39
  @runner = Runner.new(
39
40
  id: @profile_id,
40
41
  backend: :mock,
42
+ test_collector: @options.delete(:test_collector),
41
43
  )
42
44
  @runner.add_tests([@path], @options)
43
45
  @runner.rules.each do |id, rule|
@@ -4,11 +4,10 @@
4
4
 
5
5
  require 'inspec/rule'
6
6
  require 'inspec/dsl'
7
- require 'rspec/core/dsl'
8
7
  require 'securerandom'
9
8
 
10
9
  module Inspec
11
- class ProfileContext # rubocop:disable Metrics/ClassLength
10
+ class ProfileContext
12
11
  attr_reader :rules, :only_ifs
13
12
  def initialize(profile_id, backend, profile_registry = {}, only_ifs = [])
14
13
  if backend.nil?
@@ -25,9 +24,8 @@ module Inspec
25
24
  end
26
25
 
27
26
  def reload_dsl
28
- dsl = create_inner_dsl(@backend)
29
- outer_dsl = create_outer_dsl(dsl)
30
- ctx = create_context(outer_dsl)
27
+ resources_dsl = Inspec::Resource.create_dsl(@backend)
28
+ ctx = create_context(resources_dsl, rule_context(resources_dsl))
31
29
  @profile_context = ctx.new
32
30
  end
33
31
 
@@ -66,36 +64,42 @@ module Inspec
66
64
 
67
65
  private
68
66
 
69
- # Creates the inner DSL which includes all resources for
70
- # creating tests. It is always connected to one target,
71
- # which is specified via the backend argument.
67
+ # Create the context for controls. This includes all components of the DSL,
68
+ # including matchers and resources.
72
69
  #
73
- # @param backend [BackendRunner] exposing the target to resources
74
- # @return [InnerDSLModule]
75
- def create_inner_dsl(backend)
76
- Module.new do
77
- Inspec::Resource.registry.each do |id, r|
78
- define_method id.to_sym do |*args|
79
- r.new(backend, id.to_s, *args)
80
- end
81
- end
70
+ # @param [ResourcesDSL] resources_dsl which has all resources to attach
71
+ # @return [RuleContext] the inner context of rules
72
+ def rule_context(resources_dsl)
73
+ require 'rspec/core/dsl'
74
+ Class.new(Inspec::Rule) do
75
+ include RSpec::Core::DSL
76
+ include resources_dsl
82
77
  end
83
78
  end
84
79
 
85
- # Creates the outer DSL which includes all methods for creating
86
- # tests and control structures.
80
+ # Creates the heart of the profile context:
81
+ # An instantiated object which has all resources registered to it
82
+ # and exposes them to the a test file. The profile context serves as a
83
+ # container for all profiles which are registered. Within the context
84
+ # profiles get access to all DSL calls for creating tests and controls.
87
85
  #
88
- # @param dsl [InnerDSLModule] which contains all resources
89
- # @return [OuterDSLClass]
90
- def create_outer_dsl(dsl)
91
- rule_class = Class.new(Inspec::Rule) do
92
- include RSpec::Core::DSL
93
- include dsl
94
- end
86
+ # @param outer_dsl [OuterDSLClass]
87
+ # @return [ProfileContextClass]
88
+ def create_context(resources_dsl, rule_class)
89
+ profile_context_owner = self
95
90
 
96
91
  # rubocop:disable Lint/NestedMethodDefinition
97
92
  Class.new do
98
- include dsl
93
+ include Inspec::DSL
94
+ include resources_dsl
95
+
96
+ define_method :title do |arg|
97
+ profile_context_owner.set_header(:title, arg)
98
+ end
99
+
100
+ def to_s
101
+ 'Profile Context Run'
102
+ end
99
103
 
100
104
  define_method :control do |*args, &block|
101
105
  id = args[0]
@@ -107,7 +111,7 @@ module Inspec
107
111
  # controls.
108
112
  return if @skip_profile && os[:family] != 'unknown'
109
113
 
110
- __register_rule rule_class.new(id, opts, &block)
114
+ profile_context_owner.register_rule(rule_class.new(id, opts, &block))
111
115
  end
112
116
 
113
117
  alias_method :rule, :control
@@ -119,7 +123,7 @@ module Inspec
119
123
  rule = rule_class.new(id, {}) do
120
124
  describe(*args, &block)
121
125
  end
122
- __register_rule rule, &block
126
+ profile_context_owner.register_rule(rule, &block)
123
127
  end
124
128
 
125
129
  # TODO: mock method for attributes; import attribute handling
@@ -128,7 +132,7 @@ module Inspec
128
132
  end
129
133
 
130
134
  def skip_control(id)
131
- __unregister_rule id
135
+ profile_context_owner.unregister_rule(id)
132
136
  end
133
137
 
134
138
  alias_method :skip_rule, :skip_control
@@ -140,38 +144,5 @@ module Inspec
140
144
  end
141
145
  # rubocop:enable all
142
146
  end
143
-
144
- # Creates the heart of the profile context:
145
- # An instantiated object which has all resources registered to it
146
- # and exposes them to the a test file. The profile context serves as a
147
- # container for all profiles which are registered. Within the context
148
- # profiles get access to all DSL calls for creating tests and controls.
149
- #
150
- # @param outer_dsl [OuterDSLClass]
151
- # @return [ProfileContextClass]
152
- def create_context(outer_dsl)
153
- profile_context_owner = self
154
-
155
- # rubocop:disable Lint/NestedMethodDefinition
156
- Class.new(outer_dsl) do
157
- include Inspec::DSL
158
-
159
- define_method :title do |arg|
160
- profile_context_owner.set_header(:title, arg)
161
- end
162
-
163
- define_method :__register_rule do |*args|
164
- profile_context_owner.register_rule(*args)
165
- end
166
- define_method :__unregister_rule do |*args|
167
- profile_context_owner.unregister_rule(*args)
168
- end
169
-
170
- def to_s
171
- 'Profile Context Run'
172
- end
173
- end
174
- # rubocop:enable all
175
- end
176
147
  end
177
148
  end