inspec 4.18.51 → 4.18.85
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/inspec.gemspec +15 -37
- data/lib/resource_support/aws/aws_resource_mixin.rb +1 -1
- metadata +22 -709
- data/Gemfile +0 -61
- data/LICENSE +0 -14
- data/README.md +0 -474
- data/etc/deprecations.json +0 -125
- data/etc/plugin_filters.json +0 -45
- data/lib/bundles/README.md +0 -3
- data/lib/bundles/inspec-compliance/api.rb +0 -7
- data/lib/bundles/inspec-compliance/configuration.rb +0 -7
- data/lib/bundles/inspec-compliance/http.rb +0 -7
- data/lib/bundles/inspec-compliance/support.rb +0 -7
- data/lib/bundles/inspec-compliance/target.rb +0 -7
- data/lib/bundles/inspec-supermarket.rb +0 -9
- data/lib/bundles/inspec-supermarket/README.md +0 -45
- data/lib/bundles/inspec-supermarket/api.rb +0 -87
- data/lib/bundles/inspec-supermarket/cli.rb +0 -71
- data/lib/bundles/inspec-supermarket/target.rb +0 -31
- data/lib/inspec.rb +0 -30
- data/lib/inspec/archive/tar.rb +0 -25
- data/lib/inspec/archive/zip.rb +0 -15
- data/lib/inspec/backend.rb +0 -101
- data/lib/inspec/base_cli.rb +0 -318
- data/lib/inspec/cached_fetcher.rb +0 -65
- data/lib/inspec/cli.rb +0 -469
- data/lib/inspec/completions/bash.sh.erb +0 -45
- data/lib/inspec/completions/fish.sh.erb +0 -34
- data/lib/inspec/completions/zsh.sh.erb +0 -61
- data/lib/inspec/config.rb +0 -511
- data/lib/inspec/control_eval_context.rb +0 -248
- data/lib/inspec/dependencies/cache.rb +0 -74
- data/lib/inspec/dependencies/dependency_set.rb +0 -93
- data/lib/inspec/dependencies/lockfile.rb +0 -115
- data/lib/inspec/dependencies/requirement.rb +0 -135
- data/lib/inspec/dependencies/resolver.rb +0 -86
- data/lib/inspec/describe_base.rb +0 -53
- data/lib/inspec/dist.rb +0 -20
- data/lib/inspec/dsl.rb +0 -115
- data/lib/inspec/dsl_shared.rb +0 -32
- data/lib/inspec/env_printer.rb +0 -156
- data/lib/inspec/errors.rb +0 -18
- data/lib/inspec/exceptions.rb +0 -11
- data/lib/inspec/expect.rb +0 -42
- data/lib/inspec/fetcher.rb +0 -48
- data/lib/inspec/fetcher/git.rb +0 -211
- data/lib/inspec/fetcher/local.rb +0 -116
- data/lib/inspec/fetcher/mock.rb +0 -34
- data/lib/inspec/fetcher/url.rb +0 -281
- data/lib/inspec/file_provider.rb +0 -318
- data/lib/inspec/formatters.rb +0 -3
- data/lib/inspec/formatters/base.rb +0 -269
- data/lib/inspec/formatters/json_rspec.rb +0 -20
- data/lib/inspec/formatters/show_progress.rb +0 -12
- data/lib/inspec/globals.rb +0 -9
- data/lib/inspec/impact.rb +0 -36
- data/lib/inspec/input.rb +0 -421
- data/lib/inspec/input_dsl_helpers.rb +0 -26
- data/lib/inspec/input_registry.rb +0 -315
- data/lib/inspec/library_eval_context.rb +0 -55
- data/lib/inspec/log.rb +0 -7
- data/lib/inspec/metadata.rb +0 -253
- data/lib/inspec/method_source.rb +0 -20
- data/lib/inspec/objects.rb +0 -14
- data/lib/inspec/objects/control.rb +0 -85
- data/lib/inspec/objects/describe.rb +0 -106
- data/lib/inspec/objects/each_loop.rb +0 -41
- data/lib/inspec/objects/input.rb +0 -49
- data/lib/inspec/objects/list.rb +0 -15
- data/lib/inspec/objects/or_test.rb +0 -45
- data/lib/inspec/objects/ruby_helper.rb +0 -13
- data/lib/inspec/objects/tag.rb +0 -32
- data/lib/inspec/objects/test.rb +0 -94
- data/lib/inspec/objects/value.rb +0 -32
- data/lib/inspec/plugin/v1.rb +0 -2
- data/lib/inspec/plugin/v1/plugin_types/cli.rb +0 -22
- data/lib/inspec/plugin/v1/plugin_types/fetcher.rb +0 -83
- data/lib/inspec/plugin/v1/plugin_types/resource.rb +0 -176
- data/lib/inspec/plugin/v1/plugin_types/secret.rb +0 -11
- data/lib/inspec/plugin/v1/plugin_types/source_reader.rb +0 -36
- data/lib/inspec/plugin/v1/plugins.rb +0 -59
- data/lib/inspec/plugin/v1/registry.rb +0 -90
- data/lib/inspec/plugin/v2.rb +0 -46
- data/lib/inspec/plugin/v2/activator.rb +0 -40
- data/lib/inspec/plugin/v2/config_file.rb +0 -151
- data/lib/inspec/plugin/v2/filter.rb +0 -96
- data/lib/inspec/plugin/v2/installer.rb +0 -512
- data/lib/inspec/plugin/v2/loader.rb +0 -321
- data/lib/inspec/plugin/v2/plugin_base.rb +0 -112
- data/lib/inspec/plugin/v2/plugin_types/cli.rb +0 -49
- data/lib/inspec/plugin/v2/plugin_types/dsl.rb +0 -11
- data/lib/inspec/plugin/v2/plugin_types/input.rb +0 -34
- data/lib/inspec/plugin/v2/plugin_types/mock.rb +0 -12
- data/lib/inspec/plugin/v2/registry.rb +0 -98
- data/lib/inspec/plugin/v2/status.rb +0 -29
- data/lib/inspec/profile.rb +0 -658
- data/lib/inspec/profile_context.rb +0 -203
- data/lib/inspec/profile_vendor.rb +0 -84
- data/lib/inspec/reporters.rb +0 -73
- data/lib/inspec/reporters/automate.rb +0 -78
- data/lib/inspec/reporters/base.rb +0 -25
- data/lib/inspec/reporters/cli.rb +0 -370
- data/lib/inspec/reporters/json.rb +0 -113
- data/lib/inspec/reporters/json_automate.rb +0 -80
- data/lib/inspec/reporters/json_min.rb +0 -48
- data/lib/inspec/reporters/junit.rb +0 -77
- data/lib/inspec/reporters/yaml.rb +0 -20
- data/lib/inspec/require_loader.rb +0 -29
- data/lib/inspec/resource.rb +0 -114
- data/lib/inspec/resources.rb +0 -130
- data/lib/inspec/resources/aide_conf.rb +0 -153
- data/lib/inspec/resources/apache.rb +0 -47
- data/lib/inspec/resources/apache_conf.rb +0 -156
- data/lib/inspec/resources/apt.rb +0 -151
- data/lib/inspec/resources/audit_policy.rb +0 -64
- data/lib/inspec/resources/auditd.rb +0 -251
- data/lib/inspec/resources/auditd_conf.rb +0 -45
- data/lib/inspec/resources/bash.rb +0 -33
- data/lib/inspec/resources/bond.rb +0 -70
- data/lib/inspec/resources/bridge.rb +0 -125
- data/lib/inspec/resources/bsd_service.rb +0 -2
- data/lib/inspec/resources/chocolatey_package.rb +0 -82
- data/lib/inspec/resources/command.rb +0 -91
- data/lib/inspec/resources/cpan.rb +0 -58
- data/lib/inspec/resources/cran.rb +0 -64
- data/lib/inspec/resources/crontab.rb +0 -173
- data/lib/inspec/resources/csv.rb +0 -56
- data/lib/inspec/resources/dh_params.rb +0 -83
- data/lib/inspec/resources/directory.rb +0 -23
- data/lib/inspec/resources/docker.rb +0 -274
- data/lib/inspec/resources/docker_container.rb +0 -91
- data/lib/inspec/resources/docker_image.rb +0 -84
- data/lib/inspec/resources/docker_object.rb +0 -52
- data/lib/inspec/resources/docker_plugin.rb +0 -64
- data/lib/inspec/resources/docker_service.rb +0 -91
- data/lib/inspec/resources/elasticsearch.rb +0 -165
- data/lib/inspec/resources/etc_fstab.rb +0 -96
- data/lib/inspec/resources/etc_group.rb +0 -157
- data/lib/inspec/resources/etc_hosts.rb +0 -68
- data/lib/inspec/resources/etc_hosts_allow.rb +0 -2
- data/lib/inspec/resources/etc_hosts_allow_deny.rb +0 -114
- data/lib/inspec/resources/etc_hosts_deny.rb +0 -2
- data/lib/inspec/resources/file.rb +0 -339
- data/lib/inspec/resources/filesystem.rb +0 -139
- data/lib/inspec/resources/firewalld.rb +0 -148
- data/lib/inspec/resources/gem.rb +0 -80
- data/lib/inspec/resources/group.rb +0 -2
- data/lib/inspec/resources/groups.rb +0 -241
- data/lib/inspec/resources/grub_conf.rb +0 -230
- data/lib/inspec/resources/host.rb +0 -310
- data/lib/inspec/resources/http.rb +0 -275
- data/lib/inspec/resources/iis_app.rb +0 -101
- data/lib/inspec/resources/iis_app_pool.rb +0 -127
- data/lib/inspec/resources/iis_site.rb +0 -148
- data/lib/inspec/resources/iis_website.rb +0 -2
- data/lib/inspec/resources/inetd_conf.rb +0 -53
- data/lib/inspec/resources/ini.rb +0 -28
- data/lib/inspec/resources/interface.rb +0 -204
- data/lib/inspec/resources/ip6tables.rb +0 -79
- data/lib/inspec/resources/iptables.rb +0 -80
- data/lib/inspec/resources/json.rb +0 -116
- data/lib/inspec/resources/kernel_module.rb +0 -106
- data/lib/inspec/resources/kernel_parameter.rb +0 -54
- data/lib/inspec/resources/key_rsa.rb +0 -66
- data/lib/inspec/resources/ksh.rb +0 -33
- data/lib/inspec/resources/launchd_service.rb +0 -2
- data/lib/inspec/resources/limits_conf.rb +0 -45
- data/lib/inspec/resources/linux_kernel_parameter.rb +0 -2
- data/lib/inspec/resources/login_defs.rb +0 -56
- data/lib/inspec/resources/mount.rb +0 -88
- data/lib/inspec/resources/mssql_session.rb +0 -117
- data/lib/inspec/resources/mysql.rb +0 -81
- data/lib/inspec/resources/mysql_conf.rb +0 -128
- data/lib/inspec/resources/mysql_session.rb +0 -88
- data/lib/inspec/resources/nginx.rb +0 -96
- data/lib/inspec/resources/nginx_conf.rb +0 -232
- data/lib/inspec/resources/noop.rb +0 -9
- data/lib/inspec/resources/npm.rb +0 -68
- data/lib/inspec/resources/ntp_conf.rb +0 -51
- data/lib/inspec/resources/oneget.rb +0 -71
- data/lib/inspec/resources/oracledb_session.rb +0 -149
- data/lib/inspec/resources/os.rb +0 -34
- data/lib/inspec/resources/os_env.rb +0 -86
- data/lib/inspec/resources/package.rb +0 -391
- data/lib/inspec/resources/packages.rb +0 -111
- data/lib/inspec/resources/parse_config.rb +0 -112
- data/lib/inspec/resources/parse_config_file.rb +0 -2
- data/lib/inspec/resources/passwd.rb +0 -73
- data/lib/inspec/resources/pip.rb +0 -132
- data/lib/inspec/resources/platform.rb +0 -112
- data/lib/inspec/resources/port.rb +0 -791
- data/lib/inspec/resources/postfix_conf.rb +0 -35
- data/lib/inspec/resources/postgres.rb +0 -152
- data/lib/inspec/resources/postgres_conf.rb +0 -116
- data/lib/inspec/resources/postgres_hba_conf.rb +0 -86
- data/lib/inspec/resources/postgres_ident_conf.rb +0 -75
- data/lib/inspec/resources/postgres_session.rb +0 -70
- data/lib/inspec/resources/powershell.rb +0 -67
- data/lib/inspec/resources/ppa.rb +0 -2
- data/lib/inspec/resources/processes.rb +0 -219
- data/lib/inspec/resources/rabbitmq_conf.rb +0 -2
- data/lib/inspec/resources/rabbitmq_config.rb +0 -52
- data/lib/inspec/resources/registry_key.rb +0 -296
- data/lib/inspec/resources/runit_service.rb +0 -2
- data/lib/inspec/resources/script.rb +0 -1
- data/lib/inspec/resources/security_identifier.rb +0 -91
- data/lib/inspec/resources/security_policy.rb +0 -182
- data/lib/inspec/resources/service.rb +0 -820
- data/lib/inspec/resources/shadow.rb +0 -150
- data/lib/inspec/resources/ssh_config.rb +0 -98
- data/lib/inspec/resources/sshd_config.rb +0 -2
- data/lib/inspec/resources/ssl.rb +0 -99
- data/lib/inspec/resources/sys_info.rb +0 -119
- data/lib/inspec/resources/systemd_service.rb +0 -2
- data/lib/inspec/resources/sysv_service.rb +0 -2
- data/lib/inspec/resources/toml.rb +0 -30
- data/lib/inspec/resources/upstart_service.rb +0 -2
- data/lib/inspec/resources/user.rb +0 -1
- data/lib/inspec/resources/users.rb +0 -742
- data/lib/inspec/resources/vbscript.rb +0 -67
- data/lib/inspec/resources/virtualization.rb +0 -255
- data/lib/inspec/resources/windows_feature.rb +0 -126
- data/lib/inspec/resources/windows_hotfix.rb +0 -37
- data/lib/inspec/resources/windows_registry_key.rb +0 -2
- data/lib/inspec/resources/windows_task.rb +0 -112
- data/lib/inspec/resources/wmi.rb +0 -109
- data/lib/inspec/resources/x509_certificate.rb +0 -143
- data/lib/inspec/resources/xinetd_conf.rb +0 -103
- data/lib/inspec/resources/xml.rb +0 -48
- data/lib/inspec/resources/yaml.rb +0 -42
- data/lib/inspec/resources/yum.rb +0 -162
- data/lib/inspec/resources/zfs_dataset.rb +0 -62
- data/lib/inspec/resources/zfs_pool.rb +0 -50
- data/lib/inspec/rspec_extensions.rb +0 -116
- data/lib/inspec/rule.rb +0 -389
- data/lib/inspec/runner.rb +0 -333
- data/lib/inspec/runner_mock.rb +0 -37
- data/lib/inspec/runner_rspec.rb +0 -184
- data/lib/inspec/runtime_profile.rb +0 -23
- data/lib/inspec/schema.rb +0 -245
- data/lib/inspec/secrets.rb +0 -15
- data/lib/inspec/secrets/yaml.rb +0 -29
- data/lib/inspec/shell.rb +0 -211
- data/lib/inspec/shell_detector.rb +0 -89
- data/lib/inspec/source_reader.rb +0 -26
- data/lib/inspec/ui.rb +0 -213
- data/lib/inspec/ui_table_helper.rb +0 -12
- data/lib/inspec/utils/command_wrapper.rb +0 -23
- data/lib/inspec/utils/convert.rb +0 -8
- data/lib/inspec/utils/database_helpers.rb +0 -75
- data/lib/inspec/utils/deprecation.rb +0 -6
- data/lib/inspec/utils/deprecation/config_file.rb +0 -109
- data/lib/inspec/utils/deprecation/deprecator.rb +0 -118
- data/lib/inspec/utils/deprecation/errors.rb +0 -14
- data/lib/inspec/utils/deprecation/global_method.rb +0 -9
- data/lib/inspec/utils/enumerable_delegation.rb +0 -7
- data/lib/inspec/utils/erlang_parser.rb +0 -190
- data/lib/inspec/utils/file_reader.rb +0 -24
- data/lib/inspec/utils/filter.rb +0 -461
- data/lib/inspec/utils/filter_array.rb +0 -25
- data/lib/inspec/utils/find_files.rb +0 -44
- data/lib/inspec/utils/hash.rb +0 -37
- data/lib/inspec/utils/json_log.rb +0 -15
- data/lib/inspec/utils/modulator.rb +0 -9
- data/lib/inspec/utils/nginx_parser.rb +0 -101
- data/lib/inspec/utils/object_traversal.rb +0 -47
- data/lib/inspec/utils/parser.rb +0 -277
- data/lib/inspec/utils/pkey_reader.rb +0 -17
- data/lib/inspec/utils/simpleconfig.rb +0 -121
- data/lib/inspec/utils/spdx.rb +0 -10
- data/lib/inspec/utils/spdx.txt +0 -383
- data/lib/inspec/utils/telemetry.rb +0 -3
- data/lib/inspec/utils/telemetry/collector.rb +0 -81
- data/lib/inspec/utils/telemetry/data_series.rb +0 -44
- data/lib/inspec/utils/telemetry/global_methods.rb +0 -22
- data/lib/inspec/version.rb +0 -3
- data/lib/matchers/matchers.rb +0 -341
- data/lib/plugins/README.md +0 -16
- data/lib/plugins/inspec-artifact/lib/inspec-artifact.rb +0 -12
- data/lib/plugins/inspec-artifact/lib/inspec-artifact/base.rb +0 -170
- data/lib/plugins/inspec-artifact/lib/inspec-artifact/cli.rb +0 -116
- data/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb +0 -50
- data/lib/plugins/inspec-compliance/README.md +0 -207
- data/lib/plugins/inspec-compliance/lib/inspec-compliance.rb +0 -12
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +0 -362
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb +0 -198
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +0 -269
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/configuration.rb +0 -103
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/http.rb +0 -117
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/images/cc-token.png +0 -0
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/support.rb +0 -34
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/target.rb +0 -146
- data/lib/plugins/inspec-compliance/test/functional/inspec_compliance_test.rb +0 -53
- data/lib/plugins/inspec-compliance/test/integration/default/cli.rb +0 -91
- data/lib/plugins/inspec-compliance/test/unit/api/login_test.rb +0 -190
- data/lib/plugins/inspec-compliance/test/unit/api_test.rb +0 -386
- data/lib/plugins/inspec-compliance/test/unit/target_test.rb +0 -155
- data/lib/plugins/inspec-habitat/Berksfile +0 -5
- data/lib/plugins/inspec-habitat/README.md +0 -150
- data/lib/plugins/inspec-habitat/kitchen.yml +0 -28
- data/lib/plugins/inspec-habitat/lib/inspec-habitat.rb +0 -11
- data/lib/plugins/inspec-habitat/lib/inspec-habitat/cli.rb +0 -41
- data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +0 -265
- data/lib/plugins/inspec-habitat/templates/habitat/plan.sh.erb +0 -6
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/Berksfile +0 -2
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/README.md +0 -3
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/files/hab_setup.exp +0 -28
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/metadata.rb +0 -9
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/recipes/default.rb +0 -61
- data/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb +0 -34
- data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/README.md +0 -3
- data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/controls/inspec_habitat.rb +0 -40
- data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/inspec.yml +0 -10
- data/lib/plugins/inspec-habitat/test/support/example_profile/README.md +0 -3
- data/lib/plugins/inspec-habitat/test/support/example_profile/controls/example.rb +0 -7
- data/lib/plugins/inspec-habitat/test/support/example_profile/inspec.yml +0 -10
- data/lib/plugins/inspec-habitat/test/unit/profile_test.rb +0 -242
- data/lib/plugins/inspec-init/README.md +0 -31
- data/lib/plugins/inspec-init/lib/inspec-init.rb +0 -12
- data/lib/plugins/inspec-init/lib/inspec-init/cli.rb +0 -15
- data/lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb +0 -243
- data/lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb +0 -47
- data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +0 -97
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Gemfile +0 -11
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/LICENSE +0 -2
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/README.md +0 -28
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Rakefile +0 -40
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template.rb +0 -14
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/cli_command.rb +0 -62
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.rb +0 -53
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/version.rb +0 -8
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/fixtures/README.md +0 -24
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/README.md +0 -12
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/inspec_plugin_template_test.rb +0 -110
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/helper.rb +0 -24
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/README.md +0 -17
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/cli_args_test.rb +0 -67
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/plugin_def_test.rb +0 -51
- data/lib/plugins/inspec-init/templates/profiles/aws/libraries/.gitkeep +0 -0
- data/lib/plugins/inspec-init/templates/profiles/azure/libraries/.gitkeep +0 -0
- data/lib/plugins/inspec-init/templates/profiles/gcp/libraries/.gitkeep +0 -0
- data/lib/plugins/inspec-init/templates/profiles/os/README.md +0 -3
- data/lib/plugins/inspec-init/templates/profiles/os/controls/example.rb +0 -18
- data/lib/plugins/inspec-init/templates/profiles/os/inspec.yml +0 -10
- data/lib/plugins/inspec-init/templates/profiles/os/libraries/.gitkeep +0 -0
- data/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb +0 -184
- data/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb +0 -121
- data/lib/plugins/inspec-plugin-manager-cli/README.md +0 -6
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb +0 -17
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +0 -518
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/plugin.rb +0 -12
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/config_dirs/empty/.gitkeep +0 -0
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette.rb +0 -2
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette/.gitkeep +0 -0
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-wrong-structure/.gitkeep +0 -0
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name.rb +0 -1
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name/.gitkeep +0 -0
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/help_test.rb +0 -23
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb +0 -62
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/install_test.rb +0 -368
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/list_test.rb +0 -101
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/search_test.rb +0 -129
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/uninstall_test.rb +0 -63
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/update_test.rb +0 -84
- data/lib/plugins/inspec-plugin-manager-cli/test/unit/cli_args_test.rb +0 -77
- data/lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb +0 -39
- data/lib/plugins/shared/core_plugin_test_helper.rb +0 -153
- data/lib/plugins/things-for-train-integration.rb +0 -14
- data/lib/source_readers/flat.rb +0 -36
- data/lib/source_readers/inspec.rb +0 -66
@@ -1,70 +0,0 @@
|
|
1
|
-
# copyright: 2015, Vulcano Security GmbH
|
2
|
-
|
3
|
-
require "shellwords"
|
4
|
-
|
5
|
-
module Inspec::Resources
|
6
|
-
class Lines
|
7
|
-
attr_reader :output
|
8
|
-
|
9
|
-
def initialize(raw, desc)
|
10
|
-
@output = raw
|
11
|
-
@desc = desc
|
12
|
-
end
|
13
|
-
|
14
|
-
def lines
|
15
|
-
output.split("\n")
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_s
|
19
|
-
@desc
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class PostgresSession < Inspec.resource(1)
|
24
|
-
name "postgres_session"
|
25
|
-
supports platform: "unix"
|
26
|
-
supports platform: "windows"
|
27
|
-
desc "Use the postgres_session InSpec audit resource to test SQL commands run against a PostgreSQL database."
|
28
|
-
example <<~EXAMPLE
|
29
|
-
sql = postgres_session('username', 'password', 'host')
|
30
|
-
query('sql_query', ['database_name'])` contains the query and (optional) database to execute
|
31
|
-
|
32
|
-
# default values:
|
33
|
-
# username: 'postgres'
|
34
|
-
# host: 'localhost'
|
35
|
-
# db: databse == db_user running the sql query
|
36
|
-
|
37
|
-
describe sql.query('SELECT * FROM pg_shadow WHERE passwd IS NULL;') do
|
38
|
-
its('output') { should eq '' }
|
39
|
-
end
|
40
|
-
EXAMPLE
|
41
|
-
|
42
|
-
def initialize(user, pass, host = nil)
|
43
|
-
@user = user || "postgres"
|
44
|
-
@pass = pass
|
45
|
-
@host = host || "localhost"
|
46
|
-
end
|
47
|
-
|
48
|
-
def query(query, db = [])
|
49
|
-
psql_cmd = create_psql_cmd(query, db)
|
50
|
-
cmd = inspec.command(psql_cmd)
|
51
|
-
out = cmd.stdout + "\n" + cmd.stderr
|
52
|
-
if cmd.exit_status != 0 || out =~ /could not connect to .*/ || out.downcase =~ /^error:.*/
|
53
|
-
Lines.new(out, "PostgreSQL query with errors: #{query}")
|
54
|
-
else
|
55
|
-
Lines.new(cmd.stdout.strip, "PostgreSQL query: #{query}")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def escaped_query(query)
|
62
|
-
Shellwords.escape(query)
|
63
|
-
end
|
64
|
-
|
65
|
-
def create_psql_cmd(query, db = [])
|
66
|
-
dbs = db.map { |x| "-d #{x}" }.join(" ")
|
67
|
-
"PGPASSWORD='#{@pass}' psql -U #{@user} #{dbs} -h #{@host} -A -t -c #{escaped_query(query)}"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# copyright: 2015, Vulcano Security GmbH
|
2
|
-
require "inspec/resources/command"
|
3
|
-
|
4
|
-
module Inspec::Resources
|
5
|
-
class Powershell < Cmd
|
6
|
-
name "powershell"
|
7
|
-
supports platform: "windows"
|
8
|
-
supports platform: "unix"
|
9
|
-
desc "Use the powershell InSpec audit resource to test a Windows PowerShell script on the Microsoft Windows platform."
|
10
|
-
example <<~EXAMPLE
|
11
|
-
script = <<-EOH
|
12
|
-
# your powershell script
|
13
|
-
EOH
|
14
|
-
|
15
|
-
describe powershell(script) do
|
16
|
-
its('matcher') { should eq 'output' }
|
17
|
-
end
|
18
|
-
EXAMPLE
|
19
|
-
|
20
|
-
def initialize(script)
|
21
|
-
# PowerShell is the default shell on Windows, use the `command` resource
|
22
|
-
return super(script) if inspec.os.windows?
|
23
|
-
|
24
|
-
unless inspec.command("pwsh").exist?
|
25
|
-
raise Inspec::Exceptions::ResourceSkipped, "Can not find `pwsh` command"
|
26
|
-
end
|
27
|
-
|
28
|
-
# Prevent progress stream from leaking into stderr
|
29
|
-
command = "$ProgressPreference='SilentlyContinue';" + script
|
30
|
-
|
31
|
-
# Encode as Base64 to remove any quotes/escapes/etc issues
|
32
|
-
command = command.encode("UTF-16LE", "UTF-8")
|
33
|
-
command = Base64.strict_encode64(command)
|
34
|
-
|
35
|
-
# Use the `command` resource to execute the command via `pwsh`
|
36
|
-
super("pwsh -encodedCommand '#{command}'")
|
37
|
-
end
|
38
|
-
|
39
|
-
# we cannot determine if a command exists, because that does not work for scripts
|
40
|
-
def exist?
|
41
|
-
nil
|
42
|
-
end
|
43
|
-
|
44
|
-
# Removes leading and trailing whitespace from stdout
|
45
|
-
def strip
|
46
|
-
result.stdout&.strip
|
47
|
-
end
|
48
|
-
|
49
|
-
def to_s
|
50
|
-
"Powershell"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
PowershellScript = Powershell
|
55
|
-
|
56
|
-
# this is deprecated syntax and will be removed in future versions
|
57
|
-
class LegacyPowershell < Powershell
|
58
|
-
name "script"
|
59
|
-
|
60
|
-
def initialize(script)
|
61
|
-
Inspec.deprecate(:resource_script, "The `script` resource is deprecated. Please use `powershell` instead.")
|
62
|
-
super(script)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
LegacyPowershellScript = LegacyPowershell
|
67
|
-
end
|
data/lib/inspec/resources/ppa.rb
DELETED
@@ -1,219 +0,0 @@
|
|
1
|
-
# copyright: 2015, Vulcano Security GmbH
|
2
|
-
|
3
|
-
require "inspec/utils/filter"
|
4
|
-
require "ostruct"
|
5
|
-
require "inspec/resources/command"
|
6
|
-
|
7
|
-
module Inspec::Resources
|
8
|
-
class Processes < Inspec.resource(1)
|
9
|
-
name "processes"
|
10
|
-
supports platform: "unix"
|
11
|
-
supports platform: "windows"
|
12
|
-
desc "Use the processes InSpec audit resource to test properties for programs that are running on the system."
|
13
|
-
example <<~EXAMPLE
|
14
|
-
describe processes('mysqld') do
|
15
|
-
its('entries.length') { should eq 1 }
|
16
|
-
its('users') { should eq ['mysql'] }
|
17
|
-
its('states') { should include 'S' }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe processes(/.+/).where { label != 'unconfined' && pid < 1000 } do
|
21
|
-
its('users') { should cmp [] }
|
22
|
-
end
|
23
|
-
|
24
|
-
# work with all processes
|
25
|
-
describe processes do
|
26
|
-
its('entries.length') { should be <= 100 }
|
27
|
-
end
|
28
|
-
EXAMPLE
|
29
|
-
|
30
|
-
def initialize(grep = /.*/)
|
31
|
-
@grep = grep
|
32
|
-
# turn into a regexp if it isn't one yet
|
33
|
-
if grep.class == String
|
34
|
-
# if windows ignore case as we can't make up our minds
|
35
|
-
if inspec.os.windows?
|
36
|
-
grep = "(?i)" + grep
|
37
|
-
else
|
38
|
-
grep = "(/[^/]*)*" + grep unless grep[0] == "/"
|
39
|
-
grep = "^" + grep + '(\s|$)'
|
40
|
-
end
|
41
|
-
grep = Regexp.new(grep)
|
42
|
-
end
|
43
|
-
|
44
|
-
all_cmds = ps_axo
|
45
|
-
@list = all_cmds.find_all do |hm|
|
46
|
-
hm[:command] =~ grep
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def exists?
|
51
|
-
!@list.empty?
|
52
|
-
end
|
53
|
-
|
54
|
-
def to_s
|
55
|
-
"Processes #{@grep.class == String ? @grep : @grep.inspect}"
|
56
|
-
end
|
57
|
-
|
58
|
-
def list
|
59
|
-
Inspec.deprecate(:property_processes_list, "The processes `list` property is deprecated. Please use `entries` instead.")
|
60
|
-
@list
|
61
|
-
end
|
62
|
-
|
63
|
-
filter = FilterTable.create
|
64
|
-
filter.register_column(:labels, field: "label")
|
65
|
-
.register_column(:pids, field: "pid")
|
66
|
-
.register_column(:cpus, field: "cpu")
|
67
|
-
.register_column(:mem, field: "mem")
|
68
|
-
.register_column(:vsz, field: "vsz")
|
69
|
-
.register_column(:rss, field: "rss")
|
70
|
-
.register_column(:tty, field: "tty")
|
71
|
-
.register_column(:states, field: "stat")
|
72
|
-
.register_column(:start, field: "start")
|
73
|
-
.register_column(:time, field: "time")
|
74
|
-
.register_column(:users, field: "user")
|
75
|
-
.register_column(:commands, field: "command")
|
76
|
-
.install_filter_methods_on_resource(self, :filtered_processes)
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def filtered_processes
|
81
|
-
@list
|
82
|
-
end
|
83
|
-
|
84
|
-
def ps_axo
|
85
|
-
os = inspec.os
|
86
|
-
|
87
|
-
if os.linux?
|
88
|
-
command, regex, field_map = ps_configuration_for_linux
|
89
|
-
elsif os.windows?
|
90
|
-
command = '$Proc = Get-Process -IncludeUserName | Where-Object {$_.Path -ne $null } | Select-Object PriorityClass,Id,CPU,PM,VirtualMemorySize,NPM,SessionId,Responding,StartTime,TotalProcessorTime,UserName,Path | ConvertTo-Csv -NoTypeInformation;$Proc.Replace("""","").Replace("`r`n","`n")'
|
91
|
-
# Wanted to use /(?:^|,)([^,]*)/; works on rubular.com not sure why here?
|
92
|
-
regex = /^(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+),(.+)$/
|
93
|
-
field_map = {
|
94
|
-
pid: 2,
|
95
|
-
cpu: 3,
|
96
|
-
mem: 4,
|
97
|
-
vsz: 5,
|
98
|
-
rss: 6,
|
99
|
-
tty: 7,
|
100
|
-
stat: 8,
|
101
|
-
start: 9,
|
102
|
-
time: 10,
|
103
|
-
user: 11,
|
104
|
-
command: 12,
|
105
|
-
}
|
106
|
-
else
|
107
|
-
command = "ps axo pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user,command"
|
108
|
-
regex = /^\s*([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+(.*)$/
|
109
|
-
field_map = {
|
110
|
-
pid: 1,
|
111
|
-
cpu: 2,
|
112
|
-
mem: 3,
|
113
|
-
vsz: 4,
|
114
|
-
rss: 5,
|
115
|
-
tty: 6,
|
116
|
-
stat: 7,
|
117
|
-
start: 8,
|
118
|
-
time: 9,
|
119
|
-
user: 10,
|
120
|
-
command: 11,
|
121
|
-
}
|
122
|
-
end
|
123
|
-
build_process_list(command, regex, field_map)
|
124
|
-
end
|
125
|
-
|
126
|
-
def ps_configuration_for_linux
|
127
|
-
if busybox_ps?
|
128
|
-
command = "ps -o pid,vsz,rss,tty,stat,time,ruser,args"
|
129
|
-
regex = /^\s*(\d+)\s+(\d+(?:\.\d+)?[gm]?)\s+(\d+(?:\.\d+)?[gm]?)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/
|
130
|
-
field_map = {
|
131
|
-
pid: 1,
|
132
|
-
vsz: 2,
|
133
|
-
rss: 3,
|
134
|
-
tty: 4,
|
135
|
-
stat: 5,
|
136
|
-
time: 6,
|
137
|
-
user: 7,
|
138
|
-
command: 8,
|
139
|
-
}
|
140
|
-
else
|
141
|
-
command = "ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command"
|
142
|
-
regex = /^(.+?)\s+(\d+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+(\w{3} \d{2}|\d{2}:\d{2}:\d{2})\s+([^ ]+)\s+([^ ]+)\s+(.*)$/
|
143
|
-
field_map = {
|
144
|
-
label: 1,
|
145
|
-
pid: 2,
|
146
|
-
cpu: 3,
|
147
|
-
mem: 4,
|
148
|
-
vsz: 5,
|
149
|
-
rss: 6,
|
150
|
-
tty: 7,
|
151
|
-
stat: 8,
|
152
|
-
start: 9,
|
153
|
-
time: 10,
|
154
|
-
user: 11,
|
155
|
-
command: 12,
|
156
|
-
}
|
157
|
-
end
|
158
|
-
|
159
|
-
[command, regex, field_map]
|
160
|
-
end
|
161
|
-
|
162
|
-
def busybox_ps?
|
163
|
-
@busybox_ps ||= inspec.command("ps --help").stderr.include?("BusyBox")
|
164
|
-
end
|
165
|
-
|
166
|
-
def convert_to_kilobytes(param)
|
167
|
-
return param.to_i unless param.is_a?(String)
|
168
|
-
|
169
|
-
if param.end_with?("g")
|
170
|
-
(param[0..-2].to_f * 1024 * 1024).to_i
|
171
|
-
elsif param.end_with?("m")
|
172
|
-
(param[0..-2].to_f * 1024).to_i
|
173
|
-
else
|
174
|
-
param.to_i
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def build_process_list(command, regex, field_map)
|
179
|
-
cmd = inspec.command(command)
|
180
|
-
all = cmd.stdout.split("\n")[1..-1]
|
181
|
-
return [] if all.nil?
|
182
|
-
|
183
|
-
# map all the process lines into match objects, fetch the available fields,
|
184
|
-
# and then build an OpenStruct of the process data for each process
|
185
|
-
all.map do |line|
|
186
|
-
line = line.match(regex)
|
187
|
-
|
188
|
-
# skip this line if we couldn't match the regular expression
|
189
|
-
next if line.nil?
|
190
|
-
|
191
|
-
# skip this entry if there's no command for this line
|
192
|
-
next if line[field_map[:command]].nil?
|
193
|
-
|
194
|
-
# build a hash of process data that we'll turn into a struct for FilterTable
|
195
|
-
process_data = {}
|
196
|
-
%i{label pid cpu mem vsz rss tty stat start time user command}.each do |param|
|
197
|
-
# not all operating systems support all fields, so skip the field if we don't have it
|
198
|
-
process_data[param] = line[field_map[param]] if field_map.key?(param)
|
199
|
-
end
|
200
|
-
|
201
|
-
# ensure pid, vsz, and rss are integers for backward compatibility
|
202
|
-
process_data[:pid] = process_data[:pid].to_i if process_data.key?(:pid)
|
203
|
-
|
204
|
-
# some ps variants (*cough* busybox) display vsz and rss as human readable MB or GB
|
205
|
-
%i{vsz rss}.each do |param|
|
206
|
-
next unless process_data.key?(param)
|
207
|
-
|
208
|
-
process_data[param] = convert_to_kilobytes(process_data[param])
|
209
|
-
end
|
210
|
-
|
211
|
-
# strip any newlines off the command
|
212
|
-
process_data[:command].strip!
|
213
|
-
|
214
|
-
# return an OpenStruct of the process for future use by FilterTable
|
215
|
-
OpenStruct.new(process_data)
|
216
|
-
end.compact
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require "inspec/utils/erlang_parser"
|
2
|
-
require "inspec/utils/file_reader"
|
3
|
-
|
4
|
-
module Inspec::Resources
|
5
|
-
class RabbitmqConfig < Inspec.resource(1)
|
6
|
-
name "rabbitmq_conf" # TODO: this is an alias. do we want this?
|
7
|
-
name "rabbitmq_config"
|
8
|
-
supports platform: "unix"
|
9
|
-
desc "Use the rabbitmq_config InSpec resource to test configuration data "\
|
10
|
-
"for the RabbitMQ service located in /etc/rabbitmq/rabbitmq.config on "\
|
11
|
-
"Linux and UNIX platforms."
|
12
|
-
example <<~EXAMPLE
|
13
|
-
describe rabbitmq_config.params('rabbit', 'ssl_listeners') do
|
14
|
-
it { should cmp 5671 }
|
15
|
-
end
|
16
|
-
EXAMPLE
|
17
|
-
|
18
|
-
include FileReader
|
19
|
-
|
20
|
-
def initialize(conf_path = nil)
|
21
|
-
@conf_path = conf_path || "/etc/rabbitmq/rabbitmq.config"
|
22
|
-
@content = read_file_content(@conf_path, allow_empty: true)
|
23
|
-
end
|
24
|
-
|
25
|
-
def params(*opts)
|
26
|
-
opts.inject(read_params) do |res, nxt|
|
27
|
-
res.respond_to?(:key) ? res[nxt] : nil
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def to_s
|
32
|
-
"rabbitmq_config #{@conf_path}"
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def read_content
|
38
|
-
return @content if defined?(@content)
|
39
|
-
|
40
|
-
@content = read_file_content(@conf_path, allow_empty: true)
|
41
|
-
end
|
42
|
-
|
43
|
-
def read_params
|
44
|
-
return @params if defined?(@params)
|
45
|
-
return @params = {} if read_content.nil?
|
46
|
-
|
47
|
-
@params = ErlangConfigFile.parse(read_content)
|
48
|
-
rescue Parslet::ParseFailed
|
49
|
-
raise "Cannot parse RabbitMQ config: \"#{read_content}\""
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,296 +0,0 @@
|
|
1
|
-
# copyright: 2015, Vulcano Security GmbH
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
require "inspec/resources/powershell"
|
5
|
-
|
6
|
-
# Three constructor methods are available:
|
7
|
-
# 1. resistry_key(path'):
|
8
|
-
# describe registry_key('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Schedule') do
|
9
|
-
# its('Start') { should eq 2 }
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
# 2. resistry_key('name','path'):
|
13
|
-
# describe registry_key('Task Scheduler','HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Schedule') do
|
14
|
-
# its('Start') { should eq 2 }
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# 3. options hash
|
18
|
-
# describe registry_key({
|
19
|
-
# name: 'Task Scheduler',
|
20
|
-
# hive: 'HKEY_LOCAL_MACHINE',
|
21
|
-
# key: '\SYSTEM\CurrentControlSet\services\Schedule'
|
22
|
-
# }) do
|
23
|
-
# its('Start') { should eq 2 }
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# Get all childs of a registry key:
|
27
|
-
# describe registry_key('Task Scheduler','HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet').children do
|
28
|
-
# it { should_not eq [] }
|
29
|
-
# end
|
30
|
-
#
|
31
|
-
# Example to use regular expressions for keys
|
32
|
-
# describe registry_key({
|
33
|
-
# hive: HKEY_USERS
|
34
|
-
# }).children(/^S-1-5-21-[0-9]+-[0-9]+-[0-9]+-[0-9]{3,}\\Software\\Policies\\Microsoft\\Windows\\Installer/).each { |key|
|
35
|
-
# describe registry_key(key) do
|
36
|
-
# its('AlwaysInstallElevated') { should eq 'value' }
|
37
|
-
# end
|
38
|
-
# }
|
39
|
-
#
|
40
|
-
# Example to use regular expressions in responses
|
41
|
-
# describe registry_key({
|
42
|
-
# hive: 'HKEY_LOCAL_MACHINE',
|
43
|
-
# key: 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
|
44
|
-
# }) do
|
45
|
-
# its('ProductName') { should match /^[a-zA-Z0-9\(\)\s]*2012\s[rR]2[a-zA-Z0-9\(\)\s]*$/ }
|
46
|
-
# end
|
47
|
-
|
48
|
-
module Inspec::Resources
|
49
|
-
class RegistryKey < Inspec.resource(1)
|
50
|
-
name "registry_key"
|
51
|
-
supports platform: "windows"
|
52
|
-
desc "Use the registry_key InSpec audit resource to test key values in the Microsoft Windows registry."
|
53
|
-
example <<~EXAMPLE
|
54
|
-
describe registry_key('path\to\key') do
|
55
|
-
its('name') { should eq 'value' }
|
56
|
-
end
|
57
|
-
EXAMPLE
|
58
|
-
|
59
|
-
def initialize(name, reg_key = nil)
|
60
|
-
# if we have one parameter, we use it as name
|
61
|
-
reg_key ||= name
|
62
|
-
@options = {}
|
63
|
-
if reg_key && reg_key.is_a?(Hash)
|
64
|
-
@options = @options.merge!(reg_key)
|
65
|
-
|
66
|
-
# generate registry_key if we do not have a regular expression
|
67
|
-
@options[:path] = generate_registry_key_path_from_options
|
68
|
-
@options[:name] ||= @options[:path]
|
69
|
-
else
|
70
|
-
@options[:name] = name
|
71
|
-
@options[:path] = reg_key
|
72
|
-
end
|
73
|
-
|
74
|
-
return skip_resource "The `registry_key` resource is not supported on your OS yet." unless inspec.os.windows?
|
75
|
-
end
|
76
|
-
|
77
|
-
def exists?
|
78
|
-
!registry_key(@options[:path]).nil?
|
79
|
-
end
|
80
|
-
|
81
|
-
def has_value?(value)
|
82
|
-
val = registry_key(@options[:path])
|
83
|
-
!val.nil? && registry_property_value(val, "(default)") == value ? true : false
|
84
|
-
end
|
85
|
-
|
86
|
-
def has_property?(property_name, property_type = nil)
|
87
|
-
val = registry_key(@options[:path])
|
88
|
-
!val.nil? && registry_property_exists(val, property_name) && (property_type.nil? || registry_property_type(val, property_name) == map2type(property_type)) ? true : false
|
89
|
-
end
|
90
|
-
|
91
|
-
# deactivate rubocop, because we need to stay compatible with Serverspe
|
92
|
-
# rubocop:disable Style/OptionalArguments
|
93
|
-
def has_property_value?(property_name, property_type = nil, value)
|
94
|
-
# rubocop:enable Style/OptionalArguments
|
95
|
-
val = registry_key(@options[:path])
|
96
|
-
|
97
|
-
# convert value to binary if required
|
98
|
-
value = value.bytes if !property_type.nil? && map2type(property_type) == 3 && !value.is_a?(Array)
|
99
|
-
|
100
|
-
!val.nil? && registry_property_value(val, property_name) == value && (property_type.nil? || registry_property_type(val, property_name) == map2type(property_type)) ? true : false
|
101
|
-
end
|
102
|
-
|
103
|
-
# returns an arrray of child nodes
|
104
|
-
def children(filter = nil)
|
105
|
-
children_keys(@options[:path], filter)
|
106
|
-
end
|
107
|
-
|
108
|
-
# returns nil, if not existant or value
|
109
|
-
def method_missing(*keys)
|
110
|
-
# allow the use of array syntax in an `its` block so that users
|
111
|
-
# can use it to query for keys with . characters in them
|
112
|
-
if keys.is_a?(Array)
|
113
|
-
keys.shift if keys[0] == :[]
|
114
|
-
key = keys.first
|
115
|
-
else
|
116
|
-
key = keys
|
117
|
-
end
|
118
|
-
|
119
|
-
# get data
|
120
|
-
val = registry_key(@options[:path])
|
121
|
-
registry_property_value(val, key)
|
122
|
-
end
|
123
|
-
|
124
|
-
def to_s
|
125
|
-
"Registry Key #{@options[:name]}"
|
126
|
-
end
|
127
|
-
|
128
|
-
private
|
129
|
-
|
130
|
-
def prep_prop(property)
|
131
|
-
property.to_s.downcase
|
132
|
-
end
|
133
|
-
|
134
|
-
def registry_property_exists(regkey, property)
|
135
|
-
return false if regkey.nil? || property.nil?
|
136
|
-
|
137
|
-
# always ensure the key is lower case
|
138
|
-
!regkey[prep_prop(property)].nil?
|
139
|
-
end
|
140
|
-
|
141
|
-
def registry_property_value(regkey, property)
|
142
|
-
return nil unless registry_property_exists(regkey, property)
|
143
|
-
|
144
|
-
# always ensure the key is lower case
|
145
|
-
regkey[prep_prop(property)]["value"]
|
146
|
-
end
|
147
|
-
|
148
|
-
def registry_property_type(regkey, property)
|
149
|
-
return nil unless registry_property_exists(regkey, property)
|
150
|
-
|
151
|
-
# always ensure the key is lower case
|
152
|
-
regkey[prep_prop(property)]["type"]
|
153
|
-
end
|
154
|
-
|
155
|
-
def registry_key(path)
|
156
|
-
return @registry_cache if defined?(@registry_cache)
|
157
|
-
|
158
|
-
# load registry key and all properties
|
159
|
-
script = <<-EOH
|
160
|
-
Function InSpec-GetRegistryKey($path) {
|
161
|
-
$reg = Get-Item ('Registry::' + $path)
|
162
|
-
if ($reg -eq $null) {
|
163
|
-
Write-Error "InSpec: Failed to find registry key"
|
164
|
-
exit 1001
|
165
|
-
}
|
166
|
-
|
167
|
-
$properties = New-Object -Type PSObject
|
168
|
-
$reg.Property | ForEach-Object {
|
169
|
-
$key = $_
|
170
|
-
$keytype = $key
|
171
|
-
if ("(default)".Equals($key)) { $keytype = '' }
|
172
|
-
$value = New-Object psobject -Property @{
|
173
|
-
"value" = $(Get-ItemProperty ('Registry::' + $path)).$key;
|
174
|
-
"type" = $reg.GetValueKind($keytype);
|
175
|
-
}
|
176
|
-
$properties | Add-Member NoteProperty $_ $value
|
177
|
-
}
|
178
|
-
$properties
|
179
|
-
}
|
180
|
-
$path = '#{path}'
|
181
|
-
InSpec-GetRegistryKey($path) | ConvertTo-Json -Compress
|
182
|
-
EOH
|
183
|
-
|
184
|
-
cmd = inspec.powershell(script)
|
185
|
-
# cannot rely on exit code for now, successful command returns exit code 1
|
186
|
-
# return nil if cmd.exit_status != 0, try to parse json
|
187
|
-
begin
|
188
|
-
if cmd.exit_status == 1001 && cmd.stderr =~ /InSpec: Failed to find registry key/
|
189
|
-
# TODO: provide the stderr output
|
190
|
-
@registry_cache = nil
|
191
|
-
else
|
192
|
-
@registry_cache = JSON.parse(cmd.stdout)
|
193
|
-
# convert keys to lower case
|
194
|
-
@registry_cache = Hash[@registry_cache.map do |key, value|
|
195
|
-
[key.downcase, value]
|
196
|
-
end]
|
197
|
-
end
|
198
|
-
rescue JSON::ParserError => _e
|
199
|
-
@registry_cache = nil
|
200
|
-
end
|
201
|
-
@registry_cache
|
202
|
-
end
|
203
|
-
|
204
|
-
def children_keys(path, filter = "")
|
205
|
-
return @children_cache if defined?(@children_cache)
|
206
|
-
|
207
|
-
filter = filter.source if filter.is_a? ::Regexp
|
208
|
-
script = <<-EOH
|
209
|
-
Function InSpec-FindChildsRegistryKeys($path, $filter) {
|
210
|
-
# get information about the child registry keys
|
211
|
-
$items = Get-ChildItem -Path ('Registry::' + $path) -rec -ea SilentlyContinue
|
212
|
-
# filter entries
|
213
|
-
$items | Where-Object {
|
214
|
-
$name = $_.Name
|
215
|
-
$simple = $name -replace "HKEY_LOCAL_MACHINE\\\\",""
|
216
|
-
$simple = $name -replace "HKEY_USERS\\\\",""
|
217
|
-
$simple -Match $filter
|
218
|
-
} | % { $_.Name }
|
219
|
-
}
|
220
|
-
|
221
|
-
$path = '#{path}'
|
222
|
-
$filter = "#{filter}"
|
223
|
-
ConvertTo-Json @(InSpec-FindChildsRegistryKeys $path $filter)
|
224
|
-
EOH
|
225
|
-
cmd = inspec.powershell(script)
|
226
|
-
begin
|
227
|
-
@children_cache = JSON.parse(cmd.stdout)
|
228
|
-
rescue JSON::ParserError => _e
|
229
|
-
@children_cache = []
|
230
|
-
end
|
231
|
-
@children_cache
|
232
|
-
end
|
233
|
-
|
234
|
-
# Registry key value types
|
235
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884(v=vs.85).aspx
|
236
|
-
# REG_NONE 0
|
237
|
-
# REG_SZ 1
|
238
|
-
# REG_EXPAND_SZ 2
|
239
|
-
# REG_BINARY 3
|
240
|
-
# REG_DWORD 4
|
241
|
-
# REG_DWORD_LITTLE_ENDIAN 4
|
242
|
-
# REG_DWORD_BIG_ENDIAN 5
|
243
|
-
# REG_LINK 6
|
244
|
-
# REG_MULTI_SZ 7
|
245
|
-
# REG_RESOURCE_LIST 8
|
246
|
-
# REG_FULL_RESOURCE_DESCRIPTOR 9
|
247
|
-
# REG_RESOURCE_REQUIREMENTS_LIST 10
|
248
|
-
# REG_QWORD 11
|
249
|
-
# REG_QWORD_LITTLE_ENDIAN 11
|
250
|
-
def map2type(symbol)
|
251
|
-
options = {}
|
252
|
-
|
253
|
-
# chef symbols, we prefer those
|
254
|
-
options[:binary] = 3
|
255
|
-
options[:string] = 1
|
256
|
-
options[:multi_string] = 7
|
257
|
-
options[:expand_string] = 2
|
258
|
-
options[:dword] = 4
|
259
|
-
options[:dword_big_endian] = 5
|
260
|
-
options[:qword] = 11
|
261
|
-
|
262
|
-
# serverspec symbols
|
263
|
-
options[:type_string] = 1
|
264
|
-
options[:type_binary] = 3
|
265
|
-
options[:type_dword] = 4
|
266
|
-
options[:type_qword] = 11
|
267
|
-
options[:type_multistring] = 7
|
268
|
-
options[:type_expandstring] = 2
|
269
|
-
|
270
|
-
options[symbol]
|
271
|
-
end
|
272
|
-
|
273
|
-
def generate_registry_key_path_from_options
|
274
|
-
path = @options[:hive]
|
275
|
-
path += format_key_from_options
|
276
|
-
|
277
|
-
path
|
278
|
-
end
|
279
|
-
|
280
|
-
def format_key_from_options
|
281
|
-
key = @options[:key]
|
282
|
-
return "" unless key
|
283
|
-
|
284
|
-
key.start_with?('\\') ? key : "\\#{key}"
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
class WindowsRegistryKey < RegistryKey
|
289
|
-
name "windows_registry_key"
|
290
|
-
|
291
|
-
def initialize(name)
|
292
|
-
Inspec.deprecate(:resource_windows_registry_key, "The `windows_registry_key` resource is deprecated. Please use `registry_key` instead.")
|
293
|
-
super(name)
|
294
|
-
end
|
295
|
-
end
|
296
|
-
end
|