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
data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/plugin_def_test.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# This unit test performs some tests to verify that
|
2
|
-
# the inspec-resource-lister plugin is configured correctly.
|
3
|
-
|
4
|
-
# Include our test harness
|
5
|
-
require_relative '../helper'
|
6
|
-
|
7
|
-
# Load the class under test, the Plugin definition.
|
8
|
-
require '<%= plugin_name %>/plugin'
|
9
|
-
|
10
|
-
# Because InSpec is a Spec-style test suite, we're going to use Minitest::Spec
|
11
|
-
# here, for familiar look and feel. However, this isn't InSpec (or RSpec) code.
|
12
|
-
|
13
|
-
describe InspecPlugins::<%= module_name %>::Plugin do
|
14
|
-
|
15
|
-
# When writing tests, you can use `let` to create variables that you
|
16
|
-
# can reference easily.
|
17
|
-
|
18
|
-
# Internally, plugins are always known by a Symbol name. Convert here.
|
19
|
-
let(:plugin_name) { :'<%= plugin_name %>' }
|
20
|
-
|
21
|
-
# The Registry knows about all plugins that ship with InSpec by
|
22
|
-
# default, as well as any that are installed by the user. When a
|
23
|
-
# plugin definition is loaded, it will also self-register.
|
24
|
-
let(:registry) { Inspec::Plugin::V2::Registry.instance }
|
25
|
-
|
26
|
-
# The plugin status record tells us what the Registry knows.
|
27
|
-
# Note that you can use previously-defined 'let's.
|
28
|
-
let(:status) { registry[plugin_name] }
|
29
|
-
|
30
|
-
# OK, actual tests!
|
31
|
-
|
32
|
-
# Does the Registry know about us at all?
|
33
|
-
it "should be registered" do
|
34
|
-
registry.known_plugin?(plugin_name)
|
35
|
-
end
|
36
|
-
|
37
|
-
# Some tests through here use minitest Expectations, which attach to all
|
38
|
-
# Objects, and begin with 'must' (positive) or 'wont' (negative)
|
39
|
-
# See http://docs.seattlerb.org/minitest/Minitest/Expectations.html
|
40
|
-
|
41
|
-
# The plugin system had an undocumented v1 API; this should be a v2 example.
|
42
|
-
it "should be an api-v2 plugin" do
|
43
|
-
status.api_generation.must_equal(2)
|
44
|
-
end
|
45
|
-
|
46
|
-
# Plugins can support several different activator hooks, each of which has a type.
|
47
|
-
# Since this is (primarily) a CliCommand plugin, we'd expect to see that among our types.
|
48
|
-
it "should include a cli_command activator hook" do
|
49
|
-
status.plugin_types.must_include(:cli_command)
|
50
|
-
end
|
51
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# copyright: 2018, The Authors
|
2
|
-
|
3
|
-
title "sample section"
|
4
|
-
|
5
|
-
# you can also use plain tests
|
6
|
-
describe file("/tmp") do
|
7
|
-
it { should be_directory }
|
8
|
-
end
|
9
|
-
|
10
|
-
# you add controls here
|
11
|
-
control "tmp-1.0" do # A unique ID for this control
|
12
|
-
impact 0.7 # The criticality, if this control fails.
|
13
|
-
title "Create /tmp directory" # A human-readable title
|
14
|
-
desc "An optional description..."
|
15
|
-
describe file("/tmp") do # The actual test
|
16
|
-
it { should be_directory }
|
17
|
-
end
|
18
|
-
end
|
File without changes
|
@@ -1,184 +0,0 @@
|
|
1
|
-
require_relative "../../../shared/core_plugin_test_helper.rb"
|
2
|
-
|
3
|
-
class InitPluginCli < Minitest::Test
|
4
|
-
include CorePluginFunctionalHelper
|
5
|
-
|
6
|
-
def test_generating_inspec_plugin_correct_prefix_required
|
7
|
-
Dir.mktmpdir do |dir|
|
8
|
-
plugin = "wacky-name"
|
9
|
-
run_result = run_inspec_process("init plugin --no-prompt #{plugin} ", prefix: "cd #{dir} &&")
|
10
|
-
|
11
|
-
skip_windows!
|
12
|
-
assert_includes run_result.stdout, "ERROR"
|
13
|
-
assert_includes run_result.stdout, "Plugin names must begin with"
|
14
|
-
|
15
|
-
assert_empty run_result.stderr
|
16
|
-
|
17
|
-
assert_exit_code 1, run_result
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_generating_inspec_plugin_with_default_options
|
22
|
-
Dir.mktmpdir do |dir|
|
23
|
-
plugin = "inspec-test-generated-plugin"
|
24
|
-
snake_case = plugin.tr("-", "_")
|
25
|
-
module_name = plugin.sub(/^inspec\-/, "").split("-").map(&:capitalize).join("")
|
26
|
-
|
27
|
-
run_result = run_inspec_process("init plugin --no-prompt #{plugin}", prefix: "cd #{dir} &&")
|
28
|
-
|
29
|
-
skip_windows!
|
30
|
-
assert_includes run_result.stdout, "Creating new inspec plugin at"
|
31
|
-
assert_includes run_result.stdout, plugin
|
32
|
-
|
33
|
-
assert_empty run_result.stderr
|
34
|
-
|
35
|
-
assert_exit_code 0, run_result
|
36
|
-
|
37
|
-
# Check generated files and contents.
|
38
|
-
# Each file must exist, and its contents must match each of the regexen given.
|
39
|
-
{
|
40
|
-
File.join(plugin, "README.md") => [
|
41
|
-
/#{plugin}/,
|
42
|
-
],
|
43
|
-
File.join(plugin, "LICENSE") => [
|
44
|
-
/(?!opyright)/, # No copyright by default
|
45
|
-
/Apache License/,
|
46
|
-
],
|
47
|
-
File.join(plugin, "Gemfile") => [], # No interpolation
|
48
|
-
File.join(plugin, "Rakefile") => [], # No interpolation
|
49
|
-
File.join(plugin, plugin + ".gemspec") => [
|
50
|
-
%r{require '#{plugin}/version'},
|
51
|
-
/spec\.name\s+=\s+'#{plugin}'/,
|
52
|
-
/spec\.version\s+=\s+InspecPlugins::#{module_name}::VERSION/,
|
53
|
-
/README\.md\s+#{snake_case}\.gemspec\s+Gemfile/,
|
54
|
-
/spec\.authors\s+=\s+\['Your Name'\]/,
|
55
|
-
/spec\.email\s+=\s+\['you@example\.com'\]/,
|
56
|
-
/spec\.summary\s+=\s+'A plugin with a default summary'/,
|
57
|
-
/spec\.description\s+=\s+''/,
|
58
|
-
%r{spec\.homepage\s+=\s+'https://github.com/you/#{plugin}'},
|
59
|
-
/spec\.license\s+=\s+'Apache-2\.0'/,
|
60
|
-
],
|
61
|
-
File.join(plugin, "lib", plugin + ".rb") => [
|
62
|
-
%r{require\s'#{plugin}/plugin'},
|
63
|
-
],
|
64
|
-
File.join(plugin, "lib", plugin, "plugin.rb") => [
|
65
|
-
%r{require\s'#{plugin}/version'},
|
66
|
-
/\#\s#{plugin}\s=>\s#{module_name}/,
|
67
|
-
/module\s#{module_name}/,
|
68
|
-
/plugin_name\s+:'#{plugin}'/,
|
69
|
-
# Default assumes one cli hook
|
70
|
-
/cli_command :my_command/,
|
71
|
-
%r{require\s'#{plugin}/cli_command'},
|
72
|
-
/InspecPlugins::#{module_name}::CliCommand/,
|
73
|
-
],
|
74
|
-
File.join(plugin, "lib", plugin, "version.rb") => [
|
75
|
-
/module\s#{module_name}/,
|
76
|
-
],
|
77
|
-
File.join(plugin, "lib", plugin, "cli_command.rb") => [
|
78
|
-
/module\sInspecPlugins::#{module_name}/,
|
79
|
-
/\#\smakes\s`inspec\smy-command\s\.\.\.`\swork\./,
|
80
|
-
/subcommand_desc\s'my_command\s\[COMMAND\]'/,
|
81
|
-
/\#\sas\s`inspec\smy-command\sdo-something/,
|
82
|
-
/\#\sin\s`inspec\shelp\smy-command`/,
|
83
|
-
/\#\sruns\s`inspec\smy-command\sdo-something`./,
|
84
|
-
%r{Edit\slib/#{plugin}/cli_command\.rb\sto\smake\sit\sdo},
|
85
|
-
],
|
86
|
-
File.join(plugin, "test", "helper.rb") => [], # No interpolation
|
87
|
-
File.join(plugin, "test", "functional", "README.md") => [], # No interpolation
|
88
|
-
File.join(plugin, "test", "functional", snake_case + "_test.rb") => [
|
89
|
-
# Whatever goes here
|
90
|
-
],
|
91
|
-
File.join(plugin, "test", "unit", "plugin_def_test.rb") => [
|
92
|
-
%r{require\s'#{plugin}/plugin'},
|
93
|
-
/describe InspecPlugins::#{module_name}::Plugin\sdo/,
|
94
|
-
/let\(:plugin_name\) \{ \:'#{plugin}\' \}/,
|
95
|
-
],
|
96
|
-
File.join(plugin, "test", "unit", "cli_args_test.rb") => [
|
97
|
-
%r{require '#{plugin}/cli_command'},
|
98
|
-
/describe InspecPlugins::#{module_name}::CliCommand do/,
|
99
|
-
/let\(\:cli_class\) \{ InspecPlugins::#{module_name}::CliCommand \}/,
|
100
|
-
],
|
101
|
-
File.join(plugin, "test", "unit", "README.md") => [
|
102
|
-
/cli_args_test\.rb/,
|
103
|
-
],
|
104
|
-
}.each do |path, regexen|
|
105
|
-
full_path = File.join(dir, path)
|
106
|
-
assert(File.exist?(full_path), "#{path} should have been generated")
|
107
|
-
next if regexen.empty?
|
108
|
-
|
109
|
-
contents = File.read(full_path)
|
110
|
-
regexen.each do |re|
|
111
|
-
assert_match re, contents, "#{path} should match #{re}"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_generating_inspec_plugin_with_custom_options
|
118
|
-
Dir.mktmpdir do |dir|
|
119
|
-
plugin = "inspec-test-generated-plugin"
|
120
|
-
snake_case = plugin.tr("-", "_")
|
121
|
-
|
122
|
-
opts = ""
|
123
|
-
opts += " --author-email bob@example.com "
|
124
|
-
opts += " --author-name Bob "
|
125
|
-
opts += ' --copyright "Copyright © 2018 Bob" '
|
126
|
-
opts += ' --description "That you will really like" '
|
127
|
-
opts += " --license-name BSD-3-Clause "
|
128
|
-
opts += ' --summary "A fantastic plugin" '
|
129
|
-
|
130
|
-
opts += " --homepage http://example.com "
|
131
|
-
opts += " --module_name FunPlugin"
|
132
|
-
|
133
|
-
run_result = run_inspec_process("init plugin #{plugin} --no-prompt #{opts}", prefix: "cd #{dir} &&")
|
134
|
-
|
135
|
-
skip_windows!
|
136
|
-
assert_includes run_result.stdout, "Creating new inspec plugin at"
|
137
|
-
assert_includes run_result.stdout, plugin
|
138
|
-
|
139
|
-
assert_empty run_result.stderr
|
140
|
-
|
141
|
-
assert_exit_code 0, run_result
|
142
|
-
|
143
|
-
# Check generated files and contents.
|
144
|
-
# Each file must exist, and its contents must match each of the regexen given.
|
145
|
-
|
146
|
-
{
|
147
|
-
File.join(plugin, "README.md") => [],
|
148
|
-
File.join(plugin, "LICENSE") => [
|
149
|
-
/Copyright . 2018 Bob/,
|
150
|
-
/used to endorse or promote/,
|
151
|
-
],
|
152
|
-
File.join(plugin, "Gemfile") => [],
|
153
|
-
File.join(plugin, "Rakefile") => [],
|
154
|
-
File.join(plugin, plugin + ".gemspec") => [
|
155
|
-
/spec\.version\s+=\s+InspecPlugins::FunPlugin::VERSION/,
|
156
|
-
/spec\.authors\s+=\s+\['Bob'\]/,
|
157
|
-
/spec\.email\s+=\s+\['bob@example\.com'\]/,
|
158
|
-
/spec\.summary\s+=\s+'A fantastic plugin'/,
|
159
|
-
/spec\.description\s+=\s+'That you will really like'/,
|
160
|
-
%r{spec\.homepage\s+=\s+'http://example.com'},
|
161
|
-
/spec\.license\s+=\s+'BSD-3-Clause'/,
|
162
|
-
],
|
163
|
-
File.join(plugin, "lib", plugin + ".rb") => [],
|
164
|
-
File.join(plugin, "lib", plugin, "plugin.rb") => [],
|
165
|
-
File.join(plugin, "lib", plugin, "version.rb") => [],
|
166
|
-
File.join(plugin, "lib", plugin, "cli_command.rb") => [],
|
167
|
-
File.join(plugin, "test", "helper.rb") => [],
|
168
|
-
File.join(plugin, "test", "functional", snake_case + "_test.rb") => [],
|
169
|
-
File.join(plugin, "test", "unit", "plugin_def_test.rb") => [],
|
170
|
-
File.join(plugin, "test", "unit", "cli_args_test.rb") => [],
|
171
|
-
}.each do |path, regexen|
|
172
|
-
full_path = File.join(dir, path)
|
173
|
-
assert(File.exist?(full_path), "#{path} should have been generated")
|
174
|
-
next if regexen.empty?
|
175
|
-
|
176
|
-
contents = File.read(full_path)
|
177
|
-
regexen.each do |re|
|
178
|
-
assert_match re, contents, "#{path} should match #{re}"
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
require "yaml"
|
2
|
-
require_relative "../../../shared/core_plugin_test_helper.rb"
|
3
|
-
|
4
|
-
class InitCli < Minitest::Test
|
5
|
-
include CorePluginFunctionalHelper
|
6
|
-
|
7
|
-
def test_generating_inspec_profile
|
8
|
-
Dir.mktmpdir do |dir|
|
9
|
-
profile = File.join(dir, "test-profile")
|
10
|
-
out = run_inspec_process("init profile test-profile", prefix: "cd #{dir} &&")
|
11
|
-
|
12
|
-
skip_windows!
|
13
|
-
assert_includes out.stdout, "Creating new profile at"
|
14
|
-
assert_includes out.stdout, profile
|
15
|
-
assert_includes Dir.entries(profile).join, "inspec.yml"
|
16
|
-
assert_includes Dir.entries(profile).join, "README.md"
|
17
|
-
|
18
|
-
assert_exit_code 0, out
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_generating_inspec_profile_with_explicit_platform
|
23
|
-
Dir.mktmpdir do |dir|
|
24
|
-
profile = File.join(dir, "test-profile")
|
25
|
-
out = run_inspec_process("init profile --platform os test-profile", prefix: "cd #{dir} &&")
|
26
|
-
|
27
|
-
skip_windows!
|
28
|
-
assert_includes out.stdout, "Creating new profile at"
|
29
|
-
assert_includes out.stdout, profile
|
30
|
-
assert_includes Dir.entries(profile).join, "inspec.yml"
|
31
|
-
assert_includes Dir.entries(profile).join, "README.md"
|
32
|
-
|
33
|
-
assert_exit_code 0, out
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_generating_inspec_profile_with_bad_platform
|
38
|
-
Dir.mktmpdir do |dir|
|
39
|
-
out = run_inspec_process("init profile --platform nonesuch test-profile", prefix: "cd #{dir} &&")
|
40
|
-
|
41
|
-
skip_windows!
|
42
|
-
assert_includes out.stdout, "Unable to generate profile"
|
43
|
-
assert_includes out.stdout, "No template available for platform 'nonesuch'"
|
44
|
-
|
45
|
-
assert_exit_code 1, out
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_profile_with_slash_name
|
50
|
-
Dir.mktmpdir do |dir|
|
51
|
-
profile = dir + "/test/deeper/profile"
|
52
|
-
out = run_inspec_process("init profile test/deeper/profile", prefix: "cd #{dir} &&")
|
53
|
-
skip_windows!
|
54
|
-
assert_equal true, File.exist?(profile)
|
55
|
-
profile = YAML.load_file("#{profile}/inspec.yml")
|
56
|
-
assert_equal "profile", profile["name"]
|
57
|
-
|
58
|
-
assert_exit_code 0, out
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_generating_inspec_profile_gcp
|
63
|
-
Dir.mktmpdir do |dir|
|
64
|
-
profile = File.join(dir, "test-gcp-profile")
|
65
|
-
out = run_inspec_process("init profile --platform gcp test-gcp-profile", prefix: "cd #{dir} &&")
|
66
|
-
|
67
|
-
skip_windows!
|
68
|
-
assert_includes out.stdout, "Creating new profile at"
|
69
|
-
assert_includes out.stdout, profile
|
70
|
-
assert_includes Dir.entries(profile).join, "inspec.yml"
|
71
|
-
assert_includes Dir.entries(profile).join, "README.md"
|
72
|
-
|
73
|
-
assert_exit_code 0, out
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_generating_inspec_profile_aws
|
78
|
-
Dir.mktmpdir do |dir|
|
79
|
-
profile = File.join(dir, "test-aws-profile")
|
80
|
-
out = run_inspec_process("init profile --platform aws test-aws-profile", prefix: "cd #{dir} &&")
|
81
|
-
|
82
|
-
skip_windows!
|
83
|
-
assert_includes out.stdout, "Creating new profile at"
|
84
|
-
assert_includes out.stdout, profile
|
85
|
-
assert_includes Dir.entries(profile).join, "inspec.yml"
|
86
|
-
assert_includes Dir.entries(profile).join, "README.md"
|
87
|
-
|
88
|
-
assert_exit_code 0, out
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_generating_inspec_profile_azure
|
93
|
-
Dir.mktmpdir do |dir|
|
94
|
-
profile = File.join(dir, "test-azure-profile")
|
95
|
-
out = run_inspec_process("init profile --platform azure test-azure-profile", prefix: "cd #{dir} &&")
|
96
|
-
|
97
|
-
skip_windows!
|
98
|
-
assert_includes out.stdout, "Creating new profile at"
|
99
|
-
assert_includes out.stdout, profile
|
100
|
-
assert_includes Dir.entries(profile).join, "inspec.yml"
|
101
|
-
assert_includes Dir.entries(profile).join, "README.md"
|
102
|
-
|
103
|
-
assert_exit_code 0, out
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_generating_inspec_profile_os
|
108
|
-
Dir.mktmpdir do |dir|
|
109
|
-
profile = File.join(dir, "test-os-profile")
|
110
|
-
out = run_inspec_process("init profile --platform os test-os-profile", prefix: "cd #{dir} &&")
|
111
|
-
|
112
|
-
skip_windows!
|
113
|
-
assert_includes out.stdout, "Creating new profile at"
|
114
|
-
assert_includes out.stdout, profile
|
115
|
-
assert_includes Dir.entries(profile).join, "inspec.yml"
|
116
|
-
assert_includes Dir.entries(profile).join, "README.md"
|
117
|
-
|
118
|
-
assert_exit_code 0, out
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# Because this is a core plugin, we place the plugin definition here in the entry point.
|
2
|
-
# This is needed because under core testing, the entry point may be reloaded multiple times,
|
3
|
-
# and we need plugin registration to properly occur each time.
|
4
|
-
# More typically, the entry point would just load a plugin definition file.
|
5
|
-
|
6
|
-
module InspecPlugins
|
7
|
-
module PluginManager
|
8
|
-
class Plugin < Inspec.plugin(2)
|
9
|
-
plugin_name :'inspec-plugin-manager-cli'
|
10
|
-
|
11
|
-
cli_command :plugin do
|
12
|
-
require_relative "inspec-plugin-manager-cli/cli_command"
|
13
|
-
InspecPlugins::PluginManager::CliCommand
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,518 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
require "inspec/plugin/v2"
|
3
|
-
require "inspec/plugin/v2/installer"
|
4
|
-
require "inspec/dist"
|
5
|
-
|
6
|
-
module InspecPlugins
|
7
|
-
module PluginManager
|
8
|
-
class CliCommand < Inspec.plugin(2, :cli_command)
|
9
|
-
INSTALL_TYPE_LABELS = {
|
10
|
-
bundle: "core", # Calling this core, too - not much of a distinction
|
11
|
-
core: "core",
|
12
|
-
path: "path",
|
13
|
-
user_gem: "gem (user)",
|
14
|
-
system_gem: "gem (system)",
|
15
|
-
}.freeze
|
16
|
-
|
17
|
-
include Inspec::Dist
|
18
|
-
|
19
|
-
subcommand_desc "plugin SUBCOMMAND", "Manage #{PRODUCT_NAME} and Train plugins"
|
20
|
-
|
21
|
-
#==================================================================#
|
22
|
-
# inspec plugin list
|
23
|
-
#==================================================================#
|
24
|
-
|
25
|
-
desc "list [options]", "Lists user-installed #{PRODUCT_NAME} plugins."
|
26
|
-
option :all, desc: "List all types of plugins (default)", type: :boolean, default: true, aliases: [:a]
|
27
|
-
option :user, desc: "List user plugins, from ~/.inspec/gems", banner: "", type: :boolean, default: false, aliases: [:u]
|
28
|
-
option :system, desc: "List system plugins, those InSpec depends on", banner: "", type: :boolean, default: false, aliases: [:s]
|
29
|
-
option :core, desc: "List core plugins, those InSpec ships with", banner: "", type: :boolean, default: false, aliases: [:c]
|
30
|
-
|
31
|
-
def list
|
32
|
-
plugin_statuses = Inspec::Plugin::V2::Registry.instance.plugin_statuses
|
33
|
-
options[:all] = false if options[:core] || options[:user] || options[:system]
|
34
|
-
plugin_statuses.select! do |status|
|
35
|
-
type = status.installation_type
|
36
|
-
options[:all] ||
|
37
|
-
(options[:core] && %i{core bundle}.include?(type)) ||
|
38
|
-
(options[:user] && %i{user_gem path}.include?(type)) ||
|
39
|
-
(options[:system] && :system_gem == type)
|
40
|
-
end
|
41
|
-
|
42
|
-
unless plugin_statuses.empty?
|
43
|
-
ui.table do |t|
|
44
|
-
t.header = ["Plugin Name", "Version", "Via", "ApiVer"]
|
45
|
-
plugin_statuses.sort_by { |s| s.name.to_s }.each do |status|
|
46
|
-
t << [
|
47
|
-
status.name,
|
48
|
-
make_pretty_version(status),
|
49
|
-
make_pretty_install_type(status),
|
50
|
-
status.api_generation,
|
51
|
-
]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
ui.plain_line(" #{plugin_statuses.count} plugin(s) total")
|
56
|
-
puts
|
57
|
-
end
|
58
|
-
|
59
|
-
#==================================================================#
|
60
|
-
# inspec plugin search
|
61
|
-
#==================================================================#
|
62
|
-
|
63
|
-
desc "search [options] PATTERN", "Searches rubygems.org for plugins."
|
64
|
-
long_desc <<~EOLD
|
65
|
-
Searches rubygems.org for #{PRODUCT_NAME} plugins. Exits 0 on a search hit, 1 on user error,
|
66
|
-
2 on a search miss. PATTERN is a simple string; a wildcard will be added as
|
67
|
-
a suffix, unless -e is used.
|
68
|
-
EOLD
|
69
|
-
option :all, desc: "List all available versions, not just the latest one.", type: :boolean, aliases: [:a]
|
70
|
-
option :exact, desc: "Assume PATTERN is exact; do not add a wildcard to the end", type: :boolean, aliases: [:e]
|
71
|
-
option :'include-test-fixture', type: :boolean, desc: "Internal use", hide: true
|
72
|
-
# Justification for disabling ABC: currently at 33.51/33
|
73
|
-
def search(search_term) # rubocop: disable Metrics/AbcSize
|
74
|
-
search_results = installer.search(search_term, exact: options[:exact])
|
75
|
-
# The search results have already been filtered by the reject list. But the
|
76
|
-
# RejectList doesn't filter {inspec, train}-test-fixture because we need those
|
77
|
-
# for testing. We want to hide those from users, so unless we know we're in
|
78
|
-
# test mode, remove them.
|
79
|
-
unless options[:'include-test-fixture']
|
80
|
-
search_results.delete("inspec-test-fixture")
|
81
|
-
search_results.delete("train-test-fixture")
|
82
|
-
end
|
83
|
-
|
84
|
-
puts
|
85
|
-
ui.bold(format(" %-30s%-50s\n", "Plugin Name", "Versions Available"))
|
86
|
-
ui.line
|
87
|
-
search_results.keys.sort.each do |plugin_name|
|
88
|
-
versions = options[:all] ? search_results[plugin_name] : [search_results[plugin_name].first]
|
89
|
-
versions = "(" + versions.join(", ") + ")"
|
90
|
-
ui.plain_line(format(" %-30s%-50s", plugin_name, versions))
|
91
|
-
end
|
92
|
-
ui.line
|
93
|
-
ui.plain_line(" #{search_results.count} plugin(s) found")
|
94
|
-
puts
|
95
|
-
|
96
|
-
ui.exit Inspec::UI::EXIT_PLUGIN_ERROR if search_results.empty?
|
97
|
-
rescue Inspec::Plugin::V2::SearchError => ex
|
98
|
-
Inspec::Log.error ex.message
|
99
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
100
|
-
end
|
101
|
-
|
102
|
-
#==================================================================#
|
103
|
-
# inspec plugin install
|
104
|
-
#==================================================================#
|
105
|
-
desc "install [-v VERSION] PLUGIN", "Installs a plugin from rubygems.org, a gemfile, or a path to local source."
|
106
|
-
long_desc <<~EOLD
|
107
|
-
PLUGIN may be the name of a gem on rubygems.org that begins with inspec- or train-.
|
108
|
-
PLUGIN may also be the path to a local gemfile, which will then be installed like
|
109
|
-
any other gem. Finally, if PLUGIN is a path ending in .rb, it is taken to be a
|
110
|
-
local file that will act as athe entry point for a plugin (this mode is provided
|
111
|
-
for local plugin development). Exit codes are 0 on success, 2 if the plugin is
|
112
|
-
already installed, and 1 if any other error occurs.
|
113
|
-
EOLD
|
114
|
-
option :version, desc: "When installing from rubygems.org, specifies a specific version to install.", aliases: [:v]
|
115
|
-
def install(plugin_id_arg)
|
116
|
-
if plugin_id_arg =~ /\.gem$/ # Does it end in .gem?
|
117
|
-
install_from_gemfile(plugin_id_arg)
|
118
|
-
elsif plugin_id_arg =~ %r{[\/\\]} || Dir.exist?(plugin_id_arg) # Does the argument have a slash, or exist as dir in the local directory?
|
119
|
-
install_from_path(plugin_id_arg)
|
120
|
-
else
|
121
|
-
install_from_remote_gem(plugin_id_arg)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
#--------------------------
|
126
|
-
# update
|
127
|
-
#--------------------------
|
128
|
-
desc "update PLUGIN", "Updates a plugin to the latest from from rubygems.org"
|
129
|
-
long_desc <<~EOLD
|
130
|
-
PLUGIN may be the name of a gem on rubygems.org that begins with inspec- or train-.
|
131
|
-
Exit codes are 0 on success, 2 if the plugin is already up to date, and 1 if any
|
132
|
-
other error occurs.
|
133
|
-
EOLD
|
134
|
-
def update(plugin_name)
|
135
|
-
pre_update_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
|
136
|
-
old_version = pre_update_versions.join(", ")
|
137
|
-
|
138
|
-
update_preflight_check(plugin_name, pre_update_versions)
|
139
|
-
|
140
|
-
begin
|
141
|
-
installer.update(plugin_name)
|
142
|
-
rescue Inspec::Plugin::V2::UpdateError => ex
|
143
|
-
ui.plain_line("#{ui.red("Update error:", print: false)} #{ex.message} - update failed")
|
144
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
145
|
-
end
|
146
|
-
post_update_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
|
147
|
-
new_version = (post_update_versions - pre_update_versions).first
|
148
|
-
|
149
|
-
ui.bold(plugin_name + " plugin, version #{old_version} -> " \
|
150
|
-
"#{new_version}, updated from rubygems.org\n")
|
151
|
-
end
|
152
|
-
|
153
|
-
#--------------------------
|
154
|
-
# uninstall
|
155
|
-
#--------------------------
|
156
|
-
desc "uninstall PLUGIN_NAME", "Uninstalls a gem- or path- based plugin"
|
157
|
-
long_desc <<~EOLD
|
158
|
-
Removes a plugin from the users configuration.
|
159
|
-
In the case of a gem plugin (by far the most common), the plugin gem is removed, along
|
160
|
-
with any of its dependencies that are no longer needed by anything else. Finally, the
|
161
|
-
plugin configuration file is updated to reflect that the plugin is no longer present.
|
162
|
-
In the case of a path-based plugin (often used for plugin development), no changes
|
163
|
-
are made to the referenced plugin source code. Rather, the plugin's entry is simply removed
|
164
|
-
from the plugin config file.
|
165
|
-
EOLD
|
166
|
-
def uninstall(plugin_name)
|
167
|
-
status = Inspec::Plugin::V2::Registry.instance[plugin_name.to_sym]
|
168
|
-
unless status
|
169
|
-
ui.plain_line("#{ui.red("No such plugin installed:", print: false)} #{plugin_name} is not " \
|
170
|
-
"installed - uninstall failed")
|
171
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
172
|
-
end
|
173
|
-
installer = Inspec::Plugin::V2::Installer.instance
|
174
|
-
|
175
|
-
pre_uninstall_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
|
176
|
-
old_version = pre_uninstall_versions.join(", ")
|
177
|
-
|
178
|
-
installer.uninstall(plugin_name)
|
179
|
-
|
180
|
-
if status.installation_type == :path
|
181
|
-
ui.bold(plugin_name + " path-based plugin install has been " \
|
182
|
-
"uninstalled\n")
|
183
|
-
else
|
184
|
-
ui.bold(plugin_name + " plugin, version #{old_version}, has " \
|
185
|
-
"been uninstalled\n")
|
186
|
-
end
|
187
|
-
|
188
|
-
ui.exit Inspec::UI::EXIT_NORMAL
|
189
|
-
end
|
190
|
-
|
191
|
-
private
|
192
|
-
|
193
|
-
#==================================================================#
|
194
|
-
# install breakdown
|
195
|
-
#==================================================================#
|
196
|
-
# These are broken down because rubocop complained.
|
197
|
-
|
198
|
-
def install_from_gemfile(gem_file)
|
199
|
-
unless File.exist? gem_file
|
200
|
-
ui.red("No such plugin gem file #{gem_file} - installation failed.\n")
|
201
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
202
|
-
end
|
203
|
-
|
204
|
-
plugin_name_parts = File.basename(gem_file, ".gem").split("-")
|
205
|
-
version = plugin_name_parts.pop
|
206
|
-
plugin_name = plugin_name_parts.join("-")
|
207
|
-
check_plugin_name(plugin_name, "installation")
|
208
|
-
|
209
|
-
installer.install(plugin_name, gem_file: gem_file)
|
210
|
-
|
211
|
-
ui.bold("#{plugin_name} plugin, version #{version}, installed from " \
|
212
|
-
"local .gem file\n")
|
213
|
-
ui.exit Inspec::UI::EXIT_NORMAL
|
214
|
-
end
|
215
|
-
|
216
|
-
def install_from_path(path)
|
217
|
-
unless File.exist? path
|
218
|
-
ui.red("No such source code path #{path} - installation failed.\n")
|
219
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
220
|
-
end
|
221
|
-
|
222
|
-
plugin_name = File.basename(path, ".rb")
|
223
|
-
|
224
|
-
# While installer.install does some rudimentary checking,
|
225
|
-
# this file has good UI access, so we promise to validate the
|
226
|
-
# input a lot and hand the installer a sure-thing.
|
227
|
-
|
228
|
-
# Name OK?
|
229
|
-
check_plugin_name(plugin_name, "installation")
|
230
|
-
|
231
|
-
# Already installed?
|
232
|
-
if registry.known_plugin?(plugin_name.to_sym)
|
233
|
-
ui.red("Plugin already installed - #{plugin_name} - Use '#{EXEC_NAME} " \
|
234
|
-
"plugin list' to see previously installed plugin - " \
|
235
|
-
"installation failed.\n")
|
236
|
-
ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
|
237
|
-
end
|
238
|
-
|
239
|
-
# Can we figure out how to load it?
|
240
|
-
entry_point = install_from_path__apply_entry_point_heuristics(path)
|
241
|
-
|
242
|
-
# If you load it, does it act like a plugin?
|
243
|
-
install_from_path__probe_load(entry_point, plugin_name)
|
244
|
-
|
245
|
-
# OK, install it!
|
246
|
-
installer.install(plugin_name, path: entry_point)
|
247
|
-
|
248
|
-
ui.bold("#{plugin_name} plugin installed via source path reference, " \
|
249
|
-
"resolved to entry point #{entry_point}\n")
|
250
|
-
ui.exit Inspec::UI::EXIT_NORMAL
|
251
|
-
end
|
252
|
-
|
253
|
-
# Rationale for rubocop variances: It's a heuristics method, and will be full of
|
254
|
-
# conditionals. The code is well-commented; refactoring into sub-methods would
|
255
|
-
# reduce clarity.
|
256
|
-
def install_from_path__apply_entry_point_heuristics(path) # rubocop: disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
257
|
-
given = Pathname.new(path)
|
258
|
-
given = given.expand_path # Resolve any relative paths
|
259
|
-
name_regex = /^(inspec|train)-/
|
260
|
-
versioned_regex = /^(inspec|train)-[a-z0-9\-\_]+-\d+\.\d+\.\d+$/
|
261
|
-
sha_ref_regex = /^(inspec|train)-[a-z0-9\-\_]+-[0-9a-f]{5,40}$/
|
262
|
-
|
263
|
-
# What are the last four things like?
|
264
|
-
parts = [
|
265
|
-
given.parent.parent.basename,
|
266
|
-
given.parent.basename,
|
267
|
-
given.basename(".rb"),
|
268
|
-
given.extname,
|
269
|
-
].map(&:to_s)
|
270
|
-
|
271
|
-
# Case 1: Simplest case: it was a full entry point, as presented.
|
272
|
-
# /home/you/projects/inspec-something/lib/inspec-something.rb
|
273
|
-
# parts index: ^0^ ^1^ ^2^ ^3^
|
274
|
-
if parts[0] =~ name_regex && parts[1] == "lib" && parts[2] == parts[0] && parts[3] == ".rb"
|
275
|
-
return given.to_s
|
276
|
-
end
|
277
|
-
|
278
|
-
# Case 2: Also easy: they either referred to the internal library directory,
|
279
|
-
# or left the extansion off. Those are the same to us.
|
280
|
-
# /home/you/projects/inspec-something/lib/inspec-something
|
281
|
-
# parts index: ^0^ ^1^ ^2^ (3 is empty)
|
282
|
-
if parts[0] =~ name_regex && parts[1] == "lib" && parts[2] == parts[0] && parts[3].empty?
|
283
|
-
return given.to_s + ".rb"
|
284
|
-
end
|
285
|
-
|
286
|
-
# Case 3: Maybe they were refering to a path that is inside a gem installation, or an exploded gem?
|
287
|
-
# In that case, we'll have a version on the plugin name in part 0
|
288
|
-
# /home/you/.gems/2.4.0/gems/inspec-something-3.45.1/lib/inspec-something.rb
|
289
|
-
# parts index: ^0^ ^1^ ^2^ ^3^
|
290
|
-
if (parts[0] =~ versioned_regex || parts[0] =~ sha_ref_regex) && parts[1] == "lib" && parts[0].start_with?(parts[2]) && parts[3] == ".rb"
|
291
|
-
return given.to_s
|
292
|
-
end
|
293
|
-
|
294
|
-
# Case 4: Like case 3, but missing the .rb
|
295
|
-
# /home/you/.gems/2.4.0/gems/inspec-something-3.45.1/lib/inspec-something
|
296
|
-
# parts index: ^0^ ^1^ ^2^ ^3^ (empty)
|
297
|
-
if (parts[0] =~ versioned_regex || parts[0] =~ sha_ref_regex) && parts[1] == "lib" && parts[0].start_with?(parts[2]) && parts[3].empty?
|
298
|
-
return given.to_s + ".rb"
|
299
|
-
end
|
300
|
-
|
301
|
-
# Case 5: Easy to recognize, but harder to handle: they referred to the project root.
|
302
|
-
# /home/you/projects/inspec-something
|
303
|
-
# parts index: ^0^ ^1^ ^2^ (3 is empty)
|
304
|
-
# 0 and 1 are not meaningful to us, but we hope to find a parts[2]/lib/inspec-something.rb.
|
305
|
-
entry_point_guess = File.join(given.to_s, "lib", parts[2] + ".rb")
|
306
|
-
if parts[2] =~ name_regex && File.exist?(entry_point_guess)
|
307
|
-
return entry_point_guess
|
308
|
-
end
|
309
|
-
|
310
|
-
# Well, if we got here, parts[2] matches an inspec/train prefix, but we have no idea about anything.
|
311
|
-
# Give up.
|
312
|
-
ui.red("Unrecognizable plugin structure - #{parts[2]} - When " \
|
313
|
-
"installing from a path, please provide the path of the " \
|
314
|
-
"entry point file - installation failed.\n")
|
315
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
316
|
-
end
|
317
|
-
|
318
|
-
def install_from_path__probe_load(entry_point, plugin_name)
|
319
|
-
# Brazenly attempt to load a file, and see if it registers a plugin.
|
320
|
-
begin
|
321
|
-
require entry_point
|
322
|
-
rescue LoadError => ex
|
323
|
-
ui.red("Plugin contains errors - #{plugin_name} - Encountered " \
|
324
|
-
"errors while trying to test load the plugin entry point, " \
|
325
|
-
"resolved to #{entry_point} - installation failed\n")
|
326
|
-
ui.plain_line ex.message
|
327
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
328
|
-
end
|
329
|
-
|
330
|
-
# OK, the wheels didn't fall off. But is it a plugin?
|
331
|
-
if plugin_name.to_s.start_with?("train")
|
332
|
-
# Train internal names do not include the prix in their registry entries
|
333
|
-
# And the registry is keyed on Strings
|
334
|
-
registry_key = plugin_name.to_s.sub(/^train-/, "")
|
335
|
-
unless Train::Plugins.registry.key?(registry_key)
|
336
|
-
ui.red("Does not appear to be a plugin - #{plugin_name} - After " \
|
337
|
-
"probe-loading the supposed plugin, it did not register " \
|
338
|
-
"itself to Train. Ensure something inherits from " \
|
339
|
-
"'Train.plugin(1)' - installation failed.\n")
|
340
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
341
|
-
end
|
342
|
-
else
|
343
|
-
unless registry.known_plugin?(plugin_name.to_sym)
|
344
|
-
ui.red("Does not appear to be a plugin - #{plugin_name} - After " \
|
345
|
-
"probe-loading the supposed plugin, it did not register " \
|
346
|
-
"itself to InSpec. Ensure something inherits from " \
|
347
|
-
"'Inspec.plugin(2)' - installation failed.\n")
|
348
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
349
|
-
end
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
def install_from_remote_gem(plugin_name)
|
354
|
-
requested_version = options[:version]
|
355
|
-
|
356
|
-
check_plugin_name(plugin_name, "installation")
|
357
|
-
|
358
|
-
# Version pre-flighting
|
359
|
-
pre_installed_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
|
360
|
-
install_from_remote_gem_verson_preflight_check(plugin_name, requested_version, pre_installed_versions)
|
361
|
-
|
362
|
-
install_attempt_install(plugin_name)
|
363
|
-
|
364
|
-
# Success messaging. What did we actually install?
|
365
|
-
post_installed_versions = installer.list_installed_plugin_gems.select { |spec| spec.name == plugin_name }.map { |spec| spec.version.to_s }
|
366
|
-
new_version = (post_installed_versions - pre_installed_versions).first
|
367
|
-
|
368
|
-
ui.bold("#{plugin_name} plugin, version #{new_version}, installed " \
|
369
|
-
"from rubygems.org\n")
|
370
|
-
ui.exit Inspec::UI::EXIT_NORMAL
|
371
|
-
end
|
372
|
-
|
373
|
-
def install_from_remote_gem_verson_preflight_check(plugin_name, requested_version, pre_installed_versions)
|
374
|
-
return if pre_installed_versions.empty?
|
375
|
-
|
376
|
-
# Everything past here in the block is a code 2 error
|
377
|
-
|
378
|
-
# If they didn't ask for a specific version, they implicitly ask for the latest.
|
379
|
-
# Do an expensive search to determine the latest version.
|
380
|
-
unless requested_version
|
381
|
-
latest_version = installer.search(plugin_name, exact: true, scope: :latest)
|
382
|
-
latest_version = latest_version[plugin_name]&.last
|
383
|
-
if latest_version && !requested_version
|
384
|
-
requested_version = latest_version
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
# Check for already-installed at desired version conditions
|
389
|
-
they_explicitly_asked_for_a_version = !options[:version].nil?
|
390
|
-
what_we_would_install_is_already_installed = pre_installed_versions.include?(requested_version)
|
391
|
-
if what_we_would_install_is_already_installed && they_explicitly_asked_for_a_version
|
392
|
-
ui.red("Plugin already installed at requested version - plugin " \
|
393
|
-
"#{plugin_name} #{requested_version} - refusing to install.\n")
|
394
|
-
elsif what_we_would_install_is_already_installed && !they_explicitly_asked_for_a_version
|
395
|
-
ui.red("Plugin already installed at latest version - plugin " \
|
396
|
-
"#{plugin_name} #{requested_version} - refusing to install.\n")
|
397
|
-
else
|
398
|
-
# There are existing versions installed, but none of them are what was requested
|
399
|
-
ui.red("Update required - plugin #{plugin_name}, requested " \
|
400
|
-
"#{requested_version}, have " \
|
401
|
-
"#{pre_installed_versions.join(", ")}; use `inspec " \
|
402
|
-
"plugin update` - refusing to install.\n")
|
403
|
-
end
|
404
|
-
|
405
|
-
ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
|
406
|
-
end
|
407
|
-
|
408
|
-
# Rationale for RuboCop variance: This is a one-line method with heavy UX-focused error handling.
|
409
|
-
def install_attempt_install(plugin_name) # rubocop: disable Metrics/AbcSize
|
410
|
-
installer.install(plugin_name, version: options[:version])
|
411
|
-
rescue Inspec::Plugin::V2::PluginExcludedError => ex
|
412
|
-
ui.red("Plugin on Exclusion List - #{plugin_name} is listed as an " \
|
413
|
-
"incompatible gem - refusing to install.\n")
|
414
|
-
ui.plain_line("Rationale: #{ex.details.rationale}")
|
415
|
-
ui.plain_line("Exclusion list location: " +
|
416
|
-
File.join(Inspec.src_root, "etc", "plugin_filters.json"))
|
417
|
-
ui.plain_line("If you disagree with this determination, please accept " \
|
418
|
-
"our apologies for the misunderstanding, and open an issue " \
|
419
|
-
"at https://github.com/inspec/inspec/issues/new")
|
420
|
-
ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
|
421
|
-
rescue Inspec::Plugin::V2::InstallError
|
422
|
-
raise if Inspec::Log.level == :debug
|
423
|
-
|
424
|
-
results = installer.search(plugin_name, exact: true)
|
425
|
-
if results.empty?
|
426
|
-
ui.red("No such plugin gem #{plugin_name} could be found on " \
|
427
|
-
"rubygems.org - installation failed.\n")
|
428
|
-
elsif options[:version] && !results[plugin_name].include?(options[:version])
|
429
|
-
ui.red("No such version - #{plugin_name} exists, but no such " \
|
430
|
-
"version #{options[:version]} found on rubygems.org - " \
|
431
|
-
"installation failed.\n")
|
432
|
-
else
|
433
|
-
ui.red("Unknown error occured - installation failed.\n")
|
434
|
-
end
|
435
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
436
|
-
end
|
437
|
-
|
438
|
-
#==================================================================#
|
439
|
-
# update breakdown
|
440
|
-
#==================================================================#
|
441
|
-
def update_preflight_check(plugin_name, pre_update_versions)
|
442
|
-
if pre_update_versions.empty?
|
443
|
-
# Check for path install
|
444
|
-
status = Inspec::Plugin::V2::Registry.instance[plugin_name.to_sym]
|
445
|
-
if !status
|
446
|
-
ui.plain_line("#{ui.red("No such plugin installed:", print: false)} #{plugin_name} - update failed")
|
447
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
448
|
-
elsif status.installation_type == :path
|
449
|
-
ui.plain_line("#{ui.red("Cannot update path-based install:", print: false)} " \
|
450
|
-
"#{plugin_name} is installed via path reference; " \
|
451
|
-
"use `inspec plugin uninstall` to remove - refusing to" \
|
452
|
-
"update")
|
453
|
-
ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
|
454
|
-
end
|
455
|
-
end
|
456
|
-
|
457
|
-
# Check for latest version (and implicitly, existance)
|
458
|
-
latest_version = installer.search(plugin_name, exact: true, scope: :latest)
|
459
|
-
latest_version = latest_version[plugin_name]&.last
|
460
|
-
|
461
|
-
if pre_update_versions.include?(latest_version)
|
462
|
-
ui.plain_line("#{ui.red("Already installed at latest version:", print: false)} " \
|
463
|
-
"#{plugin_name} is at #{latest_version}, which the " \
|
464
|
-
"latest - refusing to update")
|
465
|
-
ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
|
466
|
-
end
|
467
|
-
end
|
468
|
-
|
469
|
-
#==================================================================#
|
470
|
-
# utilities
|
471
|
-
#==================================================================#
|
472
|
-
def installer
|
473
|
-
Inspec::Plugin::V2::Installer.instance
|
474
|
-
end
|
475
|
-
|
476
|
-
def registry
|
477
|
-
Inspec::Plugin::V2::Registry.instance
|
478
|
-
end
|
479
|
-
|
480
|
-
def check_plugin_name(plugin_name, action)
|
481
|
-
unless plugin_name =~ /^(inspec|train)-/
|
482
|
-
ui.red("Invalid plugin name - #{plugin_name} - All inspec " \
|
483
|
-
"plugins must begin with either 'inspec-' or 'train-' " \
|
484
|
-
"- #{action} failed.\n")
|
485
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
def make_pretty_version(status)
|
490
|
-
case status.installation_type
|
491
|
-
when :core, :bundle
|
492
|
-
Inspec::VERSION
|
493
|
-
when :user_gem, :system_gem
|
494
|
-
if status.version.nil?
|
495
|
-
"(unknown)"
|
496
|
-
elsif status.version =~ /^\d+\.\d+\.\d+$/
|
497
|
-
status.version
|
498
|
-
else
|
499
|
-
# Assume it is a version constraint string and try to resolve
|
500
|
-
# TODO: this is naive, and assumes the latest version is the one that will be used. Logged on #3317
|
501
|
-
# In fact, the logic to determine "what version would be used" belongs in the Loader.
|
502
|
-
plugin_name = status.name.to_s
|
503
|
-
Inspec::Plugin::V2::Loader.list_installed_plugin_gems
|
504
|
-
.select { |spec| spec.name == plugin_name }
|
505
|
-
.sort_by(&:version)
|
506
|
-
.last.version
|
507
|
-
end
|
508
|
-
when :path
|
509
|
-
"src"
|
510
|
-
end
|
511
|
-
end
|
512
|
-
|
513
|
-
def make_pretty_install_type(status)
|
514
|
-
INSTALL_TYPE_LABELS[status.installation_type]
|
515
|
-
end
|
516
|
-
end
|
517
|
-
end
|
518
|
-
end
|