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,230 +0,0 @@
|
|
1
|
-
require "inspec/utils/simpleconfig"
|
2
|
-
require "inspec/utils/file_reader"
|
3
|
-
|
4
|
-
module Inspec::Resources
|
5
|
-
class GrubConfig < Inspec.resource(1)
|
6
|
-
name "grub_conf"
|
7
|
-
supports platform: "unix"
|
8
|
-
desc "Use the grub_conf InSpec audit resource to test the boot config of Linux systems that use Grub."
|
9
|
-
example <<~EXAMPLE
|
10
|
-
describe grub_conf('/etc/grub.conf', 'default') do
|
11
|
-
its('kernel') { should include '/vmlinuz-2.6.32-573.7.1.el6.x86_64' }
|
12
|
-
its('initrd') { should include '/initramfs-2.6.32-573.el6.x86_64.img=1' }
|
13
|
-
its('default') { should_not eq '1' }
|
14
|
-
its('timeout') { should eq '5' }
|
15
|
-
end
|
16
|
-
|
17
|
-
also check specific kernels
|
18
|
-
describe grub_conf('/etc/grub.conf', 'CentOS (2.6.32-573.12.1.el6.x86_64)') do
|
19
|
-
its('kernel') { should include 'audit=1' }
|
20
|
-
end
|
21
|
-
EXAMPLE
|
22
|
-
|
23
|
-
include FileReader
|
24
|
-
|
25
|
-
class UnknownGrubConfig < StandardError; end
|
26
|
-
|
27
|
-
def initialize(path = nil, kernel = nil)
|
28
|
-
config_for_platform(path)
|
29
|
-
@content = read_file(@conf_path)
|
30
|
-
@kernel = kernel || "default"
|
31
|
-
rescue UnknownGrubConfig
|
32
|
-
skip_resource "The `grub_config` resource is not supported on your OS yet."
|
33
|
-
end
|
34
|
-
|
35
|
-
def config_for_platform(path)
|
36
|
-
os = inspec.os
|
37
|
-
if os.redhat? || os[:name] == "fedora"
|
38
|
-
config_for_redhatish(path)
|
39
|
-
elsif os.debian?
|
40
|
-
@conf_path = path || "/boot/grub/grub.cfg"
|
41
|
-
@defaults_path = "/etc/default/grub"
|
42
|
-
@grubenv_path = "/boot/grub2/grubenv"
|
43
|
-
@version = "grub2"
|
44
|
-
elsif os[:name] == "amazon"
|
45
|
-
@conf_path = path || "/etc/grub.conf"
|
46
|
-
@version = "legacy"
|
47
|
-
else
|
48
|
-
raise UnknownGrubConfig
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def config_for_redhatish(path)
|
53
|
-
if inspec.os[:release].to_f < 7
|
54
|
-
@conf_path = path || "/etc/grub.conf"
|
55
|
-
@version = "legacy"
|
56
|
-
else
|
57
|
-
@conf_path = path || "/boot/grub2/grub.cfg"
|
58
|
-
@defaults_path = "/etc/default/grub"
|
59
|
-
@grubenv_path = "/boot/grub2/grubenv"
|
60
|
-
@version = "grub2"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def method_missing(name)
|
65
|
-
read_params[name.to_s]
|
66
|
-
end
|
67
|
-
|
68
|
-
def to_s
|
69
|
-
"Grub Config"
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
######################################################################
|
75
|
-
# Grub2 This is used by all supported versions of Ubuntu and Rhel 7+ #
|
76
|
-
######################################################################
|
77
|
-
|
78
|
-
def grub2_parse_kernel_lines(content, conf)
|
79
|
-
menu_entries = extract_menu_entries(content)
|
80
|
-
|
81
|
-
if @kernel == "default"
|
82
|
-
default_menu_entry(menu_entries, conf["GRUB_DEFAULT"])
|
83
|
-
else
|
84
|
-
menu_entries.find { |entry| entry["name"] == @kernel }
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def extract_menu_entries(content)
|
89
|
-
menu_entries = []
|
90
|
-
|
91
|
-
lines = content.split("\n")
|
92
|
-
lines.each_with_index do |line, index|
|
93
|
-
next unless line =~ /^menuentry\s+.*/
|
94
|
-
|
95
|
-
entry = {}
|
96
|
-
entry["insmod"] = []
|
97
|
-
|
98
|
-
# Extract name from menuentry line
|
99
|
-
capture_data = line.match(/(?:^|\s+).*menuentry\s*['|"](.*)['|"]\s*--/)
|
100
|
-
if capture_data.nil? || capture_data.captures[0].nil?
|
101
|
-
raise Inspec::Exceptions::ResourceFailed "Failed to extract menuentry name from #{line}"
|
102
|
-
end
|
103
|
-
|
104
|
-
entry["name"] = capture_data.captures[0]
|
105
|
-
|
106
|
-
# Begin processing from index forward until a `}` line is met
|
107
|
-
lines.drop(index + 1).each do |mline|
|
108
|
-
break if mline =~ /^\s*}\s*$/
|
109
|
-
|
110
|
-
case mline
|
111
|
-
when /(?:^|\s*)initrd.*/
|
112
|
-
entry["initrd"] = mline.split(" ")[1]
|
113
|
-
when /(?:^|\s*)linux.*/
|
114
|
-
entry["kernel"] = mline.split
|
115
|
-
when /(?:^|\s*)set root=.*/
|
116
|
-
entry["root"] = mline.split("=")[1].tr("'", "")
|
117
|
-
when /(?:^|\s*)insmod.*/
|
118
|
-
entry["insmod"] << mline.split(" ")[1]
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
menu_entries << entry
|
123
|
-
end
|
124
|
-
|
125
|
-
menu_entries
|
126
|
-
end
|
127
|
-
|
128
|
-
def default_menu_entry(menu_entries, default)
|
129
|
-
# If the default entry isn't `saved` then a number is used as an index.
|
130
|
-
# By default this is `0`, which would be the first item in the list.
|
131
|
-
return menu_entries[default.to_i] unless default == "saved"
|
132
|
-
|
133
|
-
grubenv_contents = inspec.file(@grubenv_path).content
|
134
|
-
|
135
|
-
# The location of the grubenv file is not guaranteed. In the case that
|
136
|
-
# the file does not exist this will return the 0th entry. This will also
|
137
|
-
# return the 0th entry if InSpec lacks permission to read the file. Both
|
138
|
-
# of these reflect the default Grub2 behavior.
|
139
|
-
return menu_entries[0] if grubenv_contents.nil?
|
140
|
-
|
141
|
-
default_name = SimpleConfig.new(grubenv_contents).params["saved_entry"]
|
142
|
-
default_entry = menu_entries.select { |k| k["name"] == default_name }[0]
|
143
|
-
return default_entry unless default_entry.nil?
|
144
|
-
|
145
|
-
# It is possible for the saved entry to not be valid . For example, grubenv
|
146
|
-
# not being up to date. If so, the 0th entry is the default.
|
147
|
-
menu_entries[0]
|
148
|
-
end
|
149
|
-
|
150
|
-
###################################################################
|
151
|
-
# Grub1 aka legacy-grub config. Primarily used by Centos/Rhel 6.x #
|
152
|
-
###################################################################
|
153
|
-
|
154
|
-
def parse_kernel_lines(content, conf)
|
155
|
-
# Find all "title" lines and then parse them into arrays
|
156
|
-
menu_entry = 0
|
157
|
-
lines = content.split("\n")
|
158
|
-
kernel_opts = {}
|
159
|
-
lines.each_with_index do |file_line, index|
|
160
|
-
next unless file_line =~ /^title.*/
|
161
|
-
|
162
|
-
current_kernel = file_line.split(" ", 2)[1]
|
163
|
-
lines.drop(index + 1).each do |kernel_line|
|
164
|
-
if kernel_line =~ /^\s.*/
|
165
|
-
option_type = kernel_line.split(" ")[0]
|
166
|
-
line_options = kernel_line.split(" ").drop(1)
|
167
|
-
if (menu_entry == conf["default"].to_i && @kernel == "default") || current_kernel == @kernel
|
168
|
-
if option_type == "kernel"
|
169
|
-
kernel_opts["kernel"] = line_options
|
170
|
-
else
|
171
|
-
kernel_opts[option_type] = line_options[0]
|
172
|
-
end
|
173
|
-
end
|
174
|
-
else
|
175
|
-
menu_entry += 1
|
176
|
-
break
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
kernel_opts
|
181
|
-
end
|
182
|
-
|
183
|
-
def read_file(config_file)
|
184
|
-
read_file_content(config_file)
|
185
|
-
end
|
186
|
-
|
187
|
-
def read_params
|
188
|
-
return @params if defined?(@params)
|
189
|
-
|
190
|
-
content = read_file(@conf_path)
|
191
|
-
|
192
|
-
if @version == "legacy"
|
193
|
-
# parse the file
|
194
|
-
conf = SimpleConfig.new(
|
195
|
-
content,
|
196
|
-
multiple_values: true
|
197
|
-
).params
|
198
|
-
# convert single entry arrays into strings
|
199
|
-
conf.each do |key, value|
|
200
|
-
if value.size == 1
|
201
|
-
conf[key] = conf[key][0].to_s
|
202
|
-
end
|
203
|
-
end
|
204
|
-
kernel_opts = parse_kernel_lines(content, conf)
|
205
|
-
@params = conf.merge(kernel_opts)
|
206
|
-
end
|
207
|
-
|
208
|
-
if @version == "grub2"
|
209
|
-
# read defaults
|
210
|
-
defaults = read_file(@defaults_path)
|
211
|
-
|
212
|
-
conf = SimpleConfig.new(
|
213
|
-
defaults,
|
214
|
-
multiple_values: true
|
215
|
-
).params
|
216
|
-
|
217
|
-
# convert single entry arrays into strings
|
218
|
-
conf.each do |key, value|
|
219
|
-
if value.size == 1
|
220
|
-
conf[key] = conf[key][0].to_s
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
kernel_opts = grub2_parse_kernel_lines(content, conf)
|
225
|
-
@params = conf.merge(kernel_opts)
|
226
|
-
end
|
227
|
-
@params
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
@@ -1,310 +0,0 @@
|
|
1
|
-
require "inspec/resources/command"
|
2
|
-
|
3
|
-
# Usage:
|
4
|
-
# describe host('example.com') do
|
5
|
-
# it { should be_resolvable }
|
6
|
-
# it { should be_reachable }
|
7
|
-
# its('ipaddress') { should include '93.184.216.34' }
|
8
|
-
# end
|
9
|
-
#
|
10
|
-
# To verify a hostname with protocol and port
|
11
|
-
# describe host('example.com', port: 443, protocol: 'tcp') do
|
12
|
-
# it { should be_reachable }
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# We do not support the following serverspec syntax:
|
16
|
-
# describe host('example.com') do
|
17
|
-
# it { should be_reachable.with( :port => 22 ) }
|
18
|
-
# it { should be_reachable.with( :port => 22, :proto => 'tcp' ) }
|
19
|
-
# it { should be_reachable.with( :port => 53, :proto => 'udp' ) }
|
20
|
-
#
|
21
|
-
# it { should be_resolvable.by('hosts') }
|
22
|
-
# it { should be_resolvable.by('dns') }
|
23
|
-
# end
|
24
|
-
|
25
|
-
require "resolv"
|
26
|
-
|
27
|
-
module Inspec::Resources
|
28
|
-
class Host < Inspec.resource(1)
|
29
|
-
name "host"
|
30
|
-
supports platform: "unix"
|
31
|
-
supports platform: "windows"
|
32
|
-
desc "Use the host InSpec audit resource to test the name used to refer to a specific host and its availability, including the Internet protocols and ports over which that host name should be available."
|
33
|
-
example <<~EXAMPLE
|
34
|
-
describe host('example.com') do
|
35
|
-
it { should be_reachable }
|
36
|
-
it { should be_resolvable }
|
37
|
-
its('ipaddress') { should include '12.34.56.78' }
|
38
|
-
end
|
39
|
-
|
40
|
-
describe host('example.com', port: '80', protocol: 'tcp') do
|
41
|
-
it { should be_reachable }
|
42
|
-
end
|
43
|
-
EXAMPLE
|
44
|
-
|
45
|
-
attr_reader :hostname, :port, :protocol
|
46
|
-
|
47
|
-
def initialize(hostname, params = {})
|
48
|
-
@hostname = hostname
|
49
|
-
@port = params[:port]
|
50
|
-
|
51
|
-
if params[:proto]
|
52
|
-
Inspec.deprecate(:host_resource_proto_usage, "The `host` resource `proto` resource parameter is deprecated. Please use `protocol`.")
|
53
|
-
@protocol = params[:proto]
|
54
|
-
else
|
55
|
-
@protocol = params.fetch(:protocol, "icmp")
|
56
|
-
end
|
57
|
-
|
58
|
-
@host_provider = nil
|
59
|
-
if inspec.os.linux?
|
60
|
-
@host_provider = LinuxHostProvider.new(inspec)
|
61
|
-
elsif inspec.os.windows?
|
62
|
-
return skip_resource "Invalid protocol: only `tcp` and `icmp` protocols are support for the `host` resource on your OS." unless
|
63
|
-
%w{icmp tcp}.include?(@protocol)
|
64
|
-
|
65
|
-
@host_provider = WindowsHostProvider.new(inspec)
|
66
|
-
elsif inspec.os.darwin?
|
67
|
-
@host_provider = DarwinHostProvider.new(inspec)
|
68
|
-
else
|
69
|
-
return skip_resource "The `host` resource is not supported on your OS yet."
|
70
|
-
end
|
71
|
-
|
72
|
-
missing_requirements = @host_provider.missing_requirements(protocol)
|
73
|
-
unless missing_requirements.empty?
|
74
|
-
return skip_resource "The following requirements are not met for this resource: " \
|
75
|
-
"#{missing_requirements.join(", ")}"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def proto
|
80
|
-
Inspec.deprecate(:host_resource_proto_usage, "The host resource `proto` method is deprecated. Please use `protocol`.")
|
81
|
-
protocol
|
82
|
-
end
|
83
|
-
|
84
|
-
# if we get the IP address, the host is resolvable
|
85
|
-
def resolvable?(type = nil)
|
86
|
-
warn "The `host` resource ignores #{type} parameters. Continue to resolve host." unless type.nil?
|
87
|
-
resolve.nil? || resolve.empty? ? false : true
|
88
|
-
end
|
89
|
-
|
90
|
-
def reachable?
|
91
|
-
# ping checks do not require port or protocol
|
92
|
-
return ping.fetch(:success, false) if protocol == "icmp"
|
93
|
-
|
94
|
-
# if either port or protocol are specified but not both, we cannot proceed.
|
95
|
-
if port.nil? || protocol.nil?
|
96
|
-
raise "Protocol required with port. Use `host` resource with host('#{hostname}', port: 1234, proto: 'tcp') parameters." if port.nil? || protocol.nil?
|
97
|
-
end
|
98
|
-
|
99
|
-
# perform the protocol-specific reachability test
|
100
|
-
ping.fetch(:success, false)
|
101
|
-
end
|
102
|
-
|
103
|
-
def connection
|
104
|
-
ping[:connection]
|
105
|
-
end
|
106
|
-
|
107
|
-
def socket
|
108
|
-
ping[:socket]
|
109
|
-
end
|
110
|
-
|
111
|
-
# returns all A records of the IP address, will return an array
|
112
|
-
def ipaddress
|
113
|
-
resolve.nil? || resolve.empty? ? nil : resolve
|
114
|
-
end
|
115
|
-
|
116
|
-
def to_s
|
117
|
-
resource_name = "Host #{hostname}"
|
118
|
-
resource_name += " port #{port} proto #{protocol}" if port
|
119
|
-
|
120
|
-
resource_name
|
121
|
-
end
|
122
|
-
|
123
|
-
private
|
124
|
-
|
125
|
-
def ping
|
126
|
-
return @ping_cache if defined?(@ping_cache)
|
127
|
-
return {} if @host_provider.nil?
|
128
|
-
|
129
|
-
@ping_cache = @host_provider.ping(hostname, port, protocol)
|
130
|
-
end
|
131
|
-
|
132
|
-
def resolve
|
133
|
-
return @ip_cache if defined?(@ip_cache)
|
134
|
-
|
135
|
-
@ip_cache = @host_provider.resolve(hostname) unless @host_provider.nil?
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
class HostProvider
|
140
|
-
attr_reader :inspec
|
141
|
-
def initialize(inspec)
|
142
|
-
@inspec = inspec
|
143
|
-
end
|
144
|
-
|
145
|
-
def missing_requirements(_protocol)
|
146
|
-
# each provider can return an array of missing requirements that can
|
147
|
-
# be enumerated in a skip_resource message
|
148
|
-
[]
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
class UnixHostProvider < HostProvider
|
153
|
-
def initialize(inspec)
|
154
|
-
super
|
155
|
-
|
156
|
-
@has_nc = inspec.command("nc").exist?
|
157
|
-
@has_ncat = inspec.command("ncat").exist?
|
158
|
-
@has_net_redirections = inspec.command("strings `which bash` | grep -qE '/dev/(tcp|udp)/'").exit_status == 0
|
159
|
-
end
|
160
|
-
|
161
|
-
def missing_requirements(protocol)
|
162
|
-
missing = []
|
163
|
-
|
164
|
-
if %w{tcp udp}.include?(protocol) && !@has_nc && !@has_ncat
|
165
|
-
if @has_net_redirections
|
166
|
-
missing << "#{timeout} (part of coreutils) or netcat must be installed" unless inspec.command(timeout).exist?
|
167
|
-
else
|
168
|
-
missing << "netcat must be installed"
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
missing
|
173
|
-
end
|
174
|
-
|
175
|
-
def ping(hostname, port, protocol)
|
176
|
-
if %w{tcp udp}.include?(protocol)
|
177
|
-
if @has_nc || @has_ncat
|
178
|
-
resp = inspec.command(netcat_check_command(hostname, port, protocol))
|
179
|
-
else
|
180
|
-
resp = inspec.command("#{timeout} 1 bash -c \"< /dev/#{protocol}/#{hostname}/#{port}\"")
|
181
|
-
end
|
182
|
-
else
|
183
|
-
# fall back to ping, but we can only test ICMP packages with ping
|
184
|
-
resp = inspec.command("ping -w 1 -c 1 #{hostname}")
|
185
|
-
end
|
186
|
-
|
187
|
-
{
|
188
|
-
success: resp.exit_status.to_i == 0,
|
189
|
-
connection: resp.stderr,
|
190
|
-
socket: resp.stdout,
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
|
-
def netcat_check_command(hostname, port, protocol)
|
195
|
-
if @has_nc
|
196
|
-
base_cmd = "nc"
|
197
|
-
elsif @has_ncat
|
198
|
-
base_cmd = "ncat"
|
199
|
-
else
|
200
|
-
return
|
201
|
-
end
|
202
|
-
|
203
|
-
if protocol == "udp"
|
204
|
-
extra_flags = "-u"
|
205
|
-
else
|
206
|
-
extra_flags = ""
|
207
|
-
end
|
208
|
-
|
209
|
-
"echo | #{base_cmd} -v -w 1 #{extra_flags} #{hostname} #{port}"
|
210
|
-
end
|
211
|
-
|
212
|
-
def timeout
|
213
|
-
"timeout"
|
214
|
-
end
|
215
|
-
|
216
|
-
def resolve_with_dig(hostname)
|
217
|
-
addresses = []
|
218
|
-
|
219
|
-
# look for IPv4 addresses
|
220
|
-
cmd = inspec.command("dig +short A #{hostname}")
|
221
|
-
cmd.stdout.lines.each do |line|
|
222
|
-
matched = line.chomp.match(Resolv::IPv4::Regex)
|
223
|
-
addresses << matched.to_s unless matched.nil?
|
224
|
-
end
|
225
|
-
|
226
|
-
# look for IPv6 addresses
|
227
|
-
cmd = inspec.command("dig +short AAAA #{hostname}")
|
228
|
-
cmd.stdout.lines.each do |line|
|
229
|
-
matched = line.chomp.match(Resolv::IPv6::Regex)
|
230
|
-
addresses << matched.to_s unless matched.nil?
|
231
|
-
end
|
232
|
-
|
233
|
-
addresses.empty? ? nil : addresses
|
234
|
-
end
|
235
|
-
|
236
|
-
def resolve_with_getent(hostname)
|
237
|
-
cmd = inspec.command("getent ahosts #{hostname}")
|
238
|
-
return nil unless cmd.exit_status.to_i == 0
|
239
|
-
|
240
|
-
# getent ahosts output is formatted like so:
|
241
|
-
# $ getent ahosts www.google.com
|
242
|
-
# 172.217.8.4 STREAM www.google.com
|
243
|
-
# 172.217.8.4 DGRAM
|
244
|
-
# 172.217.8.4 RAW
|
245
|
-
# 2607:f8b0:4004:803::2004 STREAM
|
246
|
-
# 2607:f8b0:4004:803::2004 DGRAM
|
247
|
-
# 2607:f8b0:4004:803::2004 RAW
|
248
|
-
addresses = []
|
249
|
-
cmd.stdout.lines.each do |line|
|
250
|
-
ip, = line.split(/\s+/, 2)
|
251
|
-
next unless ip.match(Resolv::IPv4::Regex) || ip.match(Resolv::IPv6::Regex)
|
252
|
-
|
253
|
-
addresses << ip unless addresses.include?(ip)
|
254
|
-
end
|
255
|
-
|
256
|
-
addresses
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
class DarwinHostProvider < UnixHostProvider
|
261
|
-
def timeout
|
262
|
-
"gtimeout"
|
263
|
-
end
|
264
|
-
|
265
|
-
def resolve(hostname)
|
266
|
-
resolve_with_dig(hostname)
|
267
|
-
end
|
268
|
-
end
|
269
|
-
|
270
|
-
class LinuxHostProvider < UnixHostProvider
|
271
|
-
def resolve(hostname)
|
272
|
-
resolve_with_getent(hostname)
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
# Windows
|
277
|
-
# TODO: UDP is not supported yey, we need a custom ps1 script to add udp support
|
278
|
-
# @see http://blogs.technet.com/b/josebda/archive/2015/04/18/windows-powershell-equivalents-for-common-networking-commands-ipconfig-ping-nslookup.aspx
|
279
|
-
# @see http://blogs.technet.com/b/heyscriptingguy/archive/2014/03/19/creating-a-port-scanner-with-windows-powershell.aspx
|
280
|
-
class WindowsHostProvider < HostProvider
|
281
|
-
def ping(hostname, port = nil, _proto = nil)
|
282
|
-
# ICMP: Test-NetConnection www.microsoft.com
|
283
|
-
# TCP and port: Test-NetConnection -ComputerName www.microsoft.com -RemotePort 80
|
284
|
-
request = "Test-NetConnection -ComputerName #{hostname} -WarningAction SilentlyContinue"
|
285
|
-
request += " -RemotePort #{port}" unless port.nil?
|
286
|
-
request += "| Select-Object -Property ComputerName, TcpTestSucceeded, PingSucceeded | ConvertTo-Json"
|
287
|
-
cmd = inspec.command(request)
|
288
|
-
|
289
|
-
begin
|
290
|
-
ping = JSON.parse(cmd.stdout)
|
291
|
-
rescue JSON::ParserError => _e
|
292
|
-
return {}
|
293
|
-
end
|
294
|
-
|
295
|
-
{ success: port.nil? ? ping["PingSucceeded"] : ping["TcpTestSucceeded"] }
|
296
|
-
end
|
297
|
-
|
298
|
-
def resolve(hostname)
|
299
|
-
cmd = inspec.command("Resolve-DnsName –Type A #{hostname} | ConvertTo-Json")
|
300
|
-
begin
|
301
|
-
resolv = JSON.parse(cmd.stdout)
|
302
|
-
rescue JSON::ParserError => _e
|
303
|
-
return nil
|
304
|
-
end
|
305
|
-
|
306
|
-
resolv = [resolv] unless resolv.is_a?(Array)
|
307
|
-
resolv.map { |entry| entry["IPAddress"] }
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|