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,269 +0,0 @@
|
|
1
|
-
require "inspec/dist"
|
2
|
-
|
3
|
-
require_relative "api"
|
4
|
-
|
5
|
-
module InspecPlugins
|
6
|
-
module Compliance
|
7
|
-
class CLI < Inspec.plugin(2, :cli_command)
|
8
|
-
include Inspec::Dist
|
9
|
-
|
10
|
-
subcommand_desc "compliance SUBCOMMAND", "#{COMPLIANCE_PRODUCT_NAME} commands"
|
11
|
-
|
12
|
-
# desc "login https://SERVER --insecure --user='USER' --ent='ENTERPRISE' --token='TOKEN'", 'Log in to a Chef Compliance/Chef Automate SERVER'
|
13
|
-
desc "login", "Log in to a #{COMPLIANCE_PRODUCT_NAME}/#{AUTOMATE_PRODUCT_NAME} SERVER"
|
14
|
-
long_desc <<-LONGDESC
|
15
|
-
`login` allows you to use InSpec with #{AUTOMATE_PRODUCT_NAME} or a #{COMPLIANCE_PRODUCT_NAME} Server
|
16
|
-
|
17
|
-
You need to a token for communication. More information about token retrieval
|
18
|
-
is available at:
|
19
|
-
https://docs.chef.io/api_automate.html#authentication-methods
|
20
|
-
https://docs.chef.io/api_compliance.html#obtaining-an-api-token
|
21
|
-
LONGDESC
|
22
|
-
option :insecure, aliases: :k, type: :boolean,
|
23
|
-
desc: 'Explicitly allows InSpec to perform "insecure" SSL connections and transfers'
|
24
|
-
option :user, type: :string, required: false,
|
25
|
-
desc: "Username"
|
26
|
-
option :password, type: :string, required: false,
|
27
|
-
desc: "Password (#{COMPLIANCE_PRODUCT_NAME} Only)"
|
28
|
-
option :token, type: :string, required: false,
|
29
|
-
desc: "Access token"
|
30
|
-
option :refresh_token, type: :string, required: false,
|
31
|
-
desc: "#{COMPLIANCE_PRODUCT_NAME} refresh token (#{COMPLIANCE_PRODUCT_NAME} Only)"
|
32
|
-
option :dctoken, type: :string, required: false,
|
33
|
-
desc: "Data Collector token (#{AUTOMATE_PRODUCT_NAME} Only)"
|
34
|
-
option :ent, type: :string, required: false,
|
35
|
-
desc: "Enterprise for #{AUTOMATE_PRODUCT_NAME} reporting (#{AUTOMATE_PRODUCT_NAME} Only)"
|
36
|
-
def login(server)
|
37
|
-
options["server"] = server
|
38
|
-
InspecPlugins::Compliance::API.login(options)
|
39
|
-
config = InspecPlugins::Compliance::Configuration.new
|
40
|
-
puts "Stored configuration for Chef #{config["server_type"].capitalize}: #{config["server"]}' with user: '#{config["user"]}'"
|
41
|
-
end
|
42
|
-
|
43
|
-
desc "profiles", "list all available profiles in #{COMPLIANCE_PRODUCT_NAME}"
|
44
|
-
option :owner, type: :string, required: false,
|
45
|
-
desc: "owner whose profiles to list"
|
46
|
-
def profiles
|
47
|
-
config = InspecPlugins::Compliance::Configuration.new
|
48
|
-
return unless loggedin(config)
|
49
|
-
|
50
|
-
# set owner to config
|
51
|
-
config["owner"] = options["owner"] || config["user"]
|
52
|
-
|
53
|
-
msg, profiles = InspecPlugins::Compliance::API.profiles(config)
|
54
|
-
profiles.sort_by! { |hsh| hsh["title"] }
|
55
|
-
if !profiles.empty?
|
56
|
-
# iterate over profiles
|
57
|
-
headline("Available profiles:")
|
58
|
-
profiles.each do |profile|
|
59
|
-
owner = profile["owner_id"] || profile["owner"]
|
60
|
-
li("#{profile["title"]} v#{profile["version"]} (#{mark_text(owner + "/" + profile["name"])})")
|
61
|
-
end
|
62
|
-
else
|
63
|
-
puts msg if msg != "success"
|
64
|
-
puts "Could not find any profiles"
|
65
|
-
exit 1
|
66
|
-
end
|
67
|
-
rescue InspecPlugins::Compliance::ServerConfigurationMissing
|
68
|
-
$stderr.puts "\nServer configuration information is missing. Please login using `#{EXEC_NAME} compliance login`"
|
69
|
-
exit 1
|
70
|
-
end
|
71
|
-
|
72
|
-
desc "exec PROFILE", "executes a #{COMPLIANCE_PRODUCT_NAME} profile"
|
73
|
-
exec_options
|
74
|
-
def exec(*tests)
|
75
|
-
compliance_config = InspecPlugins::Compliance::Configuration.new
|
76
|
-
return unless loggedin(compliance_config)
|
77
|
-
|
78
|
-
o = config # o is an Inspec::Config object, provided by a helper method from Inspec::BaseCLI
|
79
|
-
diagnose(o)
|
80
|
-
configure_logger(o)
|
81
|
-
|
82
|
-
# iterate over tests and add compliance scheme
|
83
|
-
tests = tests.map { |t| "compliance://" + InspecPlugins::Compliance::API.sanitize_profile_name(t) }
|
84
|
-
|
85
|
-
runner = Inspec::Runner.new(o)
|
86
|
-
tests.each { |target| runner.add_target(target) }
|
87
|
-
|
88
|
-
exit runner.run
|
89
|
-
rescue ArgumentError, RuntimeError, Train::UserError => e
|
90
|
-
$stderr.puts e.message
|
91
|
-
exit 1
|
92
|
-
end
|
93
|
-
|
94
|
-
desc "download PROFILE", "downloads a profile from #{COMPLIANCE_PRODUCT_NAME}"
|
95
|
-
option :name, type: :string,
|
96
|
-
desc: "Name of the archive filename (file type will be added)"
|
97
|
-
def download(profile_name)
|
98
|
-
o = options.dup
|
99
|
-
configure_logger(o)
|
100
|
-
|
101
|
-
config = InspecPlugins::Compliance::Configuration.new
|
102
|
-
return unless loggedin(config)
|
103
|
-
|
104
|
-
profile_name = InspecPlugins::Compliance::API.sanitize_profile_name(profile_name)
|
105
|
-
if InspecPlugins::Compliance::API.exist?(config, profile_name)
|
106
|
-
puts "Downloading `#{profile_name}`"
|
107
|
-
|
108
|
-
fetcher = InspecPlugins::Compliance::Fetcher.resolve(
|
109
|
-
{
|
110
|
-
compliance: profile_name,
|
111
|
-
}
|
112
|
-
)
|
113
|
-
|
114
|
-
# we provide a name, the fetcher adds the extension
|
115
|
-
_owner, id = profile_name.split("/")
|
116
|
-
file_name = fetcher.fetch(o.name || id)
|
117
|
-
puts "Profile stored to #{file_name}"
|
118
|
-
else
|
119
|
-
puts "Profile #{profile_name} is not available in #{COMPLIANCE_PRODUCT_NAME}."
|
120
|
-
exit 1
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
desc "upload PATH", "uploads a local profile to #{COMPLIANCE_PRODUCT_NAME}"
|
125
|
-
option :overwrite, type: :boolean, default: false,
|
126
|
-
desc: "Overwrite existing profile on Server."
|
127
|
-
option :owner, type: :string, required: false,
|
128
|
-
desc: "Owner that should own the profile"
|
129
|
-
def upload(path) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, PerceivedComplexity, Metrics/CyclomaticComplexity
|
130
|
-
config = InspecPlugins::Compliance::Configuration.new
|
131
|
-
return unless loggedin(config)
|
132
|
-
|
133
|
-
# set owner to config
|
134
|
-
config["owner"] = options["owner"] || config["user"]
|
135
|
-
|
136
|
-
unless File.exist?(path)
|
137
|
-
puts "Directory #{path} does not exist."
|
138
|
-
exit 1
|
139
|
-
end
|
140
|
-
|
141
|
-
vendor_deps(path, options) if File.directory?(path)
|
142
|
-
|
143
|
-
o = options.dup
|
144
|
-
configure_logger(o)
|
145
|
-
|
146
|
-
# only run against the mock backend, otherwise we run against the local system
|
147
|
-
o[:backend] = Inspec::Backend.create(Inspec::Config.mock)
|
148
|
-
o[:check_mode] = true
|
149
|
-
o[:vendor_cache] = Inspec::Cache.new(o[:vendor_cache])
|
150
|
-
|
151
|
-
# check the profile, we only allow to upload valid profiles
|
152
|
-
profile = Inspec::Profile.for_target(path, o)
|
153
|
-
|
154
|
-
# start verification process
|
155
|
-
error_count = 0
|
156
|
-
error = lambda { |msg|
|
157
|
-
error_count += 1
|
158
|
-
puts msg
|
159
|
-
}
|
160
|
-
|
161
|
-
result = profile.check
|
162
|
-
unless result[:summary][:valid]
|
163
|
-
error.call("Profile check failed. Please fix the profile before upload.")
|
164
|
-
else
|
165
|
-
puts("Profile is valid")
|
166
|
-
end
|
167
|
-
|
168
|
-
# determine user information
|
169
|
-
if (config["token"].nil? && config["refresh_token"].nil?) || config["user"].nil?
|
170
|
-
error.call("Please login via `#{EXEC_NAME} compliance login`")
|
171
|
-
end
|
172
|
-
|
173
|
-
# read profile name from inspec.yml
|
174
|
-
profile_name = profile.params[:name]
|
175
|
-
|
176
|
-
# read profile version from inspec.yml
|
177
|
-
profile_version = profile.params[:version]
|
178
|
-
|
179
|
-
# check that the profile is not uploaded already,
|
180
|
-
# confirm upload to the user (overwrite with --force)
|
181
|
-
if InspecPlugins::Compliance::API.exist?(config, "#{config["owner"]}/#{profile_name}##{profile_version}") && !options["overwrite"]
|
182
|
-
error.call("Profile exists on the server, use --overwrite")
|
183
|
-
end
|
184
|
-
|
185
|
-
# abort if we found an error
|
186
|
-
if error_count > 0
|
187
|
-
puts "Found #{error_count} error(s)"
|
188
|
-
exit 1
|
189
|
-
end
|
190
|
-
|
191
|
-
# if it is a directory, tar it to tmp directory
|
192
|
-
generated = false
|
193
|
-
if File.directory?(path)
|
194
|
-
generated = true
|
195
|
-
archive_path = Dir::Tmpname.create([profile_name, ".tar.gz"]) {}
|
196
|
-
puts "Generate temporary profile archive at #{archive_path}"
|
197
|
-
profile.archive({ output: archive_path, ignore_errors: false, overwrite: true })
|
198
|
-
else
|
199
|
-
archive_path = path
|
200
|
-
end
|
201
|
-
|
202
|
-
puts "Start upload to #{config["owner"]}/#{profile_name}"
|
203
|
-
pname = ERB::Util.url_encode(profile_name)
|
204
|
-
|
205
|
-
if InspecPlugins::Compliance::API.is_automate_server?(config) || InspecPlugins::Compliance::API.is_automate2_server?(config)
|
206
|
-
puts "Uploading to #{AUTOMATE_PRODUCT_NAME}"
|
207
|
-
else
|
208
|
-
puts "Uploading to #{COMPLIANCE_PRODUCT_NAME}"
|
209
|
-
end
|
210
|
-
success, msg = InspecPlugins::Compliance::API.upload(config, config["owner"], pname, archive_path)
|
211
|
-
|
212
|
-
# delete temp file if it was temporary generated
|
213
|
-
File.delete(archive_path) if generated && File.exist?(archive_path)
|
214
|
-
|
215
|
-
if success
|
216
|
-
puts "Successfully uploaded profile"
|
217
|
-
else
|
218
|
-
puts "Error during profile upload:"
|
219
|
-
puts msg
|
220
|
-
exit 1
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
desc "version", "displays the version of the #{COMPLIANCE_PRODUCT_NAME} server"
|
225
|
-
def version
|
226
|
-
config = InspecPlugins::Compliance::Configuration.new
|
227
|
-
info = InspecPlugins::Compliance::API.version(config)
|
228
|
-
if !info.nil? && info["version"]
|
229
|
-
puts "Name: #{info["api"]}"
|
230
|
-
puts "Version: #{info["version"]}"
|
231
|
-
else
|
232
|
-
puts "Could not determine server version."
|
233
|
-
exit 1
|
234
|
-
end
|
235
|
-
rescue InspecPlugins::Compliance::ServerConfigurationMissing
|
236
|
-
puts "\nServer configuration information is missing. Please login using `#{EXEC_NAME} compliance login`"
|
237
|
-
exit 1
|
238
|
-
end
|
239
|
-
|
240
|
-
desc "logout", "user logout from #{COMPLIANCE_PRODUCT_NAME}"
|
241
|
-
def logout
|
242
|
-
config = InspecPlugins::Compliance::Configuration.new
|
243
|
-
unless config.supported?(:oidc) || config["token"].nil? || config["server_type"] == "automate"
|
244
|
-
config = InspecPlugins::Compliance::Configuration.new
|
245
|
-
url = "#{config["server"]}/logout"
|
246
|
-
InspecPlugins::Compliance::HTTP.post(url, config["token"], config["insecure"], !config.supported?(:oidc))
|
247
|
-
end
|
248
|
-
success = config.destroy
|
249
|
-
|
250
|
-
if success
|
251
|
-
puts "Successfully logged out"
|
252
|
-
else
|
253
|
-
puts "Could not log out"
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
private
|
258
|
-
|
259
|
-
def loggedin(config)
|
260
|
-
serverknown = !config["server"].nil?
|
261
|
-
puts "You need to login first with `#{EXEC_NAME} compliance login`" unless serverknown
|
262
|
-
serverknown
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
# register the subcommand to InSpec CLI registry
|
267
|
-
# Inspec::Plugins::CLI.add_subcommand(InspecPlugins::ComplianceCLI, 'compliance', 'compliance SUBCOMMAND ...', 'Chef InspecPlugins::Compliance commands', {})
|
268
|
-
end
|
269
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require "inspec/globals"
|
2
|
-
|
3
|
-
module InspecPlugins
|
4
|
-
module Compliance
|
5
|
-
# stores configuration on local filesystem
|
6
|
-
class Configuration
|
7
|
-
def initialize
|
8
|
-
@config_path = File.join(Inspec.config_dir, "compliance")
|
9
|
-
# ensure the directory is available
|
10
|
-
unless File.directory?(@config_path)
|
11
|
-
FileUtils.mkdir_p(@config_path)
|
12
|
-
end
|
13
|
-
# set config file path
|
14
|
-
@config_file = File.join(@config_path, "/config.json")
|
15
|
-
@config = {}
|
16
|
-
|
17
|
-
# load the data
|
18
|
-
get
|
19
|
-
end
|
20
|
-
|
21
|
-
# direct access to config
|
22
|
-
def [](key)
|
23
|
-
@config[key]
|
24
|
-
end
|
25
|
-
|
26
|
-
def []=(key, value)
|
27
|
-
@config[key] = value
|
28
|
-
end
|
29
|
-
|
30
|
-
def key?(key)
|
31
|
-
@config.key?(key)
|
32
|
-
end
|
33
|
-
|
34
|
-
def clean
|
35
|
-
@config = {}
|
36
|
-
end
|
37
|
-
|
38
|
-
# return the json data
|
39
|
-
def get
|
40
|
-
if File.exist?(@config_file)
|
41
|
-
file = File.read(@config_file)
|
42
|
-
@config = JSON.parse(file)
|
43
|
-
end
|
44
|
-
@config
|
45
|
-
end
|
46
|
-
|
47
|
-
# stores a hash to json
|
48
|
-
def store
|
49
|
-
File.open(@config_file, "w") do |f|
|
50
|
-
f.chmod(0600)
|
51
|
-
f.write(@config.to_json)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# deletes data
|
56
|
-
def destroy
|
57
|
-
if File.exist?(@config_file)
|
58
|
-
File.delete(@config_file)
|
59
|
-
else
|
60
|
-
true
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# return if the (stored) api version does not support a certain feature
|
65
|
-
def supported?(feature)
|
66
|
-
sup = version_with_support(feature)
|
67
|
-
|
68
|
-
# we do not know the version, therefore we do not know if its possible to use the feature
|
69
|
-
return if self["version"].nil? || self["version"]["version"].nil?
|
70
|
-
|
71
|
-
if sup.is_a?(Array)
|
72
|
-
Gem::Version.new(self["version"]["version"]) >= sup[0] &&
|
73
|
-
Gem::Version.new(self["version"]["version"]) < sup[1]
|
74
|
-
else
|
75
|
-
Gem::Version.new(self["version"]["version"]) >= sup
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# exit 1 if the version of compliance that we're working with doesn't support odic
|
80
|
-
def legacy_check!(feature)
|
81
|
-
return if supported?(feature)
|
82
|
-
|
83
|
-
puts "This feature (#{feature}) is not available for legacy installations."
|
84
|
-
puts "Please upgrade to a recent version of Chef Compliance."
|
85
|
-
exit 1
|
86
|
-
end
|
87
|
-
|
88
|
-
private
|
89
|
-
|
90
|
-
# for a feature, returns either:
|
91
|
-
# - a version v0: v supports v0 iff v0 <= v
|
92
|
-
# - an array [v0, v1] of two versions: v supports [v0, v1] iff v0 <= v < v1
|
93
|
-
def version_with_support(feature)
|
94
|
-
case feature.to_sym
|
95
|
-
when :oidc
|
96
|
-
Gem::Version.new("0.16.19")
|
97
|
-
else
|
98
|
-
Gem::Version.new("0.0.0")
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,117 +0,0 @@
|
|
1
|
-
require "net/http"
|
2
|
-
require "net/http/post/multipart"
|
3
|
-
require "uri"
|
4
|
-
|
5
|
-
module InspecPlugins
|
6
|
-
module Compliance
|
7
|
-
# implements a simple http abstraction on top of Net::HTTP
|
8
|
-
class HTTP
|
9
|
-
# generic get requires
|
10
|
-
def self.get(url, headers = nil, insecure)
|
11
|
-
uri = _parse_url(url)
|
12
|
-
req = Net::HTTP::Get.new(uri.path)
|
13
|
-
headers&.each do |key, value|
|
14
|
-
req.add_field(key, value)
|
15
|
-
end
|
16
|
-
send_request(uri, req, insecure)
|
17
|
-
end
|
18
|
-
|
19
|
-
# generic post request
|
20
|
-
def self.post(url, token, insecure, basic_auth = false)
|
21
|
-
# form request
|
22
|
-
uri = _parse_url(url)
|
23
|
-
req = Net::HTTP::Post.new(uri.path)
|
24
|
-
if basic_auth
|
25
|
-
req.basic_auth token, ""
|
26
|
-
else
|
27
|
-
req["Authorization"] = "Bearer #{token}"
|
28
|
-
end
|
29
|
-
req.form_data = {}
|
30
|
-
|
31
|
-
send_request(uri, req, insecure)
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.post_with_headers(url, headers, body, insecure)
|
35
|
-
uri = _parse_url(url)
|
36
|
-
req = Net::HTTP::Post.new(uri.path)
|
37
|
-
req.body = body unless body.nil?
|
38
|
-
headers&.each do |key, value|
|
39
|
-
req.add_field(key, value)
|
40
|
-
end
|
41
|
-
send_request(uri, req, insecure)
|
42
|
-
end
|
43
|
-
|
44
|
-
# post a file
|
45
|
-
def self.post_file(url, headers, file_path, insecure)
|
46
|
-
uri = _parse_url(url)
|
47
|
-
raise "Unable to parse URL: #{url}" if uri.nil? || uri.host.nil?
|
48
|
-
|
49
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
50
|
-
|
51
|
-
# set connection flags
|
52
|
-
http.use_ssl = (uri.scheme == "https")
|
53
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if insecure
|
54
|
-
|
55
|
-
req = Net::HTTP::Post.new(uri.path)
|
56
|
-
headers.each do |key, value|
|
57
|
-
req.add_field(key, value)
|
58
|
-
end
|
59
|
-
|
60
|
-
req.body_stream = File.open(file_path, "rb")
|
61
|
-
req.add_field("Content-Length", File.size(file_path))
|
62
|
-
req.add_field("Content-Type", "application/x-gzip")
|
63
|
-
|
64
|
-
boundary = "INSPEC-PROFILE-UPLOAD"
|
65
|
-
req.add_field("session", boundary)
|
66
|
-
res = http.request(req)
|
67
|
-
res
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.post_multipart_file(url, headers, file_path, insecure)
|
71
|
-
uri = _parse_url(url)
|
72
|
-
raise "Unable to parse URL: #{url}" if uri.nil? || uri.host.nil?
|
73
|
-
|
74
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
75
|
-
|
76
|
-
# set connection flags
|
77
|
-
http.use_ssl = (uri.scheme == "https")
|
78
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if insecure
|
79
|
-
|
80
|
-
File.open(file_path) do |tar|
|
81
|
-
req = Net::HTTP::Post::Multipart.new(uri, "file" => UploadIO.new(tar, "application/x-gzip", File.basename(file_path)))
|
82
|
-
headers.each do |key, value|
|
83
|
-
req.add_field(key, value)
|
84
|
-
end
|
85
|
-
res = http.request(req)
|
86
|
-
return res
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# sends a http requests
|
91
|
-
def self.send_request(uri, req, insecure)
|
92
|
-
opts = {
|
93
|
-
use_ssl: uri.scheme == "https",
|
94
|
-
}
|
95
|
-
opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if insecure
|
96
|
-
|
97
|
-
raise "Unable to parse URI: #{uri}" if uri.nil? || uri.host.nil?
|
98
|
-
|
99
|
-
res = Net::HTTP.start(uri.host, uri.port, opts) do |http|
|
100
|
-
http.request(req)
|
101
|
-
end
|
102
|
-
res
|
103
|
-
rescue OpenSSL::SSL::SSLError => e
|
104
|
-
raise e unless e.message.include? "certificate verify failed"
|
105
|
-
|
106
|
-
puts "Error: Failed to connect to #{uri}."
|
107
|
-
puts "If the server uses a self-signed certificate, please re-run the login command with the --insecure option."
|
108
|
-
exit 1
|
109
|
-
end
|
110
|
-
|
111
|
-
def self._parse_url(url)
|
112
|
-
url = "https://#{url}" if URI.parse(url).scheme.nil?
|
113
|
-
URI.parse(url)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|