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,65 +0,0 @@
|
|
1
|
-
require "inspec/fetcher"
|
2
|
-
require "forwardable"
|
3
|
-
|
4
|
-
module Inspec
|
5
|
-
class CachedFetcher
|
6
|
-
extend Forwardable
|
7
|
-
|
8
|
-
attr_reader :cache, :target, :fetcher
|
9
|
-
def initialize(target, cache)
|
10
|
-
@target = target
|
11
|
-
@fetcher = Inspec::Fetcher::Registry.resolve(target)
|
12
|
-
|
13
|
-
if @fetcher.nil?
|
14
|
-
raise("Could not fetch inspec profile in #{target.inspect}.")
|
15
|
-
end
|
16
|
-
|
17
|
-
@cache = cache
|
18
|
-
end
|
19
|
-
|
20
|
-
def resolved_source
|
21
|
-
fetch
|
22
|
-
@fetcher.resolved_source
|
23
|
-
end
|
24
|
-
|
25
|
-
def cache_key
|
26
|
-
k = if target.is_a?(Hash)
|
27
|
-
target[:sha256] || target[:ref]
|
28
|
-
end
|
29
|
-
|
30
|
-
if k.nil?
|
31
|
-
fetcher.cache_key
|
32
|
-
else
|
33
|
-
k
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def fetch
|
38
|
-
if cache.exists?(cache_key)
|
39
|
-
Inspec::Log.debug "Using cached dependency for #{target}"
|
40
|
-
[cache.prefered_entry_for(cache_key), false]
|
41
|
-
else
|
42
|
-
Inspec::Log.debug "Dependency does not exist in the cache #{target}"
|
43
|
-
fetcher.fetch(cache.base_path_for(fetcher.cache_key))
|
44
|
-
assert_cache_sanity!
|
45
|
-
[fetcher.archive_path, fetcher.writable?]
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def assert_cache_sanity!
|
50
|
-
return unless target.respond_to?(:key?) && target.key?(:sha256)
|
51
|
-
|
52
|
-
exception_message = <<~EOF
|
53
|
-
The remote source #{fetcher} no longer has the requested content:
|
54
|
-
|
55
|
-
Request Content Hash: #{target[:sha256]}
|
56
|
-
Actual Content Hash: #{fetcher.resolved_source[:sha256]}
|
57
|
-
|
58
|
-
For URL, supermarket, compliance, and other sources that do not
|
59
|
-
provide versioned artifacts, this likely means that the remote source
|
60
|
-
has changed since your lockfile was generated.
|
61
|
-
EOF
|
62
|
-
raise exception_message if fetcher.resolved_source[:sha256] != target[:sha256]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/lib/inspec/cli.rb
DELETED
@@ -1,469 +0,0 @@
|
|
1
|
-
# Copyright 2015 Dominik Richter
|
2
|
-
|
3
|
-
require "inspec/utils/deprecation/deprecator"
|
4
|
-
require "inspec/dist"
|
5
|
-
require "inspec/backend"
|
6
|
-
require "inspec/dependencies/cache"
|
7
|
-
|
8
|
-
module Inspec # TODO: move this somewhere "better"?
|
9
|
-
autoload :BaseCLI, "inspec/base_cli"
|
10
|
-
autoload :Deprecation, "inspec/utils/deprecation"
|
11
|
-
autoload :Exceptions, "inspec/exceptions"
|
12
|
-
autoload :EnvPrinter, "inspec/env_printer"
|
13
|
-
autoload :Fetcher, "inspec/fetcher"
|
14
|
-
autoload :Formatters, "inspec/formatters"
|
15
|
-
autoload :Globals, "inspec/globals"
|
16
|
-
autoload :Impact, "inspec/impact"
|
17
|
-
autoload :Impact, "inspec/impact"
|
18
|
-
autoload :InputRegistry, "inspec/input_registry"
|
19
|
-
autoload :Profile, "inspec/profile"
|
20
|
-
autoload :Reporters, "inspec/reporters"
|
21
|
-
autoload :Resource, "inspec/resource"
|
22
|
-
autoload :Rule, "inspec/rule"
|
23
|
-
autoload :Runner, "inspec/runner"
|
24
|
-
autoload :Runner, "inspec/runner"
|
25
|
-
autoload :Shell, "inspec/shell"
|
26
|
-
autoload :SourceReader, "inspec/source_reader"
|
27
|
-
autoload :Telemetry, "inspec/utils/telemetry"
|
28
|
-
autoload :V1, "inspec/plugin/v1"
|
29
|
-
autoload :V2, "inspec/plugin/v2"
|
30
|
-
autoload :VERSION, "inspec/version"
|
31
|
-
end
|
32
|
-
|
33
|
-
class Inspec::InspecCLI < Inspec::BaseCLI
|
34
|
-
class_option :log_level, aliases: :l, type: :string,
|
35
|
-
desc: "Set the log level: info (default), debug, warn, error"
|
36
|
-
|
37
|
-
class_option :log_location, type: :string,
|
38
|
-
desc: "Location to send diagnostic log messages to. (default: $stdout or Inspec::Log.error)"
|
39
|
-
|
40
|
-
class_option :diagnose, type: :boolean,
|
41
|
-
desc: "Show diagnostics (versions, configurations)"
|
42
|
-
|
43
|
-
class_option :color, type: :boolean,
|
44
|
-
desc: "Use colors in output."
|
45
|
-
|
46
|
-
class_option :interactive, type: :boolean,
|
47
|
-
desc: "Allow or disable user interaction"
|
48
|
-
|
49
|
-
class_option :disable_core_plugins, type: :string, banner: "", # Actually a boolean, but this suppresses the creation of a --no-disable...
|
50
|
-
desc: "Disable loading all plugins that are shipped in the lib/plugins directory of InSpec. Useful in development."
|
51
|
-
|
52
|
-
class_option :disable_user_plugins, type: :string, banner: "",
|
53
|
-
desc: "Disable loading all plugins that the user installed."
|
54
|
-
|
55
|
-
class_option :enable_telemetry, type: :boolean,
|
56
|
-
desc: "Allow or disable telemetry", default: false
|
57
|
-
|
58
|
-
require "license_acceptance/cli_flags/thor"
|
59
|
-
include LicenseAcceptance::CLIFlags::Thor
|
60
|
-
|
61
|
-
desc "json PATH", "read all tests in PATH and generate a JSON summary"
|
62
|
-
option :output, aliases: :o, type: :string,
|
63
|
-
desc: "Save the created profile to a path"
|
64
|
-
option :controls, type: :array,
|
65
|
-
desc: "A list of controls to include. Ignore all other tests."
|
66
|
-
profile_options
|
67
|
-
def json(target)
|
68
|
-
require "json"
|
69
|
-
|
70
|
-
o = config
|
71
|
-
diagnose(o)
|
72
|
-
o["log_location"] = $stderr
|
73
|
-
configure_logger(o)
|
74
|
-
|
75
|
-
o[:backend] = Inspec::Backend.create(Inspec::Config.mock)
|
76
|
-
o[:check_mode] = true
|
77
|
-
o[:vendor_cache] = Inspec::Cache.new(o[:vendor_cache])
|
78
|
-
|
79
|
-
profile = Inspec::Profile.for_target(target, o)
|
80
|
-
info = profile.info
|
81
|
-
# add in inspec version
|
82
|
-
info[:generator] = {
|
83
|
-
name: "inspec",
|
84
|
-
version: Inspec::VERSION,
|
85
|
-
}
|
86
|
-
dst = o[:output].to_s
|
87
|
-
if dst.empty?
|
88
|
-
puts JSON.dump(info)
|
89
|
-
else
|
90
|
-
if File.exist? dst
|
91
|
-
puts "----> updating #{dst}"
|
92
|
-
else
|
93
|
-
puts "----> creating #{dst}"
|
94
|
-
end
|
95
|
-
fdst = File.expand_path(dst)
|
96
|
-
File.write(fdst, JSON.dump(info))
|
97
|
-
end
|
98
|
-
rescue StandardError => e
|
99
|
-
pretty_handle_exception(e)
|
100
|
-
end
|
101
|
-
|
102
|
-
desc "check PATH", "verify all tests at the specified PATH"
|
103
|
-
option :format, type: :string
|
104
|
-
profile_options
|
105
|
-
def check(path) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
106
|
-
o = config
|
107
|
-
diagnose(o)
|
108
|
-
o["log_location"] ||= STDERR if o["format"] == "json"
|
109
|
-
o["log_level"] ||= "warn"
|
110
|
-
configure_logger(o)
|
111
|
-
|
112
|
-
o[:backend] = Inspec::Backend.create(Inspec::Config.mock)
|
113
|
-
o[:check_mode] = true
|
114
|
-
o[:vendor_cache] = Inspec::Cache.new(o[:vendor_cache])
|
115
|
-
|
116
|
-
# run check
|
117
|
-
profile = Inspec::Profile.for_target(path, o)
|
118
|
-
result = profile.check
|
119
|
-
|
120
|
-
if o["format"] == "json"
|
121
|
-
puts JSON.generate(result)
|
122
|
-
else
|
123
|
-
%w{location profile controls timestamp valid}.each do |item|
|
124
|
-
prepared_string = format("%-12s %s",
|
125
|
-
"#{item.to_s.capitalize} :",
|
126
|
-
result[:summary][item.to_sym])
|
127
|
-
ui.plain_line(prepared_string)
|
128
|
-
end
|
129
|
-
puts
|
130
|
-
|
131
|
-
if result[:errors].empty? && result[:warnings].empty?
|
132
|
-
ui.plain_line("No errors or warnings")
|
133
|
-
else
|
134
|
-
item_msg = lambda { |item|
|
135
|
-
pos = [item[:file], item[:line], item[:column]].compact.join(":")
|
136
|
-
pos.empty? ? item[:msg] : pos + ": " + item[:msg]
|
137
|
-
}
|
138
|
-
|
139
|
-
result[:errors].each { |item| ui.red " #{Inspec::UI::GLYPHS[:script_x]} #{item_msg.call(item)}\n" }
|
140
|
-
result[:warnings].each { |item| ui.yellow " ! #{item_msg.call(item)}\n" }
|
141
|
-
|
142
|
-
puts
|
143
|
-
|
144
|
-
errors = ui.red("#{result[:errors].length} errors", print: false)
|
145
|
-
warnings = ui.yellow("#{result[:warnings].length} warnings", print: false)
|
146
|
-
ui.plain_line("Summary: #{errors}, #{warnings}")
|
147
|
-
end
|
148
|
-
end
|
149
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR unless result[:summary][:valid]
|
150
|
-
rescue StandardError => e
|
151
|
-
pretty_handle_exception(e)
|
152
|
-
end
|
153
|
-
|
154
|
-
desc "vendor PATH", "Download all dependencies and generate a lockfile in a `vendor` directory"
|
155
|
-
option :overwrite, type: :boolean, default: false,
|
156
|
-
desc: "Overwrite existing vendored dependencies and lockfile."
|
157
|
-
def vendor(path = nil)
|
158
|
-
o = config
|
159
|
-
configure_logger(o)
|
160
|
-
o[:logger] = Logger.new($stdout)
|
161
|
-
o[:logger].level = get_log_level(o[:log_level])
|
162
|
-
|
163
|
-
vendor_deps(path, o)
|
164
|
-
end
|
165
|
-
|
166
|
-
desc "archive PATH", "archive a profile to tar.gz (default) or zip"
|
167
|
-
profile_options
|
168
|
-
option :output, aliases: :o, type: :string,
|
169
|
-
desc: "Save the archive to a path"
|
170
|
-
option :zip, type: :boolean, default: false,
|
171
|
-
desc: "Generates a zip archive."
|
172
|
-
option :tar, type: :boolean, default: false,
|
173
|
-
desc: "Generates a tar.gz archive."
|
174
|
-
option :overwrite, type: :boolean, default: false,
|
175
|
-
desc: "Overwrite existing archive."
|
176
|
-
option :ignore_errors, type: :boolean, default: false,
|
177
|
-
desc: "Ignore profile warnings."
|
178
|
-
def archive(path)
|
179
|
-
o = config
|
180
|
-
diagnose(o)
|
181
|
-
|
182
|
-
o[:logger] = Logger.new($stdout)
|
183
|
-
o[:logger].level = get_log_level(o[:log_level])
|
184
|
-
o[:backend] = Inspec::Backend.create(Inspec::Config.mock)
|
185
|
-
|
186
|
-
# Force vendoring with overwrite when archiving
|
187
|
-
vendor_options = o.dup
|
188
|
-
vendor_options[:overwrite] = true
|
189
|
-
vendor_deps(path, vendor_options)
|
190
|
-
|
191
|
-
profile = Inspec::Profile.for_target(path, o)
|
192
|
-
result = profile.check
|
193
|
-
|
194
|
-
if result && !o[:ignore_errors] == false
|
195
|
-
o[:logger].info "Profile check failed. Please fix the profile before generating an archive."
|
196
|
-
return ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
197
|
-
end
|
198
|
-
|
199
|
-
# generate archive
|
200
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR unless profile.archive(o)
|
201
|
-
rescue StandardError => e
|
202
|
-
pretty_handle_exception(e)
|
203
|
-
end
|
204
|
-
|
205
|
-
desc "exec LOCATIONS", <<~EOT
|
206
|
-
Run all test files at the specified LOCATIONS.
|
207
|
-
|
208
|
-
Loads the given profile(s) and fetches their dependencies if needed. Then
|
209
|
-
connects to the target and executes any controls contained in the profiles.
|
210
|
-
One or more reporters are used to generate output.
|
211
|
-
|
212
|
-
```
|
213
|
-
Exit codes:
|
214
|
-
0 Normal exit, all tests passed
|
215
|
-
1 Usage or general error
|
216
|
-
2 Error in plugin system
|
217
|
-
3 Fatal deprecation encountered
|
218
|
-
100 Normal exit, at least one test failed
|
219
|
-
101 Normal exit, at least one test skipped but none failed
|
220
|
-
172 Chef License not accepted
|
221
|
-
```
|
222
|
-
|
223
|
-
Below are some examples of using `exec` with different test LOCATIONS:
|
224
|
-
|
225
|
-
Automate:
|
226
|
-
```
|
227
|
-
#{Inspec::Dist::EXEC_NAME} compliance login
|
228
|
-
#{Inspec::Dist::EXEC_NAME} exec compliance://username/linux-baseline
|
229
|
-
```
|
230
|
-
|
231
|
-
Supermarket:
|
232
|
-
```
|
233
|
-
#{Inspec::Dist::EXEC_NAME} exec supermarket://username/linux-baseline
|
234
|
-
```
|
235
|
-
|
236
|
-
Local profile (executes all tests in `controls/`):
|
237
|
-
```
|
238
|
-
#{Inspec::Dist::EXEC_NAME} exec /path/to/profile
|
239
|
-
```
|
240
|
-
|
241
|
-
Local single test (doesn't allow inputs or custom resources)
|
242
|
-
```
|
243
|
-
#{Inspec::Dist::EXEC_NAME} exec /path/to/a_test.rb
|
244
|
-
```
|
245
|
-
|
246
|
-
Git via SSH
|
247
|
-
```
|
248
|
-
#{Inspec::Dist::EXEC_NAME} exec git@github.com:dev-sec/linux-baseline.git
|
249
|
-
```
|
250
|
-
|
251
|
-
Git via HTTPS (.git suffix is required):
|
252
|
-
```
|
253
|
-
#{Inspec::Dist::EXEC_NAME} exec https://github.com/dev-sec/linux-baseline.git
|
254
|
-
```
|
255
|
-
|
256
|
-
Private Git via HTTPS (.git suffix is required):
|
257
|
-
```
|
258
|
-
#{Inspec::Dist::EXEC_NAME} exec https://API_TOKEN@github.com/dev-sec/linux-baseline.git
|
259
|
-
```
|
260
|
-
|
261
|
-
Private Git via HTTPS and cached credentials (.git suffix is required):
|
262
|
-
```
|
263
|
-
git config credential.helper cache
|
264
|
-
git ls-remote https://github.com/dev-sec/linux-baseline.git
|
265
|
-
#{Inspec::Dist::EXEC_NAME} exec https://github.com/dev-sec/linux-baseline.git
|
266
|
-
```
|
267
|
-
|
268
|
-
Web hosted fileshare (also supports .zip):
|
269
|
-
```
|
270
|
-
#{Inspec::Dist::EXEC_NAME} exec https://webserver/linux-baseline.tar.gz
|
271
|
-
```
|
272
|
-
|
273
|
-
Web hosted fileshare with basic authentication (supports .zip):
|
274
|
-
```
|
275
|
-
#{Inspec::Dist::EXEC_NAME} exec https://username:password@webserver/linux-baseline.tar.gz
|
276
|
-
```
|
277
|
-
EOT
|
278
|
-
exec_options
|
279
|
-
def exec(*targets)
|
280
|
-
o = config
|
281
|
-
diagnose(o)
|
282
|
-
configure_logger(o)
|
283
|
-
|
284
|
-
runner = Inspec::Runner.new(o)
|
285
|
-
targets.each { |target| runner.add_target(target) }
|
286
|
-
|
287
|
-
ui.exit runner.run
|
288
|
-
rescue ArgumentError, RuntimeError, Train::UserError => e
|
289
|
-
$stderr.puts e.message
|
290
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
291
|
-
rescue StandardError => e
|
292
|
-
pretty_handle_exception(e)
|
293
|
-
end
|
294
|
-
|
295
|
-
desc "detect", "detect the target OS"
|
296
|
-
target_options
|
297
|
-
option :format, type: :string
|
298
|
-
def detect
|
299
|
-
o = config
|
300
|
-
o[:command] = "platform.params"
|
301
|
-
|
302
|
-
configure_logger(o)
|
303
|
-
|
304
|
-
(_, res) = run_command(o)
|
305
|
-
|
306
|
-
if o["format"] == "json"
|
307
|
-
puts res.to_json
|
308
|
-
else
|
309
|
-
ui.headline("Platform Details")
|
310
|
-
ui.plain Inspec::BaseCLI.format_platform_info(params: res, indent: 0, color: 36)
|
311
|
-
end
|
312
|
-
rescue ArgumentError, RuntimeError, Train::UserError => e
|
313
|
-
$stderr.puts e.message
|
314
|
-
ui.exit Inspec::UI::EXIT_USAGE_ERROR
|
315
|
-
rescue StandardError => e
|
316
|
-
pretty_handle_exception(e)
|
317
|
-
end
|
318
|
-
|
319
|
-
desc "shell", "open an interactive debugging shell"
|
320
|
-
target_options
|
321
|
-
option :command, aliases: :c,
|
322
|
-
desc: "A single command string to run instead of launching the shell"
|
323
|
-
option :reporter, type: :array,
|
324
|
-
banner: "one two:/output/file/path",
|
325
|
-
desc: "Enable one or more output reporters: cli, documentation, html, progress, json, json-min, json-rspec, junit"
|
326
|
-
option :depends, type: :array, default: [],
|
327
|
-
desc: "A space-delimited list of local folders containing profiles whose libraries and resources will be loaded into the new shell"
|
328
|
-
option :distinct_exit, type: :boolean, default: true,
|
329
|
-
desc: "Exit with code 100 if any tests fail, and 101 if any are skipped but none failed (default). If disabled, exit 0 on skips and 1 for failures."
|
330
|
-
def shell_func
|
331
|
-
o = config
|
332
|
-
diagnose(o)
|
333
|
-
o[:debug_shell] = true
|
334
|
-
|
335
|
-
log_device = suppress_log_output?(o) ? nil : $stdout
|
336
|
-
o[:logger] = Logger.new(log_device)
|
337
|
-
o[:logger].level = get_log_level(o[:log_level])
|
338
|
-
|
339
|
-
if o[:command].nil?
|
340
|
-
runner = Inspec::Runner.new(o)
|
341
|
-
return Inspec::Shell.new(runner).start
|
342
|
-
end
|
343
|
-
|
344
|
-
run_type, res = run_command(o)
|
345
|
-
ui.exit res unless run_type == :ruby_eval
|
346
|
-
|
347
|
-
# No InSpec tests - just print evaluation output.
|
348
|
-
reporters = o["reporter"] || {}
|
349
|
-
if reporters.keys.include?("json")
|
350
|
-
res = if res.respond_to?(:to_json)
|
351
|
-
res.to_json
|
352
|
-
else
|
353
|
-
JSON.dump(res)
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
puts res
|
358
|
-
ui.exit Inspec::UI::EXIT_NORMAL
|
359
|
-
rescue RuntimeError, Train::UserError => e
|
360
|
-
$stderr.puts e.message
|
361
|
-
rescue StandardError => e
|
362
|
-
pretty_handle_exception(e)
|
363
|
-
end
|
364
|
-
|
365
|
-
desc "env", "Output shell-appropriate completion configuration"
|
366
|
-
def env(shell = nil)
|
367
|
-
p = Inspec::EnvPrinter.new(self.class, shell)
|
368
|
-
p.print_and_exit!
|
369
|
-
rescue StandardError => e
|
370
|
-
pretty_handle_exception(e)
|
371
|
-
end
|
372
|
-
|
373
|
-
desc "schema NAME", "print the JSON schema", hide: true
|
374
|
-
def schema(name)
|
375
|
-
require "inspec/schema"
|
376
|
-
|
377
|
-
puts Inspec::Schema.json(name)
|
378
|
-
rescue StandardError => e
|
379
|
-
puts e
|
380
|
-
puts "Valid schemas are #{Inspec::Schema.names.join(", ")}"
|
381
|
-
end
|
382
|
-
|
383
|
-
desc "version", "prints the version of this tool"
|
384
|
-
option :format, type: :string
|
385
|
-
def version
|
386
|
-
if config["format"] == "json"
|
387
|
-
v = { version: Inspec::VERSION }
|
388
|
-
puts v.to_json
|
389
|
-
else
|
390
|
-
puts Inspec::VERSION
|
391
|
-
end
|
392
|
-
end
|
393
|
-
map %w{-v --version} => :version
|
394
|
-
|
395
|
-
desc "nothing", "does nothing"
|
396
|
-
def nothing
|
397
|
-
puts "you did nothing"
|
398
|
-
end
|
399
|
-
|
400
|
-
private
|
401
|
-
|
402
|
-
def run_command(opts)
|
403
|
-
runner = Inspec::Runner.new(Inspec::Config.new(opts))
|
404
|
-
res = runner.eval_with_virtual_profile(opts[:command])
|
405
|
-
runner.load
|
406
|
-
|
407
|
-
return :ruby_eval, res if runner.all_rules.empty?
|
408
|
-
|
409
|
-
return :rspec_run, runner.run_tests # rubocop:disable Style/RedundantReturn
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
#=====================================================================#
|
414
|
-
# Pre-Flight Code
|
415
|
-
#=====================================================================#
|
416
|
-
|
417
|
-
help_commands = ["-h", "--help", "help"]
|
418
|
-
|
419
|
-
#---------------------------------------------------------------------#
|
420
|
-
# Adjustments for help handling
|
421
|
-
# This allows you to use any of the normal help commands after the normal args.
|
422
|
-
#---------------------------------------------------------------------#
|
423
|
-
(help_commands & ARGV).each do |cmd|
|
424
|
-
# move the help argument to one place behind the end for Thor to digest
|
425
|
-
if ARGV.size > 1
|
426
|
-
match = ARGV.delete(cmd)
|
427
|
-
ARGV.insert(-2, match)
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
#---------------------------------------------------------------------#
|
432
|
-
# Plugin Loading
|
433
|
-
#---------------------------------------------------------------------#
|
434
|
-
require "inspec/plugin/v2"
|
435
|
-
|
436
|
-
begin
|
437
|
-
# Load v2 plugins. Manually check for plugin disablement.
|
438
|
-
omit_core = ARGV.delete("--disable-core-plugins")
|
439
|
-
omit_user = ARGV.delete("--disable-user-plugins")
|
440
|
-
v2_loader = Inspec::Plugin::V2::Loader.new(omit_core_plugins: omit_core, omit_user_plugins: omit_user)
|
441
|
-
v2_loader.load_all
|
442
|
-
v2_loader.exit_on_load_error
|
443
|
-
v2_loader.activate_mentioned_cli_plugins
|
444
|
-
|
445
|
-
# Load v1 plugins on startup
|
446
|
-
ctl = Inspec::PluginCtl.new
|
447
|
-
ctl.list.each { |x| ctl.load(x) }
|
448
|
-
|
449
|
-
# load v1 CLI plugins before the InSpec CLI has been started
|
450
|
-
Inspec::Plugins::CLI.subcommands.each do |_subcommand, params|
|
451
|
-
Inspec::InspecCLI.register(
|
452
|
-
params[:klass],
|
453
|
-
params[:subcommand_name],
|
454
|
-
params[:usage],
|
455
|
-
params[:description],
|
456
|
-
params[:options]
|
457
|
-
)
|
458
|
-
end
|
459
|
-
rescue Inspec::Plugin::V2::Exception => v2ex
|
460
|
-
Inspec::Log.error v2ex.message
|
461
|
-
|
462
|
-
if ARGV.include?("--debug")
|
463
|
-
Inspec::Log.error v2ex.class.name
|
464
|
-
Inspec::Log.error v2ex.backtrace.join("\n")
|
465
|
-
else
|
466
|
-
Inspec::Log.error "Run again with --debug for a stacktrace."
|
467
|
-
end
|
468
|
-
ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
|
469
|
-
end
|