inspec 4.18.51 → 4.18.85

Sign up to get free protection for your applications and to get access to all the features.
Files changed (371) hide show
  1. checksums.yaml +4 -4
  2. data/inspec.gemspec +15 -37
  3. data/lib/resource_support/aws/aws_resource_mixin.rb +1 -1
  4. metadata +22 -709
  5. data/Gemfile +0 -61
  6. data/LICENSE +0 -14
  7. data/README.md +0 -474
  8. data/etc/deprecations.json +0 -125
  9. data/etc/plugin_filters.json +0 -45
  10. data/lib/bundles/README.md +0 -3
  11. data/lib/bundles/inspec-compliance/api.rb +0 -7
  12. data/lib/bundles/inspec-compliance/configuration.rb +0 -7
  13. data/lib/bundles/inspec-compliance/http.rb +0 -7
  14. data/lib/bundles/inspec-compliance/support.rb +0 -7
  15. data/lib/bundles/inspec-compliance/target.rb +0 -7
  16. data/lib/bundles/inspec-supermarket.rb +0 -9
  17. data/lib/bundles/inspec-supermarket/README.md +0 -45
  18. data/lib/bundles/inspec-supermarket/api.rb +0 -87
  19. data/lib/bundles/inspec-supermarket/cli.rb +0 -71
  20. data/lib/bundles/inspec-supermarket/target.rb +0 -31
  21. data/lib/inspec.rb +0 -30
  22. data/lib/inspec/archive/tar.rb +0 -25
  23. data/lib/inspec/archive/zip.rb +0 -15
  24. data/lib/inspec/backend.rb +0 -101
  25. data/lib/inspec/base_cli.rb +0 -318
  26. data/lib/inspec/cached_fetcher.rb +0 -65
  27. data/lib/inspec/cli.rb +0 -469
  28. data/lib/inspec/completions/bash.sh.erb +0 -45
  29. data/lib/inspec/completions/fish.sh.erb +0 -34
  30. data/lib/inspec/completions/zsh.sh.erb +0 -61
  31. data/lib/inspec/config.rb +0 -511
  32. data/lib/inspec/control_eval_context.rb +0 -248
  33. data/lib/inspec/dependencies/cache.rb +0 -74
  34. data/lib/inspec/dependencies/dependency_set.rb +0 -93
  35. data/lib/inspec/dependencies/lockfile.rb +0 -115
  36. data/lib/inspec/dependencies/requirement.rb +0 -135
  37. data/lib/inspec/dependencies/resolver.rb +0 -86
  38. data/lib/inspec/describe_base.rb +0 -53
  39. data/lib/inspec/dist.rb +0 -20
  40. data/lib/inspec/dsl.rb +0 -115
  41. data/lib/inspec/dsl_shared.rb +0 -32
  42. data/lib/inspec/env_printer.rb +0 -156
  43. data/lib/inspec/errors.rb +0 -18
  44. data/lib/inspec/exceptions.rb +0 -11
  45. data/lib/inspec/expect.rb +0 -42
  46. data/lib/inspec/fetcher.rb +0 -48
  47. data/lib/inspec/fetcher/git.rb +0 -211
  48. data/lib/inspec/fetcher/local.rb +0 -116
  49. data/lib/inspec/fetcher/mock.rb +0 -34
  50. data/lib/inspec/fetcher/url.rb +0 -281
  51. data/lib/inspec/file_provider.rb +0 -318
  52. data/lib/inspec/formatters.rb +0 -3
  53. data/lib/inspec/formatters/base.rb +0 -269
  54. data/lib/inspec/formatters/json_rspec.rb +0 -20
  55. data/lib/inspec/formatters/show_progress.rb +0 -12
  56. data/lib/inspec/globals.rb +0 -9
  57. data/lib/inspec/impact.rb +0 -36
  58. data/lib/inspec/input.rb +0 -421
  59. data/lib/inspec/input_dsl_helpers.rb +0 -26
  60. data/lib/inspec/input_registry.rb +0 -315
  61. data/lib/inspec/library_eval_context.rb +0 -55
  62. data/lib/inspec/log.rb +0 -7
  63. data/lib/inspec/metadata.rb +0 -253
  64. data/lib/inspec/method_source.rb +0 -20
  65. data/lib/inspec/objects.rb +0 -14
  66. data/lib/inspec/objects/control.rb +0 -85
  67. data/lib/inspec/objects/describe.rb +0 -106
  68. data/lib/inspec/objects/each_loop.rb +0 -41
  69. data/lib/inspec/objects/input.rb +0 -49
  70. data/lib/inspec/objects/list.rb +0 -15
  71. data/lib/inspec/objects/or_test.rb +0 -45
  72. data/lib/inspec/objects/ruby_helper.rb +0 -13
  73. data/lib/inspec/objects/tag.rb +0 -32
  74. data/lib/inspec/objects/test.rb +0 -94
  75. data/lib/inspec/objects/value.rb +0 -32
  76. data/lib/inspec/plugin/v1.rb +0 -2
  77. data/lib/inspec/plugin/v1/plugin_types/cli.rb +0 -22
  78. data/lib/inspec/plugin/v1/plugin_types/fetcher.rb +0 -83
  79. data/lib/inspec/plugin/v1/plugin_types/resource.rb +0 -176
  80. data/lib/inspec/plugin/v1/plugin_types/secret.rb +0 -11
  81. data/lib/inspec/plugin/v1/plugin_types/source_reader.rb +0 -36
  82. data/lib/inspec/plugin/v1/plugins.rb +0 -59
  83. data/lib/inspec/plugin/v1/registry.rb +0 -90
  84. data/lib/inspec/plugin/v2.rb +0 -46
  85. data/lib/inspec/plugin/v2/activator.rb +0 -40
  86. data/lib/inspec/plugin/v2/config_file.rb +0 -151
  87. data/lib/inspec/plugin/v2/filter.rb +0 -96
  88. data/lib/inspec/plugin/v2/installer.rb +0 -512
  89. data/lib/inspec/plugin/v2/loader.rb +0 -321
  90. data/lib/inspec/plugin/v2/plugin_base.rb +0 -112
  91. data/lib/inspec/plugin/v2/plugin_types/cli.rb +0 -49
  92. data/lib/inspec/plugin/v2/plugin_types/dsl.rb +0 -11
  93. data/lib/inspec/plugin/v2/plugin_types/input.rb +0 -34
  94. data/lib/inspec/plugin/v2/plugin_types/mock.rb +0 -12
  95. data/lib/inspec/plugin/v2/registry.rb +0 -98
  96. data/lib/inspec/plugin/v2/status.rb +0 -29
  97. data/lib/inspec/profile.rb +0 -658
  98. data/lib/inspec/profile_context.rb +0 -203
  99. data/lib/inspec/profile_vendor.rb +0 -84
  100. data/lib/inspec/reporters.rb +0 -73
  101. data/lib/inspec/reporters/automate.rb +0 -78
  102. data/lib/inspec/reporters/base.rb +0 -25
  103. data/lib/inspec/reporters/cli.rb +0 -370
  104. data/lib/inspec/reporters/json.rb +0 -113
  105. data/lib/inspec/reporters/json_automate.rb +0 -80
  106. data/lib/inspec/reporters/json_min.rb +0 -48
  107. data/lib/inspec/reporters/junit.rb +0 -77
  108. data/lib/inspec/reporters/yaml.rb +0 -20
  109. data/lib/inspec/require_loader.rb +0 -29
  110. data/lib/inspec/resource.rb +0 -114
  111. data/lib/inspec/resources.rb +0 -130
  112. data/lib/inspec/resources/aide_conf.rb +0 -153
  113. data/lib/inspec/resources/apache.rb +0 -47
  114. data/lib/inspec/resources/apache_conf.rb +0 -156
  115. data/lib/inspec/resources/apt.rb +0 -151
  116. data/lib/inspec/resources/audit_policy.rb +0 -64
  117. data/lib/inspec/resources/auditd.rb +0 -251
  118. data/lib/inspec/resources/auditd_conf.rb +0 -45
  119. data/lib/inspec/resources/bash.rb +0 -33
  120. data/lib/inspec/resources/bond.rb +0 -70
  121. data/lib/inspec/resources/bridge.rb +0 -125
  122. data/lib/inspec/resources/bsd_service.rb +0 -2
  123. data/lib/inspec/resources/chocolatey_package.rb +0 -82
  124. data/lib/inspec/resources/command.rb +0 -91
  125. data/lib/inspec/resources/cpan.rb +0 -58
  126. data/lib/inspec/resources/cran.rb +0 -64
  127. data/lib/inspec/resources/crontab.rb +0 -173
  128. data/lib/inspec/resources/csv.rb +0 -56
  129. data/lib/inspec/resources/dh_params.rb +0 -83
  130. data/lib/inspec/resources/directory.rb +0 -23
  131. data/lib/inspec/resources/docker.rb +0 -274
  132. data/lib/inspec/resources/docker_container.rb +0 -91
  133. data/lib/inspec/resources/docker_image.rb +0 -84
  134. data/lib/inspec/resources/docker_object.rb +0 -52
  135. data/lib/inspec/resources/docker_plugin.rb +0 -64
  136. data/lib/inspec/resources/docker_service.rb +0 -91
  137. data/lib/inspec/resources/elasticsearch.rb +0 -165
  138. data/lib/inspec/resources/etc_fstab.rb +0 -96
  139. data/lib/inspec/resources/etc_group.rb +0 -157
  140. data/lib/inspec/resources/etc_hosts.rb +0 -68
  141. data/lib/inspec/resources/etc_hosts_allow.rb +0 -2
  142. data/lib/inspec/resources/etc_hosts_allow_deny.rb +0 -114
  143. data/lib/inspec/resources/etc_hosts_deny.rb +0 -2
  144. data/lib/inspec/resources/file.rb +0 -339
  145. data/lib/inspec/resources/filesystem.rb +0 -139
  146. data/lib/inspec/resources/firewalld.rb +0 -148
  147. data/lib/inspec/resources/gem.rb +0 -80
  148. data/lib/inspec/resources/group.rb +0 -2
  149. data/lib/inspec/resources/groups.rb +0 -241
  150. data/lib/inspec/resources/grub_conf.rb +0 -230
  151. data/lib/inspec/resources/host.rb +0 -310
  152. data/lib/inspec/resources/http.rb +0 -275
  153. data/lib/inspec/resources/iis_app.rb +0 -101
  154. data/lib/inspec/resources/iis_app_pool.rb +0 -127
  155. data/lib/inspec/resources/iis_site.rb +0 -148
  156. data/lib/inspec/resources/iis_website.rb +0 -2
  157. data/lib/inspec/resources/inetd_conf.rb +0 -53
  158. data/lib/inspec/resources/ini.rb +0 -28
  159. data/lib/inspec/resources/interface.rb +0 -204
  160. data/lib/inspec/resources/ip6tables.rb +0 -79
  161. data/lib/inspec/resources/iptables.rb +0 -80
  162. data/lib/inspec/resources/json.rb +0 -116
  163. data/lib/inspec/resources/kernel_module.rb +0 -106
  164. data/lib/inspec/resources/kernel_parameter.rb +0 -54
  165. data/lib/inspec/resources/key_rsa.rb +0 -66
  166. data/lib/inspec/resources/ksh.rb +0 -33
  167. data/lib/inspec/resources/launchd_service.rb +0 -2
  168. data/lib/inspec/resources/limits_conf.rb +0 -45
  169. data/lib/inspec/resources/linux_kernel_parameter.rb +0 -2
  170. data/lib/inspec/resources/login_defs.rb +0 -56
  171. data/lib/inspec/resources/mount.rb +0 -88
  172. data/lib/inspec/resources/mssql_session.rb +0 -117
  173. data/lib/inspec/resources/mysql.rb +0 -81
  174. data/lib/inspec/resources/mysql_conf.rb +0 -128
  175. data/lib/inspec/resources/mysql_session.rb +0 -88
  176. data/lib/inspec/resources/nginx.rb +0 -96
  177. data/lib/inspec/resources/nginx_conf.rb +0 -232
  178. data/lib/inspec/resources/noop.rb +0 -9
  179. data/lib/inspec/resources/npm.rb +0 -68
  180. data/lib/inspec/resources/ntp_conf.rb +0 -51
  181. data/lib/inspec/resources/oneget.rb +0 -71
  182. data/lib/inspec/resources/oracledb_session.rb +0 -149
  183. data/lib/inspec/resources/os.rb +0 -34
  184. data/lib/inspec/resources/os_env.rb +0 -86
  185. data/lib/inspec/resources/package.rb +0 -391
  186. data/lib/inspec/resources/packages.rb +0 -111
  187. data/lib/inspec/resources/parse_config.rb +0 -112
  188. data/lib/inspec/resources/parse_config_file.rb +0 -2
  189. data/lib/inspec/resources/passwd.rb +0 -73
  190. data/lib/inspec/resources/pip.rb +0 -132
  191. data/lib/inspec/resources/platform.rb +0 -112
  192. data/lib/inspec/resources/port.rb +0 -791
  193. data/lib/inspec/resources/postfix_conf.rb +0 -35
  194. data/lib/inspec/resources/postgres.rb +0 -152
  195. data/lib/inspec/resources/postgres_conf.rb +0 -116
  196. data/lib/inspec/resources/postgres_hba_conf.rb +0 -86
  197. data/lib/inspec/resources/postgres_ident_conf.rb +0 -75
  198. data/lib/inspec/resources/postgres_session.rb +0 -70
  199. data/lib/inspec/resources/powershell.rb +0 -67
  200. data/lib/inspec/resources/ppa.rb +0 -2
  201. data/lib/inspec/resources/processes.rb +0 -219
  202. data/lib/inspec/resources/rabbitmq_conf.rb +0 -2
  203. data/lib/inspec/resources/rabbitmq_config.rb +0 -52
  204. data/lib/inspec/resources/registry_key.rb +0 -296
  205. data/lib/inspec/resources/runit_service.rb +0 -2
  206. data/lib/inspec/resources/script.rb +0 -1
  207. data/lib/inspec/resources/security_identifier.rb +0 -91
  208. data/lib/inspec/resources/security_policy.rb +0 -182
  209. data/lib/inspec/resources/service.rb +0 -820
  210. data/lib/inspec/resources/shadow.rb +0 -150
  211. data/lib/inspec/resources/ssh_config.rb +0 -98
  212. data/lib/inspec/resources/sshd_config.rb +0 -2
  213. data/lib/inspec/resources/ssl.rb +0 -99
  214. data/lib/inspec/resources/sys_info.rb +0 -119
  215. data/lib/inspec/resources/systemd_service.rb +0 -2
  216. data/lib/inspec/resources/sysv_service.rb +0 -2
  217. data/lib/inspec/resources/toml.rb +0 -30
  218. data/lib/inspec/resources/upstart_service.rb +0 -2
  219. data/lib/inspec/resources/user.rb +0 -1
  220. data/lib/inspec/resources/users.rb +0 -742
  221. data/lib/inspec/resources/vbscript.rb +0 -67
  222. data/lib/inspec/resources/virtualization.rb +0 -255
  223. data/lib/inspec/resources/windows_feature.rb +0 -126
  224. data/lib/inspec/resources/windows_hotfix.rb +0 -37
  225. data/lib/inspec/resources/windows_registry_key.rb +0 -2
  226. data/lib/inspec/resources/windows_task.rb +0 -112
  227. data/lib/inspec/resources/wmi.rb +0 -109
  228. data/lib/inspec/resources/x509_certificate.rb +0 -143
  229. data/lib/inspec/resources/xinetd_conf.rb +0 -103
  230. data/lib/inspec/resources/xml.rb +0 -48
  231. data/lib/inspec/resources/yaml.rb +0 -42
  232. data/lib/inspec/resources/yum.rb +0 -162
  233. data/lib/inspec/resources/zfs_dataset.rb +0 -62
  234. data/lib/inspec/resources/zfs_pool.rb +0 -50
  235. data/lib/inspec/rspec_extensions.rb +0 -116
  236. data/lib/inspec/rule.rb +0 -389
  237. data/lib/inspec/runner.rb +0 -333
  238. data/lib/inspec/runner_mock.rb +0 -37
  239. data/lib/inspec/runner_rspec.rb +0 -184
  240. data/lib/inspec/runtime_profile.rb +0 -23
  241. data/lib/inspec/schema.rb +0 -245
  242. data/lib/inspec/secrets.rb +0 -15
  243. data/lib/inspec/secrets/yaml.rb +0 -29
  244. data/lib/inspec/shell.rb +0 -211
  245. data/lib/inspec/shell_detector.rb +0 -89
  246. data/lib/inspec/source_reader.rb +0 -26
  247. data/lib/inspec/ui.rb +0 -213
  248. data/lib/inspec/ui_table_helper.rb +0 -12
  249. data/lib/inspec/utils/command_wrapper.rb +0 -23
  250. data/lib/inspec/utils/convert.rb +0 -8
  251. data/lib/inspec/utils/database_helpers.rb +0 -75
  252. data/lib/inspec/utils/deprecation.rb +0 -6
  253. data/lib/inspec/utils/deprecation/config_file.rb +0 -109
  254. data/lib/inspec/utils/deprecation/deprecator.rb +0 -118
  255. data/lib/inspec/utils/deprecation/errors.rb +0 -14
  256. data/lib/inspec/utils/deprecation/global_method.rb +0 -9
  257. data/lib/inspec/utils/enumerable_delegation.rb +0 -7
  258. data/lib/inspec/utils/erlang_parser.rb +0 -190
  259. data/lib/inspec/utils/file_reader.rb +0 -24
  260. data/lib/inspec/utils/filter.rb +0 -461
  261. data/lib/inspec/utils/filter_array.rb +0 -25
  262. data/lib/inspec/utils/find_files.rb +0 -44
  263. data/lib/inspec/utils/hash.rb +0 -37
  264. data/lib/inspec/utils/json_log.rb +0 -15
  265. data/lib/inspec/utils/modulator.rb +0 -9
  266. data/lib/inspec/utils/nginx_parser.rb +0 -101
  267. data/lib/inspec/utils/object_traversal.rb +0 -47
  268. data/lib/inspec/utils/parser.rb +0 -277
  269. data/lib/inspec/utils/pkey_reader.rb +0 -17
  270. data/lib/inspec/utils/simpleconfig.rb +0 -121
  271. data/lib/inspec/utils/spdx.rb +0 -10
  272. data/lib/inspec/utils/spdx.txt +0 -383
  273. data/lib/inspec/utils/telemetry.rb +0 -3
  274. data/lib/inspec/utils/telemetry/collector.rb +0 -81
  275. data/lib/inspec/utils/telemetry/data_series.rb +0 -44
  276. data/lib/inspec/utils/telemetry/global_methods.rb +0 -22
  277. data/lib/inspec/version.rb +0 -3
  278. data/lib/matchers/matchers.rb +0 -341
  279. data/lib/plugins/README.md +0 -16
  280. data/lib/plugins/inspec-artifact/lib/inspec-artifact.rb +0 -12
  281. data/lib/plugins/inspec-artifact/lib/inspec-artifact/base.rb +0 -170
  282. data/lib/plugins/inspec-artifact/lib/inspec-artifact/cli.rb +0 -116
  283. data/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb +0 -50
  284. data/lib/plugins/inspec-compliance/README.md +0 -207
  285. data/lib/plugins/inspec-compliance/lib/inspec-compliance.rb +0 -12
  286. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +0 -362
  287. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb +0 -198
  288. data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +0 -269
  289. data/lib/plugins/inspec-compliance/lib/inspec-compliance/configuration.rb +0 -103
  290. data/lib/plugins/inspec-compliance/lib/inspec-compliance/http.rb +0 -117
  291. data/lib/plugins/inspec-compliance/lib/inspec-compliance/images/cc-token.png +0 -0
  292. data/lib/plugins/inspec-compliance/lib/inspec-compliance/support.rb +0 -34
  293. data/lib/plugins/inspec-compliance/lib/inspec-compliance/target.rb +0 -146
  294. data/lib/plugins/inspec-compliance/test/functional/inspec_compliance_test.rb +0 -53
  295. data/lib/plugins/inspec-compliance/test/integration/default/cli.rb +0 -91
  296. data/lib/plugins/inspec-compliance/test/unit/api/login_test.rb +0 -190
  297. data/lib/plugins/inspec-compliance/test/unit/api_test.rb +0 -386
  298. data/lib/plugins/inspec-compliance/test/unit/target_test.rb +0 -155
  299. data/lib/plugins/inspec-habitat/Berksfile +0 -5
  300. data/lib/plugins/inspec-habitat/README.md +0 -150
  301. data/lib/plugins/inspec-habitat/kitchen.yml +0 -28
  302. data/lib/plugins/inspec-habitat/lib/inspec-habitat.rb +0 -11
  303. data/lib/plugins/inspec-habitat/lib/inspec-habitat/cli.rb +0 -41
  304. data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +0 -265
  305. data/lib/plugins/inspec-habitat/templates/habitat/plan.sh.erb +0 -6
  306. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/Berksfile +0 -2
  307. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/README.md +0 -3
  308. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/files/hab_setup.exp +0 -28
  309. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/metadata.rb +0 -9
  310. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/recipes/default.rb +0 -61
  311. data/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb +0 -34
  312. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/README.md +0 -3
  313. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/controls/inspec_habitat.rb +0 -40
  314. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/inspec.yml +0 -10
  315. data/lib/plugins/inspec-habitat/test/support/example_profile/README.md +0 -3
  316. data/lib/plugins/inspec-habitat/test/support/example_profile/controls/example.rb +0 -7
  317. data/lib/plugins/inspec-habitat/test/support/example_profile/inspec.yml +0 -10
  318. data/lib/plugins/inspec-habitat/test/unit/profile_test.rb +0 -242
  319. data/lib/plugins/inspec-init/README.md +0 -31
  320. data/lib/plugins/inspec-init/lib/inspec-init.rb +0 -12
  321. data/lib/plugins/inspec-init/lib/inspec-init/cli.rb +0 -15
  322. data/lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb +0 -243
  323. data/lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb +0 -47
  324. data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +0 -97
  325. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Gemfile +0 -11
  326. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/LICENSE +0 -2
  327. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/README.md +0 -28
  328. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Rakefile +0 -40
  329. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template.rb +0 -14
  330. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/cli_command.rb +0 -62
  331. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.rb +0 -53
  332. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/version.rb +0 -8
  333. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/fixtures/README.md +0 -24
  334. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/README.md +0 -12
  335. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/inspec_plugin_template_test.rb +0 -110
  336. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/helper.rb +0 -24
  337. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/README.md +0 -17
  338. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/cli_args_test.rb +0 -67
  339. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/plugin_def_test.rb +0 -51
  340. data/lib/plugins/inspec-init/templates/profiles/aws/libraries/.gitkeep +0 -0
  341. data/lib/plugins/inspec-init/templates/profiles/azure/libraries/.gitkeep +0 -0
  342. data/lib/plugins/inspec-init/templates/profiles/gcp/libraries/.gitkeep +0 -0
  343. data/lib/plugins/inspec-init/templates/profiles/os/README.md +0 -3
  344. data/lib/plugins/inspec-init/templates/profiles/os/controls/example.rb +0 -18
  345. data/lib/plugins/inspec-init/templates/profiles/os/inspec.yml +0 -10
  346. data/lib/plugins/inspec-init/templates/profiles/os/libraries/.gitkeep +0 -0
  347. data/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb +0 -184
  348. data/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb +0 -121
  349. data/lib/plugins/inspec-plugin-manager-cli/README.md +0 -6
  350. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb +0 -17
  351. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +0 -518
  352. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/plugin.rb +0 -12
  353. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/config_dirs/empty/.gitkeep +0 -0
  354. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette.rb +0 -2
  355. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette/.gitkeep +0 -0
  356. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-wrong-structure/.gitkeep +0 -0
  357. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name.rb +0 -1
  358. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name/.gitkeep +0 -0
  359. data/lib/plugins/inspec-plugin-manager-cli/test/functional/help_test.rb +0 -23
  360. data/lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb +0 -62
  361. data/lib/plugins/inspec-plugin-manager-cli/test/functional/install_test.rb +0 -368
  362. data/lib/plugins/inspec-plugin-manager-cli/test/functional/list_test.rb +0 -101
  363. data/lib/plugins/inspec-plugin-manager-cli/test/functional/search_test.rb +0 -129
  364. data/lib/plugins/inspec-plugin-manager-cli/test/functional/uninstall_test.rb +0 -63
  365. data/lib/plugins/inspec-plugin-manager-cli/test/functional/update_test.rb +0 -84
  366. data/lib/plugins/inspec-plugin-manager-cli/test/unit/cli_args_test.rb +0 -77
  367. data/lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb +0 -39
  368. data/lib/plugins/shared/core_plugin_test_helper.rb +0 -153
  369. data/lib/plugins/things-for-train-integration.rb +0 -14
  370. data/lib/source_readers/flat.rb +0 -36
  371. data/lib/source_readers/inspec.rb +0 -66
@@ -1,2 +0,0 @@
1
- # This is just here to make the dynamic loader happy.
2
- require "inspec/resources/service"
@@ -1,2 +0,0 @@
1
- # This is just here to make the dynamic loader happy.
2
- require "inspec/resources/service"
@@ -1,30 +0,0 @@
1
- require "tomlrb"
2
- require "inspec/resources/json"
3
-
4
- module Inspec::Resources
5
- class TomlConfig < JsonConfig
6
- name "toml"
7
- desc "Use the toml InSpec resource to test configuration data in a TOML file"
8
- example <<~EXAMPLE
9
- describe toml('default.toml') do
10
- its('key') { should eq('value') }
11
- its (['arr', 1]) { should eq 2 }
12
- its (['mytable', 'key1']) { should eq 'value1' }
13
- end
14
- EXAMPLE
15
-
16
- def parse(content)
17
- Tomlrb.parse(content)
18
- rescue => e
19
- raise Inspec::Exceptions::ResourceFailed, "Unable to parse TOML: #{e.message}"
20
- end
21
-
22
- private
23
-
24
- # used by JsonConfig to build up a full to_s method
25
- # based on whether a file path, content, or command was supplied.
26
- def resource_base_name
27
- "TOML"
28
- end
29
- end
30
- end
@@ -1,2 +0,0 @@
1
- # This is just here to make the dynamic loader happy.
2
- require "inspec/resources/service"
@@ -1 +0,0 @@
1
- require "inspec/resources/users"
@@ -1,742 +0,0 @@
1
- require "inspec/utils/parser"
2
- require "inspec/utils/convert"
3
- require "inspec/utils/filter"
4
- require "inspec/utils/simpleconfig"
5
- require "inspec/resources/powershell"
6
- require "date"
7
-
8
- module Inspec::Resources
9
- # This file contains two resources, the `user` and `users` resource.
10
- # The `user` resource is optimized for requests that verify specific users
11
- # that you know upfront for testing. If you need to query all users or search
12
- # specific users with certain properties, use the `users` resource.
13
- module UserManagementSelector
14
- # select user provider based on the operating system
15
- # returns nil, if no user manager was found for the operating system
16
- def select_user_manager(os)
17
- if os.linux?
18
- LinuxUser.new(inspec)
19
- elsif os.windows?
20
- WindowsUser.new(inspec)
21
- elsif ["darwin"].include?(os[:family])
22
- DarwinUser.new(inspec)
23
- elsif ["freebsd"].include?(os[:family])
24
- FreeBSDUser.new(inspec)
25
- elsif ["aix"].include?(os[:family])
26
- AixUser.new(inspec)
27
- elsif os.solaris?
28
- SolarisUser.new(inspec)
29
- elsif ["hpux"].include?(os[:family])
30
- HpuxUser.new(inspec)
31
- end
32
- end
33
- end
34
-
35
- # The InSpec users resources looksup all local users available on a system.
36
- # TODO: the current version of the users resource will use eg. /etc/passwd
37
- # on Linux to parse all usernames. Therefore the resource may not return
38
- # users managed on other systems like LDAP/ActiveDirectory. Please open
39
- # a feature request at https://github.com/chef/inspec if you need that
40
- # functionality
41
- #
42
- # This resource allows complex filter mechanisms
43
- #
44
- # describe users.where(uid: 0).entries do
45
- # it { should eq ['root'] }
46
- # its('uids') { should eq [1234] }
47
- # its('gids') { should eq [1234] }
48
- # end
49
- #
50
- # describe users.where { uid =~ /S\-1\-5\-21\-\d+\-\d+\-\d+\-500/ } do
51
- # it { should exist }
52
- # end
53
- class Users < Inspec.resource(1)
54
- include UserManagementSelector
55
-
56
- name "users"
57
- supports platform: "unix"
58
- supports platform: "windows"
59
- desc "Use the users InSpec audit resource to test local user profiles. Users can be filtered by groups to which they belong, the frequency of required password changes, the directory paths to home and shell."
60
- example <<~EXAMPLE
61
- describe users.where { uid == 0 }.entries do
62
- it { should eq ['root'] }
63
- its('uids') { should eq [1234] }
64
- its('gids') { should eq [1234] }
65
- end
66
- EXAMPLE
67
- def initialize
68
- # select user provider
69
- @user_provider = select_user_manager(inspec.os)
70
- return skip_resource "The `users` resource is not supported on your OS yet." if @user_provider.nil?
71
- end
72
-
73
- filter = FilterTable.create
74
- filter.register_custom_matcher(:exists?) { |x| !x.entries.empty? }
75
- filter.register_column(:usernames, field: :username)
76
- .register_column(:uids, field: :uid)
77
- .register_column(:gids, field: :gid)
78
- .register_column(:groupnames, field: :groupname)
79
- .register_column(:groups, field: :groups)
80
- .register_column(:homes, field: :home)
81
- .register_column(:shells, field: :shell)
82
- .register_column(:mindays, field: :mindays)
83
- .register_column(:maxdays, field: :maxdays)
84
- .register_column(:warndays, field: :warndays)
85
- .register_column(:disabled, field: :disabled)
86
- .register_custom_matcher(:disabled?) { |x| x.where { disabled == false }.entries.empty? }
87
- .register_custom_matcher(:enabled?) { |x| x.where { disabled == true }.entries.empty? }
88
- filter.install_filter_methods_on_resource(self, :collect_user_details)
89
-
90
- def to_s
91
- "Users"
92
- end
93
-
94
- private
95
-
96
- # method to get all available users
97
- def list_users
98
- @username_cache ||= @user_provider.list_users unless @user_provider.nil?
99
- end
100
-
101
- # collects information about every user
102
- def collect_user_details
103
- @users_cache ||= @user_provider.collect_user_details unless @user_provider.nil?
104
- end
105
- end
106
-
107
- # The `user` resource handles the special case where only one resource is required
108
- #
109
- # describe user('root') do
110
- # it { should exist }
111
- # its('uid') { should eq 0 }
112
- # its('gid') { should eq 0 }
113
- # its('group') { should eq 'root' }
114
- # its('groups') { should eq ['root', 'wheel']}
115
- # its('home') { should eq '/root' }
116
- # its('shell') { should eq '/bin/bash' }
117
- # its('mindays') { should eq 0 }
118
- # its('maxdays') { should eq 99 }
119
- # its('warndays') { should eq 5 }
120
- # its('passwordage') { should be >= 0 }
121
- # its('maxbadpasswords') { should eq nil } // not yet supported on linux
122
- # its('badpasswordattempts') { should eq 0 }
123
- # end
124
- # describe user('Administrator') do
125
- # it { should exist }
126
- # its('uid') { should eq "S-1-5-21-1759981009-4135989804-1844563890-500" }
127
- # its('gid') { should eq nil } // not supported on Windows
128
- # its('group') { should eq nil } // not supported on Windows
129
- # its('groups') { should eq ['Administrators', 'Users']}
130
- # its('home') { should eq '' }
131
- # its('shell') { should eq nil } // not supported on Windows
132
- # its('mindays') { should eq 0 }
133
- # its('maxdays') { should eq 42 }
134
- # its('warndays') { should eq nil }
135
- # its('passwordage') { should eq 355 }
136
- # its('maxbadpasswords') { should eq 0 }
137
- # its('badpasswordattempts') { should eq 0 }
138
- # end
139
- #
140
- # The following Serverspec matchers are deprecated in favor for direct value access
141
- #
142
- # describe user('root') do
143
- # it { should belong_to_group 'root' }
144
- # it { should have_uid 0 }
145
- # it { should have_home_directory '/root' }
146
- # it { should have_login_shell '/bin/bash' }
147
- # its('minimum_days_between_password_change') { should eq 0 }
148
- # its('maximum_days_between_password_change') { should eq 99 }
149
- # end
150
- #
151
- # ServerSpec tests that are not supported:
152
- #
153
- # describe user('root') do
154
- # it { should have_authorized_key 'ssh-rsa ADg54...3434 user@example.local' }
155
- # its(:encrypted_password) { should eq 1234 }
156
- # end
157
- class User < Inspec.resource(1)
158
- include UserManagementSelector
159
- name "user"
160
- supports platform: "unix"
161
- supports platform: "windows"
162
- desc "Use the user InSpec audit resource to test user profiles, including the groups to which they belong, the frequency of required password changes, the directory paths to home and shell."
163
- example <<~EXAMPLE
164
- describe user('root') do
165
- it { should exist }
166
- its('uid') { should eq 1234 }
167
- its('gid') { should eq 1234 }
168
- end
169
- EXAMPLE
170
- def initialize(username = nil)
171
- @username = username
172
- # select user provider
173
- @user_provider = select_user_manager(inspec.os)
174
- return skip_resource "The `user` resource is not supported on your OS yet." if @user_provider.nil?
175
- end
176
-
177
- def exists?
178
- !identity.nil? && !identity[:username].nil?
179
- end
180
-
181
- def disabled?
182
- identity[:disabled] == true unless identity.nil?
183
- end
184
-
185
- def enabled?
186
- identity[:disabled] == false unless identity.nil?
187
- end
188
-
189
- def username
190
- identity[:username] unless identity.nil?
191
- end
192
-
193
- def uid
194
- identity[:uid] unless identity.nil?
195
- end
196
-
197
- def gid
198
- identity[:gid] unless identity.nil?
199
- end
200
-
201
- def groupname
202
- identity[:groupname] unless identity.nil?
203
- end
204
- alias group groupname
205
-
206
- def groups
207
- identity[:groups] unless identity.nil?
208
- end
209
-
210
- def home
211
- meta_info[:home] unless meta_info.nil?
212
- end
213
-
214
- def shell
215
- meta_info[:shell] unless meta_info.nil?
216
- end
217
-
218
- def domain
219
- meta_info[:domain] unless meta_info.nil?
220
- end
221
-
222
- def userflags
223
- meta_info[:userflags] unless meta_info.nil?
224
- end
225
-
226
- def lastlogin
227
- meta_info[:lastlogin] unless meta_info.nil?
228
- end
229
-
230
- # returns the minimum days between password changes
231
- def mindays
232
- credentials[:mindays] unless credentials.nil?
233
- end
234
-
235
- # returns the maximum days between password changes
236
- def maxdays
237
- credentials[:maxdays] unless credentials.nil?
238
- end
239
-
240
- # returns the days for password change warning
241
- def warndays
242
- credentials[:warndays] unless credentials.nil?
243
- end
244
-
245
- def badpasswordattempts
246
- credentials[:badpasswordattempts] unless credentials.nil?
247
- end
248
-
249
- def maxbadpasswords
250
- credentials[:maxbadpasswords] unless credentials.nil?
251
- end
252
-
253
- def passwordage
254
- credentials[:passwordage] unless credentials.nil?
255
- end
256
-
257
- # implement 'mindays' method to be compatible with serverspec
258
- def minimum_days_between_password_change
259
- Inspec.deprecate(:resource_user_serverspec_compat, "The user resource `minimum_days_between_password_change` property is deprecated. Please use `mindays`.")
260
- mindays
261
- end
262
-
263
- # implement 'maxdays' method to be compatible with serverspec
264
- def maximum_days_between_password_change
265
- Inspec.deprecate(:resource_user_serverspec_compat, "The user resource `maximum_days_between_password_change` property is deprecated. Please use `maxdays`.")
266
- maxdays
267
- end
268
-
269
- # implements rspec has matcher, to be compatible with serverspec
270
- # @see: https://github.com/rspec/rspec-expectations/blob/master/lib/rspec/matchers/built_in/has.rb
271
- def has_uid?(compare_uid)
272
- Inspec.deprecate(:resource_user_serverspec_compat, "The user resource `has_uid?` matcher is deprecated.")
273
- uid == compare_uid
274
- end
275
-
276
- def has_home_directory?(compare_home)
277
- Inspec.deprecate(:resource_user_serverspec_compat, "The user resource `has_home_directory?` matcher is deprecated. Please use `its('home')`.")
278
- home == compare_home
279
- end
280
-
281
- def has_login_shell?(compare_shell)
282
- Inspec.deprecate(:resource_user_serverspec_compat, "The user resource `has_login_shell?` matcher is deprecated. Please use `its('shell')`.")
283
- shell == compare_shell
284
- end
285
-
286
- def has_authorized_key?(_compare_key)
287
- Inspec.deprecate(:resource_user_serverspec_compat, "The user resource `has_authorized_key?` matcher is deprecated. There is no currently implemented alternative")
288
- raise NotImplementedError
289
- end
290
-
291
- def to_s
292
- "User #{@username}"
293
- end
294
-
295
- private
296
-
297
- # returns the iden
298
- def identity
299
- return @id_cache if defined?(@id_cache)
300
-
301
- @id_cache = @user_provider.identity(@username) unless @user_provider.nil?
302
- end
303
-
304
- def meta_info
305
- return @meta_cache if defined?(@meta_cache)
306
-
307
- @meta_cache = @user_provider.meta_info(@username) unless @user_provider.nil?
308
- end
309
-
310
- def credentials
311
- return @cred_cache if defined?(@cred_cache)
312
-
313
- @cred_cache = @user_provider.credentials(@username) unless @user_provider.nil?
314
- end
315
- end
316
-
317
- # This is an abstract class that every user provoider has to implement.
318
- # A user provider implements a system abstracts and helps the InSpec resource
319
- # hand-over system specific behavior to those providers
320
- class UserInfo
321
- include Converter
322
-
323
- attr_reader :inspec
324
- def initialize(inspec)
325
- @inspec = inspec
326
- end
327
-
328
- # returns a hash with user-specific values:
329
- # {
330
- # uid: '',
331
- # user: '',
332
- # gid: '',
333
- # group: '',
334
- # groups: '',
335
- # }
336
- def identity(_username)
337
- raise "user provider must implement the `identity` method"
338
- end
339
-
340
- # returns optional information about a user, eg shell
341
- def meta_info(_username)
342
- nil
343
- end
344
-
345
- # returns a hash with meta-data about user credentials
346
- # {
347
- # mindays: 1,
348
- # maxdays: 1,
349
- # warndays: 1,
350
- # }
351
- # this method is optional and may not be implemented by each provider
352
- def credentials(_username)
353
- nil
354
- end
355
-
356
- # returns an array with users
357
- def list_users
358
- raise "user provider must implement the `list_users` method"
359
- end
360
-
361
- # retuns all aspects of the user as one hash
362
- def user_details(username)
363
- item = {}
364
- id = identity(username)
365
- item.merge!(id) unless id.nil?
366
- meta = meta_info(username)
367
- item.merge!(meta) unless meta.nil?
368
- cred = credentials(username)
369
- item.merge!(cred) unless cred.nil?
370
- item
371
- end
372
-
373
- # returns the full information list for a user
374
- def collect_user_details
375
- list_users.map do |username|
376
- user_details(username.chomp)
377
- end
378
- end
379
- end
380
-
381
- # implements generic unix id handling
382
- class UnixUser < UserInfo
383
- attr_reader :inspec, :id_cmd, :list_users_cmd
384
- def initialize(inspec)
385
- @inspec = inspec
386
- @id_cmd ||= "id"
387
- @list_users_cmd ||= 'cut -d: -f1 /etc/passwd | grep -v "^#"'
388
- super
389
- end
390
-
391
- # returns a list of all local users on a system
392
- def list_users
393
- cmd = inspec.command(list_users_cmd)
394
- return [] if cmd.exit_status != 0
395
-
396
- cmd.stdout.chomp.lines
397
- end
398
-
399
- # parse one id entry like '0(wheel)''
400
- def parse_value(line)
401
- SimpleConfig.new(
402
- line,
403
- line_separator: ",",
404
- assignment_regex: /^\s*([^\(]*?)\s*\(\s*(.*?)\)*$/,
405
- group_re: nil,
406
- multiple_values: false
407
- ).params
408
- end
409
-
410
- # extracts the identity
411
- def identity(username)
412
- cmd = inspec.command("#{id_cmd} #{username}")
413
- return nil if cmd.exit_status != 0
414
-
415
- # parse words
416
- params = SimpleConfig.new(
417
- parse_id_entries(cmd.stdout.chomp),
418
- assignment_regex: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/,
419
- group_re: nil,
420
- multiple_values: false
421
- ).params
422
-
423
- {
424
- uid: convert_to_i(parse_value(params["uid"]).keys[0]),
425
- username: parse_value(params["uid"]).values[0],
426
- gid: convert_to_i(parse_value(params["gid"]).keys[0]),
427
- groupname: parse_value(params["gid"]).values[0],
428
- groups: parse_value(params["groups"]).values,
429
- }
430
- end
431
-
432
- # splits the results of id into seperate lines
433
- def parse_id_entries(raw)
434
- data = []
435
- until (index = raw.index(/\)\s{1}/)).nil?
436
- data.push(raw[0, index + 1]) # inclue closing )
437
- raw = raw[index + 2, raw.length - index - 2]
438
- end
439
- data.push(raw) unless raw.nil?
440
- data.join("\n")
441
- end
442
- end
443
-
444
- class LinuxUser < UnixUser
445
- include PasswdParser
446
- include CommentParser
447
-
448
- def meta_info(username)
449
- cmd = inspec.command("getent passwd #{username}")
450
- return nil if cmd.exit_status != 0
451
-
452
- # returns: root:x:0:0:root:/root:/bin/bash
453
- passwd = parse_passwd_line(cmd.stdout.chomp)
454
- {
455
- home: passwd["home"],
456
- shell: passwd["shell"],
457
- }
458
- end
459
-
460
- def credentials(username)
461
- cmd = inspec.command("chage -l #{username}")
462
- return nil if cmd.exit_status != 0
463
-
464
- params = SimpleConfig.new(
465
- cmd.stdout.chomp,
466
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
467
- group_re: nil,
468
- multiple_values: false
469
- ).params
470
-
471
- last_change = params["Last password change"]
472
- dparse = Date.parse "#{last_change}" rescue nil
473
- dayslastset = (Date.today - dparse).to_i if dparse
474
- cmd = inspec.command("lastb -w -a | grep #{username} | wc -l")
475
- badpasswordattempts = convert_to_i(cmd.stdout.chomp) if cmd.exit_status == 0
476
-
477
- {
478
- mindays: convert_to_i(params["Minimum number of days between password change"]),
479
- maxdays: convert_to_i(params["Maximum number of days between password change"]),
480
- warndays: convert_to_i(params["Number of days of warning before password expires"]),
481
- passwordage: dayslastset,
482
- badpasswordattempts: badpasswordattempts,
483
- }
484
- end
485
- end
486
-
487
- class SolarisUser < LinuxUser
488
- def initialize(inspec)
489
- @inspec = inspec
490
- @id_cmd ||= "id -a"
491
- super
492
- end
493
- end
494
-
495
- class AixUser < UnixUser
496
- def identity(username)
497
- id = super(username)
498
- return nil if id.nil?
499
-
500
- # AIX 'id' command doesn't include the primary group in the supplementary
501
- # yet it can be somewhere in the supplementary list if someone added root
502
- # to a groups list in /etc/group
503
- # we rearrange to expected list if that is the case
504
- if id[:groups].first != id[:group]
505
- id[:groups].reject! { |i| i == id[:group] } if id[:groups].include?(id[:group])
506
- id[:groups].unshift(id[:group])
507
- end
508
-
509
- id
510
- end
511
-
512
- def meta_info(username)
513
- lsuser = inspec.command("lsuser -C -a home shell #{username}")
514
- return nil if lsuser.exit_status != 0
515
-
516
- user = lsuser.stdout.chomp.split("\n").last.split(":")
517
- {
518
- home: user[1],
519
- shell: user[2],
520
- }
521
- end
522
-
523
- def credentials(username)
524
- cmd = inspec.command(
525
- "lssec -c -f /etc/security/user -s #{username} -a minage -a maxage -a pwdwarntime"
526
- )
527
- return nil if cmd.exit_status != 0
528
-
529
- user_sec = cmd.stdout.chomp.split("\n").last.split(":")
530
-
531
- {
532
- mindays: user_sec[1].to_i * 7,
533
- maxdays: user_sec[2].to_i * 7,
534
- warndays: user_sec[3].to_i,
535
- passwordage: nil,
536
- badpasswordattempts: nil,
537
- }
538
- end
539
- end
540
-
541
- class HpuxUser < UnixUser
542
- def meta_info(username)
543
- hpuxuser = inspec.command("logins -x -l #{username}")
544
- return nil if hpuxuser.exit_status != 0
545
-
546
- user = hpuxuser.stdout.chomp.split(" ")
547
- {
548
- home: user[4],
549
- shell: user[5],
550
- }
551
- end
552
- end
553
-
554
- # we do not use 'finger' for MacOS, because it is harder to parse data with it
555
- # @see https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/fingerd.8.html
556
- # instead we use 'dscl' to request user data
557
- # @see https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dscl.1.html
558
- # @see http://superuser.com/questions/592921/mac-osx-users-vs-dscl-command-to-list-user
559
- class DarwinUser < UnixUser
560
- def initialize(inspec)
561
- @list_users_cmd ||= "dscl . list /Users"
562
- super
563
- end
564
-
565
- def meta_info(username)
566
- cmd = inspec.command("dscl -q . -read /Users/#{username} NFSHomeDirectory PrimaryGroupID RecordName UniqueID UserShell")
567
- return nil if cmd.exit_status != 0
568
-
569
- params = SimpleConfig.new(
570
- cmd.stdout.chomp,
571
- assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
572
- group_re: nil,
573
- multiple_values: false
574
- ).params
575
-
576
- {
577
- home: params["NFSHomeDirectory"],
578
- shell: params["UserShell"],
579
- }
580
- end
581
- end
582
-
583
- # FreeBSD recommends to use the 'pw' command for user management
584
- # @see: https://www.freebsd.org/doc/handbook/users-synopsis.html
585
- # @see: https://www.freebsd.org/cgi/man.cgi?pw(8)
586
- # It offers the following commands:
587
- # - adduser(8) The recommended command-line application for adding new users.
588
- # - rmuser(8) The recommended command-line application for removing users.
589
- # - chpass(1) A flexible tool for changing user database information.
590
- # - passwd(1) The command-line tool to change user passwords.
591
- class FreeBSDUser < UnixUser
592
- include PasswdParser
593
-
594
- def meta_info(username)
595
- cmd = inspec.command("pw usershow #{username} -7")
596
- return nil if cmd.exit_status != 0
597
-
598
- # returns: root:*:0:0:Charlie &:/root:/bin/csh
599
- passwd = parse_passwd_line(cmd.stdout.chomp)
600
- {
601
- home: passwd["home"],
602
- shell: passwd["shell"],
603
- }
604
- end
605
- end
606
-
607
- # This optimization was inspired by
608
- # @see https://mcpmag.com/articles/2015/04/15/reporting-on-local-accounts.aspx
609
- # Alternative solutions are WMI Win32_UserAccount
610
- # @see https://msdn.microsoft.com/en-us/library/aa394507(v=vs.85).aspx
611
- # @see https://msdn.microsoft.com/en-us/library/aa394153(v=vs.85).aspx
612
- class WindowsUser < UserInfo
613
- def parse_windows_account(username)
614
- account = username.split('\\')
615
- name = account.pop
616
- domain = account.pop unless account.empty?
617
- [name, domain]
618
- end
619
-
620
- def identity(username)
621
- # TODO: we look for local users only at this point
622
- name, _domain = parse_windows_account(username)
623
- return if collect_user_details.nil?
624
-
625
- res = collect_user_details.select { |user| user[:username] == name }
626
- res[0] unless res.empty?
627
- end
628
-
629
- def meta_info(username)
630
- res = identity(username)
631
-
632
- return if res.nil?
633
-
634
- {
635
- home: res[:home],
636
- shell: res[:shell],
637
- domain: res[:domain],
638
- userflags: res[:userflags],
639
- lastlogin: res[:lastlogin],
640
- }
641
- end
642
-
643
- def credentials(username)
644
- res = identity(username)
645
-
646
- return if res.nil?
647
-
648
- {
649
- mindays: res[:mindays],
650
- maxdays: res[:maxdays],
651
- warndays: res[:warndays],
652
- badpasswordattempts: res[:badpasswordattempts],
653
- maxbadpasswords: res[:maxbadpasswords],
654
- minpasswordlength: res[:minpasswordlength],
655
- passwordage: res[:passwordage],
656
- }
657
- end
658
-
659
- def list_users
660
- collect_user_details.map { |user| user[:username] }
661
- end
662
-
663
- # https://msdn.microsoft.com/en-us/library/aa746340(v=vs.85).aspx
664
- def collect_user_details # rubocop:disable Metrics/MethodLength
665
- return @users_cache if defined?(@users_cache)
666
-
667
- script = <<~EOH
668
- Function ConvertTo-SID { Param([byte[]]$BinarySID)
669
- (New-Object System.Security.Principal.SecurityIdentifier($BinarySID,0)).Value
670
- }
671
-
672
- Function Convert-UserFlag { Param ($UserFlag)
673
- $List = @()
674
- Switch ($UserFlag) {
675
- ($UserFlag -BOR 0x0001) { $List += 'SCRIPT' }
676
- ($UserFlag -BOR 0x0002) { $List += 'ACCOUNTDISABLE' }
677
- ($UserFlag -BOR 0x0008) { $List += 'HOMEDIR_REQUIRED' }
678
- ($UserFlag -BOR 0x0010) { $List += 'LOCKOUT' }
679
- ($UserFlag -BOR 0x0020) { $List += 'PASSWD_NOTREQD' }
680
- ($UserFlag -BOR 0x0040) { $List += 'PASSWD_CANT_CHANGE' }
681
- ($UserFlag -BOR 0x0080) { $List += 'ENCRYPTED_TEXT_PWD_ALLOWED' }
682
- ($UserFlag -BOR 0x0100) { $List += 'TEMP_DUPLICATE_ACCOUNT' }
683
- ($UserFlag -BOR 0x0200) { $List += 'NORMAL_ACCOUNT' }
684
- ($UserFlag -BOR 0x0800) { $List += 'INTERDOMAIN_TRUST_ACCOUNT' }
685
- ($UserFlag -BOR 0x1000) { $List += 'WORKSTATION_TRUST_ACCOUNT' }
686
- ($UserFlag -BOR 0x2000) { $List += 'SERVER_TRUST_ACCOUNT' }
687
- ($UserFlag -BOR 0x10000) { $List += 'DONT_EXPIRE_PASSWORD' }
688
- ($UserFlag -BOR 0x20000) { $List += 'MNS_LOGON_ACCOUNT' }
689
- ($UserFlag -BOR 0x40000) { $List += 'SMARTCARD_REQUIRED' }
690
- ($UserFlag -BOR 0x80000) { $List += 'TRUSTED_FOR_DELEGATION' }
691
- ($UserFlag -BOR 0x100000) { $List += 'NOT_DELEGATED' }
692
- ($UserFlag -BOR 0x200000) { $List += 'USE_DES_KEY_ONLY' }
693
- ($UserFlag -BOR 0x400000) { $List += 'DONT_REQ_PREAUTH' }
694
- ($UserFlag -BOR 0x800000) { $List += 'PASSWORD_EXPIRED' }
695
- ($UserFlag -BOR 0x1000000) { $List += 'TRUSTED_TO_AUTH_FOR_DELEGATION' }
696
- ($UserFlag -BOR 0x04000000) { $List += 'PARTIAL_SECRETS_ACCOUNT' }
697
- }
698
- $List
699
- }
700
-
701
- $Computername = $Env:Computername
702
- $adsi = [ADSI]"WinNT://$Computername"
703
- $adsi.Children | where {$_.SchemaClassName -eq 'user'} | ForEach {
704
- New-Object PSObject -property @{
705
- uid = ConvertTo-SID -BinarySID $_.ObjectSID[0]
706
- username = $_.Name[0]
707
- description = $_.Description[0]
708
- disabled = $_.AccountDisabled[0]
709
- userflags = Convert-UserFlag -UserFlag $_.UserFlags[0]
710
- passwordage = [math]::Round($_.PasswordAge[0]/86400)
711
- minpasswordlength = $_.MinPasswordLength[0]
712
- mindays = [math]::Round($_.MinPasswordAge[0]/86400)
713
- maxdays = [math]::Round($_.MaxPasswordAge[0]/86400)
714
- warndays = $null
715
- badpasswordattempts = $_.BadPasswordAttempts[0]
716
- maxbadpasswords = $_.MaxBadPasswordsAllowed[0]
717
- gid = $null
718
- group = $null
719
- groups = @($_.Groups() | Foreach-Object { $_.GetType().InvokeMember('Name', 'GetProperty', $null, $_, $null) })
720
- home = $_.HomeDirectory[0]
721
- shell = $null
722
- domain = $Computername
723
- lastlogin = if($_.lastlogin.getType().Tostring() -eq "System.Management.Automation.PSMethod" ){ $null }else{[String]$_.lastlogin}
724
- }
725
- } | ConvertTo-Json
726
- EOH
727
- cmd = inspec.powershell(script)
728
- # cannot rely on exit code for now, successful command returns exit code 1
729
- # return nil if cmd.exit_status != 0, try to parse json
730
- begin
731
- users = JSON.parse(cmd.stdout)
732
- rescue JSON::ParserError => _e
733
- return nil
734
- end
735
-
736
- # ensure we have an array of groups
737
- users = [users] unless users.is_a?(Array)
738
- # convert keys to symbols
739
- @users_cache = users.map { |user| user.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } }
740
- end
741
- end
742
- end