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/inspec/secrets.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "inspec/plugin/v1"
|
2
|
-
|
3
|
-
module Inspec
|
4
|
-
SecretsBackend = PluginRegistry.new
|
5
|
-
|
6
|
-
def self.secrets(version)
|
7
|
-
if version != 1
|
8
|
-
raise "Only secrets version 1 is supported!"
|
9
|
-
end
|
10
|
-
|
11
|
-
Inspec::Plugins::Secret
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
require "inspec/secrets/yaml"
|
data/lib/inspec/secrets/yaml.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require "yaml"
|
2
|
-
|
3
|
-
module Secrets
|
4
|
-
class YAML < Inspec.secrets(1)
|
5
|
-
name "yaml"
|
6
|
-
|
7
|
-
attr_reader :inputs
|
8
|
-
|
9
|
-
def self.resolve(target)
|
10
|
-
unless target.is_a?(String) && File.file?(target) && [".yml", ".yaml"].include?(File.extname(target).downcase)
|
11
|
-
return nil
|
12
|
-
end
|
13
|
-
|
14
|
-
new(target)
|
15
|
-
end
|
16
|
-
|
17
|
-
# array of yaml file paths
|
18
|
-
def initialize(target)
|
19
|
-
@inputs = ::YAML.load_file(target)
|
20
|
-
|
21
|
-
if @inputs == false || !@inputs.is_a?(Hash)
|
22
|
-
Inspec::Log.warn("#{self.class} unable to parse #{target}: invalid YAML or contents is not a Hash")
|
23
|
-
@inputs = nil
|
24
|
-
end
|
25
|
-
rescue => e
|
26
|
-
raise "Error reading InSpec inputs: #{e}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/inspec/shell.rb
DELETED
@@ -1,211 +0,0 @@
|
|
1
|
-
require "pry"
|
2
|
-
|
3
|
-
module Inspec
|
4
|
-
# A pry based shell for inspec. Given a runner (with a configured backend and
|
5
|
-
# all that jazz), this shell will produce a pry shell from which you can run
|
6
|
-
# inspec/ruby commands that will be run within the context of the runner.
|
7
|
-
class Shell
|
8
|
-
def initialize(runner)
|
9
|
-
@runner = runner
|
10
|
-
end
|
11
|
-
|
12
|
-
def start
|
13
|
-
# This will hold a single evaluation binding context as opened within
|
14
|
-
# the instance_eval context of the anonymous class that the profile
|
15
|
-
# context creates to evaluate each individual test file. We want to
|
16
|
-
# pretend like we are constantly appending to the same file and want
|
17
|
-
# to capture the local variable context from inside said class.
|
18
|
-
@ctx_binding = @runner.eval_with_virtual_profile("binding")
|
19
|
-
configure_pry
|
20
|
-
@ctx_binding.pry
|
21
|
-
end
|
22
|
-
|
23
|
-
def configure_pry # rubocop:disable Metrics/AbcSize
|
24
|
-
# Delete any before_session, before_eval, and after_eval hooks so we can
|
25
|
-
# replace them with our own. Pry 0.10 used to have a single method to clear
|
26
|
-
# all hooks, but this was removed in Pry 0.11.
|
27
|
-
%i{before_session before_eval after_eval}.each do |event|
|
28
|
-
Pry.hooks.get_hooks(event).keys.map { |hook| Pry.hooks.delete_hook(event, hook) }
|
29
|
-
end
|
30
|
-
|
31
|
-
that = self
|
32
|
-
|
33
|
-
# Add the help command
|
34
|
-
Pry::Commands.block_command "help", "Show examples" do |resource|
|
35
|
-
that.help(resource)
|
36
|
-
end
|
37
|
-
|
38
|
-
# configure pry shell prompt
|
39
|
-
Pry.config.prompt_name = "inspec"
|
40
|
-
Pry.prompt = [proc { "#{readline_ignore("\e[1m\e[32m")}#{Pry.config.prompt_name}> #{readline_ignore("\e[0m")}" }]
|
41
|
-
|
42
|
-
# Add a help menu as the default intro
|
43
|
-
Pry.hooks.add_hook(:before_session, "inspec_intro") do
|
44
|
-
intro
|
45
|
-
print_target_info
|
46
|
-
end
|
47
|
-
|
48
|
-
# Track the rules currently registered and what their merge count is.
|
49
|
-
Pry.hooks.add_hook(:before_eval, "inspec_before_eval") do
|
50
|
-
@runner.reset
|
51
|
-
end
|
52
|
-
|
53
|
-
# After pry has evaluated a commanding within the binding context of a
|
54
|
-
# test file, register all the rules it discovered.
|
55
|
-
Pry.hooks.add_hook(:after_eval, "inspec_after_eval") do
|
56
|
-
@runner.load
|
57
|
-
@runner.run_tests unless @runner.all_rules.empty?
|
58
|
-
end
|
59
|
-
|
60
|
-
# Don't print out control class inspection when the user uses DSL methods.
|
61
|
-
# Instead produce a result of evaluating their control.
|
62
|
-
Pry.config.print = proc do |_output_, value, pry|
|
63
|
-
next unless @runner.all_rules.empty?
|
64
|
-
|
65
|
-
pry.pager.open do |pager|
|
66
|
-
pager.print pry.config.output_prefix
|
67
|
-
Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def readline_ignore(code)
|
73
|
-
"\001#{code}\002"
|
74
|
-
end
|
75
|
-
|
76
|
-
def mark(x)
|
77
|
-
"\e[1m\e[39m#{x}\e[0m"
|
78
|
-
end
|
79
|
-
|
80
|
-
def intro
|
81
|
-
puts "Welcome to the interactive InSpec Shell"
|
82
|
-
puts "To find out how to use it, type: #{mark "help"}"
|
83
|
-
puts
|
84
|
-
end
|
85
|
-
|
86
|
-
def print_target_info
|
87
|
-
ctx = @runner.backend
|
88
|
-
puts <<~EOF
|
89
|
-
You are currently running on:
|
90
|
-
|
91
|
-
#{Inspec::BaseCLI.format_platform_info(params: ctx.platform.params, indent: 4, color: 39)}
|
92
|
-
EOF
|
93
|
-
end
|
94
|
-
|
95
|
-
def help(topic = nil)
|
96
|
-
if topic.nil?
|
97
|
-
|
98
|
-
puts <<~EOF
|
99
|
-
Available commands:
|
100
|
-
|
101
|
-
`[resource]` - run resource on target machine
|
102
|
-
`help resources` - show all available resources that can be used as commands
|
103
|
-
`help [resource]` - information about a specific resource
|
104
|
-
`help matchers` - show information about common matchers
|
105
|
-
`exit` - exit the InSpec shell
|
106
|
-
|
107
|
-
You can use resources in this environment to test the target machine. For example:
|
108
|
-
|
109
|
-
command('uname -a').stdout
|
110
|
-
file('/proc/cpuinfo').content => "value"
|
111
|
-
|
112
|
-
#{print_target_info}
|
113
|
-
EOF
|
114
|
-
elsif topic == "resources"
|
115
|
-
require "inspec/resources"
|
116
|
-
resources.sort.each do |resource|
|
117
|
-
puts " - #{resource}"
|
118
|
-
end
|
119
|
-
elsif topic == "matchers"
|
120
|
-
print_matchers_help
|
121
|
-
elsif !Inspec::Resource.registry[topic].nil? # TODO: fix unnecessary logic
|
122
|
-
topic_info = Inspec::Resource.registry[topic]
|
123
|
-
info = "#{mark "Name:"} #{topic}\n\n"
|
124
|
-
unless topic_info.desc.nil?
|
125
|
-
info += "#{mark "Description:"}\n\n"
|
126
|
-
info += "#{topic_info.desc}\n\n"
|
127
|
-
end
|
128
|
-
|
129
|
-
unless topic_info.example.nil?
|
130
|
-
info += "#{mark "Example:"}\n\n"
|
131
|
-
info += "#{topic_info.example}\n\n"
|
132
|
-
end
|
133
|
-
|
134
|
-
info += "#{mark "Web Reference:"}\n\n"
|
135
|
-
info += "https://www.inspec.io/docs/reference/resources/#{topic}\n\n"
|
136
|
-
puts info
|
137
|
-
else
|
138
|
-
begin
|
139
|
-
require "inspec/resources/#{topic}"
|
140
|
-
help topic
|
141
|
-
rescue LoadError
|
142
|
-
# TODO: stderr!
|
143
|
-
puts "The resource #{topic} does not exist. For a list of valid resources, type: help resources"
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def resources
|
149
|
-
Inspec::Resource.registry.keys
|
150
|
-
end
|
151
|
-
|
152
|
-
def print_matchers_help
|
153
|
-
puts <<~EOL
|
154
|
-
Matchers are used to compare resource values to expectations. While some
|
155
|
-
resources implement their own custom matchers, the following matchers are
|
156
|
-
common amongst all resources:
|
157
|
-
|
158
|
-
#{mark "be"}
|
159
|
-
|
160
|
-
The #{mark "be"} matcher can be used to compare numeric values.
|
161
|
-
|
162
|
-
its('size') { should be >= 10 }
|
163
|
-
|
164
|
-
#{mark "cmp"}
|
165
|
-
|
166
|
-
The #{mark "cmp"} matcher is like #{mark "eq"} but less restrictive. It will try
|
167
|
-
to fit the resource value to the expectation.
|
168
|
-
|
169
|
-
"Protocol" likely returns a string, but cmp will ensure it's a number before
|
170
|
-
comparing:
|
171
|
-
|
172
|
-
its('Protocol') { should cmp 2 }
|
173
|
-
its('Protocol') { should cmp '2' }
|
174
|
-
|
175
|
-
"users" may return an array, but if it contains only one item, cmp will compare
|
176
|
-
it as a string or number as needed:
|
177
|
-
|
178
|
-
its('users') { should cmp 'root' }
|
179
|
-
|
180
|
-
cmp is not case-sensitive:
|
181
|
-
|
182
|
-
its('log_format') { should cmp 'raw' }
|
183
|
-
its('log_format') { should cmp 'RAW' }
|
184
|
-
|
185
|
-
#{mark "eq"}
|
186
|
-
|
187
|
-
The #{mark "eq"} matcher tests for exact equality of two values. Value type
|
188
|
-
(string, number, etc.) is important and must be the same. For a less-restrictive
|
189
|
-
comparison matcher, use the #{mark "cmp"} matcher.
|
190
|
-
|
191
|
-
its('RSAAuthentication') { should_not eq 'no' }
|
192
|
-
|
193
|
-
#{mark "include"}
|
194
|
-
|
195
|
-
The #{mark "include"} matcher tests to see if a value is included in a list.
|
196
|
-
|
197
|
-
its('users') { should include 'my_user' }
|
198
|
-
|
199
|
-
#{mark "match"}
|
200
|
-
|
201
|
-
The #{mark "match"} matcher can be used to test a string for a match using a
|
202
|
-
regular expression.
|
203
|
-
|
204
|
-
its('content') { should_not match /^MyKey:\\s+some value/ }
|
205
|
-
|
206
|
-
For more examples, see: https://www.inspec.io/docs/reference/matchers/
|
207
|
-
|
208
|
-
EOL
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require "etc"
|
2
|
-
require "rbconfig"
|
3
|
-
|
4
|
-
module Inspec
|
5
|
-
#
|
6
|
-
# ShellDetector attempts to detect the shell the invoking user is
|
7
|
-
# running by checking:
|
8
|
-
#
|
9
|
-
# - The command of our parent
|
10
|
-
# - The SHELL environment variable
|
11
|
-
# - The shell returned by getpwuid for our process UID
|
12
|
-
#
|
13
|
-
# Since none of these methods is fullproof, the detected shell is
|
14
|
-
# verified against a list of known shells before being returned to
|
15
|
-
# the caller.
|
16
|
-
#
|
17
|
-
class ShellDetector
|
18
|
-
NOT_DETECTED = Object.new.freeze
|
19
|
-
KNOWN_SHELLS = %w{bash zsh ksh csh sh fish}.freeze
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
@shell = NOT_DETECTED
|
23
|
-
end
|
24
|
-
|
25
|
-
def shell
|
26
|
-
@shell = detect unless detected?(@shell)
|
27
|
-
@shell
|
28
|
-
end
|
29
|
-
|
30
|
-
def shell!
|
31
|
-
@shell = detect
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def detect
|
37
|
-
# Most of our detection code assumes a unix-like environment
|
38
|
-
return nil if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
|
39
|
-
|
40
|
-
shellpath = detect_by_ppid
|
41
|
-
|
42
|
-
if shellpath.nil? || shellpath.empty? || !known_shell?(shellpath)
|
43
|
-
shellpath = detect_by_env
|
44
|
-
end
|
45
|
-
|
46
|
-
if shellpath.nil? || shellpath.empty? || !known_shell?(shellpath)
|
47
|
-
shellpath = detect_by_getpwuid
|
48
|
-
end
|
49
|
-
|
50
|
-
shellname(shellpath) if known_shell?(shellpath)
|
51
|
-
end
|
52
|
-
|
53
|
-
def detected?(arg)
|
54
|
-
arg != NOT_DETECTED
|
55
|
-
end
|
56
|
-
|
57
|
-
def detect_by_ppid
|
58
|
-
ppid = Process.ppid
|
59
|
-
if Dir.exist?("/proc")
|
60
|
-
File.readlink("/proc/#{ppid}/exe")
|
61
|
-
else
|
62
|
-
`ps -cp #{ppid} -o command=`.chomp
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def detect_by_env
|
67
|
-
ENV["SHELL"]
|
68
|
-
end
|
69
|
-
|
70
|
-
def detect_by_getpwuid
|
71
|
-
Etc.getpwuid(Process.uid).shell
|
72
|
-
end
|
73
|
-
|
74
|
-
#
|
75
|
-
# Strip any leading path elements
|
76
|
-
#
|
77
|
-
def shellname(shellpath)
|
78
|
-
shellpath.split("/").last
|
79
|
-
end
|
80
|
-
|
81
|
-
#
|
82
|
-
# Only return shells that we know about, just to be sure we never
|
83
|
-
# do anything very silly.
|
84
|
-
#
|
85
|
-
def known_shell?(shell)
|
86
|
-
KNOWN_SHELLS.include?(shellname(shell))
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
data/lib/inspec/source_reader.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require "inspec/plugin/v1"
|
2
|
-
|
3
|
-
module Inspec
|
4
|
-
# Pre-checking of target resolution. Make sure that SourceReader plugins
|
5
|
-
# always receive a fetcher.
|
6
|
-
class SourceReaderRegistry < PluginRegistry
|
7
|
-
def resolve(target)
|
8
|
-
return nil if target.nil?
|
9
|
-
|
10
|
-
super(target)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
SourceReader = SourceReaderRegistry.new
|
15
|
-
|
16
|
-
def self.source_reader(version)
|
17
|
-
if version != 1
|
18
|
-
raise "Only source readers version 1 is supported!"
|
19
|
-
end
|
20
|
-
|
21
|
-
Inspec::Plugins::SourceReader
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
require "source_readers/inspec"
|
26
|
-
require "source_readers/flat"
|
data/lib/inspec/ui.rb
DELETED
@@ -1,213 +0,0 @@
|
|
1
|
-
module Inspec
|
2
|
-
# Provides simple terminal UI interaction primitives for CLI commands and plugins.
|
3
|
-
class UI
|
4
|
-
ANSI_CODES = {
|
5
|
-
reset: "\e[0m",
|
6
|
-
bold: "\e[1m",
|
7
|
-
color: {
|
8
|
-
red: "\e[38;5;9m", # 256-color light red
|
9
|
-
green: "\e[38;5;41m", # 256-color light green
|
10
|
-
yellow: "\e[33m",
|
11
|
-
cyan: "\e[36m",
|
12
|
-
white: "\e[37m",
|
13
|
-
grey: "\e[38;5;247m", # 256-color medium grey
|
14
|
-
},
|
15
|
-
}.freeze
|
16
|
-
|
17
|
-
GLYPHS = {
|
18
|
-
bullet: "•", # BULLET, Unicode: U+2022, UTF-8: E2 80 A2
|
19
|
-
check: "✔", # HEAVY CHECK MARK, Unicode: U+2714, UTF-8: E2 9C 94
|
20
|
-
swirl: "↺", # ANTICLOCKWISE OPEN CIRCLE ARROW, Unicode U+21BA, UTF-8: E2 86 BA
|
21
|
-
script_x: "×", # MULTIPLICATION SIGN, Unicode: U+00D7, UTF-8: C3 97
|
22
|
-
question: "?", # normal ASCII question mark
|
23
|
-
em_dash: "─", # BOX DRAWINGS LIGHT HORIZONTAL Unicode: U+2500, UTF-8: E2 94 80
|
24
|
-
heavy_dash: "≖", # RING IN EQUAL TO, Unicode: U+2256, UTF-8: E2 89 96
|
25
|
-
vertical_dash: "│", # BOX DRAWINGS LIGHT VERTICAL, Unicode: U+2502, UTF-8: E2 94 82
|
26
|
-
table_corner: "⨀", # N-ARY CIRCLED DOT OPERATOR, Unicode: U+2A00, UTF-8: E2 A8 80
|
27
|
-
}.freeze
|
28
|
-
|
29
|
-
EXIT_NORMAL = 0
|
30
|
-
EXIT_USAGE_ERROR = 1
|
31
|
-
EXIT_PLUGIN_ERROR = 2
|
32
|
-
EXIT_FATAL_DEPRECATION = 3
|
33
|
-
EXIT_LICENSE_NOT_ACCEPTED = 172
|
34
|
-
EXIT_FAILED_TESTS = 100
|
35
|
-
EXIT_SKIPPED_TESTS = 101
|
36
|
-
|
37
|
-
attr_reader :io
|
38
|
-
|
39
|
-
def initialize(opts = {})
|
40
|
-
@color = opts[:color].nil? ? true : opts[:color]
|
41
|
-
@interactive = opts[:interactive].nil? ? $stdout.isatty : opts[:interactive]
|
42
|
-
@io = opts[:io] || $stdout
|
43
|
-
end
|
44
|
-
|
45
|
-
def color?
|
46
|
-
@color
|
47
|
-
end
|
48
|
-
|
49
|
-
def print_or_return(str, print_flag)
|
50
|
-
io.print(str) if print_flag
|
51
|
-
str
|
52
|
-
end
|
53
|
-
|
54
|
-
#=========================================================================#
|
55
|
-
# Low-level formatting methods
|
56
|
-
#=========================================================================#
|
57
|
-
|
58
|
-
def plain(str, opts = { print: true })
|
59
|
-
print_or_return(str.to_s, opts[:print])
|
60
|
-
end
|
61
|
-
|
62
|
-
def plain_line(str = "", opts = { print: true })
|
63
|
-
print_or_return(str.to_s + "\n", opts[:print])
|
64
|
-
end
|
65
|
-
|
66
|
-
def bold(str, opts = { print: true })
|
67
|
-
result = color? ? io.print(ANSI_CODES[:bold] + str.to_s + ANSI_CODES[:reset]) : str.to_s
|
68
|
-
print_or_return(result, opts[:print])
|
69
|
-
end
|
70
|
-
|
71
|
-
ANSI_CODES[:color].keys.each do |color|
|
72
|
-
define_method(color) do |str, opts = { print: true }|
|
73
|
-
result = color? ? (ANSI_CODES[:color][color] + str.to_s + ANSI_CODES[:reset]) : str.to_s
|
74
|
-
print_or_return(result, opts[:print])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
#=========================================================================#
|
79
|
-
# High-Level formatting methods
|
80
|
-
#=========================================================================#
|
81
|
-
|
82
|
-
def emphasis(str, opts = { print: false })
|
83
|
-
cyan(str, opts)
|
84
|
-
end
|
85
|
-
|
86
|
-
def headline(str, opts = { print: true })
|
87
|
-
str = str.dup.to_s
|
88
|
-
if str.length < 76
|
89
|
-
dash_length = 80 - str.length - 4 # 4 spaces
|
90
|
-
dash_length /= 2
|
91
|
-
else
|
92
|
-
dash_length = 0
|
93
|
-
end
|
94
|
-
|
95
|
-
result = "\n"
|
96
|
-
result += " " + (color? ? GLYPHS[:em_dash] : "-") * dash_length + " "
|
97
|
-
result += color? ? ANSI_CODES[:bold] + ANSI_CODES[:color][:white] : ""
|
98
|
-
result += str
|
99
|
-
result += color? ? ANSI_CODES[:reset] : ""
|
100
|
-
result += " " + (color? ? GLYPHS[:em_dash] : "-") * dash_length + " "
|
101
|
-
result += "\n\n"
|
102
|
-
|
103
|
-
print_or_return(result, opts[:print])
|
104
|
-
end
|
105
|
-
|
106
|
-
# Issues a one-line message, with 'ERROR: ' prepended in bold red.
|
107
|
-
def error(str, opts = { print: true })
|
108
|
-
str = str.dup.to_s
|
109
|
-
result = ""
|
110
|
-
result += color? ? ANSI_CODES[:bold] + ANSI_CODES[:color][:red] : ""
|
111
|
-
result += "ERROR:"
|
112
|
-
result += color? ? ANSI_CODES[:reset] : ""
|
113
|
-
result += " "
|
114
|
-
result += str
|
115
|
-
result += "\n"
|
116
|
-
print_or_return(result, opts[:print])
|
117
|
-
end
|
118
|
-
|
119
|
-
# Issues a one-line message, with 'WARNING: ' prepended in bold yellow.
|
120
|
-
def warning(str, opts = { print: true })
|
121
|
-
str = str.dup.to_s
|
122
|
-
result = ""
|
123
|
-
result += color? ? ANSI_CODES[:bold] + ANSI_CODES[:color][:yellow] : ""
|
124
|
-
result += "WARNING:"
|
125
|
-
result += color? ? ANSI_CODES[:reset] : ""
|
126
|
-
result += " "
|
127
|
-
result += str
|
128
|
-
result += "\n"
|
129
|
-
print_or_return(result, opts[:print])
|
130
|
-
end
|
131
|
-
|
132
|
-
# Draws a horizontal line.
|
133
|
-
def line(opts = { print: true })
|
134
|
-
if color?
|
135
|
-
result = ANSI_CODES[:bold] + GLYPHS[:heavy_dash] * 80 + ANSI_CODES[:reset] + "\n"
|
136
|
-
else
|
137
|
-
result = "-" * 80 + "\n"
|
138
|
-
end
|
139
|
-
print_or_return(result, opts[:print])
|
140
|
-
end
|
141
|
-
|
142
|
-
# Makes a bullet point.
|
143
|
-
def list_item(str, opts = { print: true })
|
144
|
-
bullet = color? ? ANSI_CODES[:bold] + ANSI_CODES[:color][:white] + GLYPHS[:bullet] + ANSI_CODES[:reset] : "*"
|
145
|
-
result = " " + bullet + " " + str.to_s + "\n"
|
146
|
-
print_or_return(result, opts[:print])
|
147
|
-
end
|
148
|
-
|
149
|
-
# Makes a table. Call with a block; block arg will be a TTY::Table object,
|
150
|
-
# with an extension for setting the header.
|
151
|
-
# Typical use:
|
152
|
-
# ui.table do |t|
|
153
|
-
# t.header = ['Name', 'Rank', 'Cereal Number']
|
154
|
-
# t << ['Crunch', 'Captain', 1]
|
155
|
-
# t << ['', '', 1]
|
156
|
-
# end
|
157
|
-
def table(opts = { print: true })
|
158
|
-
require "inspec/ui_table_helper"
|
159
|
-
|
160
|
-
the_table = TableHelper.new
|
161
|
-
yield(the_table)
|
162
|
-
|
163
|
-
colorizer = proc do |data, row, _col|
|
164
|
-
if color? && row == 0
|
165
|
-
ANSI_CODES[:bold] + ANSI_CODES[:color][:white] + data.to_s + ANSI_CODES[:reset]
|
166
|
-
else
|
167
|
-
data
|
168
|
-
end
|
169
|
-
end
|
170
|
-
render_mode = color? ? :unicode : :ascii
|
171
|
-
padding = [0, 1, 0, 1] # T R B L
|
172
|
-
result = the_table.render(render_mode, filter: colorizer, padding: padding) + "\n"
|
173
|
-
print_or_return(result, opts[:print])
|
174
|
-
end
|
175
|
-
|
176
|
-
#=========================================================================#
|
177
|
-
# Exit Codes
|
178
|
-
#=========================================================================#
|
179
|
-
|
180
|
-
def exit(code_sym = :normal)
|
181
|
-
# If it's a number, give them a pass for now.
|
182
|
-
if code_sym.is_a? Numeric
|
183
|
-
code_int = code_sym
|
184
|
-
else
|
185
|
-
code_const = ("EXIT_" + code_sym.to_s.upcase).to_sym
|
186
|
-
unless self.class.const_defined?(code_const)
|
187
|
-
warning("Unrecognized exit constant #{code_const} - exit with code 1")
|
188
|
-
exit(:usage_error)
|
189
|
-
end
|
190
|
-
code_int = self.class.const_get(code_const)
|
191
|
-
end
|
192
|
-
Kernel.exit(code_int)
|
193
|
-
end
|
194
|
-
|
195
|
-
#=========================================================================#
|
196
|
-
# Interactivity
|
197
|
-
#=========================================================================#
|
198
|
-
def interactive?
|
199
|
-
@interactive
|
200
|
-
end
|
201
|
-
|
202
|
-
# This simply returns a TTY::Prompt object, gated on interactivity being enabled.
|
203
|
-
def prompt
|
204
|
-
unless interactive?
|
205
|
-
raise Inspec::UserInteractionRequired, "Somthing is trying to ask the user a question, but interactivity is disabled."
|
206
|
-
end
|
207
|
-
|
208
|
-
require "tty-prompt"
|
209
|
-
|
210
|
-
@prompt ||= TTY::Prompt.new
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|