inspec 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (346) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -2
  3. data/Gemfile +6 -0
  4. data/bin/inspec +5 -1
  5. data/docs/dsl_inspec.rst +1 -1
  6. data/docs/resources.rst +39 -2
  7. data/examples/resource/controls/tiny.rb +3 -0
  8. data/examples/resource/inspec.yml +10 -0
  9. data/examples/resource/libraries/tiny.rb +3 -0
  10. data/lib/bundles/inspec-compliance/cli.rb +1 -1
  11. data/lib/bundles/inspec-supermarket/README.md +0 -19
  12. data/lib/bundles/inspec-supermarket/api.rb +46 -22
  13. data/lib/bundles/inspec-supermarket/cli.rb +13 -18
  14. data/lib/bundles/inspec-supermarket/target.rb +6 -23
  15. data/lib/inspec/plugins.rb +4 -4
  16. data/lib/inspec/plugins/cli.rb +4 -4
  17. data/lib/inspec/version.rb +1 -1
  18. data/lib/resources/apache_conf.rb +8 -0
  19. data/lib/resources/auditd_rules.rb +163 -14
  20. data/lib/resources/registry_key.rb +5 -5
  21. data/lib/resources/script.rb +7 -9
  22. data/lib/utils/filter_array.rb +28 -0
  23. data/test/helper.rb +5 -2
  24. data/test/integration/cookbooks/os_prepare/metadata.rb +2 -0
  25. data/test/integration/cookbooks/os_prepare/recipes/auditctl.rb +8 -0
  26. data/test/integration/cookbooks/os_prepare/recipes/default.rb +13 -3
  27. data/test/integration/test/integration/default/apache_conf_spec.rb +15 -0
  28. data/test/integration/test/integration/default/auditd_rules_spec.rb +32 -0
  29. data/test/unit/mock/cmd/auditctl +3 -7
  30. data/test/unit/mock/cmd/auditctl-legacy +7 -0
  31. data/test/unit/mock/cmd/auditctl-s +8 -0
  32. data/test/unit/mock/profiles/resource-tiny/inspec.yml +10 -0
  33. data/test/unit/mock/profiles/resource-tiny/libraries/resource.rb +3 -0
  34. data/test/unit/plugin_test.rb +5 -6
  35. data/test/unit/resources/auditd_rules_test.rb +80 -10
  36. data/test/unit/resources/script_test.rb +5 -1
  37. data/test/unit/utils/filter_array_test.rb +59 -0
  38. data/test/unit/{simpleconfig_test.rb → utils/simpleconfig_test.rb} +0 -0
  39. metadata +25 -542
  40. data/bin/os +0 -23
  41. data/examples/kitchen-ansible/.kitchen/default-ubuntu-1404.yml +0 -6
  42. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  43. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  44. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +0 -1
  45. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  46. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +0 -27
  47. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  48. data/examples/kitchen-ansible/.kitchen/kitchen-vagrant/kitchen-kitchen-ansible-default-ubuntu-1404/Vagrantfile +0 -9
  49. data/examples/kitchen-ansible/.kitchen/logs/default-centos-71.log +0 -0
  50. data/examples/kitchen-ansible/.kitchen/logs/default-ubuntu-1204.log +0 -0
  51. data/examples/kitchen-ansible/.kitchen/logs/default-ubuntu-1404.log +0 -395
  52. data/examples/kitchen-ansible/.kitchen/logs/kitchen.log +0 -3
  53. data/examples/kitchen-ansible/Gemfile.lock +0 -158
  54. data/examples/kitchen-ansible/test/.DS_Store +0 -0
  55. data/examples/kitchen-ansible/test/integration/.DS_Store +0 -0
  56. data/examples/kitchen-azure/.kitchen.yml +0 -30
  57. data/examples/kitchen-azure/.kitchen/default-debian-80-20151022-x86-64.yml +0 -1
  58. data/examples/kitchen-azure/.kitchen/default-ubuntu-1204.yml +0 -9
  59. data/examples/kitchen-azure/.kitchen/logs/default-debian-80-20151022-x86-64.log +0 -59
  60. data/examples/kitchen-azure/.kitchen/logs/default-ubuntu-1204.log +0 -27
  61. data/examples/kitchen-azure/.kitchen/logs/default-windows2012-r2.log +0 -0
  62. data/examples/kitchen-azure/.kitchen/logs/kitchen.log +0 -29
  63. data/examples/kitchen-azure/Berksfile +0 -3
  64. data/examples/kitchen-azure/Gemfile +0 -20
  65. data/examples/kitchen-azure/Gemfile.lock +0 -273
  66. data/examples/kitchen-azure/README.md +0 -14
  67. data/examples/kitchen-azure/credentials.sh +0 -0
  68. data/examples/kitchen-azure/metadata.rb +0 -7
  69. data/examples/kitchen-azure/recipes/default.rb +0 -6
  70. data/examples/kitchen-azure/recipes/nginx.rb +0 -30
  71. data/examples/kitchen-azure/test/integration/default/web_spec.rb +0 -28
  72. data/examples/kitchen-chef/.kitchen/default-ubuntu-1404.yml +0 -6
  73. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  74. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  75. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +0 -1
  76. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  77. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +0 -27
  78. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  79. data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/Vagrantfile +0 -9
  80. data/examples/kitchen-chef/.kitchen/logs/default-centos-71.log +0 -0
  81. data/examples/kitchen-chef/.kitchen/logs/default-ubuntu-1204.log +0 -0
  82. data/examples/kitchen-chef/.kitchen/logs/default-ubuntu-1404.log +0 -3
  83. data/examples/kitchen-chef/.kitchen/logs/kitchen.log +0 -3
  84. data/examples/kitchen-chef/Berksfile.lock +0 -11
  85. data/examples/kitchen-chef/Gemfile.lock +0 -226
  86. data/examples/kitchen-chef/test/integration/.DS_Store +0 -0
  87. data/examples/kitchen-puppet/.bundle/config +0 -2
  88. data/examples/kitchen-puppet/.kitchen/default-ubuntu-1404.yml +0 -6
  89. data/examples/kitchen-puppet/.kitchen/kitchen-vagrant/kitchen-kitchen-puppet-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  90. data/examples/kitchen-puppet/.kitchen/kitchen-vagrant/kitchen-kitchen-puppet-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  91. data/examples/kitchen-puppet/.kitchen/kitchen-vagrant/kitchen-kitchen-puppet-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +0 -1
  92. data/examples/kitchen-puppet/.kitchen/kitchen-vagrant/kitchen-kitchen-puppet-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  93. data/examples/kitchen-puppet/.kitchen/kitchen-vagrant/kitchen-kitchen-puppet-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +0 -27
  94. data/examples/kitchen-puppet/.kitchen/kitchen-vagrant/kitchen-kitchen-puppet-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  95. data/examples/kitchen-puppet/.kitchen/kitchen-vagrant/kitchen-kitchen-puppet-default-ubuntu-1404/Vagrantfile +0 -9
  96. data/examples/kitchen-puppet/.kitchen/logs/default-centos-71.log +0 -0
  97. data/examples/kitchen-puppet/.kitchen/logs/default-ubuntu-1204.log +0 -0
  98. data/examples/kitchen-puppet/.kitchen/logs/default-ubuntu-1404.log +0 -305
  99. data/examples/kitchen-puppet/.kitchen/logs/kitchen.log +0 -6
  100. data/examples/kitchen-puppet/.librarian/puppet/config +0 -2
  101. data/examples/kitchen-puppet/Gemfile.lock +0 -175
  102. data/examples/kitchen-puppet/Puppetfile.lock +0 -2
  103. data/examples/kitchen-puppet/test/integration/.DS_Store +0 -0
  104. data/examples/kitchen-puppet/test/integration/default/.DS_Store +0 -0
  105. data/examples/profile/libraries/.DS_Store +0 -0
  106. data/examples/test-kitchen/.kitchen/logs/default-centos-71.log +0 -5
  107. data/examples/test-kitchen/.kitchen/logs/default-ubuntu-1204.log +0 -5
  108. data/examples/test-kitchen/.kitchen/logs/default-ubuntu-1404.log +0 -5
  109. data/examples/test-kitchen/.kitchen/logs/kitchen.log +0 -5
  110. data/examples/test-kitchen/Berksfile.lock +0 -11
  111. data/examples/test-kitchen/Gemfile.lock +0 -233
  112. data/lib/.DS_Store +0 -0
  113. data/lib/bundles/inspec-compliance/TODO.md +0 -4
  114. data/lib/bundles/inspec-supermarket.rb +0 -14
  115. data/lib/bundles/inspec-supermarket/TODO.md +0 -5
  116. data/lib/bundles/inspec-supermarket/cache.rb +0 -30
  117. data/test/chefdk/.gitignore +0 -16
  118. data/test/chefdk/.kitchen.yml +0 -27
  119. data/test/chefdk/Policyfile.rb +0 -16
  120. data/test/chefdk/README.md +0 -4
  121. data/test/chefdk/chefignore +0 -100
  122. data/test/chefdk/metadata.rb +0 -7
  123. data/test/chefdk/recipes/default.rb +0 -5
  124. data/test/chefdk/spec/spec_helper.rb +0 -2
  125. data/test/chefdk/spec/unit/recipes/default_spec.rb +0 -20
  126. data/test/chefdk/test/integration/default/serverspec/default_spec.rb +0 -9
  127. data/test/chefdk/test/integration/helpers/serverspec/spec_helper.rb +0 -8
  128. data/test/integration/.kitchen.chef.yml +0 -29
  129. data/test/integration/.kitchen.shell.yml +0 -19
  130. data/test/integration/.kitchen/default-aws-linux.yml +0 -4
  131. data/test/integration/.kitchen/default-centos-7.yml +0 -4
  132. data/test/integration/.kitchen/default-chef-solaris-1011.yml +0 -6
  133. data/test/integration/.kitchen/default-chef-solaris-113.yml +0 -6
  134. data/test/integration/.kitchen/default-chef-windows-server-2008r2-standard.yml +0 -7
  135. data/test/integration/.kitchen/default-chris-rock-omnios-r151014.yml +0 -6
  136. data/test/integration/.kitchen/default-debian-8.yml +0 -4
  137. data/test/integration/.kitchen/default-debian-81.yml +0 -6
  138. data/test/integration/.kitchen/default-fedora-22.yml +0 -4
  139. data/test/integration/.kitchen/default-omniti-omnios-r151014.yml +0 -1
  140. data/test/integration/.kitchen/default-redhat-65.yml +0 -4
  141. data/test/integration/.kitchen/default-redhat-71.yml +0 -4
  142. data/test/integration/.kitchen/default-suse-11sp3.yml +0 -4
  143. data/test/integration/.kitchen/default-suse-12.yml +0 -4
  144. data/test/integration/.kitchen/default-suse-hi11sp3.yml +0 -4
  145. data/test/integration/.kitchen/default-ubuntu-1204.yml +0 -4
  146. data/test/integration/.kitchen/default-ubuntu-1404.yml +0 -4
  147. data/test/integration/.kitchen/default-ubuntu-1510.yml +0 -4
  148. data/test/integration/.kitchen/default-windows-2008.yml +0 -5
  149. data/test/integration/.kitchen/default-windows-2012.yml +0 -1
  150. data/test/integration/.kitchen/default-windows-2012r2.yml +0 -6
  151. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67-i386/Vagrantfile +0 -9
  152. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  153. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  154. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/id +0 -1
  155. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  156. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/private_key +0 -27
  157. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  158. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-1011/Vagrantfile +0 -8
  159. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-113/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  160. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-113/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  161. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-113/.vagrant/machines/default/virtualbox/id +0 -1
  162. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-113/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  163. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-113/.vagrant/machines/default/virtualbox/private_key +0 -27
  164. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-113/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  165. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-solaris-113/Vagrantfile +0 -8
  166. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  167. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  168. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/id +0 -1
  169. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  170. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  171. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chef-windows-server-2008r2-standard/Vagrantfile +0 -7
  172. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  173. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  174. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/id +0 -1
  175. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  176. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/private_key +0 -27
  177. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  178. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-chris-rock-omnios-r151014/Vagrantfile +0 -8
  179. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  180. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  181. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/id +0 -1
  182. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  183. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/private_key +0 -27
  184. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  185. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/Vagrantfile +0 -9
  186. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  187. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  188. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/.vagrant/machines/default/virtualbox/id +0 -1
  189. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  190. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-modernIE-w10-edge/Vagrantfile +0 -8
  191. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  192. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  193. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/id +0 -1
  194. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  195. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/.vagrant/machines/default/virtualbox/private_key +0 -27
  196. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-omniti-omnios-r151014/Vagrantfile +0 -8
  197. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  198. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  199. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +0 -1
  200. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  201. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +0 -27
  202. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  203. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/Vagrantfile +0 -9
  204. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  205. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  206. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +0 -1
  207. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  208. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +0 -27
  209. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  210. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/Vagrantfile +0 -9
  211. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  212. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  213. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/.vagrant/machines/default/virtualbox/id +0 -1
  214. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  215. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-windows-2012R2-matt/Vagrantfile +0 -8
  216. data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-new-ubuntu-1404/Vagrantfile +0 -9
  217. data/test/integration/.kitchen/logs/default-aws-linux.log +0 -0
  218. data/test/integration/.kitchen/logs/default-centos-511-i386.log +0 -0
  219. data/test/integration/.kitchen/logs/default-centos-511.log +0 -0
  220. data/test/integration/.kitchen/logs/default-centos-67-i386.log +0 -0
  221. data/test/integration/.kitchen/logs/default-centos-67.log +0 -0
  222. data/test/integration/.kitchen/logs/default-centos-7.log +0 -0
  223. data/test/integration/.kitchen/logs/default-centos-71.log +0 -0
  224. data/test/integration/.kitchen/logs/default-chef-solaris-1011.log +0 -0
  225. data/test/integration/.kitchen/logs/default-chef-solaris-113.log +0 -0
  226. data/test/integration/.kitchen/logs/default-chef-windows-server-2008r2-standard.log +0 -43
  227. data/test/integration/.kitchen/logs/default-chef-windows-server-2012r2-standard.log +0 -0
  228. data/test/integration/.kitchen/logs/default-chris-rock-omnios-r151014.log +0 -41
  229. data/test/integration/.kitchen/logs/default-debian-6010-i386.log +0 -0
  230. data/test/integration/.kitchen/logs/default-debian-6010.log +0 -0
  231. data/test/integration/.kitchen/logs/default-debian-78-i386.log +0 -0
  232. data/test/integration/.kitchen/logs/default-debian-78.log +0 -0
  233. data/test/integration/.kitchen/logs/default-debian-8.log +0 -0
  234. data/test/integration/.kitchen/logs/default-debian-81-i386.log +0 -0
  235. data/test/integration/.kitchen/logs/default-debian-81.log +0 -240
  236. data/test/integration/.kitchen/logs/default-dusank-oi-server.log +0 -0
  237. data/test/integration/.kitchen/logs/default-fedora-21-i386.log +0 -0
  238. data/test/integration/.kitchen/logs/default-fedora-21.log +0 -0
  239. data/test/integration/.kitchen/logs/default-fedora-22.log +0 -0
  240. data/test/integration/.kitchen/logs/default-freebsd-102.log +0 -0
  241. data/test/integration/.kitchen/logs/default-freebsd-93.log +0 -0
  242. data/test/integration/.kitchen/logs/default-livinginthepast-smartos-base64.log +0 -0
  243. data/test/integration/.kitchen/logs/default-mint-172-cinnamon.log +0 -0
  244. data/test/integration/.kitchen/logs/default-modernIE-w10-edge.log +0 -2
  245. data/test/integration/.kitchen/logs/default-modernIE-w7-ie11.log +0 -2
  246. data/test/integration/.kitchen/logs/default-modernIE-w81-ie11.log +0 -2
  247. data/test/integration/.kitchen/logs/default-omniti-omnios-r151014.log +0 -0
  248. data/test/integration/.kitchen/logs/default-opensuse-132-i386.log +0 -0
  249. data/test/integration/.kitchen/logs/default-opensuse-132-x86-64.log +0 -0
  250. data/test/integration/.kitchen/logs/default-opentable-win-2008r2-standard-amd64-nocm.log +0 -0
  251. data/test/integration/.kitchen/logs/default-opentable-win-2012r2-standard-amd64-nocm.log +0 -0
  252. data/test/integration/.kitchen/logs/default-redhat-65.log +0 -0
  253. data/test/integration/.kitchen/logs/default-redhat-71.log +0 -0
  254. data/test/integration/.kitchen/logs/default-suse-11sp3.log +0 -0
  255. data/test/integration/.kitchen/logs/default-suse-12.log +0 -0
  256. data/test/integration/.kitchen/logs/default-suse-hi11sp3.log +0 -37
  257. data/test/integration/.kitchen/logs/default-ubuntu-1004-i386.log +0 -0
  258. data/test/integration/.kitchen/logs/default-ubuntu-1004.log +0 -0
  259. data/test/integration/.kitchen/logs/default-ubuntu-1204-i386.log +0 -0
  260. data/test/integration/.kitchen/logs/default-ubuntu-1204.log +0 -23
  261. data/test/integration/.kitchen/logs/default-ubuntu-1404-i386.log +0 -0
  262. data/test/integration/.kitchen/logs/default-ubuntu-1404.log +0 -0
  263. data/test/integration/.kitchen/logs/default-ubuntu-1510.log +0 -0
  264. data/test/integration/.kitchen/logs/default-windows-2008-opentable.log +0 -2
  265. data/test/integration/.kitchen/logs/default-windows-2008.log +0 -0
  266. data/test/integration/.kitchen/logs/default-windows-2012.log +0 -0
  267. data/test/integration/.kitchen/logs/default-windows-2012R2-matt.log +0 -2
  268. data/test/integration/.kitchen/logs/default-windows-2012r2-opentable.log +0 -2
  269. data/test/integration/.kitchen/logs/default-windows-2012r2.log +0 -0
  270. data/test/integration/.kitchen/logs/default-winrm.log +0 -0
  271. data/test/integration/.kitchen/logs/kitchen.log +0 -3
  272. data/test/integration/.kitchen/logs/new-centos-511-i386.log +0 -0
  273. data/test/integration/.kitchen/logs/new-centos-511.log +0 -0
  274. data/test/integration/.kitchen/logs/new-centos-67-i386.log +0 -0
  275. data/test/integration/.kitchen/logs/new-centos-67.log +0 -0
  276. data/test/integration/.kitchen/logs/new-centos-71.log +0 -0
  277. data/test/integration/.kitchen/logs/new-debian-6010-i386.log +0 -0
  278. data/test/integration/.kitchen/logs/new-debian-6010.log +0 -0
  279. data/test/integration/.kitchen/logs/new-debian-78-i386.log +0 -0
  280. data/test/integration/.kitchen/logs/new-debian-78.log +0 -0
  281. data/test/integration/.kitchen/logs/new-debian-81-i386.log +0 -0
  282. data/test/integration/.kitchen/logs/new-debian-81.log +0 -0
  283. data/test/integration/.kitchen/logs/new-fedora-21-i386.log +0 -0
  284. data/test/integration/.kitchen/logs/new-fedora-21.log +0 -0
  285. data/test/integration/.kitchen/logs/new-fedora-22.log +0 -0
  286. data/test/integration/.kitchen/logs/new-freebsd-102.log +0 -0
  287. data/test/integration/.kitchen/logs/new-freebsd-93.log +0 -0
  288. data/test/integration/.kitchen/logs/new-opensuse-132-i386.log +0 -0
  289. data/test/integration/.kitchen/logs/new-opensuse-132-x86-64.log +0 -0
  290. data/test/integration/.kitchen/logs/new-ubuntu-1004-i386.log +0 -0
  291. data/test/integration/.kitchen/logs/new-ubuntu-1004.log +0 -0
  292. data/test/integration/.kitchen/logs/new-ubuntu-1204-i386.log +0 -0
  293. data/test/integration/.kitchen/logs/new-ubuntu-1204.log +0 -0
  294. data/test/integration/.kitchen/logs/new-ubuntu-1404-i386.log +0 -0
  295. data/test/integration/.kitchen/logs/new-ubuntu-1404.log +0 -3
  296. data/test/integration/.kitchen/logs/test-centos-511-i386.log +0 -0
  297. data/test/integration/.kitchen/logs/test-centos-511.log +0 -0
  298. data/test/integration/.kitchen/logs/test-centos-67-i386.log +0 -0
  299. data/test/integration/.kitchen/logs/test-centos-67.log +0 -0
  300. data/test/integration/.kitchen/logs/test-centos-71.log +0 -0
  301. data/test/integration/.kitchen/logs/test-debian-6010-i386.log +0 -0
  302. data/test/integration/.kitchen/logs/test-debian-6010.log +0 -0
  303. data/test/integration/.kitchen/logs/test-debian-78-i386.log +0 -0
  304. data/test/integration/.kitchen/logs/test-debian-78.log +0 -0
  305. data/test/integration/.kitchen/logs/test-debian-81-i386.log +0 -0
  306. data/test/integration/.kitchen/logs/test-debian-81.log +0 -0
  307. data/test/integration/.kitchen/logs/test-fedora-21-i386.log +0 -0
  308. data/test/integration/.kitchen/logs/test-fedora-21.log +0 -0
  309. data/test/integration/.kitchen/logs/test-fedora-22.log +0 -0
  310. data/test/integration/.kitchen/logs/test-freebsd-102.log +0 -0
  311. data/test/integration/.kitchen/logs/test-freebsd-93.log +0 -0
  312. data/test/integration/.kitchen/logs/test-opensuse-132-i386.log +0 -0
  313. data/test/integration/.kitchen/logs/test-opensuse-132-x86-64.log +0 -0
  314. data/test/integration/.kitchen/logs/test-ubuntu-1004-i386.log +0 -0
  315. data/test/integration/.kitchen/logs/test-ubuntu-1004.log +0 -0
  316. data/test/integration/.kitchen/logs/test-ubuntu-1204-i386.log +0 -0
  317. data/test/integration/.kitchen/logs/test-ubuntu-1204.log +0 -0
  318. data/test/integration/.kitchen/logs/test-ubuntu-1404-i386.log +0 -0
  319. data/test/integration/.kitchen/logs/test-ubuntu-1404.log +0 -0
  320. data/test/integration/.kitchen/new-ubuntu-1404.yml +0 -1
  321. data/test/integration/Berksfile.lock +0 -27
  322. data/test/integration/TODO.md +0 -15
  323. data/test/integration/bootstrap.sh +0 -3
  324. data/test/integration/test/.DS_Store +0 -0
  325. data/test/integration/test/integration/.DS_Store +0 -0
  326. data/test/integration/test/integration/default/.DS_Store +0 -0
  327. data/test/integration/test/integration/default/certificate_spec.rb +0 -7
  328. data/test/mac/service_spec.rb +0 -5
  329. data/test/serverspec/.kitchen.yml +0 -18
  330. data/test/serverspec/.kitchen/default-ubuntu-1404.yml +0 -6
  331. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +0 -1
  332. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +0 -1
  333. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +0 -1
  334. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +0 -1
  335. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +0 -27
  336. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +0 -1
  337. data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/Vagrantfile +0 -9
  338. data/test/serverspec/.kitchen/logs/default-ubuntu-1404.log +0 -2
  339. data/test/serverspec/.kitchen/logs/kitchen.log +0 -3
  340. data/test/serverspec/Berksfile +0 -3
  341. data/test/serverspec/Berksfile.lock +0 -5
  342. data/test/serverspec/TODO.md +0 -2
  343. data/test/serverspec/test/integration/default/serverspec/os_spec.rb +0 -25
  344. data/test/serverspec/test/integration/default/serverspec/spec_helper.rb +0 -48
  345. data/test/serverspec/test/integration/default/serverspec/sysctl_spec.rb +0 -37
  346. data/test/solaris_test.rb +0 -70
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9faacfe31cee7ccb07175da65b07f589165c8960
4
- data.tar.gz: a2d9f9b214a2af6ff48dd738b325786b0d5bb593
3
+ metadata.gz: 70a0c204211c2bd4a689aff2790fe23999a5013a
4
+ data.tar.gz: ee648ad90d3d80a6f2cd4f2c18207d39916a6b49
5
5
  SHA512:
6
- metadata.gz: 5f90de24ba19b21d3653c73f4501c546883d42aa098e47368205d9711a7ae8fbf71bf5117ca2b884350abdf1530f84f1378d690cdc2335dede6ff1882dfbef12
7
- data.tar.gz: 8c408ae57fed30a71e85873bbeaf83a6b9eeee02c6f05702f5c3d699d6bfbb7c99f68ad6c20a4b997ceb2ba50055bc30654e3a708e7ff9976bb59b5ee4d90540
6
+ metadata.gz: c71d588c6547180d6f54e769c1580dc88d98634cc7100583e6723ea172014fb1f3feb7471791cbd9429b112bda7dbba840564e6ea65ec61faf36427847ca92e2
7
+ data.tar.gz: 0d5750125ca6c6cce5ab69a001726dc7663ae95b2269cf8a162ff9e08037ae64ca3607a220af7ae11f47b2c623b3f17b99da92ebabd8650481ae6916b5286a18
@@ -1,12 +1,43 @@
1
1
  # Change Log
2
2
 
3
- ## [0.10.1](https://github.com/chef/inspec/tree/0.10.1) (2016-02-05)
4
- [Full Changelog](https://github.com/chef/inspec/compare/v0.10.0...0.10.1)
3
+ ## [0.11.0](https://github.com/chef/inspec/tree/0.11.0) (2016-02-09)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.10.1...0.11.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Improve apache resource [\#407](https://github.com/chef/inspec/pull/407) ([chris-rock](https://github.com/chris-rock))
9
+ - auditd\_rules rework [\#400](https://github.com/chef/inspec/pull/400) ([srenatus](https://github.com/srenatus))
10
+
11
+ **Fixed bugs:**
12
+
13
+ - File stats are not always working properly [\#430](https://github.com/chef/inspec/issues/430)
14
+ - Integration test for apache config [\#406](https://github.com/chef/inspec/issues/406)
15
+ - rework auditd\_rules resource [\#312](https://github.com/chef/inspec/issues/312)
16
+ - resource/auditd\_rules: update rule list format [\#309](https://github.com/chef/inspec/issues/309)
5
17
 
6
18
  **Merged pull requests:**
7
19
 
20
+ - Fix supermarket cli registration [\#441](https://github.com/chef/inspec/pull/441) ([chris-rock](https://github.com/chris-rock))
21
+ - update to winrm 1.6.1 command scheme [\#439](https://github.com/chef/inspec/pull/439) ([arlimus](https://github.com/arlimus))
22
+ - semantics: rename CLI plugins registry -\> commands [\#435](https://github.com/chef/inspec/pull/435) ([arlimus](https://github.com/arlimus))
23
+ - avoid automatic plugin loading via library [\#434](https://github.com/chef/inspec/pull/434) ([arlimus](https://github.com/arlimus))
24
+ - clarify the role of the plugin API at the moment [\#433](https://github.com/chef/inspec/pull/433) ([arlimus](https://github.com/arlimus))
25
+ - Implement Supermarket Extension [\#432](https://github.com/chef/inspec/pull/432) ([chris-rock](https://github.com/chris-rock))
26
+ - dedup Gemfiles [\#429](https://github.com/chef/inspec/pull/429) ([srenatus](https://github.com/srenatus))
27
+ - fix loading order of plugins [\#428](https://github.com/chef/inspec/pull/428) ([arlimus](https://github.com/arlimus))
28
+ - Update dsl\_inspec.rst [\#427](https://github.com/chef/inspec/pull/427) ([GeoFruck](https://github.com/GeoFruck))
29
+
30
+ ## [v0.10.1](https://github.com/chef/inspec/tree/v0.10.1) (2016-02-05)
31
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.10.0...v0.10.1)
32
+
33
+ **Fixed bugs:**
34
+
8
35
  - wrap basecli in inspec module [\#425](https://github.com/chef/inspec/pull/425) ([arlimus](https://github.com/arlimus))
9
36
 
37
+ **Merged pull requests:**
38
+
39
+ - 0.10.1 [\#426](https://github.com/chef/inspec/pull/426) ([chris-rock](https://github.com/chris-rock))
40
+
10
41
  ## [v0.10.0](https://github.com/chef/inspec/tree/v0.10.0) (2016-02-05)
11
42
  [Full Changelog](https://github.com/chef/inspec/compare/v0.9.11...v0.10.0)
12
43
 
data/Gemfile CHANGED
@@ -2,6 +2,12 @@
2
2
  source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
+ # pin dependency for Ruby 1.9.3 since bundler is not
6
+ # detecting that net-ssh 3 does not work with 1.9.3
7
+ if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('1.9.3')
8
+ gem 'net-ssh', '~> 2.9'
9
+ end
10
+
5
11
  group :test do
6
12
  gem 'bundler', '~> 1.5'
7
13
  gem 'minitest', '~> 5.5'
data/bin/inspec CHANGED
@@ -142,8 +142,12 @@ class Inspec::InspecCLI < Inspec::BaseCLI # rubocop:disable Metrics/ClassLength
142
142
  end
143
143
  end
144
144
 
145
+ # Load all plugins on startup
146
+ ctl = Inspec::PluginCtl.new
147
+ ctl.list.each { |x| ctl.load(x) }
148
+
145
149
  # load CLI plugins before the Inspec CLI has been started
146
- Inspec::Plugins::CLI.registry.each { |_subcommand, params|
150
+ Inspec::Plugins::CLI.subcommands.each { |_subcommand, params|
147
151
  Inspec::InspecCLI.register(
148
152
  params[:klass],
149
153
  params[:subcommand_name],
@@ -11,7 +11,7 @@ The following sections describe the syntax and show some simple examples of usin
11
11
  Syntax
12
12
  =====================================================
13
13
 
14
- The following resource tests |ssh| server configuration. For example, a simple control may desrcibed as:
14
+ The following resource tests |ssh| server configuration. For example, a simple control may described as:
15
15
 
16
16
  .. code-block:: ruby
17
17
 
@@ -306,12 +306,14 @@ The following examples show how to use this InSpec audit resource.
306
306
 
307
307
  auditd_rules
308
308
  =====================================================
309
- Use the ``auditd_rules`` |inspec resource| to test the rules for logging that exist on the system. The ``audit.rules`` file is typically located under ``/etc/audit/`` and contains the list of rules that define what is captured in log files.
309
+ Use the ``auditd_rules`` |inspec resource| to test the rules for logging that exist on the system. The ``audit.rules`` file is typically located under ``/etc/audit/`` and contains the list of rules that define what is captured in log files. This resource uses `auditctl` to query the _run-time_ auditd rules setup (which may divert from `audit.rules`).
310
310
 
311
311
  **Stability: Experimental**
312
312
 
313
313
  Syntax
314
314
  -----------------------------------------------------
315
+ A change in the output format (with an `audit` package version 2.3 or newer) is reflected in two interfaces included in `auditd_rules`:
316
+
315
317
  A ``auditd_rules`` |inspec resource| block declares one (or more) rules to be tested, and then what that rule should do:
316
318
 
317
319
  .. code-block:: ruby
@@ -342,7 +344,7 @@ or test that individual rules are defined:
342
344
 
343
345
  where each test
344
346
 
345
- * Must declare one (or more) rules to be tested
347
+ * must declare one (or more) rules to be tested
346
348
 
347
349
  Examples
348
350
  -----------------------------------------------------
@@ -352,12 +354,47 @@ The following examples show how to use this InSpec audit resource.
352
354
 
353
355
  .. code-block:: ruby
354
356
 
357
+ # syntax for audit < 2.3
355
358
  describe audit_daemon_rules do
356
359
  its("LIST_RULES") {
357
360
  should contain_match(/^exit,always arch=.* key=time-change syscall=adjtimex,settimeofday/)
358
361
  }
359
362
  end
360
363
 
364
+ # syntax for auditd >= 2.3
365
+ describe auditd_rules do
366
+ its(:lines) { should contain_match(%r{-w /etc/ssh/sshd_config/}) }
367
+ end
368
+
369
+ The syntax for recent auditd versions allows more precise tests, such as the following:
370
+
371
+ **Query the audit daemon status.**
372
+
373
+ .. code-block:: ruby
374
+
375
+ describe auditd_rules.status('backlog') do
376
+ it { should cmp 0 }
377
+ end
378
+
379
+ **Query properties of rules targeting specific syscalls or files.**
380
+
381
+ .. code-block:: ruby
382
+
383
+ describe auditd_rules.syscall('open').action do
384
+ it { should eq(['always']) }
385
+ end
386
+
387
+ describe auditd_rules.key('sshd_config') do
388
+ its(:permissions) { should contain_match(/x/) }
389
+ end
390
+
391
+ Note that filters can be chained, for example:
392
+
393
+ .. code-block:: ruby
394
+
395
+ describe auditd_rules.syscall('open').action('always').list do
396
+ it { should eq(['exit']) }
397
+ end
361
398
 
362
399
 
363
400
  bond
@@ -0,0 +1,3 @@
1
+ describe tiny do
2
+ require 'pry'; binding.pry
3
+ end
@@ -0,0 +1,10 @@
1
+ name: resource
2
+ title: InSpec Example Resources
3
+ maintainer: Chef Software, Inc.
4
+ copyright: Chef Software, Inc.
5
+ copyright_email: support@chef.io
6
+ license: Apache 2 license
7
+ summary: Demonstrates the use of InSpec custom resources
8
+ version: 1.0.0
9
+ supports:
10
+ - linux
@@ -0,0 +1,3 @@
1
+ class Tiny < Inspec.resource(1)
2
+ name 'tiny'
3
+ end
@@ -142,5 +142,5 @@ module Compliance
142
142
  end
143
143
 
144
144
  # register the subcommand to Inspec CLI registry
145
- Inspec::Plugins::CLI.register(ComplianceCLI, 'compliance', 'compliance SUBCOMMAND ...', 'Chef Compliance commands', {})
145
+ Inspec::Plugins::CLI.add_subcommand(ComplianceCLI, 'compliance', 'compliance SUBCOMMAND ...', 'Chef Compliance commands', {})
146
146
  end
@@ -10,22 +10,3 @@ To use the CLI, this InSpec add-on adds the following commands:
10
10
 
11
11
  - via supermarket exec: `inspec supermarket exec nathenharvey/tmp-compliance-profile`
12
12
  - via supermarket scheme: `inspec exec supermarket://nathenharvey/tmp-compliance-profile`
13
-
14
-
15
- # fetch all available profiles in local cache
16
- # https://supermarket.chef.io/api/v1/tools-search\?q\=compliance_profile
17
-
18
- # get the tool slug url
19
- # https://supermarket.chef.io/api/v1/tools/tmp-compliance-profile
20
- # https://supermarket.chef.io/api/v1/tools/tmp_compliance_profile
21
- # response
22
- # {
23
- # "description": "An InSpec compliance profile for use with Chef Compliance Server.\r\n",
24
- # "instructions": "## Installation\r\n\r\nDownload the [latest release](https://github.com/nathenharvey/tmp_compliance_profile/releases) from GitHub and upload the tar.gz to your Chef Compliance Server.\r\n\r\n## Controls Included\r\n\r\n* tmp-1.0 - A /tmp directory must exist\r\n* tmp-1.1 - The /tmp directory must be owned by the root user\r\n\r\n## License & Authors\r\n\r\n*Author:* Nathen Harvey\r\n\r\n*Copyright:* 2015-2016, Chef Software, Inc.\r\n\r\n Licensed under the Apache License, Version 2.0 (the \"License\");\r\n you may not use this file except in compliance with the License.\r\n You may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\n Unless required by applicable law or agreed to in writing, software\r\n distributed under the License is distributed on an \"AS IS\" BASIS,\r\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n See the License for the specific language governing permissions and\r\n limitations under the License.\r\n",
25
- # "name": "/tmp Compliance Profile",
26
- # "owner": "nathenharvey",
27
- # "slug": "tmp-compliance-profile",
28
- # "source_url": "https://github.com/nathenharvey/tmp_compliance_profile/",
29
- # "type": "compliance_profile",
30
- # "up_for_adoption": false
31
- # }
@@ -4,36 +4,65 @@
4
4
 
5
5
  module Supermarket
6
6
  class API
7
+ SUPERMARKET_URL = 'https://supermarket.chef.io'.freeze
8
+
9
+ def self.supermarket_url
10
+ SUPERMARKET_URL
11
+ end
12
+
13
+ # displays a list of profiles
7
14
  def self.profiles
8
- url = 'https://supermarket.chef.io/api/v1/tools-search'
9
- data = get(url, { :q => 'compliance_profile' })
15
+ url = "#{SUPERMARKET_URL}/api/v1/tools-search"
16
+ _success, data = get(url, { q: 'compliance_profile' })
10
17
  if !data.nil?
11
18
  profiles = JSON.parse(data)
12
19
  profiles['items']
13
- # val = []
14
- # # iterate over profiles
15
- # profiles.each_key { |org|
16
- # profiles[org].each_key { |name|
17
- # val.push({ org: org, name: name})
18
- # }
19
- # }
20
- # val
21
20
  else
22
21
  []
23
22
  end
24
23
  end
25
24
 
26
- def self.info(slug)
27
- url = "https://supermarket.chef.io/api/v1/tools/#{slug}"
28
- data = get(url, {})
25
+ def self.profile_name(profile)
26
+ uri = URI(profile)
27
+ [uri.host, uri.path[1..-1]]
28
+ rescue URI::Error => _e
29
+ nil
30
+ end
31
+
32
+ # displays profile infos
33
+ def self.info(profile)
34
+ _tool_owner, tool_name = profile_name("supermarket://#{profile}")
35
+ url = "#{SUPERMARKET_URL}/api/v1/tools/#{tool_name}"
36
+ _success, data = get(url, {})
29
37
  if !data.nil?
30
- info = JSON.parse(data)
38
+ JSON.parse(data)
31
39
  else
32
40
  {}
33
41
  end
42
+ rescue JSON::ParserError
43
+ {}
34
44
  end
35
45
 
36
- private
46
+ # compares a profile with the supermarket tool info
47
+ def self.same?(profile, supermarket_tool)
48
+ tool_owner, tool_name = profile_name(profile)
49
+ tool = "#{SUPERMARKET_URL}/api/v1/tools/#{tool_name}"
50
+ supermarket_tool['tool_owner'] == tool_owner && supermarket_tool['tool'] == tool
51
+ end
52
+
53
+ def self.find(profile)
54
+ profiles = Supermarket::API.profiles
55
+ if !profiles.empty?
56
+ index = profiles.index { |t| same?(profile, t) }
57
+ # return profile or nil
58
+ profiles[index] if !index.nil? && index >= 0
59
+ end
60
+ end
61
+
62
+ # verifies that a profile exists
63
+ def self.exist?(profile)
64
+ !find(profile).nil?
65
+ end
37
66
 
38
67
  def self.get(url, params)
39
68
  uri = URI.parse(url)
@@ -44,15 +73,10 @@ module Supermarket
44
73
 
45
74
  def self.send_request(uri, req)
46
75
  # send request
47
- res = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') {|http|
76
+ res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') {|http|
48
77
  http.request(req)
49
78
  }
50
- if res.is_a?(Net::HTTPSuccess)
51
- res.body
52
- else
53
- puts res.body
54
- nil
55
- end
79
+ [res.is_a?(Net::HTTPSuccess), res.body]
56
80
  end
57
81
  end
58
82
  end
@@ -6,17 +6,15 @@ module Supermarket
6
6
  class SupermarketCLI < Inspec::BaseCLI
7
7
  namespace 'supermarket'
8
8
 
9
- desc 'configure SERVER', 'Changes the default supermarket https://supermarket.chef.io/api/v1/'
10
- def configure(server)
11
- end
12
-
13
9
  desc 'profiles', 'list all available profiles in Chef Supermarket'
14
10
  def profiles
15
- # display profiles in format nathenharvey/tmp_compliance_profile
11
+ # display profiles in format user/profile
16
12
  supermarket_profiles = Supermarket::API.profiles
13
+
14
+ headline('Available profiles:')
17
15
  supermarket_profiles.each { |p|
18
- m = %r{^https://supermarket.chef.io/api/v1/tools/(?<slug>[\w-]+)(/)?$}.match(p['tool'])
19
- puts "#{p['tool_owner']}/#{m[:slug]}"
16
+ m = %r{^#{Supermarket::API.supermarket_url}/api/v1/tools/(?<slug>[\w-]+)(/)?$}.match(p['tool'])
17
+ li("#{p['tool_owner']}/#{m[:slug]}")
20
18
  }
21
19
  end
22
20
 
@@ -36,19 +34,16 @@ module Supermarket
36
34
 
37
35
  desc 'info profile', 'display profile details'
38
36
  def info(profile)
39
- # display profiles in format nathenharvey/tmp-compliance-profile
40
- # name: tmp_compliance_profile
41
- # owner: nathenharvey
42
- # description: ...
43
- info = Supermarket::API.info('tmp-compliance-profile')
44
- puts "name: #{info['slug']}"
45
- puts "owner: #{info['owner']} "
46
- puts "url: #{info['source_url']}"
47
- puts "\n"
48
- puts "description:\n#{info['description']}"
37
+ info = Supermarket::API.info(profile)
38
+
39
+ puts "#{mark_text('name: ')} #{info['slug']}"
40
+ puts "#{mark_text('owner:')} #{info['owner']}"
41
+ puts "#{mark_text('url: ')} #{info['source_url']}"
42
+ puts
43
+ puts "#{mark_text('description: ')} #{info['description']}"
49
44
  end
50
45
  end
51
46
 
52
47
  # register the subcommand to Inspec CLI registry
53
- Inspec::Plugins::CLI.register(Supermarket::SupermarketCLI, "supermarket", "supermarket SUBCOMMAND ...", "Supermarket commands", {})
48
+ Inspec::Plugins::CLI.add_subcommand(Supermarket::SupermarketCLI, 'supermarket', 'supermarket SUBCOMMAND ...', 'Supermarket commands', {})
54
49
  end
@@ -10,34 +10,17 @@ module Supermarket
10
10
  def handles?(profile)
11
11
  # check for local scheme supermarket://
12
12
  return unless URI(profile).scheme == 'supermarket'
13
- # emulate supermarket namespace
14
- profile == 'supermarket://nathenharvey/tmp-compliance-profile'
15
- rescue URI::Error => e
13
+
14
+ # verifies that the target e.g base/ssh exists
15
+ Supermarket::API.exist?(profile)
16
+ rescue URI::Error => _e
16
17
  false
17
18
  end
18
19
 
19
20
  # generates proper url
20
21
  def resolve(profile, opts = {})
21
- profile = get_profile_name(URI(target))
22
- target = build_target_url(profile)
23
- super(target, opts)
24
- end
25
-
26
- # extracts profile name from url
27
- def get_profile_name(uri)
28
- uri.host + uri.path
29
- end
30
-
31
- def build_target_url(target)
32
-
33
- # read details from json
34
- # extracts github url
35
-
36
- supermarket, slug = target.split('/')
37
- # search profile with slug
38
- # get github url
39
- # return github url
40
- "https://github.com/nathenharvey/tmp_compliance_profile/"
22
+ tool_info = Supermarket::API.find(profile)
23
+ super(tool_info['tool_source_url'], opts)
41
24
  end
42
25
 
43
26
  def to_s
@@ -11,6 +11,10 @@ module Inspec
11
11
  autoload :CLI, 'inspec/plugins/cli'
12
12
  end
13
13
 
14
+ # PLEASE NOTE: The Plugin system is an internal mechanism for connecting
15
+ # inspec components. Its API is currently considered in an alpha state
16
+ # and may change between minor version revisions. A stable plugin API will be
17
+ # released in the future.
14
18
  class PluginCtl
15
19
  extend Forwardable
16
20
 
@@ -44,7 +48,3 @@ module Inspec
44
48
  end
45
49
  end
46
50
  end
47
-
48
- # Load all plugins on startup
49
- ctl = Inspec::PluginCtl.new
50
- ctl.list.each { |x| ctl.load(x) }
@@ -6,12 +6,12 @@ module Inspec
6
6
  module Plugins
7
7
  # stores all CLI plugin, we expect those to the `Thor` subclasses
8
8
  class CLI
9
- def self.registry
10
- @registry ||= {}
9
+ def self.subcommands
10
+ @subcommands ||= {}
11
11
  end
12
12
 
13
- def self.register(klass, subcommand_name, usage, description, options = {})
14
- registry[subcommand_name] = {
13
+ def self.add_subcommand(klass, subcommand_name, usage, description, options = {})
14
+ subcommands[subcommand_name] = {
15
15
  klass: klass,
16
16
  subcommand_name: subcommand_name,
17
17
  usage: usage,