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,25 +0,0 @@
|
|
1
|
-
# copyright: 2015, Chef Software, Inc.
|
2
|
-
|
3
|
-
class FilterArray
|
4
|
-
attr_accessor :rules
|
5
|
-
alias content rules
|
6
|
-
|
7
|
-
def initialize(rules)
|
8
|
-
@rules = rules
|
9
|
-
end
|
10
|
-
|
11
|
-
# allows for chaining
|
12
|
-
# .field('arch', 'b32').field('key', 'access').rules
|
13
|
-
def field(key, value = nil)
|
14
|
-
if value
|
15
|
-
res = rules.find_all { |r| r[key.to_sym] == value }
|
16
|
-
FilterArray.new(res)
|
17
|
-
else
|
18
|
-
rules.map { |h| h[key.to_sym] }.uniq
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def method_missing(meth, *args)
|
23
|
-
field(meth, args[0])
|
24
|
-
end
|
25
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# copyright: 2015, Vulcano Security GmbH
|
2
|
-
|
3
|
-
module FindFiles
|
4
|
-
TYPES = {
|
5
|
-
block: "b",
|
6
|
-
character: "c",
|
7
|
-
directory: "d",
|
8
|
-
pipe: "p",
|
9
|
-
file: "f",
|
10
|
-
link: "l",
|
11
|
-
socket: "s",
|
12
|
-
door: "D",
|
13
|
-
}.freeze
|
14
|
-
|
15
|
-
# ignores errors
|
16
|
-
def find_files(path, opts = {})
|
17
|
-
find_files_or_warn(path, opts) || []
|
18
|
-
end
|
19
|
-
|
20
|
-
def find_files_or_warn(path, opts = {})
|
21
|
-
depth = opts[:depth]
|
22
|
-
type = TYPES[opts[:type].to_sym] if opts[:type]
|
23
|
-
|
24
|
-
# If `path` contains a `'` we must modify how we quote the `sh -c` argument
|
25
|
-
quote = path.include?("'") ? '"' : "'"
|
26
|
-
|
27
|
-
cmd = "sh -c #{quote}find #{path}"
|
28
|
-
cmd += " -type #{type}" unless type.nil?
|
29
|
-
cmd += " -maxdepth #{depth.to_i}" if depth.to_i > 0
|
30
|
-
cmd += quote
|
31
|
-
|
32
|
-
result = inspec.command(cmd)
|
33
|
-
exit_status = result.exit_status
|
34
|
-
|
35
|
-
unless exit_status == 0
|
36
|
-
warn "find_files(): exit #{exit_status} from `#{cmd}`"
|
37
|
-
return nil
|
38
|
-
end
|
39
|
-
|
40
|
-
result.stdout.split("\n")
|
41
|
-
.map(&:strip)
|
42
|
-
.find_all { |x| !x.empty? }
|
43
|
-
end
|
44
|
-
end
|
data/lib/inspec/utils/hash.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
class ::Hash
|
2
|
-
# Inspired by: http://stackoverflow.com/a/9381776
|
3
|
-
def deep_merge(second)
|
4
|
-
merger = proc { |_key, v1, v2|
|
5
|
-
v1.is_a?(Hash) && v2.is_a?(Hash) ? v1.merge(v2, &merger) : v2
|
6
|
-
}
|
7
|
-
merge(second, &merger)
|
8
|
-
end
|
9
|
-
|
10
|
-
# converts a deep hash into a flat hash
|
11
|
-
# hash = {
|
12
|
-
# 'a' => 1,
|
13
|
-
# 'b' => {'c' => 2},
|
14
|
-
# }
|
15
|
-
# hash.smash # => {"a"=>1, "b-c"=>2}
|
16
|
-
def smash(prefix = nil)
|
17
|
-
inject({}) do |acc, (key, value)|
|
18
|
-
index = prefix.to_s + key.to_s
|
19
|
-
if value.is_a?(Hash)
|
20
|
-
acc.merge(value.smash(index + "-"))
|
21
|
-
else
|
22
|
-
acc.merge(index => value)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# deep check if all values are contained
|
28
|
-
def contains(contains)
|
29
|
-
hash = smash
|
30
|
-
contains = contains.smash
|
31
|
-
|
32
|
-
contains.each do |key, val|
|
33
|
-
return false if hash[key] != val
|
34
|
-
end
|
35
|
-
true
|
36
|
-
end
|
37
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
|
3
|
-
# a simple streaming json logger
|
4
|
-
class Logger::JSONFormatter < Logger::Formatter
|
5
|
-
def call(severity, time, progname, msg)
|
6
|
-
puts JSON.generate(
|
7
|
-
{
|
8
|
-
"progname" => progname,
|
9
|
-
"severity" => severity,
|
10
|
-
"time" => time,
|
11
|
-
"msg" => msg,
|
12
|
-
}
|
13
|
-
)
|
14
|
-
end
|
15
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
require "parslet"
|
2
|
-
|
3
|
-
class NginxParser < Parslet::Parser
|
4
|
-
root :outermost
|
5
|
-
# only designed for rabbitmq config files for now:
|
6
|
-
rule(:outermost) { filler? >> exp.repeat }
|
7
|
-
|
8
|
-
rule(:filler?) { one_filler.repeat }
|
9
|
-
rule(:one_filler) { match('\s+') | match["\n"] | comment }
|
10
|
-
rule(:space) { match('\s+') }
|
11
|
-
rule(:comment) { str("#") >> (match["\n\r"].absent? >> any).repeat }
|
12
|
-
|
13
|
-
rule(:exp) do
|
14
|
-
section | assignment
|
15
|
-
end
|
16
|
-
rule(:assignment) do
|
17
|
-
(identifier >> values.maybe.as(:args)).as(:assignment) >> str(";") >> filler?
|
18
|
-
end
|
19
|
-
|
20
|
-
rule(:standard_identifier) do
|
21
|
-
(match("[a-zA-Z~*.]") >> match('\S').repeat).as(:identifier) >> space >> space.repeat
|
22
|
-
end
|
23
|
-
|
24
|
-
rule(:quoted_identifier) do
|
25
|
-
str('"') >> (str('"').absent? >> any).repeat.as(:identifier) >> str('"') >> space.repeat
|
26
|
-
end
|
27
|
-
|
28
|
-
rule(:identifier) do
|
29
|
-
standard_identifier | quoted_identifier
|
30
|
-
end
|
31
|
-
|
32
|
-
rule(:standard_value) do
|
33
|
-
((match(/[#;{'"]/).absent? >> any) >> (
|
34
|
-
str('\\') >> any | match('[#;{]|\s').absent? >> any
|
35
|
-
).repeat).as(:value) >> space.repeat
|
36
|
-
end
|
37
|
-
|
38
|
-
rule(:single_quoted_value) do
|
39
|
-
str("'") >> (
|
40
|
-
str('\\') >> any | str("'").absent? >> any
|
41
|
-
).repeat.as(:value) >> str("'") >> space.repeat
|
42
|
-
end
|
43
|
-
|
44
|
-
rule(:double_quoted_value) do
|
45
|
-
str('"') >> (
|
46
|
-
str('\\') >> any | str('"').absent? >> any
|
47
|
-
).repeat.as(:value) >> str('"') >> space.repeat
|
48
|
-
end
|
49
|
-
|
50
|
-
rule(:quoted_value) do
|
51
|
-
single_quoted_value | double_quoted_value
|
52
|
-
end
|
53
|
-
|
54
|
-
rule(:value) do
|
55
|
-
standard_value | quoted_value
|
56
|
-
end
|
57
|
-
|
58
|
-
rule(:values) do
|
59
|
-
value.repeat >> space.maybe
|
60
|
-
end
|
61
|
-
|
62
|
-
rule(:section) do
|
63
|
-
identifier.as(:section) >> values.maybe.as(:args) >> str("{") >> filler? >> exp.repeat.as(:expressions) >> str("}") >> filler?
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class NginxTransform < Parslet::Transform
|
68
|
-
Group = Struct.new(:id, :args, :body)
|
69
|
-
Exp = Struct.new(:key, :vals)
|
70
|
-
|
71
|
-
def self.assemble_binary(seq)
|
72
|
-
b = ErlangBitstream.new
|
73
|
-
seq.each { |i| b.add(i) }
|
74
|
-
b.value
|
75
|
-
end
|
76
|
-
|
77
|
-
rule(section: { identifier: simple(:x) }, args: subtree(:y), expressions: subtree(:z)) { Group.new(x.to_s, y, z) }
|
78
|
-
rule(assignment: { identifier: simple(:x), args: subtree(:y) }) { Exp.new(x.to_s, y) }
|
79
|
-
rule(value: simple(:x)) { x.to_s }
|
80
|
-
end
|
81
|
-
|
82
|
-
class NginxConfig
|
83
|
-
def self.parse(content)
|
84
|
-
lex = NginxParser.new.parse(content)
|
85
|
-
tree = NginxTransform.new.apply(lex)
|
86
|
-
gtree = NginxTransform::Group.new(nil, "", tree)
|
87
|
-
read_nginx_group(gtree)
|
88
|
-
rescue Parslet::ParseFailed => err
|
89
|
-
raise "Failed to parse NginX config: #{err}"
|
90
|
-
end
|
91
|
-
|
92
|
-
def self.read_nginx_group(t)
|
93
|
-
agg_conf = Hash.new([])
|
94
|
-
agg_conf["_"] = t.args unless t.args == ""
|
95
|
-
|
96
|
-
groups, conf = t.body.partition { |i| i.is_a? NginxTransform::Group }
|
97
|
-
conf.each { |x| agg_conf[x.key] += [x.vals] }
|
98
|
-
groups.each { |x| agg_conf[x.id] += [read_nginx_group(x)] }
|
99
|
-
agg_conf
|
100
|
-
end
|
101
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module ObjectTraverser
|
2
|
-
def extract_value(keys, value)
|
3
|
-
return nil if value.nil?
|
4
|
-
|
5
|
-
key = keys.shift
|
6
|
-
return nil if key.nil?
|
7
|
-
|
8
|
-
# if the current value is not a Hash or Array, it is undefined
|
9
|
-
# behavior so value will be assigned nil by default.
|
10
|
-
value = if value.is_a?(Array)
|
11
|
-
extract_from_array(key, value)
|
12
|
-
elsif value.is_a?(Hash)
|
13
|
-
extract_from_hash(key, value)
|
14
|
-
end
|
15
|
-
|
16
|
-
# if there are no more keys, just return the value
|
17
|
-
return value if keys.first.nil?
|
18
|
-
|
19
|
-
# if there are more keys, extract more
|
20
|
-
extract_value(keys.clone, value)
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
# If the values to return from is an Array, allow returning by index.
|
26
|
-
# Otherwise, support methods on the Array itself.
|
27
|
-
def extract_from_array(key, value)
|
28
|
-
if key.is_a?(Integer)
|
29
|
-
value[key]
|
30
|
-
elsif value.respond_to?(key.to_sym)
|
31
|
-
value.send(key.to_sym)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# for Hashes, try to return the value by the key.
|
36
|
-
# We first try to find by the raw key before we stringify
|
37
|
-
# if the keys themselves are symbols, for example.
|
38
|
-
#
|
39
|
-
# This will return nil default if we can't find the key.
|
40
|
-
def extract_from_hash(key, value)
|
41
|
-
if value.key?(key)
|
42
|
-
value[key]
|
43
|
-
elsif value.key?(key.to_s)
|
44
|
-
value[key.to_s]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/lib/inspec/utils/parser.rb
DELETED
@@ -1,277 +0,0 @@
|
|
1
|
-
require "inspec/resources/command"
|
2
|
-
|
3
|
-
module PasswdParser
|
4
|
-
# Parse /etc/passwd files.
|
5
|
-
#
|
6
|
-
# @param [String] content the raw content of /etc/passwd
|
7
|
-
# @return [Array] Collection of passwd entries
|
8
|
-
def parse_passwd(content)
|
9
|
-
content.to_s.split("\n").map do |line|
|
10
|
-
next if line[0] == "#"
|
11
|
-
|
12
|
-
parse_passwd_line(line)
|
13
|
-
end.compact
|
14
|
-
end
|
15
|
-
|
16
|
-
# Parse a line of /etc/passwd
|
17
|
-
#
|
18
|
-
# @param [String] line a line of /etc/passwd
|
19
|
-
# @return [Hash] Map of entries in this line
|
20
|
-
def parse_passwd_line(line)
|
21
|
-
x = line.split(":")
|
22
|
-
{
|
23
|
-
# rubocop:disable Layout/AlignHash
|
24
|
-
"user" => x[0],
|
25
|
-
"password" => x[1],
|
26
|
-
"uid" => x[2],
|
27
|
-
"gid" => x[3],
|
28
|
-
"desc" => x[4],
|
29
|
-
"home" => x[5],
|
30
|
-
"shell" => x[6],
|
31
|
-
}
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
module CommentParser
|
36
|
-
# Parse a line with a command. For example: `a = b # comment`.
|
37
|
-
# Retrieves the actual content.
|
38
|
-
#
|
39
|
-
# @param [String] raw the content lines you want to be parsed
|
40
|
-
# @param [Hash] opts optional configuration
|
41
|
-
# @return [Array] contains the actual line and the position of the line end
|
42
|
-
def parse_comment_line(raw, opts)
|
43
|
-
idx_nl = raw.index("\n")
|
44
|
-
idx_comment = raw.index(opts[:comment_char])
|
45
|
-
idx_nl = raw.length if idx_nl.nil?
|
46
|
-
idx_comment = idx_nl + 1 if idx_comment.nil?
|
47
|
-
line = ""
|
48
|
-
|
49
|
-
# is a comment inside this line
|
50
|
-
if idx_comment < idx_nl && idx_comment != 0
|
51
|
-
line = raw[0..(idx_comment - 1)]
|
52
|
-
# in case we don't allow comments at the end
|
53
|
-
# of an assignment/statement, ignore it and fall
|
54
|
-
# back to treating this as a regular line
|
55
|
-
if opts[:standalone_comments] && !is_empty_line(line)
|
56
|
-
line = raw[0..(idx_nl - 1)]
|
57
|
-
end
|
58
|
-
# if there is no comment in this line
|
59
|
-
elsif idx_comment > idx_nl && idx_nl != 0
|
60
|
-
line = raw[0..(idx_nl - 1)]
|
61
|
-
end
|
62
|
-
[line, idx_nl]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
module LinuxMountParser
|
67
|
-
# this parses the output of mount command (only tested on linux)
|
68
|
-
# this method expects only one line of the mount output
|
69
|
-
def parse_mount_options(mount_line, compatibility = false)
|
70
|
-
if includes_whitespaces?(mount_line)
|
71
|
-
# Device-/Sharenames and Mountpoints including whitespaces require special treatment:
|
72
|
-
# We use the keyword ' type ' to split up and rebuild the desired array of fields
|
73
|
-
type_split = mount_line.split(" type ")
|
74
|
-
fs_path = type_split[0]
|
75
|
-
other_opts = type_split[1]
|
76
|
-
fs, path = fs_path.match(%r{^(.+?)\son\s(/.+?)$}).captures
|
77
|
-
mount = [fs, "on", path, "type"]
|
78
|
-
mount.concat(other_opts.scan(/\S+/))
|
79
|
-
else
|
80
|
-
# ... otherwise we just split the fields by whitespaces
|
81
|
-
mount = mount_line.scan(/\S+/)
|
82
|
-
end
|
83
|
-
|
84
|
-
# parse device and type
|
85
|
-
mount_options = { device: mount[0], type: mount[4] }
|
86
|
-
|
87
|
-
if compatibility == false
|
88
|
-
# parse options as array
|
89
|
-
mount_options[:options] = mount[5].gsub(/\(|\)/, "").split(",")
|
90
|
-
else
|
91
|
-
Inspec.deprecate(:mount_parser_serverspec_compat, "Parsing mount options in this fashion is deprecated")
|
92
|
-
mount_options[:options] = {}
|
93
|
-
mount[5].gsub(/\(|\)/, "").split(",").each do |option|
|
94
|
-
name, val = option.split("=")
|
95
|
-
if val.nil?
|
96
|
-
val = true
|
97
|
-
elsif val =~ /^\d+$/
|
98
|
-
# parse numbers
|
99
|
-
val = val.to_i
|
100
|
-
end
|
101
|
-
mount_options[:options][name.to_sym] = val
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
mount_options
|
106
|
-
end
|
107
|
-
|
108
|
-
# Device-/Sharename or Mountpoint includes whitespaces?
|
109
|
-
def includes_whitespaces?(mount_line)
|
110
|
-
ws = mount_line.match(/^(.+)\son\s(.+)\stype\s.*$/)
|
111
|
-
ws.captures[0].include?(" ") || ws.captures[1].include?(" ")
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
module BsdMountParser
|
116
|
-
# this parses the output of mount command (only tested on freebsd)
|
117
|
-
# this method expects only one line of the mount output
|
118
|
-
def parse_mount_options(mount_line, _compatibility = false)
|
119
|
-
return {} if mount_line.nil? || mount_line.empty?
|
120
|
-
|
121
|
-
mount = mount_line.chomp.split(" ", 4)
|
122
|
-
options = mount[3].tr("()", "").split(", ")
|
123
|
-
|
124
|
-
# parse device and type
|
125
|
-
{ device: mount[0], type: options.shift, options: options }
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
module SolarisNetstatParser
|
130
|
-
# takes this as a input and parses the values
|
131
|
-
# UDP: IPv4
|
132
|
-
# Local Address Remote Address State
|
133
|
-
# -------------------- -------------------- ----------
|
134
|
-
# *.* Unbound
|
135
|
-
def parse_netstat(content) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
136
|
-
return [] if content.nil? || content.empty?
|
137
|
-
|
138
|
-
protocol = nil
|
139
|
-
column_widths = nil
|
140
|
-
ports = []
|
141
|
-
cache_name_line = nil
|
142
|
-
|
143
|
-
content.each_line do |line|
|
144
|
-
# find header, its delimiter
|
145
|
-
if line =~ /TCP:|UDP:|SCTP:/
|
146
|
-
# get protocol
|
147
|
-
protocol = line.split(":")[0].chomp.strip.downcase
|
148
|
-
|
149
|
-
# determine version tcp, tcp6, udp, udp6
|
150
|
-
proto_version = line.split(":")[1].chomp.strip
|
151
|
-
protocol += "6" if proto_version == "IPv6"
|
152
|
-
|
153
|
-
# reset names cache
|
154
|
-
column_widths = nil
|
155
|
-
cache_name_line = nil
|
156
|
-
names = nil
|
157
|
-
# calulate width of a column based on the horizontal line
|
158
|
-
elsif line =~ /^[- ]+$/
|
159
|
-
column_widths = columns(line)
|
160
|
-
# parse header values from line
|
161
|
-
elsif column_widths.nil? && !line.nil?
|
162
|
-
# we do not know the width at this point of time, therefore we need to cache
|
163
|
-
cache_name_line = line
|
164
|
-
# content line
|
165
|
-
elsif !column_widths.nil? && !line.nil? && !line.chomp.empty?
|
166
|
-
# default row
|
167
|
-
port = split_columns(column_widths, line).to_a.map { |v| v.chomp.strip }
|
168
|
-
|
169
|
-
# parse the header names
|
170
|
-
# TODO: names should be optional
|
171
|
-
names = split_columns(column_widths, cache_name_line).to_a.map { |v| v.chomp.strip.downcase.tr(" ", "-").gsub(/[^\w-]/, "_") }
|
172
|
-
info = {
|
173
|
-
"protocol" => protocol.downcase,
|
174
|
-
}
|
175
|
-
|
176
|
-
# generate hash for each line and use the names as keys
|
177
|
-
names.each_index do |i|
|
178
|
-
info[names[i]] = port[i] if i != 0
|
179
|
-
end
|
180
|
-
|
181
|
-
ports.push(info)
|
182
|
-
end
|
183
|
-
end
|
184
|
-
ports
|
185
|
-
end
|
186
|
-
|
187
|
-
private
|
188
|
-
|
189
|
-
# takes a line like "-------------------- -------------------- ----------"
|
190
|
-
# as input and calculates the length of each column
|
191
|
-
def columns(line)
|
192
|
-
# find all columns
|
193
|
-
m = line.scan(/-+/)
|
194
|
-
# calculate the length each column
|
195
|
-
m.map { |x| x.length } # rubocop:disable Style/SymbolProc
|
196
|
-
end
|
197
|
-
|
198
|
-
# takes a line and the width of the columns to extract the values
|
199
|
-
def split_columns(columns, line)
|
200
|
-
# generate regex based on columns
|
201
|
-
sep = '\\s'
|
202
|
-
length = columns.length
|
203
|
-
arr = columns.map.with_index do |x, i|
|
204
|
-
reg = "(.{#{x}})#{sep}" # add seperator between columns
|
205
|
-
reg = "(.{,#{x}})#{sep}" if i == length - 2 # make the pre-last one optional
|
206
|
-
reg = "(.{,#{x}})" if i == length - 1 # use , to say max value
|
207
|
-
reg
|
208
|
-
end
|
209
|
-
# extracts the columns
|
210
|
-
line.match(Regexp.new(arr.join))
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
# This parser for xinetd (extended Internet daemon) configuration files
|
215
|
-
module XinetdParser
|
216
|
-
def xinetd_include_dir(dir)
|
217
|
-
return [] if dir.nil?
|
218
|
-
|
219
|
-
unless inspec.file(dir).directory?
|
220
|
-
raise Inspec::Exceptions::ResourceSkipped, "Can't find folder: #{dir}"
|
221
|
-
end
|
222
|
-
|
223
|
-
files = inspec.command("find #{dir} -type f").stdout.split("\n")
|
224
|
-
files.map { |file| parse_xinetd(read_content(file)) }
|
225
|
-
end
|
226
|
-
|
227
|
-
def parse_xinetd(raw) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
228
|
-
return {} if raw.nil?
|
229
|
-
|
230
|
-
require "inspec/utils/simpleconfig"
|
231
|
-
|
232
|
-
res = {}
|
233
|
-
cur_group = nil
|
234
|
-
simple_conf = []
|
235
|
-
rest = raw + "\n"
|
236
|
-
until rest.empty?
|
237
|
-
# extract content line
|
238
|
-
nl = rest.index("\n") || (rest.length - 1)
|
239
|
-
comment = rest.index("#") || (rest.length - 1)
|
240
|
-
dst_idx = comment < nl ? comment : nl
|
241
|
-
inner_line = dst_idx == 0 ? "" : rest[0..dst_idx - 1].strip
|
242
|
-
# update unparsed content
|
243
|
-
rest = rest[nl + 1..-1]
|
244
|
-
next if inner_line.empty?
|
245
|
-
|
246
|
-
if inner_line == "}"
|
247
|
-
if cur_group == "defaults"
|
248
|
-
res[cur_group] = SimpleConfig.new(simple_conf.join("\n"))
|
249
|
-
else
|
250
|
-
res[cur_group] ||= []
|
251
|
-
res[cur_group].push(SimpleConfig.new(simple_conf.join("\n")))
|
252
|
-
end
|
253
|
-
cur_group = nil
|
254
|
-
elsif rest.lstrip[0] == "{"
|
255
|
-
cur_group = inner_line
|
256
|
-
simple_conf = []
|
257
|
-
rest = rest[rest.index("\n") + 1..-1]
|
258
|
-
elsif cur_group.nil?
|
259
|
-
# parse all included files
|
260
|
-
others = xinetd_include_dir(inner_line[/includedir (.+)/, 1])
|
261
|
-
|
262
|
-
# complex merging of included configurations, as multiple services
|
263
|
-
# may be defined with the same name but different configuration
|
264
|
-
others.each do |ores|
|
265
|
-
ores.each do |k, v|
|
266
|
-
res[k] ||= []
|
267
|
-
res[k].concat(v)
|
268
|
-
end
|
269
|
-
end
|
270
|
-
else
|
271
|
-
simple_conf.push(inner_line)
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
res
|
276
|
-
end
|
277
|
-
end
|