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,321 +0,0 @@
|
|
1
|
-
require "inspec/log"
|
2
|
-
require "inspec/version"
|
3
|
-
require "inspec/plugin/v2/config_file"
|
4
|
-
require "inspec/plugin/v2/filter"
|
5
|
-
|
6
|
-
module Inspec::Plugin::V2
|
7
|
-
class Loader
|
8
|
-
attr_reader :conf_file, :registry, :options
|
9
|
-
|
10
|
-
# For {inspec|train}_plugin_name?
|
11
|
-
include Inspec::Plugin::V2::FilterPredicates
|
12
|
-
extend Inspec::Plugin::V2::FilterPredicates
|
13
|
-
|
14
|
-
def initialize(options = {})
|
15
|
-
@options = options
|
16
|
-
@registry = Inspec::Plugin::V2::Registry.instance
|
17
|
-
|
18
|
-
# User plugins are those installed by the user via `inspec plugin install`
|
19
|
-
# and are installed under ~/.inspec/gems
|
20
|
-
unless options[:omit_user_plugins]
|
21
|
-
@conf_file = Inspec::Plugin::V2::ConfigFile.new
|
22
|
-
read_conf_file_into_registry
|
23
|
-
end
|
24
|
-
|
25
|
-
# Old-style (v0, v1) co-distributed plugins were called 'bundles'
|
26
|
-
# and were located in lib/bundles
|
27
|
-
detect_bundled_plugins unless options[:omit_bundles]
|
28
|
-
|
29
|
-
# New-style (v2) co-distributed plugins are in lib/plugins,
|
30
|
-
# and may be safely loaded
|
31
|
-
detect_core_plugins unless options[:omit_core_plugins]
|
32
|
-
|
33
|
-
# Identify plugins that inspec is co-installed with
|
34
|
-
detect_system_plugins unless options[:omit_sys_plugins]
|
35
|
-
end
|
36
|
-
|
37
|
-
def load_all
|
38
|
-
# This fixes the gem paths on some bundles
|
39
|
-
Gem.path << plugin_gem_path
|
40
|
-
Gem.refresh
|
41
|
-
|
42
|
-
# Be careful not to actually iterate directly over the registry here;
|
43
|
-
# we want to allow "sidecar loading", in which case a plugin may add an entry to the registry.
|
44
|
-
registry.plugin_names.dup.each do |plugin_name|
|
45
|
-
plugin_details = registry[plugin_name]
|
46
|
-
# We want to capture literally any possible exception here, since we are storing them.
|
47
|
-
# rubocop: disable Lint/RescueException
|
48
|
-
begin
|
49
|
-
# We could use require, but under testing, we need to repeatedly reload the same
|
50
|
-
# plugin. However, gems only work with require (rubygems dooes not overload `load`)
|
51
|
-
if plugin_details.installation_type == :user_gem
|
52
|
-
activate_managed_gems_for_plugin(plugin_name)
|
53
|
-
require plugin_details.entry_point
|
54
|
-
else
|
55
|
-
load_path = plugin_details.entry_point
|
56
|
-
load_path += ".rb" unless plugin_details.entry_point.end_with?(".rb")
|
57
|
-
load load_path
|
58
|
-
end
|
59
|
-
plugin_details.loaded = true
|
60
|
-
annotate_status_after_loading(plugin_name)
|
61
|
-
rescue ::Exception => ex
|
62
|
-
plugin_details.load_exception = ex
|
63
|
-
Inspec::Log.error "Could not load plugin #{plugin_name}: #{ex.message}"
|
64
|
-
end
|
65
|
-
# rubocop: enable Lint/RescueException
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# This should possibly be in either lib/inspec/cli.rb or Registry
|
70
|
-
def exit_on_load_error
|
71
|
-
if registry.any_load_failures?
|
72
|
-
Inspec::Log.error "Errors were encountered while loading plugins..."
|
73
|
-
registry.plugin_statuses.select(&:load_exception).each do |plugin_status|
|
74
|
-
Inspec::Log.error "Plugin name: " + plugin_status.name.to_s
|
75
|
-
Inspec::Log.error "Error: " + plugin_status.load_exception.message
|
76
|
-
if ARGV.include?("--debug")
|
77
|
-
Inspec::Log.error "Exception: " + plugin_status.load_exception.class.name
|
78
|
-
Inspec::Log.error "Trace: " + plugin_status.load_exception.backtrace.join("\n")
|
79
|
-
end
|
80
|
-
end
|
81
|
-
Inspec::Log.error("Run again with --debug for a stacktrace.") unless ARGV.include?("--debug")
|
82
|
-
exit 2
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def activate_mentioned_cli_plugins(cli_args = ARGV)
|
87
|
-
# Get a list of CLI plugin activation hooks
|
88
|
-
registry.find_activators(plugin_type: :cli_command).each do |act|
|
89
|
-
next if act.activated?
|
90
|
-
|
91
|
-
# Decide whether to activate. Several conditions, so split them out for clarity.
|
92
|
-
# Assume no, to start. Each condition may flip it true, which will short-circuit
|
93
|
-
# all following ||= ops.
|
94
|
-
activate_me = false
|
95
|
-
|
96
|
-
# If the user invoked `inspec help`, `inspec --help`, or only `inspec`
|
97
|
-
# then activate all CLI plugins so they can display their usage message.
|
98
|
-
activate_me ||= ["help", "--help", nil].include?(cli_args.first)
|
99
|
-
|
100
|
-
# If there is anything in the CLI args with the same name, activate it.
|
101
|
-
# This is the expected usual activation for individual plugins.
|
102
|
-
# `inspec dosomething` => activate the :dosomething hook
|
103
|
-
activate_me ||= cli_args.include?(act.activator_name.to_s)
|
104
|
-
|
105
|
-
# OK, activate.
|
106
|
-
if activate_me
|
107
|
-
act.activate
|
108
|
-
act.implementation_class.register_with_thor
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def plugin_gem_path
|
114
|
-
self.class.plugin_gem_path
|
115
|
-
end
|
116
|
-
|
117
|
-
def self.plugin_gem_path
|
118
|
-
require "rbconfig"
|
119
|
-
ruby_abi_version = RbConfig::CONFIG["ruby_version"]
|
120
|
-
# TODO: why are we installing under the api directory for plugins?
|
121
|
-
base_dir = Inspec.config_dir
|
122
|
-
base_dir = File.realpath base_dir if File.exist? base_dir
|
123
|
-
File.join(base_dir, "gems", ruby_abi_version)
|
124
|
-
end
|
125
|
-
|
126
|
-
# Lists all gems found in the plugin_gem_path.
|
127
|
-
# @return [Array[Gem::Specification]] Specs of all gems found.
|
128
|
-
def self.list_managed_gems
|
129
|
-
Dir.glob(File.join(plugin_gem_path, "specifications", "*.gemspec")).map { |p| Gem::Specification.load(p) }
|
130
|
-
end
|
131
|
-
|
132
|
-
def list_managed_gems
|
133
|
-
self.class.list_managed_gems
|
134
|
-
end
|
135
|
-
|
136
|
-
# Lists all plugin gems found in the plugin_gem_path.
|
137
|
-
# This is simply all gems that begin with train- or inspec-
|
138
|
-
# and are not on the exclusion list.
|
139
|
-
# @return [Array[Gem::Specification]] Specs of all gems found.
|
140
|
-
def self.list_installed_plugin_gems
|
141
|
-
list_managed_gems.select { |spec| valid_plugin_name?(spec.name) }
|
142
|
-
end
|
143
|
-
|
144
|
-
def list_installed_plugin_gems
|
145
|
-
self.class.list_managed_gems
|
146
|
-
end
|
147
|
-
|
148
|
-
private
|
149
|
-
|
150
|
-
# 'Activating' a gem adds it to the load path, so 'require "gemname"' will work.
|
151
|
-
# Given a gem name, this activates the gem and all of its dependencies, respecting
|
152
|
-
# version pinning needs.
|
153
|
-
def activate_managed_gems_for_plugin(plugin_gem_name, version_constraint = "> 0")
|
154
|
-
# TODO: enforce first-level version pinning
|
155
|
-
plugin_deps = [Gem::Dependency.new(plugin_gem_name.to_s, version_constraint)]
|
156
|
-
managed_gem_set = Gem::Resolver::VendorSet.new
|
157
|
-
list_managed_gems.each { |spec| managed_gem_set.add_vendor_gem(spec.name, spec.gem_dir) }
|
158
|
-
|
159
|
-
# TODO: Next two lines merge our managed gems with the other gems available
|
160
|
-
# in our "local universe" - which may be the system, or it could be in a Bundler microcosm,
|
161
|
-
# or rbenv, etc. Do we want to merge that, though?
|
162
|
-
distrib_gem_set = Gem::Resolver::CurrentSet.new
|
163
|
-
installed_gem_set = Gem::Resolver.compose_sets(managed_gem_set, distrib_gem_set)
|
164
|
-
|
165
|
-
# So, given what we need, and what we have available, what activations are needed?
|
166
|
-
resolver = Gem::Resolver.new(plugin_deps, installed_gem_set)
|
167
|
-
begin
|
168
|
-
solution = resolver.resolve
|
169
|
-
rescue Gem::UnsatisfiableDependencyError => gem_ex
|
170
|
-
# If you broke your install, or downgraded to a plugin with a bad gemspec, you could get here.
|
171
|
-
ex = Inspec::Plugin::V2::LoadError.new(gem_ex.message)
|
172
|
-
raise ex
|
173
|
-
end
|
174
|
-
solution.each do |activation_request|
|
175
|
-
next if activation_request.full_spec.activated?
|
176
|
-
|
177
|
-
activation_request.full_spec.activate
|
178
|
-
# TODO: If we are under Bundler, inform it that we loaded a gem
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
def annotate_status_after_loading(plugin_name)
|
183
|
-
status = registry[plugin_name]
|
184
|
-
return if status.api_generation == 2 # Gen2 have self-annotating superclasses
|
185
|
-
return if status.api_generation == :'train-1' # Train plugins are here as a courtesy, don't poke them
|
186
|
-
|
187
|
-
case status.installation_type
|
188
|
-
when :bundle
|
189
|
-
annotate_bundle_plugin_status_after_load(plugin_name)
|
190
|
-
else
|
191
|
-
# TODO: are there any other cases? can this whole thing be eliminated?
|
192
|
-
raise "I only know how to annotate :bundle plugins when trying to load plugin #{plugin_name}" unless status.installation_type == :bundle
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def annotate_bundle_plugin_status_after_load(plugin_name)
|
197
|
-
# HACK: we're relying on the fact that all bundles are gen0 and cli type
|
198
|
-
status = registry[plugin_name]
|
199
|
-
status.api_generation = 0
|
200
|
-
act = Activator.new
|
201
|
-
act.activated = true
|
202
|
-
act.plugin_type = :cli_command
|
203
|
-
act.plugin_name = plugin_name
|
204
|
-
act.activator_name = :default
|
205
|
-
status.activators = [act]
|
206
|
-
|
207
|
-
v0_subcommand_name = plugin_name.to_s.gsub("inspec-", "")
|
208
|
-
status.plugin_class = Inspec::Plugins::CLI.subcommands[v0_subcommand_name][:klass]
|
209
|
-
end
|
210
|
-
|
211
|
-
def detect_bundled_plugins
|
212
|
-
bundle_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bundles"))
|
213
|
-
globs = [
|
214
|
-
File.join(bundle_dir, "inspec-*.rb"),
|
215
|
-
File.join(bundle_dir, "train-*.rb"),
|
216
|
-
]
|
217
|
-
Dir.glob(globs).each do |loader_file|
|
218
|
-
name = File.basename(loader_file, ".rb").to_sym
|
219
|
-
status = Inspec::Plugin::V2::Status.new
|
220
|
-
status.name = name
|
221
|
-
status.entry_point = loader_file
|
222
|
-
status.installation_type = :bundle
|
223
|
-
status.loaded = false
|
224
|
-
registry[name] = status
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
def detect_core_plugins
|
229
|
-
core_plugins_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "plugins"))
|
230
|
-
# These are expected to be organized as proper separate projects,
|
231
|
-
# with lib/ dirs, etc.
|
232
|
-
Dir.glob(File.join(core_plugins_dir, "inspec-*")).each do |plugin_dir|
|
233
|
-
status = Inspec::Plugin::V2::Status.new
|
234
|
-
status.name = File.basename(plugin_dir).to_sym
|
235
|
-
status.entry_point = File.join(plugin_dir, "lib", status.name.to_s + ".rb")
|
236
|
-
status.installation_type = :core
|
237
|
-
status.loaded = false
|
238
|
-
registry[status.name.to_sym] = status
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
def read_conf_file_into_registry
|
243
|
-
conf_file.each do |plugin_entry|
|
244
|
-
status = Inspec::Plugin::V2::Status.new
|
245
|
-
status.name = plugin_entry[:name]
|
246
|
-
status.loaded = false
|
247
|
-
status.installation_type = (plugin_entry[:installation_type] || :user_gem)
|
248
|
-
case status.installation_type
|
249
|
-
when :user_gem
|
250
|
-
status.entry_point = status.name.to_s
|
251
|
-
status.version = plugin_entry[:version]
|
252
|
-
when :path
|
253
|
-
status.entry_point = plugin_entry[:installation_path]
|
254
|
-
end
|
255
|
-
|
256
|
-
# Train plugins are not true InSpec plugins; we need to decorate them a
|
257
|
-
# bit more to integrate them.
|
258
|
-
fixup_train_plugin_status(status) if train_plugin_name?(plugin_entry[:name])
|
259
|
-
|
260
|
-
registry[status.name] = status
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
def fixup_train_plugin_status(status)
|
265
|
-
status.api_generation = :'train-1'
|
266
|
-
if status.installation_type == :user_gem
|
267
|
-
# Activate the gem. This allows train to 'require' the gem later.
|
268
|
-
activate_managed_gems_for_plugin(status.entry_point)
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
def find_inspec_gemspec(name, ver)
|
273
|
-
Gem::Specification.find_by_name(name, ver)
|
274
|
-
rescue Gem::MissingSpecError
|
275
|
-
nil
|
276
|
-
end
|
277
|
-
|
278
|
-
def detect_system_plugins
|
279
|
-
# Find the gemspec for inspec
|
280
|
-
inspec_gemspec =
|
281
|
-
find_inspec_gemspec("inspec", "=#{Inspec::VERSION}") ||
|
282
|
-
find_inspec_gemspec("inspec-core", "=#{Inspec::VERSION}")
|
283
|
-
|
284
|
-
unless inspec_gemspec
|
285
|
-
Inspec::Log.warn "inspec gem not found, skipping detecting of system plugins"
|
286
|
-
return
|
287
|
-
end
|
288
|
-
|
289
|
-
# Make a RequestSet that represents the dependencies of inspec
|
290
|
-
inspec_deps_request_set = Gem::RequestSet.new(*inspec_gemspec.dependencies)
|
291
|
-
inspec_deps_request_set.remote = false
|
292
|
-
|
293
|
-
# Resolve the request against the installed gem universe
|
294
|
-
gem_resolver = Gem::Resolver::CurrentSet.new
|
295
|
-
runtime_solution = inspec_deps_request_set.resolve(gem_resolver)
|
296
|
-
|
297
|
-
inspec_gemspec.dependencies.each do |inspec_dep|
|
298
|
-
next unless inspec_plugin_name?(inspec_dep.name) || train_plugin_name?(inspec_dep.name)
|
299
|
-
|
300
|
-
plugin_spec = runtime_solution.detect { |s| s.name == inspec_dep.name }.spec
|
301
|
-
|
302
|
-
status = Inspec::Plugin::V2::Status.new
|
303
|
-
status.name = inspec_dep.name
|
304
|
-
status.entry_point = inspec_dep.name # gem-based, just 'require' the name
|
305
|
-
status.version = plugin_spec.version.to_s
|
306
|
-
status.loaded = false
|
307
|
-
status.installation_type = :system_gem
|
308
|
-
|
309
|
-
if train_plugin_name?(status[:name])
|
310
|
-
# Train plugins are not true InSpec plugins; we need to decorate them a
|
311
|
-
# bit more to integrate them.
|
312
|
-
fixup_train_plugin_status(status)
|
313
|
-
else
|
314
|
-
status.api_generation = 2
|
315
|
-
end
|
316
|
-
|
317
|
-
registry[status.name.to_sym] = status
|
318
|
-
end
|
319
|
-
end
|
320
|
-
end
|
321
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
module Inspec::Plugin::V2
|
2
|
-
# Base class for all plugins. Specific plugin types *may* inherit from this; but they must register with it.
|
3
|
-
class PluginBase
|
4
|
-
# rubocop: disable Style/ClassVars
|
5
|
-
@@plugin_type_classes = {}
|
6
|
-
# rubocop: enable Style/ClassVars
|
7
|
-
|
8
|
-
#=====================================================================#
|
9
|
-
# Management Methods
|
10
|
-
#=====================================================================#
|
11
|
-
|
12
|
-
# The global registry.
|
13
|
-
# @returns [Inspec::Plugin::V2::Registry] the singleton Plugin Registry object.
|
14
|
-
def self.registry
|
15
|
-
Inspec::Plugin::V2::Registry.instance
|
16
|
-
end
|
17
|
-
|
18
|
-
# Inform the plugin system of a new plgin type.
|
19
|
-
# This has the following effects:
|
20
|
-
# * enables Inspec.plugin(2, :your_type_here) to return the plugin
|
21
|
-
# type base class
|
22
|
-
# * defines the DSL method with the same name as the plugin type.
|
23
|
-
#
|
24
|
-
# @param [Symbol] plugin_type_name
|
25
|
-
# @param [Class] the plugin type class, defaults to assuming inheritance
|
26
|
-
def self.register_plugin_type(plugin_type_name, new_plugin_type_base_class = self)
|
27
|
-
new_dsl_method_name = plugin_type_name
|
28
|
-
|
29
|
-
# This lets the Inspec.plugin(2,:your_plugin_type) work
|
30
|
-
@@plugin_type_classes[plugin_type_name] = new_plugin_type_base_class
|
31
|
-
|
32
|
-
# This part defines the DSL command to register a concrete plugin's implementation of a plugin type
|
33
|
-
Inspec::Plugin::V2::PluginBase.define_singleton_method(new_dsl_method_name) do |hook_name, &hook_body|
|
34
|
-
plugin_concrete_class = self
|
35
|
-
|
36
|
-
# Verify class is registered (i.e. plugin_name has been called)
|
37
|
-
status = registry.find_status_by_class(plugin_concrete_class)
|
38
|
-
if status.nil?
|
39
|
-
raise Inspec::Plugin::V2::LoadError, "You must call 'plugin_name' prior to calling #{plugin_type_name} for plugin class #{plugin_concrete_class}"
|
40
|
-
end
|
41
|
-
|
42
|
-
# Construct the Activator record
|
43
|
-
activator = Inspec::Plugin::V2::Activator.new
|
44
|
-
activator.plugin_name = plugin_concrete_class.plugin_name
|
45
|
-
activator.plugin_type = plugin_type_name
|
46
|
-
activator.activator_name = hook_name.to_sym
|
47
|
-
activator.activation_proc = hook_body
|
48
|
-
|
49
|
-
status.activators << activator
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Determine the base class for a given plugin type
|
54
|
-
# @param [Symbol] plugin_type_name
|
55
|
-
# @returns [Class] the plugin type base class
|
56
|
-
def self.base_class_for_type(plugin_type_name)
|
57
|
-
@@plugin_type_classes[plugin_type_name]
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.find_name_by_implementation_class(impl_class)
|
61
|
-
# This is super awkward
|
62
|
-
activators = Inspec::Plugin::V2::Registry.instance.find_activators
|
63
|
-
activator = activators.detect { |a| a.implementation_class == impl_class }
|
64
|
-
activator.plugin_name
|
65
|
-
end
|
66
|
-
|
67
|
-
#=====================================================================#
|
68
|
-
# DSL Methods
|
69
|
-
#=====================================================================#
|
70
|
-
|
71
|
-
# If no name provided, looks up a known plugin by class and returns the name.
|
72
|
-
#
|
73
|
-
# DSL method to declare a plugin. Once this has been called, the plugin will certainly be
|
74
|
-
# registered (known) with the Registry, and is eligible to be activated.
|
75
|
-
# This mainly handles status annotation.
|
76
|
-
#
|
77
|
-
# @param [Symbol] Name of the plugin. If a string is provided, it is converted to a Symbol.
|
78
|
-
# @returns [Symbol] Name of the plugin
|
79
|
-
def self.plugin_name(name = nil)
|
80
|
-
reg = Inspec::Plugin::V2::Registry.instance
|
81
|
-
if name.nil?
|
82
|
-
# If called from a Plugin definition class...
|
83
|
-
stat = reg.find_status_by_class(self)
|
84
|
-
return stat.name if stat
|
85
|
-
|
86
|
-
# Called from an implementation class
|
87
|
-
return find_name_by_implementation_class(self)
|
88
|
-
end
|
89
|
-
|
90
|
-
name = name.to_sym
|
91
|
-
|
92
|
-
# Typically our status will already exist in the registry, from loading the
|
93
|
-
# plugin.json. If we're being loaded, presumably entry_point,
|
94
|
-
# installation_type, version
|
95
|
-
# are known.
|
96
|
-
unless reg.known_plugin?(name)
|
97
|
-
# Under some testing situations, we may not pre-exist.
|
98
|
-
status = Inspec::Plugin::V2::Status.new
|
99
|
-
reg.register(name, status)
|
100
|
-
status.entry_point = "inline"
|
101
|
-
status.installation_type = :mock_inline
|
102
|
-
end
|
103
|
-
|
104
|
-
status = reg[name]
|
105
|
-
status.api_generation = 2
|
106
|
-
status.plugin_class = self
|
107
|
-
status.name = name
|
108
|
-
|
109
|
-
name
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "inspec/base_cli"
|
2
|
-
|
3
|
-
# The InSpec load order has this file being loaded before `inspec/base_cli` can
|
4
|
-
# finish being loaded. So, we must define Inspec::BaseCLI here first to avoid
|
5
|
-
# a NameError below.
|
6
|
-
class Inspec::BaseCLI < Thor; end
|
7
|
-
|
8
|
-
module Inspec::Plugin::V2::PluginType
|
9
|
-
class CliCommand < Inspec::BaseCLI
|
10
|
-
# initialize log options for plugins
|
11
|
-
def initialize(args, options, config)
|
12
|
-
super(args, options, config)
|
13
|
-
class_options = config.fetch(:class_options, nil)
|
14
|
-
if class_options
|
15
|
-
Inspec::Log.init(class_options["log_location"]) if class_options.key?("log_location")
|
16
|
-
Inspec::Log.level = get_log_level(class_options["log_level"]) if class_options.key?("log_level")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# This class MUST inherit from Thor, which makes it a bit awkward to register the plugin subtype
|
21
|
-
# Since we can't inherit from PluginBase, we use the two-arg form of register_plugin_type
|
22
|
-
Inspec::Plugin::V2::PluginBase.register_plugin_type(:cli_command, self)
|
23
|
-
|
24
|
-
# Provide a description for the command group.
|
25
|
-
def self.subcommand_desc(usage_msg, desc_msg)
|
26
|
-
@usage_msg = usage_msg
|
27
|
-
@desc_msg = desc_msg
|
28
|
-
end
|
29
|
-
|
30
|
-
# Register the command group with Thor. This must be called on the implementation class AFTER
|
31
|
-
# the the cli_command activator has been called
|
32
|
-
def self.register_with_thor
|
33
|
-
# Figure out my activator name (= subcommand group name)
|
34
|
-
subcommand_name = Inspec::Plugin::V2::Registry.instance \
|
35
|
-
.find_activators(plugin_type: :cli_command, implementation_class: self) \
|
36
|
-
.first.activator_name.to_s
|
37
|
-
|
38
|
-
# Register with Thor
|
39
|
-
Inspec::InspecCLI.register(self, subcommand_name, @usage_msg, @desc_msg, {})
|
40
|
-
end
|
41
|
-
|
42
|
-
# Allow plugins to use inspec log settings
|
43
|
-
class_option :log_level, type: :string,
|
44
|
-
desc: "Set the log level: info (default), debug, warn, error"
|
45
|
-
|
46
|
-
class_option :log_location, type: :string,
|
47
|
-
desc: "Location to send diagnostic log messages to. (default: $stdout or Inspec::Log.error)"
|
48
|
-
end
|
49
|
-
end
|