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,23 +0,0 @@
|
|
1
|
-
require "shellwords"
|
2
|
-
|
3
|
-
class CommandWrapper
|
4
|
-
UNIX_SHELLS = %w{sh bash zsh ksh}.freeze
|
5
|
-
|
6
|
-
def self.wrap(cmd, options)
|
7
|
-
unless options.is_a?(Hash)
|
8
|
-
raise "All options for the command wrapper must be provided as a hash. "\
|
9
|
-
"You entered: #{options.inspect}. Please consult the documentation."
|
10
|
-
end
|
11
|
-
|
12
|
-
wrap = options[:wrap]
|
13
|
-
raise "Called command wrapper with wrap: #{wrap.inspect}. It must be called with a Proc." if !wrap.nil? && !wrap.is_a?(Proc)
|
14
|
-
return wrap.call(cmd) unless wrap.nil?
|
15
|
-
|
16
|
-
shell = options[:shell]
|
17
|
-
raise "Don't know how to wrap commands for shell: #{shell.inspect}." unless UNIX_SHELLS.include?(shell)
|
18
|
-
|
19
|
-
path = options[:path] || shell
|
20
|
-
args = options[:args] || "-c"
|
21
|
-
path.to_s + " " + args + " " + Shellwords.escape(cmd)
|
22
|
-
end
|
23
|
-
end
|
data/lib/inspec/utils/convert.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
module DatabaseHelper
|
2
|
-
class SQLColumn
|
3
|
-
def initialize(row, name)
|
4
|
-
@row = row
|
5
|
-
@name = name
|
6
|
-
end
|
7
|
-
|
8
|
-
def value
|
9
|
-
@row.nil? ? "" : @row[@name.downcase]
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_s
|
13
|
-
"SQL Column"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class SQLRow
|
18
|
-
def initialize(query, row)
|
19
|
-
@query = query
|
20
|
-
@row = row
|
21
|
-
end
|
22
|
-
|
23
|
-
def column(column)
|
24
|
-
SQLColumn.new(@row, column)
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_s
|
28
|
-
"SQL Row"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class SQLQueryResult
|
33
|
-
attr_reader :error
|
34
|
-
def initialize(cmd, results)
|
35
|
-
@cmd = cmd
|
36
|
-
@results = results
|
37
|
-
end
|
38
|
-
|
39
|
-
def empty?
|
40
|
-
@results.empty?
|
41
|
-
end
|
42
|
-
|
43
|
-
def successful?
|
44
|
-
@cmd.exit_status == 0 && @error.nil?
|
45
|
-
end
|
46
|
-
|
47
|
-
def rows
|
48
|
-
@results
|
49
|
-
end
|
50
|
-
|
51
|
-
def row(id)
|
52
|
-
SQLRow.new(self, @results[id])
|
53
|
-
end
|
54
|
-
|
55
|
-
def column(column)
|
56
|
-
result = []
|
57
|
-
@results.each do |row|
|
58
|
-
result << row[column]
|
59
|
-
end
|
60
|
-
result
|
61
|
-
end
|
62
|
-
|
63
|
-
def size
|
64
|
-
@results.size
|
65
|
-
end
|
66
|
-
|
67
|
-
def inspect
|
68
|
-
to_s
|
69
|
-
end
|
70
|
-
|
71
|
-
def to_s
|
72
|
-
"SQL ResultSet"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require "stringio"
|
2
|
-
require "json"
|
3
|
-
require "inspec/globals"
|
4
|
-
|
5
|
-
module Inspec
|
6
|
-
module Deprecation
|
7
|
-
class ConfigFile
|
8
|
-
GroupEntry = Struct.new(:name, :action, :prefix, :suffix, :exit_status)
|
9
|
-
|
10
|
-
# What actions may you specify to be taken when a deprecation is encountered?
|
11
|
-
VALID_ACTIONS = [
|
12
|
-
:exit, # Hard exit `inspec`, no stacktrace, exit code specified or Inspec::UI::EXIT_FATAL_DEPRECATION
|
13
|
-
:fail_control, # Fail the control with a message. If not in a control, do :warn action instead.
|
14
|
-
:ignore, # Do nothing.
|
15
|
-
:warn, # Issue a warning
|
16
|
-
].freeze
|
17
|
-
|
18
|
-
# Note that 'comment' is ignored, but listed here so you can have it present
|
19
|
-
# and pass validation.
|
20
|
-
VALID_GROUP_FIELDS = %w{action suffix prefix exit_status comment}.freeze
|
21
|
-
|
22
|
-
attr_reader :groups, :unknown_group_action
|
23
|
-
|
24
|
-
def initialize(io = nil)
|
25
|
-
io ||= open_default_config_io
|
26
|
-
begin
|
27
|
-
@raw_data = JSON.parse(io.read)
|
28
|
-
rescue JSON::ParserError => e
|
29
|
-
raise Inspec::Deprecation::MalformedConfigFileError, "Could not parse deprecation config file: #{e.message}"
|
30
|
-
end
|
31
|
-
|
32
|
-
@groups = {}
|
33
|
-
@unknown_group_action = :warn
|
34
|
-
validate!
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def open_default_config_io
|
40
|
-
default_path = File.join(Inspec.src_root, "etc", "deprecations.json")
|
41
|
-
unless File.exist?(default_path)
|
42
|
-
raise Inspec::Deprecation::MalformedConfigError, "Missing deprecation config file: #{default_path}"
|
43
|
-
end
|
44
|
-
|
45
|
-
File.open(default_path)
|
46
|
-
end
|
47
|
-
|
48
|
-
#====================================================================================================#
|
49
|
-
# Validation
|
50
|
-
#====================================================================================================#
|
51
|
-
def validate!
|
52
|
-
validate_file_version
|
53
|
-
validate_unknown_group_action
|
54
|
-
|
55
|
-
unless @raw_data.key?("groups")
|
56
|
-
raise Inspec::Deprecation::InvalidConfigFileError, "Missing groups field"
|
57
|
-
end
|
58
|
-
unless @raw_data["groups"].is_a?(Hash)
|
59
|
-
raise Inspec::Deprecation::InvalidConfigFileError, "Groups field must be a Hash"
|
60
|
-
end
|
61
|
-
|
62
|
-
@raw_data["groups"].each do |group_name, group_info|
|
63
|
-
validate_group_entry(group_name, group_info)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def validate_file_version
|
68
|
-
unless @raw_data.key?("file_version")
|
69
|
-
raise Inspec::Deprecation::InvalidConfigFileError, "Missing file_version field"
|
70
|
-
end
|
71
|
-
unless @raw_data["file_version"] == "1.0.0"
|
72
|
-
raise Inspec::Deprecation::InvalidConfigFileError, "Unrecognized file_version '#{@raw_data["file_version"]}' - supported versions: 1.0.0"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def validate_unknown_group_action
|
77
|
-
seen_action = (@raw_data["unknown_group_action"] || @unknown_group_action).to_sym
|
78
|
-
unless VALID_ACTIONS.include?(seen_action)
|
79
|
-
raise Inspec::Deprecation::UnrecognizedActionError, "Unrecognized value '#{seen_action}' for field 'unknown_group_action' - supported actions: #{VALID_ACTIONS.map(&:to_s).join(", ")}"
|
80
|
-
end
|
81
|
-
|
82
|
-
@unknown_group_action = seen_action
|
83
|
-
end
|
84
|
-
|
85
|
-
def validate_group_entry(name, opts)
|
86
|
-
opts.each do |seen_field, _value|
|
87
|
-
unless VALID_GROUP_FIELDS.include?(seen_field)
|
88
|
-
raise Inspec::Deprecation::InvalidConfigFileError, "Unrecognized field for group '#{name}' - saw '#{seen_field}', supported fields: #{VALID_GROUP_FIELDS.map(&:to_s).join(", ")}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
entry = GroupEntry.new(name.to_sym)
|
93
|
-
|
94
|
-
opts["action"] = (opts["action"] || :warn).to_sym
|
95
|
-
unless VALID_ACTIONS.include?(opts["action"])
|
96
|
-
raise Inspec::Deprecation::UnrecognizedActionError, "Unrecognized action for group '#{name}' - saw '#{opts["action"]}', supported actions: #{VALID_ACTIONS.map(&:to_s).join(", ")}"
|
97
|
-
end
|
98
|
-
|
99
|
-
entry.action = opts["action"]
|
100
|
-
|
101
|
-
entry.suffix = opts["suffix"]
|
102
|
-
entry.prefix = opts["prefix"]
|
103
|
-
entry.exit_status = opts["exit_status"]
|
104
|
-
|
105
|
-
groups[name.to_sym] = entry
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require "inspec/utils/deprecation/config_file"
|
2
|
-
require "inspec/log"
|
3
|
-
|
4
|
-
module Inspec
|
5
|
-
module Deprecation
|
6
|
-
class Deprecator
|
7
|
-
attr_reader :config, :groups
|
8
|
-
|
9
|
-
def initialize(opts = {})
|
10
|
-
@config = Inspec::Deprecation::ConfigFile.new(opts[:config_io])
|
11
|
-
@groups = @config.groups
|
12
|
-
end
|
13
|
-
|
14
|
-
def handle_deprecation(group_name, message, opts = {})
|
15
|
-
group = groups[group_name.to_sym] || create_group_entry_for_unknown_group(group_name)
|
16
|
-
annotate_stack_information(opts)
|
17
|
-
assembled_message = assemble_message(message, group, opts)
|
18
|
-
|
19
|
-
action = group[:action] || :warn
|
20
|
-
action_method = ("handle_" + action.to_s + "_action").to_sym
|
21
|
-
send(action_method, group_name.to_sym, assembled_message, group)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def create_group_entry_for_unknown_group(group_name)
|
27
|
-
group = ConfigFile::GroupEntry.new
|
28
|
-
group.name = group_name
|
29
|
-
group.action = config.unknown_group_action
|
30
|
-
group.suffix = "Additionally, the deprecation message is in an unknown group '#{group_name}'."
|
31
|
-
group
|
32
|
-
end
|
33
|
-
|
34
|
-
def annotate_stack_information(opts)
|
35
|
-
stack = caller_locations(1, 25)
|
36
|
-
|
37
|
-
# Attempt to give a meaningful stack location of the place
|
38
|
-
# where the deprecated functionality was used. This is likely
|
39
|
-
# user (profile) code.
|
40
|
-
used_at = nil
|
41
|
-
|
42
|
-
# If we are in a profile, call stack will first include RSpec its,
|
43
|
-
# then a single call from the profile that originated within a load_with_context.
|
44
|
-
# rspec-core surrounds these.
|
45
|
-
|
46
|
-
# First, purge the deprecation system frames
|
47
|
-
stack.reject! { |frame| frame.path && frame.path =~ %r{lib/inspec/utils/deprecation} }
|
48
|
-
# Next, purge all RSpec entries (at least rspec-core, rspec-support, rspec-its).
|
49
|
-
stack.reject! { |frame| frame.path && frame.path =~ %r{rspec-.+/lib/rspec} }
|
50
|
-
# Now look for the frame that includes load_with_context.
|
51
|
-
used_at ||= stack.detect { |frame| frame.label.include? "load_with_context" }
|
52
|
-
|
53
|
-
opts[:used_at_stack_frame] = used_at if used_at
|
54
|
-
end
|
55
|
-
|
56
|
-
def assemble_message(message, group, opts)
|
57
|
-
prefix = group.prefix || ""
|
58
|
-
suffix = group.suffix || ""
|
59
|
-
prefix += " " unless prefix.empty?
|
60
|
-
suffix = " " + suffix unless suffix.empty?
|
61
|
-
|
62
|
-
suffix += (" (used at " + opts[:used_at_stack_frame].path + ":" + opts[:used_at_stack_frame].lineno.to_s + ")") if opts.key?(:used_at_stack_frame)
|
63
|
-
|
64
|
-
"DEPRECATION: " + prefix + message + suffix
|
65
|
-
end
|
66
|
-
|
67
|
-
def called_from_control?
|
68
|
-
# Heuristics for determining if the deprecation is coming from within a control
|
69
|
-
stack = caller_locations(10, 45)
|
70
|
-
|
71
|
-
# Within a control block, that is actually an RSpec:ExampleGroup
|
72
|
-
stack.each do |frame|
|
73
|
-
return true if frame.path.end_with?("rspec/core/example_group.rb")
|
74
|
-
end
|
75
|
-
|
76
|
-
false
|
77
|
-
end
|
78
|
-
|
79
|
-
# Unused args needed for unit test deprecation harness
|
80
|
-
def handle_ignore_action(_group_name, message, _group)
|
81
|
-
handle_log_action(message, :debug)
|
82
|
-
end
|
83
|
-
|
84
|
-
def handle_log_action(message, level)
|
85
|
-
case level
|
86
|
-
when :debug
|
87
|
-
Inspec::Log.debug message
|
88
|
-
when :warn
|
89
|
-
Inspec::Log.warn message
|
90
|
-
when :error
|
91
|
-
Inspec::Log.error message
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def handle_warn_action(_group_name, message, _group)
|
96
|
-
handle_log_action(message, :warn)
|
97
|
-
end
|
98
|
-
|
99
|
-
def handle_error_action(_group_name, message, _group)
|
100
|
-
handle_log_action(message, :error)
|
101
|
-
end
|
102
|
-
|
103
|
-
def handle_fail_control_action(group_name, message, group)
|
104
|
-
if called_from_control?
|
105
|
-
raise Inspec::Exceptions::ResourceFailed, message
|
106
|
-
else
|
107
|
-
handle_warn_action(group_name, message, group)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def handle_exit_action(group_name, message, group)
|
112
|
-
handle_error_action(group_name, message, group)
|
113
|
-
status = group[:exit_status] || :fatal_deprecation
|
114
|
-
Inspec::UI.new.exit(status)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "inspec/errors"
|
2
|
-
|
3
|
-
module Inspec
|
4
|
-
module Deprecation
|
5
|
-
class Error < Inspec::Error; end
|
6
|
-
|
7
|
-
class NoSuchGroupError < Error; end
|
8
|
-
|
9
|
-
class InvalidConfigFileError < Error; end
|
10
|
-
class MalformedConfigFileError < InvalidConfigFileError; end
|
11
|
-
class UnrecognizedActionError < InvalidConfigFileError; end
|
12
|
-
class UnrecognizedOutputStreamError < InvalidConfigFileError; end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
require "inspec/utils/deprecation/deprecator"
|
2
|
-
|
3
|
-
module Inspec
|
4
|
-
def self.deprecate(group, msg = "", opts = {})
|
5
|
-
config_io = opts.delete(:config_io)
|
6
|
-
deprecator = Inspec::Deprecation::Deprecator.new(config_io: config_io)
|
7
|
-
deprecator.handle_deprecation(group, msg, opts)
|
8
|
-
end
|
9
|
-
end
|
@@ -1,190 +0,0 @@
|
|
1
|
-
require "parslet"
|
2
|
-
|
3
|
-
class ErlangParser < Parslet::Parser
|
4
|
-
root :outermost
|
5
|
-
# only designed for rabbitmq config files for now:
|
6
|
-
rule(:outermost) { filler? >> array.maybe >> dot.maybe }
|
7
|
-
|
8
|
-
rule(:exp) do
|
9
|
-
(tuple | array | binary | string | bool | identifier | float | integer) >> filler?
|
10
|
-
end
|
11
|
-
|
12
|
-
rule(:array) do
|
13
|
-
str("[") >> filler? >> (
|
14
|
-
exp.repeat(1) >>
|
15
|
-
(comma >> exp).repeat
|
16
|
-
).maybe.as(:array) >> str("]") >> filler?
|
17
|
-
end
|
18
|
-
|
19
|
-
rule(:tuple) do
|
20
|
-
str("{") >> filler? >> (
|
21
|
-
exp.repeat(1) >> filler? >>
|
22
|
-
(comma >> exp).repeat
|
23
|
-
).maybe.as(:tuple) >> str("}") >> filler?
|
24
|
-
end
|
25
|
-
|
26
|
-
rule(:filler?) { space.repeat }
|
27
|
-
rule(:space) { match('\s+') | match["\n"] | comment }
|
28
|
-
|
29
|
-
rule(:comment) { str("%") >> (match["\n\r"].absent? >> any).repeat }
|
30
|
-
rule(:comma) { str(",") >> filler? }
|
31
|
-
rule(:dot) { str(".") >> filler? }
|
32
|
-
rule(:bool) { str("true").as(:bool) | str("false").as(:bool) }
|
33
|
-
|
34
|
-
rule(:identifier) do
|
35
|
-
(match("[a-zA-Z]") >> match("[a-zA-Z0-9_]").repeat).as(:identifier) >> filler?
|
36
|
-
end
|
37
|
-
|
38
|
-
rule(:float) do
|
39
|
-
(
|
40
|
-
integer >> (
|
41
|
-
str(".") >> match("[0-9]").repeat(1) |
|
42
|
-
str("e") >> match("[0-9]").repeat(1)
|
43
|
-
).as(:e)
|
44
|
-
).as(:float) >> filler?
|
45
|
-
end
|
46
|
-
|
47
|
-
rule(:integer) do
|
48
|
-
((str("+") | str("-")).maybe >> match("[0-9]").repeat(1)).as(:integer) >> filler?
|
49
|
-
end
|
50
|
-
|
51
|
-
rule(:string) { stringS | stringD }
|
52
|
-
|
53
|
-
rule(:stringS) do
|
54
|
-
str("'") >> (
|
55
|
-
str('\\') >> any | str("'").absent? >> any
|
56
|
-
).repeat.as(:string) >> str("'") >> filler?
|
57
|
-
end
|
58
|
-
|
59
|
-
rule(:stringD) do
|
60
|
-
str('"') >> (
|
61
|
-
str('\\') >> any | str('"').absent? >> any
|
62
|
-
).repeat.as(:string) >> str('"') >> filler?
|
63
|
-
end
|
64
|
-
|
65
|
-
rule(:binary_item) do
|
66
|
-
(string | integer) >>
|
67
|
-
(str(":") >> integer).maybe.as(:size) >>
|
68
|
-
(str("/") >> identifier).maybe.as(:type) >>
|
69
|
-
filler?
|
70
|
-
end
|
71
|
-
|
72
|
-
rule(:binary) do
|
73
|
-
str("<<") >> filler? >> (
|
74
|
-
binary_item.repeat(1) >>
|
75
|
-
(comma >> binary_item).repeat
|
76
|
-
).maybe.as(:binary) >> str(">>") >> filler?
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
class ErlangBitstream
|
81
|
-
def initialize
|
82
|
-
@data = [] # a stream of 8-bit numbers
|
83
|
-
@cur_bits = "" # a string of binary bits 10010010...
|
84
|
-
end
|
85
|
-
|
86
|
-
TYPES = {
|
87
|
-
"integer" => 8,
|
88
|
-
"float" => 8 * 8,
|
89
|
-
"utf8" => 8,
|
90
|
-
"utf16" => 8 * 2,
|
91
|
-
"utf32" => 8 * 4,
|
92
|
-
}.freeze
|
93
|
-
|
94
|
-
def bit_size(size, type)
|
95
|
-
raise "Cannot specify size and type at the same time." if !type.nil? && !size.nil?
|
96
|
-
return (size || 8).to_i if type.nil?
|
97
|
-
|
98
|
-
TYPES[type] || raise("Cannot handle binary-stream type #{type}")
|
99
|
-
end
|
100
|
-
|
101
|
-
def add(i)
|
102
|
-
if i[:integer].nil? && i[:string].nil?
|
103
|
-
raise "No data provided, internal error for binary-stream processing!"
|
104
|
-
end
|
105
|
-
|
106
|
-
s = bit_size(i[:size], i[:type])
|
107
|
-
unless i[:string].nil?
|
108
|
-
str2int(i[:string].to_s, i[:type]).map { |e| add_bits(int2bits(e, 8)) }
|
109
|
-
else
|
110
|
-
add_int(i[:integer], s)
|
111
|
-
end
|
112
|
-
rescue RuntimeError => e
|
113
|
-
raise "Error processing Erlang bit string "\
|
114
|
-
"'#{i[:string] || i[:integer]}:#{i[:size]}/#{i[:type]}'. #{e.message}"
|
115
|
-
end
|
116
|
-
|
117
|
-
def str2int(s, type)
|
118
|
-
case type
|
119
|
-
when "utf8" then s.encode("utf-8").unpack("C*")
|
120
|
-
when "utf16" then s.encode("utf-16").unpack("C*").drop(2)
|
121
|
-
when "utf32" then s.encode("utf-32").unpack("C*").drop(4)
|
122
|
-
when "integer", "float" then raise "Cannot handle bit string as type #{type}"
|
123
|
-
else s.split("").map { |x| x.ord & 0xff }
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def int2bits(i, len)
|
128
|
-
format("%0#{len}b", i)
|
129
|
-
end
|
130
|
-
|
131
|
-
def add_int(v, size)
|
132
|
-
x = v.to_i & (2**size - 1) # only get the bits specified in size
|
133
|
-
add_bits(int2bits(x, size))
|
134
|
-
end
|
135
|
-
|
136
|
-
def add_bits(s)
|
137
|
-
b = (@cur_bits + s).scan(/.{1,8}/)
|
138
|
-
@data += b[0..-2].map { |x| x.to_i(2) }
|
139
|
-
@cur_bits = b.last
|
140
|
-
end
|
141
|
-
|
142
|
-
def value(encoding = "utf-8")
|
143
|
-
# fill in the rest
|
144
|
-
rest = "0" * (8 - @cur_bits.length) + @cur_bits
|
145
|
-
arr = @data + [rest.to_i(2)]
|
146
|
-
s = arr.pack("C*")
|
147
|
-
s.force_encoding(encoding) unless encoding.nil?
|
148
|
-
s
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
class ErlangTransform < Parslet::Transform
|
153
|
-
class Tuple < Array; end
|
154
|
-
class Identifier < String; end
|
155
|
-
|
156
|
-
def self.assemble_binary(seq)
|
157
|
-
b = ErlangBitstream.new
|
158
|
-
seq.each { |i| b.add(i) }
|
159
|
-
b.value
|
160
|
-
end
|
161
|
-
|
162
|
-
rule(string: simple(:x)) { x.to_s }
|
163
|
-
rule(string: []) { "" }
|
164
|
-
rule(integer: simple(:x)) { x.to_i }
|
165
|
-
rule(float: { integer: simple(:a), e: simple(:b) }) { (a + b).to_f }
|
166
|
-
rule(bool: "true") { true }
|
167
|
-
rule(bool: "false") { false }
|
168
|
-
rule(binary: subtree(:x)) { x.nil? ? "" : ErlangTransform.assemble_binary(x) }
|
169
|
-
rule(identifier: simple(:x)) { Identifier.new(x.to_s) }
|
170
|
-
rule(array: subtree(:x)) { Array(x) }
|
171
|
-
rule(tuple: subtree(:x)) do
|
172
|
-
x.nil? ? Tuple.new : Tuple.new(x)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
class ErlangConfigFile
|
177
|
-
def self.parse(content)
|
178
|
-
lex = ErlangParser.new.parse(content)
|
179
|
-
tree = ErlangTransform.new.apply(lex)
|
180
|
-
turn_to_hash(tree)
|
181
|
-
end
|
182
|
-
|
183
|
-
def self.turn_to_hash(t)
|
184
|
-
if t.is_a?(Array) && t.all? { |x| x.class == ErlangTransform::Tuple && x.length == 2 }
|
185
|
-
Hash[t.map { |i| [i[0], turn_to_hash(i[1])] }]
|
186
|
-
else
|
187
|
-
t
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|