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,96 +0,0 @@
|
|
1
|
-
# copyright:
|
2
|
-
|
3
|
-
require "inspec/utils/parser"
|
4
|
-
require "inspec/utils/file_reader"
|
5
|
-
|
6
|
-
module Inspec::Resources
|
7
|
-
class EtcFstab < Inspec.resource(1)
|
8
|
-
name "etc_fstab"
|
9
|
-
supports platform: "unix"
|
10
|
-
desc "Use the etc_fstab InSpec audit resource to check the configuration of the etc/fstab file."
|
11
|
-
example <<~EXAMPLE
|
12
|
-
nfs_systems = etc_fstab.nfs_file_systems.entries
|
13
|
-
nfs_systems.each do |file_system|
|
14
|
-
describe file_system do
|
15
|
-
its ('mount_options') { should include 'nosuid' }
|
16
|
-
its ('mount_options') { should include 'noexec' }
|
17
|
-
its ('mount_options') { should include 'sec=krb5:krb5i:krb5p }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe etc_fstab do
|
22
|
-
its ('home_mount_options') { should include 'nosuid' }
|
23
|
-
end
|
24
|
-
EXAMPLE
|
25
|
-
|
26
|
-
attr_reader :params
|
27
|
-
|
28
|
-
include CommentParser
|
29
|
-
include FileReader
|
30
|
-
|
31
|
-
def initialize(fstab_path = nil)
|
32
|
-
@conf_path = fstab_path || "/etc/fstab"
|
33
|
-
@files_contents = {}
|
34
|
-
@content = nil
|
35
|
-
@params = nil
|
36
|
-
read_content
|
37
|
-
end
|
38
|
-
|
39
|
-
filter = FilterTable.create
|
40
|
-
filter.register_column(:device_name, field: "device_name")
|
41
|
-
.register_column(:mount_point, field: "mount_point")
|
42
|
-
.register_column(:file_system_type, field: "file_system_type")
|
43
|
-
.register_column(:mount_options, field: "mount_options")
|
44
|
-
.register_column(:dump_options, field: "dump_options")
|
45
|
-
.register_column(:file_system_options, field: "file_system_options")
|
46
|
-
.register_custom_matcher(:configured?) { |x| x.entries.any? }
|
47
|
-
|
48
|
-
filter.install_filter_methods_on_resource(self, :params)
|
49
|
-
|
50
|
-
def nfs_file_systems
|
51
|
-
where { file_system_type.match(/nfs/) }
|
52
|
-
end
|
53
|
-
|
54
|
-
def home_mount_options
|
55
|
-
return nil unless where { mount_point == "/home" }.configured?
|
56
|
-
|
57
|
-
where { mount_point == "/home" }.entries[0].mount_options
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_s
|
61
|
-
"File System Table File (fstab)"
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def read_content
|
67
|
-
@content = ""
|
68
|
-
@params = {}
|
69
|
-
@content = read_file(@conf_path)
|
70
|
-
@params = parse_conf(@content)
|
71
|
-
end
|
72
|
-
|
73
|
-
def parse_conf(content)
|
74
|
-
content.map do |line|
|
75
|
-
data, = parse_comment_line(line, comment_char: "#", standalone_comments: false)
|
76
|
-
parse_line(data) unless data == ""
|
77
|
-
end.compact
|
78
|
-
end
|
79
|
-
|
80
|
-
def parse_line(line)
|
81
|
-
attributes = line.split
|
82
|
-
{
|
83
|
-
"device_name" => attributes[0],
|
84
|
-
"mount_point" => attributes[1],
|
85
|
-
"file_system_type" => attributes[2],
|
86
|
-
"mount_options" => attributes[3].split(","),
|
87
|
-
"dump_options" => attributes[4].to_i,
|
88
|
-
"file_system_options" => attributes[5].to_i,
|
89
|
-
}
|
90
|
-
end
|
91
|
-
|
92
|
-
def read_file(conf_path = @conf_path)
|
93
|
-
read_file_content(conf_path).lines
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,157 +0,0 @@
|
|
1
|
-
# copyright: 2015, Vulcano Security GmbH
|
2
|
-
|
3
|
-
# The file format consists of
|
4
|
-
# - group name
|
5
|
-
# - password - group's encrypted password
|
6
|
-
# - gid - group's decimal ID
|
7
|
-
# - member list - group members, comma seperated list
|
8
|
-
#
|
9
|
-
# Usage:
|
10
|
-
# describe etc_group do
|
11
|
-
# its('gids') { should_not contain_duplicates }
|
12
|
-
# its('groups') { should include 'my_user' }
|
13
|
-
# its('users') { should include 'my_user' }
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# describe etc_group.where(name: 'my_group') do
|
17
|
-
# its('users') { should include 'my_user' }
|
18
|
-
# end
|
19
|
-
|
20
|
-
require "inspec/utils/convert"
|
21
|
-
require "inspec/utils/parser"
|
22
|
-
require "inspec/utils/file_reader"
|
23
|
-
|
24
|
-
module Inspec::Resources
|
25
|
-
class EtcGroup < Inspec.resource(1)
|
26
|
-
include Converter
|
27
|
-
include CommentParser
|
28
|
-
|
29
|
-
name "etc_group"
|
30
|
-
supports platform: "unix"
|
31
|
-
desc "Use the etc_group InSpec audit resource to test groups that are defined on Linux and UNIX platforms. The /etc/group file stores details about each group---group name, password, group identifier, along with a comma-separate list of users that belong to the group."
|
32
|
-
example <<~EXAMPLE
|
33
|
-
describe etc_group do
|
34
|
-
its('gids') { should_not contain_duplicates }
|
35
|
-
its('groups') { should include 'my_user' }
|
36
|
-
its('users') { should include 'my_user' }
|
37
|
-
end
|
38
|
-
EXAMPLE
|
39
|
-
|
40
|
-
include FileReader
|
41
|
-
|
42
|
-
attr_accessor :gid, :entries
|
43
|
-
def initialize(path = nil)
|
44
|
-
@path = path || "/etc/group"
|
45
|
-
@entries = parse_group(@path)
|
46
|
-
end
|
47
|
-
|
48
|
-
def groups(filter = nil)
|
49
|
-
(filter || @entries)&.map { |x| x["name"] }
|
50
|
-
end
|
51
|
-
|
52
|
-
def gids(filter = nil)
|
53
|
-
(filter || @entries)&.map { |x| x["gid"] }
|
54
|
-
end
|
55
|
-
|
56
|
-
def users(filter = nil)
|
57
|
-
entries = filter || @entries
|
58
|
-
return nil if entries.nil?
|
59
|
-
|
60
|
-
# filter the user entry
|
61
|
-
res = entries.map do |x|
|
62
|
-
x["members"].split(",") if !x.nil? && !x["members"].nil?
|
63
|
-
end.flatten
|
64
|
-
# filter nil elements
|
65
|
-
res.reject { |x| x.nil? || x.empty? }
|
66
|
-
end
|
67
|
-
|
68
|
-
def where(conditions = {})
|
69
|
-
return if conditions.empty?
|
70
|
-
|
71
|
-
fields = {
|
72
|
-
name: "name",
|
73
|
-
group_name: "name",
|
74
|
-
password: "password",
|
75
|
-
gid: "gid",
|
76
|
-
group_id: "gid",
|
77
|
-
users: "members",
|
78
|
-
members: "members",
|
79
|
-
}
|
80
|
-
res = entries
|
81
|
-
|
82
|
-
unless res.nil?
|
83
|
-
conditions.each do |k, v|
|
84
|
-
idx = fields[k.to_sym]
|
85
|
-
next if idx.nil?
|
86
|
-
|
87
|
-
res = res.select { |x| x[idx].to_s == v.to_s }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
EtcGroupView.new(self, res)
|
92
|
-
end
|
93
|
-
|
94
|
-
def to_s
|
95
|
-
"/etc/group"
|
96
|
-
end
|
97
|
-
|
98
|
-
private
|
99
|
-
|
100
|
-
def parse_group(path)
|
101
|
-
@content = read_file_content(path, allow_empty: true)
|
102
|
-
|
103
|
-
# iterate over each line and filter comments
|
104
|
-
@content.split("\n").each_with_object([]) do |line, lines|
|
105
|
-
grp_info = parse_group_line(line)
|
106
|
-
lines.push(grp_info) if !grp_info.nil? && !grp_info.empty?
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def parse_group_line(line)
|
111
|
-
opts = {
|
112
|
-
comment_char: "#",
|
113
|
-
standalone_comments: false,
|
114
|
-
}
|
115
|
-
line, _idx_nl = parse_comment_line(line, opts)
|
116
|
-
x = line.split(":")
|
117
|
-
# abort if we have an empty or comment line
|
118
|
-
return nil if x.empty?
|
119
|
-
|
120
|
-
# map data
|
121
|
-
{
|
122
|
-
"name" => x.at(0), # Name of the group.
|
123
|
-
"password" => x.at(1), # Group's encrypted password.
|
124
|
-
"gid" => convert_to_i(x.at(2)), # The group's decimal ID.
|
125
|
-
"members" => x.at(3), # Group members.
|
126
|
-
}
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# object that hold a specifc view on etc group
|
131
|
-
class EtcGroupView
|
132
|
-
def initialize(parent, filter)
|
133
|
-
@parent = parent
|
134
|
-
@filter = filter
|
135
|
-
end
|
136
|
-
|
137
|
-
# returns the group object
|
138
|
-
def entries
|
139
|
-
@filter
|
140
|
-
end
|
141
|
-
|
142
|
-
# only returns group name
|
143
|
-
def groups
|
144
|
-
@parent.groups(@filter)
|
145
|
-
end
|
146
|
-
|
147
|
-
# only return gids
|
148
|
-
def gids
|
149
|
-
@parent.gids(@filter)
|
150
|
-
end
|
151
|
-
|
152
|
-
# only returns users
|
153
|
-
def users
|
154
|
-
@parent.users(@filter)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require "inspec/utils/parser"
|
2
|
-
require "inspec/utils/file_reader"
|
3
|
-
|
4
|
-
module Inspec::Resources
|
5
|
-
class EtcHosts < Inspec.resource(1)
|
6
|
-
name "etc_hosts"
|
7
|
-
supports platform: "linux"
|
8
|
-
supports platform: "bsd"
|
9
|
-
supports platform: "windows"
|
10
|
-
desc 'Use the etc_hosts InSpec audit resource to find an
|
11
|
-
ip_address and its associated hosts'
|
12
|
-
example <<~EXAMPLE
|
13
|
-
describe etc_hosts.where { ip_address == '127.0.0.1' } do
|
14
|
-
its('ip_address') { should cmp '127.0.0.1' }
|
15
|
-
its('primary_name') { should cmp 'localhost' }
|
16
|
-
its('all_host_names') { should eq [['localhost', 'localhost.localdomain', 'localhost4', 'localhost4.localdomain4']] }
|
17
|
-
end
|
18
|
-
EXAMPLE
|
19
|
-
|
20
|
-
attr_reader :params
|
21
|
-
|
22
|
-
include CommentParser
|
23
|
-
include FileReader
|
24
|
-
|
25
|
-
DEFAULT_UNIX_PATH = "/etc/hosts".freeze
|
26
|
-
DEFAULT_WINDOWS_PATH = 'C:\windows\system32\drivers\etc\hosts'.freeze
|
27
|
-
|
28
|
-
def initialize(hosts_path = nil)
|
29
|
-
content = read_file_content(hosts_path || default_hosts_file_path)
|
30
|
-
|
31
|
-
@params = parse_conf(content.lines)
|
32
|
-
end
|
33
|
-
|
34
|
-
FilterTable.create
|
35
|
-
.register_column(:ip_address, field: "ip_address")
|
36
|
-
.register_column(:primary_name, field: "primary_name")
|
37
|
-
.register_column(:all_host_names, field: "all_host_names")
|
38
|
-
.install_filter_methods_on_resource(self, :params)
|
39
|
-
|
40
|
-
def to_s
|
41
|
-
"Hosts File"
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def default_hosts_file_path
|
47
|
-
inspec.os.windows? ? DEFAULT_WINDOWS_PATH : DEFAULT_UNIX_PATH
|
48
|
-
end
|
49
|
-
|
50
|
-
def parse_conf(lines)
|
51
|
-
lines.reject(&:empty?).reject(&comment?).map(&parse_data).map(&format_data)
|
52
|
-
end
|
53
|
-
|
54
|
-
def comment?
|
55
|
-
parse_options = { comment_char: "#", standalone_comments: false }
|
56
|
-
|
57
|
-
->(data) { parse_comment_line(data, parse_options).first.empty? }
|
58
|
-
end
|
59
|
-
|
60
|
-
def parse_data
|
61
|
-
->(data) { [data.split[0], data.split[1], data.split[1..-1]] }
|
62
|
-
end
|
63
|
-
|
64
|
-
def format_data
|
65
|
-
->(data) { %w{ip_address primary_name all_host_names}.zip(data).to_h }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
require "inspec/utils/parser"
|
2
|
-
require "inspec/utils/file_reader"
|
3
|
-
|
4
|
-
module Inspec::Resources
|
5
|
-
class EtcHostsAllow < Inspec.resource(1)
|
6
|
-
name "etc_hosts_allow"
|
7
|
-
supports platform: "unix"
|
8
|
-
desc 'Use the etc_hosts_allow InSpec audit resource to test the connections
|
9
|
-
the client will allow. Controlled by the /etc/hosts.allow file.'
|
10
|
-
example <<~EXAMPLE
|
11
|
-
describe etc_hosts_allow.where { daemon == 'ALL' } do
|
12
|
-
its('client_list') { should include ['127.0.0.1', '[::1]'] }
|
13
|
-
its('options') { should eq [[]] }
|
14
|
-
end
|
15
|
-
EXAMPLE
|
16
|
-
|
17
|
-
attr_reader :params
|
18
|
-
|
19
|
-
include CommentParser
|
20
|
-
include FileReader
|
21
|
-
|
22
|
-
def initialize(hosts_allow_path = nil)
|
23
|
-
@conf_path = hosts_allow_path || "/etc/hosts.allow"
|
24
|
-
@content = nil
|
25
|
-
@params = nil
|
26
|
-
read_content
|
27
|
-
end
|
28
|
-
|
29
|
-
filter = FilterTable.create
|
30
|
-
filter.register_column(:daemon, field: "daemon")
|
31
|
-
.register_column(:client_list, field: "client_list")
|
32
|
-
.register_column(:options, field: "options")
|
33
|
-
|
34
|
-
filter.install_filter_methods_on_resource(self, :params)
|
35
|
-
|
36
|
-
def to_s
|
37
|
-
"hosts.allow Configuration"
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def read_content
|
43
|
-
@content = ""
|
44
|
-
@params = {}
|
45
|
-
@content = split_daemons(read_file(@conf_path))
|
46
|
-
@params = parse_conf(@content)
|
47
|
-
end
|
48
|
-
|
49
|
-
def split_daemons(content)
|
50
|
-
split_daemons_list = []
|
51
|
-
content.each do |line|
|
52
|
-
data, = parse_comment_line(line, comment_char: "#", standalone_comments: false)
|
53
|
-
next unless data != ""
|
54
|
-
|
55
|
-
data.split(":")[0].split(",").each do |daemon|
|
56
|
-
split_daemons_list.push("#{daemon} : " + line.split(":", 2)[1])
|
57
|
-
end
|
58
|
-
end
|
59
|
-
split_daemons_list
|
60
|
-
end
|
61
|
-
|
62
|
-
def parse_conf(content)
|
63
|
-
content.map do |line|
|
64
|
-
data, = parse_comment_line(line, comment_char: "#", standalone_comments: false)
|
65
|
-
parse_line(data) unless data == ""
|
66
|
-
end.compact
|
67
|
-
end
|
68
|
-
|
69
|
-
def parse_line(line)
|
70
|
-
daemon, clients_and_options = line.split(/:\s+/, 2)
|
71
|
-
daemon = daemon.strip
|
72
|
-
|
73
|
-
clients_and_options ||= ""
|
74
|
-
clients, options = clients_and_options.split(/\s+:\s+/, 2)
|
75
|
-
client_list = clients.split(/,/).map(&:strip)
|
76
|
-
|
77
|
-
options ||= ""
|
78
|
-
options_list = options.split(/:\s+/).map(&:strip)
|
79
|
-
|
80
|
-
{
|
81
|
-
"daemon" => daemon,
|
82
|
-
"client_list" => client_list,
|
83
|
-
"options" => options_list,
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
def read_file(conf_path = @conf_path)
|
88
|
-
read_file_content(conf_path).lines
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
class EtcHostsDeny < EtcHostsAllow
|
93
|
-
name "etc_hosts_deny"
|
94
|
-
supports platform: "unix"
|
95
|
-
desc 'Use the etc_hosts_deny InSpec audit resource to test the connections
|
96
|
-
the client will deny. Controlled by the /etc/hosts.deny file.'
|
97
|
-
example <<~EXAMPLE
|
98
|
-
describe etc_hosts_deny.where { daemon_list == 'ALL' } do
|
99
|
-
its('client_list') { should eq [['127.0.0.1', '[::1]']] }
|
100
|
-
its('options') { should eq [] }
|
101
|
-
end
|
102
|
-
EXAMPLE
|
103
|
-
|
104
|
-
def initialize(path = nil)
|
105
|
-
return skip_resource "`etc_hosts_deny` is not supported on your OS" unless inspec.os.linux?
|
106
|
-
|
107
|
-
super(path || "/etc/hosts.deny")
|
108
|
-
end
|
109
|
-
|
110
|
-
def to_s
|
111
|
-
"hosts.deny Configuration"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,339 +0,0 @@
|
|
1
|
-
# copyright: 2015, Vulcano Security GmbH
|
2
|
-
|
3
|
-
require "shellwords"
|
4
|
-
require "inspec/utils/parser"
|
5
|
-
|
6
|
-
module Inspec::Resources
|
7
|
-
module FilePermissionsSelector
|
8
|
-
def select_file_perms_style(os)
|
9
|
-
if os.unix?
|
10
|
-
UnixFilePermissions.new(inspec)
|
11
|
-
elsif os.windows?
|
12
|
-
WindowsFilePermissions.new(inspec)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# TODO: rename file_resource.rb
|
18
|
-
class FileResource < Inspec.resource(1)
|
19
|
-
include FilePermissionsSelector
|
20
|
-
include LinuxMountParser
|
21
|
-
|
22
|
-
name "file"
|
23
|
-
supports platform: "unix"
|
24
|
-
supports platform: "windows"
|
25
|
-
desc "Use the file InSpec audit resource to test all system file types, including files, directories, symbolic links, named pipes, sockets, character devices, block devices, and doors."
|
26
|
-
example <<~EXAMPLE
|
27
|
-
describe file('path') do
|
28
|
-
it { should exist }
|
29
|
-
it { should be_file }
|
30
|
-
it { should be_readable }
|
31
|
-
it { should be_writable }
|
32
|
-
it { should be_executable.by_user('root') }
|
33
|
-
it { should be_owned_by 'root' }
|
34
|
-
its('mode') { should cmp '0644' }
|
35
|
-
end
|
36
|
-
EXAMPLE
|
37
|
-
|
38
|
-
attr_reader :file, :mount_options
|
39
|
-
def initialize(path)
|
40
|
-
# select permissions style
|
41
|
-
@perms_provider = select_file_perms_style(inspec.os)
|
42
|
-
@file = inspec.backend.file(path)
|
43
|
-
end
|
44
|
-
|
45
|
-
%w{
|
46
|
-
type exist? file? block_device? character_device? socket? directory?
|
47
|
-
symlink? pipe? mode mode? owner owned_by? group grouped_into?
|
48
|
-
link_path shallow_link_path linked_to? mtime size selinux_label immutable?
|
49
|
-
product_version file_version version? md5sum sha256sum
|
50
|
-
path basename source source_path uid gid
|
51
|
-
}.each do |m|
|
52
|
-
define_method m do |*args|
|
53
|
-
file.send(m, *args)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def content
|
58
|
-
res = file.content
|
59
|
-
return nil if res.nil?
|
60
|
-
|
61
|
-
res.force_encoding("utf-8")
|
62
|
-
end
|
63
|
-
|
64
|
-
def contain(*_)
|
65
|
-
raise "Contain is not supported. Please use standard RSpec matchers."
|
66
|
-
end
|
67
|
-
|
68
|
-
def readable?(by_usergroup, by_specific_user)
|
69
|
-
return false unless exist?
|
70
|
-
return skip_resource "`readable?` is not supported on your OS yet." if @perms_provider.nil?
|
71
|
-
|
72
|
-
file_permission_granted?("read", by_usergroup, by_specific_user)
|
73
|
-
end
|
74
|
-
|
75
|
-
def writable?(by_usergroup, by_specific_user)
|
76
|
-
return false unless exist?
|
77
|
-
return skip_resource "`writable?` is not supported on your OS yet." if @perms_provider.nil?
|
78
|
-
|
79
|
-
file_permission_granted?("write", by_usergroup, by_specific_user)
|
80
|
-
end
|
81
|
-
|
82
|
-
def executable?(by_usergroup, by_specific_user)
|
83
|
-
return false unless exist?
|
84
|
-
return skip_resource "`executable?` is not supported on your OS yet." if @perms_provider.nil?
|
85
|
-
|
86
|
-
file_permission_granted?("execute", by_usergroup, by_specific_user)
|
87
|
-
end
|
88
|
-
|
89
|
-
def allowed?(permission, opts = {})
|
90
|
-
return false unless exist?
|
91
|
-
return skip_resource "`allowed?` is not supported on your OS yet." if @perms_provider.nil?
|
92
|
-
|
93
|
-
file_permission_granted?(permission, opts[:by], opts[:by_user])
|
94
|
-
end
|
95
|
-
|
96
|
-
def mounted?(expected_options = nil, identical = false)
|
97
|
-
mounted = file.mounted
|
98
|
-
|
99
|
-
# return if no additional parameters have been provided
|
100
|
-
return file.mounted? if expected_options.nil?
|
101
|
-
|
102
|
-
# deprecation warning, this functionality will be removed in future version
|
103
|
-
Inspec.deprecate(:file_resource_be_mounted_matchers, "The file resource `be_mounted.with` and `be_mounted.only_with` matchers are deprecated. Please use the `mount` resource instead")
|
104
|
-
|
105
|
-
# we cannot read mount data on non-Linux systems
|
106
|
-
return nil unless inspec.os.linux?
|
107
|
-
|
108
|
-
# parse content if we are on linux
|
109
|
-
@mount_options ||= parse_mount_options(mounted.stdout, true)
|
110
|
-
|
111
|
-
if identical
|
112
|
-
# check if the options should be identical
|
113
|
-
@mount_options == expected_options
|
114
|
-
else
|
115
|
-
# otherwise compare the selected values
|
116
|
-
@mount_options.contains(expected_options)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def suid
|
121
|
-
(mode & 04000) > 0
|
122
|
-
end
|
123
|
-
|
124
|
-
alias setuid? suid
|
125
|
-
|
126
|
-
def sgid
|
127
|
-
(mode & 02000) > 0
|
128
|
-
end
|
129
|
-
|
130
|
-
alias setgid? sgid
|
131
|
-
|
132
|
-
def sticky
|
133
|
-
(mode & 01000) > 0
|
134
|
-
end
|
135
|
-
|
136
|
-
alias sticky? sticky
|
137
|
-
|
138
|
-
def more_permissive_than?(max_mode = nil)
|
139
|
-
raise Inspec::Exceptions::ResourceFailed, "The file" + file.path + "doesn't seem to exist" unless exist?
|
140
|
-
raise ArgumentError, "You must proivde a value for the `maximum allowable permission` for the file." if max_mode.nil?
|
141
|
-
raise ArgumentError, "You must proivde the `maximum permission target` as a `String`, you provided: " + max_mode.class.to_s unless max_mode.is_a?(String)
|
142
|
-
raise ArgumentError, "The value of the `maximum permission target` should be a valid file mode in 4-ditgit octal format: for example, `0644` or `0777`" unless /(0)?([0-7])([0-7])([0-7])/.match?(max_mode)
|
143
|
-
|
144
|
-
# Using the files mode and a few bit-wise calculations we can ensure a
|
145
|
-
# file is no more permisive than desired.
|
146
|
-
#
|
147
|
-
# 1. Calculate the inverse of the desired mode (e.g., 0644) by XOR it with
|
148
|
-
# 0777 (all 1s). We are interested in the bits that are currently 0 since
|
149
|
-
# it indicates that the actual mode is more permissive than the desired mode.
|
150
|
-
# Conversely, we dont care about the bits that are currently 1 because they
|
151
|
-
# cannot be any more permissive and we can safely ignore them.
|
152
|
-
#
|
153
|
-
# 2. Calculate the above result of ANDing the actual mode and the inverse
|
154
|
-
# mode. This will determine if any of the bits that would indicate a more
|
155
|
-
# permissive mode are set in the actual mode.
|
156
|
-
#
|
157
|
-
# 3. If the result is 0000, the files mode is equal
|
158
|
-
# to or less permissive than the desired mode (PASS). Otherwise, the files
|
159
|
-
# mode is more permissive than the desired mode (FAIL).
|
160
|
-
|
161
|
-
max_mode = max_mode.to_i(8)
|
162
|
-
inv_mode = 0777 ^ max_mode
|
163
|
-
|
164
|
-
inv_mode & file.mode != 0
|
165
|
-
end
|
166
|
-
|
167
|
-
def to_s
|
168
|
-
if file
|
169
|
-
"File #{source_path}"
|
170
|
-
else
|
171
|
-
"Bad File on %s" % [inspec.backend.class]
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
private
|
176
|
-
|
177
|
-
def file_permission_granted?(access_type, by_usergroup, by_specific_user)
|
178
|
-
raise "`file_permission_granted?` is not supported on your OS" if @perms_provider.nil?
|
179
|
-
|
180
|
-
if by_specific_user.nil? || by_specific_user.empty?
|
181
|
-
@perms_provider.check_file_permission_by_mask(file, access_type, by_usergroup, by_specific_user)
|
182
|
-
else
|
183
|
-
@perms_provider.check_file_permission_by_user(access_type, by_specific_user, source_path)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
class FilePermissions
|
189
|
-
attr_reader :inspec
|
190
|
-
def initialize(inspec)
|
191
|
-
@inspec = inspec
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
class UnixFilePermissions < FilePermissions
|
196
|
-
def permission_flag(access_type)
|
197
|
-
case access_type
|
198
|
-
when "read"
|
199
|
-
"r"
|
200
|
-
when "write"
|
201
|
-
"w"
|
202
|
-
when "execute"
|
203
|
-
"x"
|
204
|
-
else
|
205
|
-
raise "Invalid access_type provided"
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
def usergroup_for(usergroup, specific_user)
|
210
|
-
if usergroup == "others"
|
211
|
-
"other"
|
212
|
-
elsif (usergroup.nil? || usergroup.empty?) && specific_user.nil?
|
213
|
-
"all"
|
214
|
-
else
|
215
|
-
usergroup
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
def check_file_permission_by_mask(file, access_type, usergroup, specific_user)
|
220
|
-
usergroup = usergroup_for(usergroup, specific_user)
|
221
|
-
flag = permission_flag(access_type)
|
222
|
-
mask = file.unix_mode_mask(usergroup, flag)
|
223
|
-
raise "Invalid usergroup/owner provided" if mask.nil?
|
224
|
-
|
225
|
-
(file.mode & mask) != 0
|
226
|
-
end
|
227
|
-
|
228
|
-
def check_file_permission_by_user(access_type, user, path)
|
229
|
-
flag = permission_flag(access_type)
|
230
|
-
if inspec.os.linux?
|
231
|
-
perm_cmd = "su -s /bin/sh -c \"test -#{flag} #{path}\" #{user}"
|
232
|
-
elsif inspec.os.bsd? || inspec.os.solaris?
|
233
|
-
perm_cmd = "sudo -u #{user} test -#{flag} #{path}"
|
234
|
-
elsif inspec.os.aix?
|
235
|
-
perm_cmd = "su #{user} -c test -#{flag} #{path}"
|
236
|
-
elsif inspec.os.hpux?
|
237
|
-
perm_cmd = "su #{user} -c \"test -#{flag} #{path}\""
|
238
|
-
else
|
239
|
-
return skip_resource "The `file` resource does not support `by_user` on your OS."
|
240
|
-
end
|
241
|
-
|
242
|
-
cmd = inspec.command(perm_cmd)
|
243
|
-
cmd.exit_status == 0 ? true : false
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
class WindowsFilePermissions < FilePermissions
|
248
|
-
def check_file_permission_by_mask(_file, _access_type, _usergroup, _specific_user)
|
249
|
-
raise "`check_file_permission_by_mask` is not supported on Windows"
|
250
|
-
end
|
251
|
-
|
252
|
-
def more_permissive_than?(*)
|
253
|
-
raise Inspec::Exceptions::ResourceSkipped, "The `more_permissive_than?` matcher is not supported on your OS yet."
|
254
|
-
end
|
255
|
-
|
256
|
-
def check_file_permission_by_user(access_type, user, path)
|
257
|
-
access_rule = translate_perm_names(access_type)
|
258
|
-
access_rule = convert_to_powershell_array(access_rule)
|
259
|
-
|
260
|
-
cmd = inspec.command("@(@((Get-Acl '#{path}').access | Where-Object {$_.AccessControlType -eq 'Allow' -and $_.IdentityReference -eq '#{user}' }) | Where-Object {($_.FileSystemRights.ToString().Split(',') | % {$_.trim()} | ? {#{access_rule} -contains $_}) -ne $null}) | measure | % { $_.Count }")
|
261
|
-
cmd.stdout.chomp == "0" ? false : true
|
262
|
-
end
|
263
|
-
|
264
|
-
private
|
265
|
-
|
266
|
-
def convert_to_powershell_array(arr)
|
267
|
-
if arr.empty?
|
268
|
-
"@()"
|
269
|
-
else
|
270
|
-
%{@('#{arr.join("', '")}')}
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
# Translates a developer-friendly string into a list of acceptable
|
275
|
-
# FileSystemRights that match it, because Windows has a fun heirarchy
|
276
|
-
# of permissions that are able to be noted in multiple ways.
|
277
|
-
#
|
278
|
-
# See also: https://www.codeproject.com/Reference/871338/AccessControl-FileSystemRights-Permissions-Table
|
279
|
-
def translate_perm_names(access_type)
|
280
|
-
names = translate_common_perms(access_type)
|
281
|
-
names ||= translate_granular_perms(access_type)
|
282
|
-
names ||= translate_uncommon_perms(access_type)
|
283
|
-
raise "Invalid access_type provided" unless names
|
284
|
-
|
285
|
-
names
|
286
|
-
end
|
287
|
-
|
288
|
-
def translate_common_perms(access_type)
|
289
|
-
case access_type
|
290
|
-
when "full-control"
|
291
|
-
%w{FullControl}
|
292
|
-
when "modify"
|
293
|
-
translate_perm_names("full-control") + %w{Modify}
|
294
|
-
when "read"
|
295
|
-
translate_perm_names("modify") + %w{ReadAndExecute Read}
|
296
|
-
when "write"
|
297
|
-
translate_perm_names("modify") + %w{Write}
|
298
|
-
when "execute"
|
299
|
-
translate_perm_names("modify") + %w{ReadAndExecute ExecuteFile Traverse}
|
300
|
-
when "delete"
|
301
|
-
translate_perm_names("modify") + %w{Delete}
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
def translate_uncommon_perms(access_type)
|
306
|
-
case access_type
|
307
|
-
when "delete-subdirectories-and-files"
|
308
|
-
translate_perm_names("full-control") + %w{DeleteSubdirectoriesAndFiles}
|
309
|
-
when "change-permissions"
|
310
|
-
translate_perm_names("full-control") + %w{ChangePermissions}
|
311
|
-
when "take-ownership"
|
312
|
-
translate_perm_names("full-control") + %w{TakeOwnership}
|
313
|
-
when "synchronize"
|
314
|
-
translate_perm_names("full-control") + %w{Synchronize}
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
def translate_granular_perms(access_type)
|
319
|
-
case access_type
|
320
|
-
when "write-data", "create-files"
|
321
|
-
translate_perm_names("write") + %w{WriteData CreateFiles}
|
322
|
-
when "append-data", "create-directories"
|
323
|
-
translate_perm_names("write") + %w{CreateDirectories AppendData}
|
324
|
-
when "write-extended-attributes"
|
325
|
-
translate_perm_names("write") + %w{WriteExtendedAttributes}
|
326
|
-
when "write-attributes"
|
327
|
-
translate_perm_names("write") + %w{WriteAttributes}
|
328
|
-
when "read-data", "list-directory"
|
329
|
-
translate_perm_names("read") + %w{ReadData ListDirectory}
|
330
|
-
when "read-attributes"
|
331
|
-
translate_perm_names("read") + %w{ReadAttributes}
|
332
|
-
when "read-extended-attributes"
|
333
|
-
translate_perm_names("read") + %w{ReadExtendedAttributes}
|
334
|
-
when "read-permissions"
|
335
|
-
translate_perm_names("read") + %w{ReadPermissions}
|
336
|
-
end
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|