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 +0,0 @@
|
|
1
|
-
require "inspec/resources/powershell"
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "inspec/resources/command"
|
4
|
-
|
5
|
-
module Inspec::Resources
|
6
|
-
class SecurityIdentifier < Inspec.resource(1)
|
7
|
-
name "security_identifier"
|
8
|
-
supports platform: "windows"
|
9
|
-
desc "Resource that returns a Security Identifier for a given entity name in Windows."
|
10
|
-
example <<~EXAMPLE
|
11
|
-
describe security_identifier(group: 'Everyone') do
|
12
|
-
it { should exist }
|
13
|
-
its('sid') { should eq 'S-1-1-0' }
|
14
|
-
end
|
15
|
-
EXAMPLE
|
16
|
-
|
17
|
-
def initialize(opts = {})
|
18
|
-
supported_opt_keys = %i{user group unspecified}
|
19
|
-
raise ArgumentError, "Invalid security_identifier param '#{opts}'. Please pass a hash with these supported keys: #{supported_opt_keys}" unless opts.respond_to?(:keys)
|
20
|
-
raise ArgumentError, "Unsupported security_identifier options '#{opts.keys - supported_opt_keys}'. Supported keys: #[supported_opt_keys]" unless (opts.keys - supported_opt_keys).empty?
|
21
|
-
raise ArgumentError, "Specifying more than one of :user :group or :unspecified for security_identifier is not supported" unless opts.keys && (opts.keys & supported_opt_keys).length == 1
|
22
|
-
|
23
|
-
if opts[:user]
|
24
|
-
@type = :user
|
25
|
-
@name = opts[:user]
|
26
|
-
end
|
27
|
-
if opts[:group]
|
28
|
-
@type = :group
|
29
|
-
@name = opts[:group]
|
30
|
-
end
|
31
|
-
if opts[:unspecified]
|
32
|
-
@type = :unspecified
|
33
|
-
@name = opts[:unspecified]
|
34
|
-
end
|
35
|
-
raise ArgumentError, "Specify one of :user :group or :unspecified for security_identifier" unless @name
|
36
|
-
|
37
|
-
@sids = nil
|
38
|
-
end
|
39
|
-
|
40
|
-
def sid
|
41
|
-
fetch_sids unless @sids
|
42
|
-
@sids[@name] # nil if not found
|
43
|
-
end
|
44
|
-
|
45
|
-
def exist?
|
46
|
-
fetch_sids unless @sids
|
47
|
-
@sids.key?(@name)
|
48
|
-
end
|
49
|
-
|
50
|
-
def to_s
|
51
|
-
"Security Identifier"
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def fetch_sids
|
57
|
-
@sids = {}
|
58
|
-
case @type
|
59
|
-
when :group
|
60
|
-
sid_data = wmi_results(:group)
|
61
|
-
when :user
|
62
|
-
sid_data = wmi_results(:user)
|
63
|
-
when :unspecified
|
64
|
-
# try group first, then user
|
65
|
-
sid_data = wmi_results(:group)
|
66
|
-
if sid_data.empty?
|
67
|
-
sid_data = wmi_results(:user)
|
68
|
-
end
|
69
|
-
else
|
70
|
-
raise "Unhandled entity type '#{@type}'"
|
71
|
-
end
|
72
|
-
sid_data.each { |sid| @sids[sid[1]] = sid[2] }
|
73
|
-
end
|
74
|
-
|
75
|
-
def wmi_results(type)
|
76
|
-
query = "wmic "
|
77
|
-
case type
|
78
|
-
when :group
|
79
|
-
query += "group"
|
80
|
-
when :user
|
81
|
-
query += "useraccount"
|
82
|
-
end
|
83
|
-
query += " where 'Name=\"#{@name}\"' get Name\",\"SID /format:csv"
|
84
|
-
# Example output:
|
85
|
-
# inspec> command("wmic useraccount where 'Name=\"Administrator\"' get Name\",\"SID /format:csv").stdout
|
86
|
-
# => "\r\n\r\nNode,Name,SID\r\n\r\nComputer1,Administrator,S-1-5-21-650485088-1194226989-968533923-500\r\n\r\n"
|
87
|
-
# Remove the \r characters, split on \n\n, ignore the CSV header row
|
88
|
-
inspec.command(query).stdout.strip.tr("\r", "").split("\n\n")[1..-1].map { |entry| entry.split(",") }
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,182 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Security Configuration and Analysis
|
3
|
-
#
|
4
|
-
# Export local security policy:
|
5
|
-
# secedit /export /cfg secpol.cfg
|
6
|
-
#
|
7
|
-
# @link http://www.microsoft.com/en-us/download/details.aspx?id=25250
|
8
|
-
#
|
9
|
-
# In Windows, some security options are managed differently that the local GPO
|
10
|
-
# All local GPO parameters can be examined via Registry, but not all security
|
11
|
-
# parameters. Therefore we need a combination of Registry and secedit output
|
12
|
-
|
13
|
-
require "hashie"
|
14
|
-
require "inspec/resources/command"
|
15
|
-
require "inspec/utils/simpleconfig"
|
16
|
-
|
17
|
-
module Inspec::Resources
|
18
|
-
# known and supported MS privilege rights
|
19
|
-
# @see https://technet.microsoft.com/en-us/library/dd277311.aspx
|
20
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/bb530716(v=vs.85).aspx
|
21
|
-
MS_PRIVILEGES_RIGHTS = [
|
22
|
-
"SeNetworkLogonRight",
|
23
|
-
"SeBackupPrivilege",
|
24
|
-
"SeChangeNotifyPrivilege",
|
25
|
-
"SeSystemtimePrivilege",
|
26
|
-
"SeCreatePagefilePrivilege",
|
27
|
-
"SeDebugPrivilege",
|
28
|
-
"SeRemoteShutdownPrivilege",
|
29
|
-
"SeAuditPrivilege",
|
30
|
-
"SeIncreaseQuotaPrivilege",
|
31
|
-
"SeIncreaseBasePriorityPrivilege",
|
32
|
-
"SeLoadDriverPrivilege",
|
33
|
-
"SeBatchLogonRight",
|
34
|
-
"SeServiceLogonRight",
|
35
|
-
"SeInteractiveLogonRight",
|
36
|
-
"SeSecurityPrivilege",
|
37
|
-
"SeSystemEnvironmentPrivilege",
|
38
|
-
"SeProfileSingleProcessPrivilege",
|
39
|
-
"SeSystemProfilePrivilege",
|
40
|
-
"SeAssignPrimaryTokenPrivilege",
|
41
|
-
"SeRestorePrivilege",
|
42
|
-
"SeShutdownPrivilege",
|
43
|
-
"SeTakeOwnershipPrivilege",
|
44
|
-
"SeUndockPrivilege",
|
45
|
-
"SeManageVolumePrivilege",
|
46
|
-
"SeRemoteInteractiveLogonRight",
|
47
|
-
"SeImpersonatePrivilege",
|
48
|
-
"SeCreateGlobalPrivilege",
|
49
|
-
"SeIncreaseWorking",
|
50
|
-
"SeTimeZonePrivilege",
|
51
|
-
"SeCreateSymbolicLinkPrivilege",
|
52
|
-
"SeDenyNetworkLogonRight", # Deny access to this computer from the network
|
53
|
-
"SeDenyInteractiveLogonRight", # Deny logon locally
|
54
|
-
"SeDenyBatchLogonRight", # Deny logon as a batch job
|
55
|
-
"SeDenyServiceLogonRight", # Deny logon as a service
|
56
|
-
"SeTcbPrivilege",
|
57
|
-
"SeMachineAccountPrivilege",
|
58
|
-
"SeCreateTokenPrivilege",
|
59
|
-
"SeCreatePermanentPrivilege",
|
60
|
-
"SeEnableDelegationPrivilege",
|
61
|
-
"SeLockMemoryPrivilege",
|
62
|
-
"SeSyncAgentPrivilege",
|
63
|
-
"SeUnsolicitedInputPrivilege",
|
64
|
-
"SeTrustedCredManAccessPrivilege",
|
65
|
-
"SeRelabelPrivilege", # the privilege to change a Windows integrity label (new to Windows Vista)
|
66
|
-
"SeDenyRemoteInteractiveLogonRight", # Deny logon through Terminal Services
|
67
|
-
].freeze
|
68
|
-
|
69
|
-
class SecurityPolicy < Inspec.resource(1)
|
70
|
-
name "security_policy"
|
71
|
-
supports platform: "windows"
|
72
|
-
desc "Use the security_policy InSpec audit resource to test security policies on the Microsoft Windows platform."
|
73
|
-
example <<~EXAMPLE
|
74
|
-
describe security_policy do
|
75
|
-
its('SeNetworkLogonRight') { should include 'S-1-5-11' }
|
76
|
-
end
|
77
|
-
|
78
|
-
describe security_policy(translate_sid: true) do
|
79
|
-
its('SeNetworkLogonRight') { should include 'NT AUTHORITY\\Authenticated Users' }
|
80
|
-
end
|
81
|
-
EXAMPLE
|
82
|
-
|
83
|
-
def initialize(opts = {})
|
84
|
-
@translate_sid = opts[:translate_sid] || false
|
85
|
-
end
|
86
|
-
|
87
|
-
def content
|
88
|
-
read_content
|
89
|
-
end
|
90
|
-
|
91
|
-
def params(*opts)
|
92
|
-
opts.inject(read_params) do |res, nxt|
|
93
|
-
res.respond_to?(:key) ? res[nxt] : nil
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def method_missing(name)
|
98
|
-
params = read_params
|
99
|
-
return nil if params.nil?
|
100
|
-
|
101
|
-
# deep search for hash key
|
102
|
-
params.extend Hashie::Extensions::DeepFind
|
103
|
-
res = params.deep_find(name.to_s)
|
104
|
-
|
105
|
-
# return an empty array if configuration does not include rights configuration
|
106
|
-
return [] if res.nil? && MS_PRIVILEGES_RIGHTS.include?(name.to_s)
|
107
|
-
|
108
|
-
res
|
109
|
-
end
|
110
|
-
|
111
|
-
def to_s
|
112
|
-
"Security Policy"
|
113
|
-
end
|
114
|
-
|
115
|
-
private
|
116
|
-
|
117
|
-
def read_content
|
118
|
-
return @content if defined?(@content)
|
119
|
-
|
120
|
-
# using process pid to prevent any race conditions with multiple runners
|
121
|
-
export_file = "win_secpol-#{Process.pid}.cfg"
|
122
|
-
|
123
|
-
# export the security policy
|
124
|
-
cmd = inspec.command("secedit /export /cfg #{export_file}")
|
125
|
-
return nil if cmd.exit_status.to_i != 0
|
126
|
-
|
127
|
-
# store file content
|
128
|
-
cmd = inspec.command("Get-Content #{export_file}")
|
129
|
-
return skip_resource "Can't read security policy" if cmd.exit_status.to_i != 0
|
130
|
-
|
131
|
-
@content = cmd.stdout
|
132
|
-
ensure
|
133
|
-
# delete temp file
|
134
|
-
inspec.command("Remove-Item #{export_file}").exit_status.to_i
|
135
|
-
end
|
136
|
-
|
137
|
-
def read_params
|
138
|
-
return @params if defined?(@params)
|
139
|
-
return @params = {} if read_content.nil?
|
140
|
-
|
141
|
-
conf = SimpleConfig.new(
|
142
|
-
@content,
|
143
|
-
assignment_regex: /^\s*(.*)=\s*(\S*)\s*$/
|
144
|
-
)
|
145
|
-
@params = convert_hash(conf.params)
|
146
|
-
end
|
147
|
-
|
148
|
-
# extracts the values, this methods detects:
|
149
|
-
# numbers and SIDs and optimizes them for further usage
|
150
|
-
def extract_value(val)
|
151
|
-
if val =~ /^\d+$/
|
152
|
-
val.to_i
|
153
|
-
# special handling for SID array
|
154
|
-
elsif val =~ /[,]{0,1}\*\S/
|
155
|
-
if @translate_sid
|
156
|
-
val.split(",").map do |v|
|
157
|
-
object_name = inspec.command("(New-Object System.Security.Principal.SecurityIdentifier(\"#{v.sub("*S", "S")}\")).Translate( [System.Security.Principal.NTAccount]).Value").stdout.to_s.strip
|
158
|
-
object_name.empty? || object_name.nil? ? v.sub("*S", "S") : object_name
|
159
|
-
end
|
160
|
-
else
|
161
|
-
val.split(",").map do |v|
|
162
|
-
v.sub("*S", "S")
|
163
|
-
end
|
164
|
-
end
|
165
|
-
# special handling for string values with "
|
166
|
-
elsif !(m = /^\"(.*)\"$/.match(val)).nil?
|
167
|
-
m[1]
|
168
|
-
else
|
169
|
-
val
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
def convert_hash(hash)
|
174
|
-
new_hash = {}
|
175
|
-
hash.each do |k, v|
|
176
|
-
v.is_a?(Hash) ? value = convert_hash(v) : value = extract_value(v)
|
177
|
-
new_hash[k.strip] = value
|
178
|
-
end
|
179
|
-
new_hash
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
@@ -1,820 +0,0 @@
|
|
1
|
-
require "hashie"
|
2
|
-
require "inspec/utils/file_reader"
|
3
|
-
require "inspec/utils/simpleconfig"
|
4
|
-
|
5
|
-
module Inspec::Resources
|
6
|
-
class Runlevels < Hash
|
7
|
-
attr_accessor :owner
|
8
|
-
|
9
|
-
def self.from_hash(owner, hash = {}, filter = nil)
|
10
|
-
res = Runlevels.new(owner)
|
11
|
-
filter = filter.first if filter.is_a?(Array) && filter.length <= 1
|
12
|
-
|
13
|
-
ks = case filter
|
14
|
-
when nil
|
15
|
-
hash.keys
|
16
|
-
when Regexp
|
17
|
-
hash.keys.find_all { |x| x.to_s =~ filter }
|
18
|
-
when Array
|
19
|
-
f = filter.map(&:to_s)
|
20
|
-
hash.keys.find_all { |x| f.include?(x.to_s) }
|
21
|
-
when Numeric
|
22
|
-
hash.keys.include?(filter) ? [filter] : []
|
23
|
-
else
|
24
|
-
hash.keys.find_all { |x| x == filter }
|
25
|
-
end
|
26
|
-
|
27
|
-
ks.each { |k| res[k] = hash[k] }
|
28
|
-
res
|
29
|
-
end
|
30
|
-
|
31
|
-
def initialize(owner, default = false)
|
32
|
-
@owner = owner
|
33
|
-
super(default)
|
34
|
-
end
|
35
|
-
|
36
|
-
def filter(f)
|
37
|
-
Runlevels.from_hash(owner, self, f)
|
38
|
-
end
|
39
|
-
|
40
|
-
# Check if all runlevels are enabled
|
41
|
-
#
|
42
|
-
# @return [boolean] true if all runlevels are enabled
|
43
|
-
def enabled?
|
44
|
-
values.all?
|
45
|
-
end
|
46
|
-
|
47
|
-
# Check if all runlevels are disabled
|
48
|
-
#
|
49
|
-
# @return [boolean] true if all runlevels are disabled
|
50
|
-
def disabled?
|
51
|
-
values.none?
|
52
|
-
end
|
53
|
-
|
54
|
-
def to_s
|
55
|
-
"#{owner} runlevels #{keys.join(", ")}"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# We detect the init system for each operating system, based on the operating
|
60
|
-
# system.
|
61
|
-
#
|
62
|
-
# Fedora 15 : systemd
|
63
|
-
# RedHat 7 : systemd
|
64
|
-
# Ubuntu 15.04 : systemd
|
65
|
-
# Ubuntu < 15.04 : upstart
|
66
|
-
#
|
67
|
-
# TODO: extend the logic to detect the running init system, independently of OS
|
68
|
-
class Service < Inspec.resource(1)
|
69
|
-
name "service"
|
70
|
-
supports platform: "unix"
|
71
|
-
supports platform: "windows"
|
72
|
-
desc "Use the service InSpec audit resource to test if the named service is installed, running and/or enabled."
|
73
|
-
example <<~EXAMPLE
|
74
|
-
describe service('service_name') do
|
75
|
-
it { should be_installed }
|
76
|
-
it { should be_enabled }
|
77
|
-
it { should be_running }
|
78
|
-
its('type') { should be 'systemd' }
|
79
|
-
its ('startmode') { should be 'Auto'}
|
80
|
-
end
|
81
|
-
|
82
|
-
describe service('service_name').runlevels(3, 5) do
|
83
|
-
it { should be_enabled }
|
84
|
-
end
|
85
|
-
|
86
|
-
describe service('service_name').params do
|
87
|
-
its('UnitFileState') { should eq 'enabled' }
|
88
|
-
end
|
89
|
-
EXAMPLE
|
90
|
-
|
91
|
-
attr_reader :service_ctl
|
92
|
-
|
93
|
-
def initialize(service_name, service_ctl = nil)
|
94
|
-
@service_name = service_name
|
95
|
-
@service_mgmt = nil
|
96
|
-
@service_ctl ||= service_ctl
|
97
|
-
@cache = nil
|
98
|
-
@service_mgmt = select_service_mgmt
|
99
|
-
|
100
|
-
return skip_resource "The `service` resource is not supported on your OS yet." if @service_mgmt.nil?
|
101
|
-
end
|
102
|
-
|
103
|
-
def select_service_mgmt # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
104
|
-
os = inspec.os
|
105
|
-
platform = os[:name]
|
106
|
-
|
107
|
-
# Ubuntu
|
108
|
-
# @see: https://wiki.ubuntu.com/SystemdForUpstartUsers
|
109
|
-
# Ubuntu 15.04 : Systemd
|
110
|
-
# Systemd runs with PID 1 as /sbin/init.
|
111
|
-
# Upstart runs with PID 1 as /sbin/upstart.
|
112
|
-
# Ubuntu < 15.04 : Upstart
|
113
|
-
# Upstart runs with PID 1 as /sbin/init.
|
114
|
-
# Systemd runs with PID 1 as /lib/systemd/systemd.
|
115
|
-
if %w{ubuntu}.include?(platform)
|
116
|
-
version = os[:release].to_f
|
117
|
-
if version < 15.04
|
118
|
-
Upstart.new(inspec, service_ctl)
|
119
|
-
else
|
120
|
-
Systemd.new(inspec, service_ctl)
|
121
|
-
end
|
122
|
-
elsif %w{linuxmint}.include?(platform)
|
123
|
-
version = os[:release].to_f
|
124
|
-
if version < 18
|
125
|
-
Upstart.new(inspec, service_ctl)
|
126
|
-
else
|
127
|
-
Systemd.new(inspec, service_ctl)
|
128
|
-
end
|
129
|
-
elsif %w{debian}.include?(platform)
|
130
|
-
if os[:release] == "buster/sid"
|
131
|
-
version = 10
|
132
|
-
else
|
133
|
-
version = os[:release].to_i
|
134
|
-
end
|
135
|
-
if version > 7
|
136
|
-
Systemd.new(inspec, service_ctl)
|
137
|
-
elsif version > 0
|
138
|
-
SysV.new(inspec, service_ctl || "/usr/sbin/service")
|
139
|
-
end
|
140
|
-
elsif %w{redhat fedora centos oracle cloudlinux}.include?(platform)
|
141
|
-
version = os[:release].to_i
|
142
|
-
if (%w{redhat centos oracle cloudlinux}.include?(platform) && version >= 7) || (platform == "fedora" && version >= 15)
|
143
|
-
Systemd.new(inspec, service_ctl)
|
144
|
-
else
|
145
|
-
SysV.new(inspec, service_ctl || "/sbin/service")
|
146
|
-
end
|
147
|
-
elsif %w{wrlinux}.include?(platform)
|
148
|
-
SysV.new(inspec, service_ctl)
|
149
|
-
elsif %w{mac_os_x}.include?(platform)
|
150
|
-
LaunchCtl.new(inspec, service_ctl)
|
151
|
-
elsif os.windows?
|
152
|
-
WindowsSrv.new(inspec)
|
153
|
-
elsif %w{freebsd}.include?(platform)
|
154
|
-
BSDInit.new(inspec, service_ctl)
|
155
|
-
elsif %w{arch}.include?(platform)
|
156
|
-
Systemd.new(inspec, service_ctl)
|
157
|
-
elsif %w{coreos}.include?(platform)
|
158
|
-
Systemd.new(inspec, service_ctl)
|
159
|
-
elsif %w{suse opensuse}.include?(platform)
|
160
|
-
if os[:release].to_i >= 12
|
161
|
-
Systemd.new(inspec, service_ctl)
|
162
|
-
else
|
163
|
-
SysV.new(inspec, service_ctl || "/sbin/service")
|
164
|
-
end
|
165
|
-
elsif %w{aix}.include?(platform)
|
166
|
-
SrcMstr.new(inspec)
|
167
|
-
elsif %w{amazon}.include?(platform)
|
168
|
-
if os[:release] =~ /^20\d\d/
|
169
|
-
Upstart.new(inspec, service_ctl)
|
170
|
-
else
|
171
|
-
Systemd.new(inspec, service_ctl)
|
172
|
-
end
|
173
|
-
elsif os.solaris?
|
174
|
-
Svcs.new(inspec)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def info
|
179
|
-
return nil if @service_mgmt.nil?
|
180
|
-
|
181
|
-
@cache ||= @service_mgmt.info(@service_name)
|
182
|
-
end
|
183
|
-
|
184
|
-
# verifies if the service is enabled
|
185
|
-
def enabled?(_level = nil)
|
186
|
-
return false if info.nil?
|
187
|
-
|
188
|
-
info[:enabled]
|
189
|
-
end
|
190
|
-
|
191
|
-
def params
|
192
|
-
return {} if info.nil?
|
193
|
-
|
194
|
-
Hashie::Mash.new(info[:params] || {})
|
195
|
-
end
|
196
|
-
|
197
|
-
# verifies the service is registered
|
198
|
-
def installed?(_name = nil, _version = nil)
|
199
|
-
return false if info.nil?
|
200
|
-
|
201
|
-
info[:installed]
|
202
|
-
end
|
203
|
-
|
204
|
-
# verifies the service is currently running
|
205
|
-
def running?(_under = nil)
|
206
|
-
return false if info.nil?
|
207
|
-
|
208
|
-
info[:running]
|
209
|
-
end
|
210
|
-
|
211
|
-
# get all runlevels that are available and their configuration
|
212
|
-
def runlevels(*args)
|
213
|
-
return Runlevels.new(self) if info.nil? || info[:runlevels].nil?
|
214
|
-
|
215
|
-
Runlevels.from_hash(self, info[:runlevels], args)
|
216
|
-
end
|
217
|
-
|
218
|
-
# returns the service type from info
|
219
|
-
def type
|
220
|
-
return nil if info.nil?
|
221
|
-
|
222
|
-
info[:type]
|
223
|
-
end
|
224
|
-
|
225
|
-
# returns the service name from info
|
226
|
-
def name
|
227
|
-
return @service_name if info.nil?
|
228
|
-
|
229
|
-
info[:name]
|
230
|
-
end
|
231
|
-
|
232
|
-
# returns the service description from info
|
233
|
-
def description
|
234
|
-
return nil if info.nil?
|
235
|
-
|
236
|
-
info[:description]
|
237
|
-
end
|
238
|
-
|
239
|
-
# returns the service start up mode from info
|
240
|
-
def startmode
|
241
|
-
return nil if info.nil?
|
242
|
-
|
243
|
-
info[:startmode]
|
244
|
-
end
|
245
|
-
|
246
|
-
# returns the service's user from info
|
247
|
-
def startname
|
248
|
-
return nil if info.nil?
|
249
|
-
|
250
|
-
info[:startname]
|
251
|
-
end
|
252
|
-
|
253
|
-
def to_s
|
254
|
-
"Service #{@service_name}"
|
255
|
-
end
|
256
|
-
|
257
|
-
private :info
|
258
|
-
end
|
259
|
-
|
260
|
-
class ServiceManager
|
261
|
-
attr_reader :inspec, :service_ctl
|
262
|
-
def initialize(inspec, service_ctl = nil)
|
263
|
-
@inspec = inspec
|
264
|
-
@service_ctl ||= service_ctl
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
# @see: http://www.freedesktop.org/software/systemd/man/systemctl.html
|
269
|
-
# @see: http://www.freedesktop.org/software/systemd/man/systemd-system.conf.html
|
270
|
-
class Systemd < ServiceManager
|
271
|
-
def initialize(inspec, service_ctl = nil)
|
272
|
-
@service_ctl = service_ctl || "systemctl"
|
273
|
-
super
|
274
|
-
end
|
275
|
-
|
276
|
-
def is_enabled?(service_name)
|
277
|
-
result = inspec.command("#{service_ctl} is-enabled #{service_name} --quiet")
|
278
|
-
return true if result.exit_status == 0
|
279
|
-
|
280
|
-
# Some systems may not have a `.service` file for a particular service
|
281
|
-
# which causes the `systemctl is-enabled` check to fail despite the
|
282
|
-
# service being enabled. In that event we fallback to `sysv_service`.
|
283
|
-
if result.stderr =~ /Failed to get.*No such file or directory/
|
284
|
-
return inspec.sysv_service(service_name).enabled?
|
285
|
-
end
|
286
|
-
|
287
|
-
false
|
288
|
-
end
|
289
|
-
|
290
|
-
def is_active?(service_name)
|
291
|
-
inspec.command("#{service_ctl} is-active #{service_name} --quiet").exit_status == 0
|
292
|
-
end
|
293
|
-
|
294
|
-
def info(service_name)
|
295
|
-
cmd = inspec.command("#{service_ctl} show --no-pager --all #{service_name}")
|
296
|
-
return nil if cmd.exit_status.to_i != 0
|
297
|
-
|
298
|
-
# parse data
|
299
|
-
params = SimpleConfig.new(
|
300
|
-
cmd.stdout.chomp,
|
301
|
-
assignment_regex: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/,
|
302
|
-
multiple_values: false
|
303
|
-
).params
|
304
|
-
|
305
|
-
# LoadState values eg. loaded, not-found
|
306
|
-
installed = params["LoadState"] == "loaded"
|
307
|
-
startname = params["User"]
|
308
|
-
|
309
|
-
{
|
310
|
-
name: params["Id"],
|
311
|
-
description: params["Description"],
|
312
|
-
startname: startname,
|
313
|
-
installed: installed,
|
314
|
-
running: is_active?(service_name),
|
315
|
-
enabled: is_enabled?(service_name),
|
316
|
-
type: "systemd",
|
317
|
-
params: params,
|
318
|
-
}
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
# AIX services
|
323
|
-
class SrcMstr < ServiceManager
|
324
|
-
attr_reader :name
|
325
|
-
|
326
|
-
def info(service_name)
|
327
|
-
@name = service_name
|
328
|
-
running = status?
|
329
|
-
return nil if running.nil?
|
330
|
-
|
331
|
-
{
|
332
|
-
name: service_name,
|
333
|
-
description: nil,
|
334
|
-
installed: true,
|
335
|
-
running: running,
|
336
|
-
enabled: enabled?,
|
337
|
-
type: "srcmstr",
|
338
|
-
}
|
339
|
-
end
|
340
|
-
|
341
|
-
private
|
342
|
-
|
343
|
-
def status?
|
344
|
-
status_cmd = inspec.command("lssrc -s #{@name}")
|
345
|
-
return nil if status_cmd.exit_status.to_i != 0
|
346
|
-
|
347
|
-
status_cmd.stdout.split(/\n/).last.chomp =~ /active$/ ? true : false
|
348
|
-
end
|
349
|
-
|
350
|
-
def enabled?
|
351
|
-
enabled_rc_tcpip? || enabled_inittab?
|
352
|
-
end
|
353
|
-
|
354
|
-
def enabled_rc_tcpip?
|
355
|
-
inspec.command(
|
356
|
-
"grep -v ^# /etc/rc.tcpip | grep 'start ' | grep -Eq '(/{0,1}| )#{name} '"
|
357
|
-
).exit_status == 0
|
358
|
-
end
|
359
|
-
|
360
|
-
def enabled_inittab?
|
361
|
-
inspec.command("lsitab #{name}").exit_status == 0
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
# @see: http://upstart.ubuntu.com
|
366
|
-
class Upstart < ServiceManager
|
367
|
-
include FileReader
|
368
|
-
|
369
|
-
def initialize(service_name, service_ctl = nil)
|
370
|
-
@service_ctl = service_ctl || "initctl"
|
371
|
-
super
|
372
|
-
end
|
373
|
-
|
374
|
-
def info(service_name)
|
375
|
-
# get the status of upstart service
|
376
|
-
status = inspec.command("#{service_ctl} status #{service_name}")
|
377
|
-
|
378
|
-
# fallback for systemv services, those are not handled via `initctl`
|
379
|
-
return SysV.new(inspec).info(service_name) if status.exit_status.to_i != 0 || status.stdout == ""
|
380
|
-
|
381
|
-
# @see: http://upstart.ubuntu.com/cookbook/#job-states
|
382
|
-
# grep for running to indicate the service is there
|
383
|
-
running = !status.stdout[%r{start/running}].nil?
|
384
|
-
enabled = info_enabled(service_name)
|
385
|
-
|
386
|
-
{
|
387
|
-
name: service_name,
|
388
|
-
description: nil,
|
389
|
-
installed: true,
|
390
|
-
running: running,
|
391
|
-
enabled: enabled,
|
392
|
-
type: "upstart",
|
393
|
-
}
|
394
|
-
end
|
395
|
-
|
396
|
-
private
|
397
|
-
|
398
|
-
def info_enabled(service_name)
|
399
|
-
# check if a service is enabled
|
400
|
-
config = read_file_content("/etc/init/#{service_name}.conf", allow_empty: true)
|
401
|
-
|
402
|
-
!config.match(/^\s*start on/).nil?
|
403
|
-
end
|
404
|
-
|
405
|
-
def version
|
406
|
-
@version ||= begin
|
407
|
-
out = inspec.command("#{service_ctl} --version").stdout
|
408
|
-
Gem::Version.new(out[/\(upstart ([^\)]+)\)/, 1])
|
409
|
-
end
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
class SysV < ServiceManager
|
414
|
-
RUNLEVELS = { 0 => false, 1 => false, 2 => false, 3 => false, 4 => false, 5 => false, 6 => false }.freeze
|
415
|
-
|
416
|
-
def initialize(service_name, service_ctl = nil)
|
417
|
-
@service_ctl = service_ctl || "service"
|
418
|
-
super
|
419
|
-
end
|
420
|
-
|
421
|
-
def info(service_name)
|
422
|
-
# check if service is installed
|
423
|
-
# read all available services via ls /etc/init.d/
|
424
|
-
srvlist = inspec.command("ls -1 /etc/init.d/")
|
425
|
-
return nil if srvlist.exit_status != 0
|
426
|
-
|
427
|
-
# check if the service is in list
|
428
|
-
service = srvlist.stdout.split("\n").select { |srv| srv == service_name }
|
429
|
-
|
430
|
-
# abort if we could not find any service
|
431
|
-
return nil if service.empty?
|
432
|
-
|
433
|
-
# read all enabled services from runlevel
|
434
|
-
# on rhel via: 'chkconfig --list', is not installed by default
|
435
|
-
# bash: for i in `find /etc/rc*.d -name S*`; do basename $i | sed -r 's/^S[0-9]+//'; done | sort | uniq
|
436
|
-
enabled_services_cmd = inspec.command('find /etc/rc*.d /etc/init.d/rc*.d -name "S*"').stdout
|
437
|
-
service_line = %r{rc(?<runlevel>[0-6])\.d/S[^/]*?#{Regexp.escape service_name}$}
|
438
|
-
all_services = enabled_services_cmd.split("\n").map do |line|
|
439
|
-
service_line.match(line)
|
440
|
-
end.compact
|
441
|
-
enabled = !all_services.empty?
|
442
|
-
|
443
|
-
# Determine a list of runlevels which this service is activated for
|
444
|
-
runlevels = RUNLEVELS.dup
|
445
|
-
all_services.each { |x| runlevels[x[:runlevel].to_i] = true }
|
446
|
-
|
447
|
-
# check if service is really running
|
448
|
-
# service throws an exit code if the service is not installed or
|
449
|
-
# not enabled
|
450
|
-
|
451
|
-
cmd = inspec.command("#{service_ctl} #{service_name} status")
|
452
|
-
running = cmd.exit_status == 0
|
453
|
-
{
|
454
|
-
name: service_name,
|
455
|
-
description: nil,
|
456
|
-
installed: true,
|
457
|
-
running: running,
|
458
|
-
enabled: enabled,
|
459
|
-
runlevels: runlevels,
|
460
|
-
type: "sysv",
|
461
|
-
}
|
462
|
-
end
|
463
|
-
end
|
464
|
-
|
465
|
-
# @see: https://www.freebsd.org/doc/en/articles/linux-users/startup.html
|
466
|
-
# @see: https://www.freebsd.org/cgi/man.cgi?query=rc.conf&sektion=5
|
467
|
-
class BSDInit < ServiceManager
|
468
|
-
def initialize(service_name, service_ctl = nil)
|
469
|
-
@service_ctl = service_ctl || "service"
|
470
|
-
super
|
471
|
-
end
|
472
|
-
|
473
|
-
def info(service_name)
|
474
|
-
# check if service is enabled
|
475
|
-
# services are enabled in /etc/rc.conf and /etc/defaults/rc.conf
|
476
|
-
# via #{service_name}_enable="YES"
|
477
|
-
# service SERVICE status returns the following result if not activated:
|
478
|
-
# Cannot 'status' sshd. Set sshd_enable to YES in /etc/rc.conf or use 'onestatus' instead of 'status'.
|
479
|
-
# gather all enabled services
|
480
|
-
cmd = inspec.command("#{service_ctl} -e")
|
481
|
-
return nil if cmd.exit_status != 0
|
482
|
-
|
483
|
-
# search for the service
|
484
|
-
srv = /(^.*#{service_name}$)/.match(cmd.stdout)
|
485
|
-
return nil if srv.nil? || srv[0].nil?
|
486
|
-
|
487
|
-
enabled = true
|
488
|
-
|
489
|
-
# check if the service is running
|
490
|
-
# if the service is not available or not running, we always get an error code
|
491
|
-
cmd = inspec.command("#{service_ctl} #{service_name} onestatus")
|
492
|
-
running = cmd.exit_status == 0
|
493
|
-
|
494
|
-
{
|
495
|
-
name: service_name,
|
496
|
-
description: nil,
|
497
|
-
installed: true,
|
498
|
-
running: running,
|
499
|
-
enabled: enabled,
|
500
|
-
type: "bsd-init",
|
501
|
-
}
|
502
|
-
end
|
503
|
-
end
|
504
|
-
|
505
|
-
class Runit < ServiceManager
|
506
|
-
def initialize(service_name, service_ctl = nil)
|
507
|
-
@service_ctl = service_ctl || "sv"
|
508
|
-
super
|
509
|
-
end
|
510
|
-
|
511
|
-
# rubocop:disable Style/DoubleNegation
|
512
|
-
def info(service_name)
|
513
|
-
# get the status of runit service
|
514
|
-
cmd = inspec.command("#{service_ctl} status #{service_name}")
|
515
|
-
# return nil unless cmd.exit_status == 0 # NOTE(sr) why do we do this?
|
516
|
-
|
517
|
-
installed = cmd.exit_status == 0
|
518
|
-
running = installed && !!(cmd.stdout =~ /^run:/)
|
519
|
-
enabled = installed && (running || !!(cmd.stdout =~ /normally up/) || !!(cmd.stdout =~ /want up/))
|
520
|
-
|
521
|
-
{
|
522
|
-
name: service_name,
|
523
|
-
description: nil,
|
524
|
-
installed: installed,
|
525
|
-
running: running,
|
526
|
-
enabled: enabled,
|
527
|
-
type: "runit",
|
528
|
-
}
|
529
|
-
end
|
530
|
-
end
|
531
|
-
|
532
|
-
# MacOS / Darwin
|
533
|
-
# new launctl on macos 10.10
|
534
|
-
class LaunchCtl < ServiceManager
|
535
|
-
def initialize(service_name, service_ctl = nil)
|
536
|
-
@service_ctl = service_ctl || "launchctl"
|
537
|
-
super
|
538
|
-
end
|
539
|
-
|
540
|
-
def info(service_name)
|
541
|
-
# get the status of upstart service
|
542
|
-
cmd = inspec.command("#{service_ctl} list")
|
543
|
-
return nil if cmd.exit_status != 0
|
544
|
-
|
545
|
-
# search for the service
|
546
|
-
srv = /(^.*#{service_name}.*)/.match(cmd.stdout)
|
547
|
-
return nil if srv.nil? || srv[0].nil?
|
548
|
-
|
549
|
-
# extract values from service
|
550
|
-
parsed_srv = /^(?<pid>[0-9-]+)\t(?<exit>[0-9]+)\t(?<name>\S*)$/.match(srv[0])
|
551
|
-
enabled = !parsed_srv["name"].nil? # it's in the list
|
552
|
-
|
553
|
-
# check if the service is running
|
554
|
-
pid = parsed_srv["pid"]
|
555
|
-
running = pid != "-"
|
556
|
-
|
557
|
-
# extract service label
|
558
|
-
srv = parsed_srv["name"] || service_name
|
559
|
-
|
560
|
-
{
|
561
|
-
name: srv,
|
562
|
-
description: nil,
|
563
|
-
installed: true,
|
564
|
-
running: running,
|
565
|
-
enabled: enabled,
|
566
|
-
type: "darwin",
|
567
|
-
}
|
568
|
-
end
|
569
|
-
end
|
570
|
-
|
571
|
-
# Determine the service state from Windows
|
572
|
-
# Uses Powershell to retrieve the information
|
573
|
-
class WindowsSrv < ServiceManager
|
574
|
-
# Determine service details
|
575
|
-
# PS: Get-Service -Name 'dhcp'| Select-Object -Property Name, DisplayName, Status | ConvertTo-Json
|
576
|
-
# {
|
577
|
-
# "Name": "dhcp",
|
578
|
-
# "DisplayName": "DHCP Client",
|
579
|
-
# "Status": 4
|
580
|
-
# }
|
581
|
-
#
|
582
|
-
# Until StartMode is not added to Get-Service, we need to do a workaround
|
583
|
-
# @see: https://connect.microsoft.com/PowerShell/feedback/details/424948/i-would-like-to-see-the-property-starttype-added-to-get-services
|
584
|
-
# Also see: https://msdn.microsoft.com/en-us/library/aa384896(v=vs.85).aspx
|
585
|
-
# Use the following powershell to determine the start mode
|
586
|
-
# PS: Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq $name -or $_.DisplayName -eq $name} | Select-Object -Prop
|
587
|
-
# erty Name, StartMode, State, Status, StartName | ConvertTo-Json
|
588
|
-
# {
|
589
|
-
# "Name": "Dhcp",
|
590
|
-
# "StartMode": "Auto",
|
591
|
-
# "State": "Running",
|
592
|
-
# "Status": "OK",
|
593
|
-
# "StartName": "LocalSystem"
|
594
|
-
# }
|
595
|
-
#
|
596
|
-
# Windows Services have the following status code:
|
597
|
-
# @see: https://msdn.microsoft.com/en-us/library/windows/desktop/ms685996(v=vs.85).aspx
|
598
|
-
# - 1: Stopped
|
599
|
-
# - 2: Starting
|
600
|
-
# - 3: Stopping
|
601
|
-
# - 4: Running
|
602
|
-
# - 5: Continue Pending
|
603
|
-
# - 6: Pause Pending
|
604
|
-
# - 7: Paused
|
605
|
-
def info(service_name)
|
606
|
-
cmd = inspec.command("New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Service -Value (Get-Service -Name '#{service_name}'| Select-Object -Property Name, DisplayName, Status) -PassThru | Add-Member -MemberType NoteProperty -Name WMI -Value (Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq '#{service_name}' -or $_.DisplayName -eq '#{service_name}'} | Select-Object -Property StartMode, StartName) -PassThru | ConvertTo-Json")
|
607
|
-
|
608
|
-
# cannot rely on exit code for now, successful command returns exit code 1
|
609
|
-
# return nil if cmd.exit_status != 0
|
610
|
-
# try to parse json
|
611
|
-
begin
|
612
|
-
service = JSON.parse(cmd.stdout)
|
613
|
-
rescue JSON::ParserError => _e
|
614
|
-
return nil
|
615
|
-
end
|
616
|
-
|
617
|
-
# check that we got a response
|
618
|
-
return nil if service.nil? || service["Service"].nil?
|
619
|
-
|
620
|
-
{
|
621
|
-
name: service["Service"]["Name"],
|
622
|
-
description: service["Service"]["DisplayName"],
|
623
|
-
installed: true,
|
624
|
-
running: service_running?(service),
|
625
|
-
enabled: service_enabled?(service),
|
626
|
-
startmode: service["WMI"]["StartMode"],
|
627
|
-
startname: service["WMI"]["StartName"],
|
628
|
-
type: "windows",
|
629
|
-
}
|
630
|
-
end
|
631
|
-
|
632
|
-
private
|
633
|
-
|
634
|
-
# detect if service is enabled
|
635
|
-
def service_enabled?(service)
|
636
|
-
!service["WMI"].nil? &&
|
637
|
-
!service["WMI"]["StartMode"].nil? &&
|
638
|
-
(service["WMI"]["StartMode"] == "Auto" ||
|
639
|
-
service["WMI"]["StartMode"] == "Manual")
|
640
|
-
end
|
641
|
-
|
642
|
-
# detect if service is running
|
643
|
-
def service_running?(service)
|
644
|
-
!service["Service"]["Status"].nil? && service["Service"]["Status"] == 4
|
645
|
-
end
|
646
|
-
end
|
647
|
-
|
648
|
-
# Solaris services
|
649
|
-
class Svcs < ServiceManager
|
650
|
-
def initialize(service_name, service_ctl = nil)
|
651
|
-
@service_ctl = service_ctl || "svcs"
|
652
|
-
super
|
653
|
-
end
|
654
|
-
|
655
|
-
def info(service_name)
|
656
|
-
# get the status of runit service
|
657
|
-
cmd = inspec.command("#{service_ctl} -l #{service_name}")
|
658
|
-
return nil if cmd.exit_status != 0
|
659
|
-
|
660
|
-
params = SimpleConfig.new(
|
661
|
-
cmd.stdout.chomp,
|
662
|
-
assignment_regex: /^(\w+)\s*(.*)$/,
|
663
|
-
multiple_values: false
|
664
|
-
).params
|
665
|
-
|
666
|
-
installed = cmd.exit_status == 0
|
667
|
-
running = installed && (params["state"] == "online")
|
668
|
-
enabled = installed && (params["enabled"] == "true")
|
669
|
-
|
670
|
-
{
|
671
|
-
name: service_name,
|
672
|
-
description: params["name"],
|
673
|
-
installed: installed,
|
674
|
-
running: running,
|
675
|
-
enabled: enabled,
|
676
|
-
type: "svcs",
|
677
|
-
}
|
678
|
-
end
|
679
|
-
end
|
680
|
-
|
681
|
-
# specific resources for specific service managers
|
682
|
-
|
683
|
-
class SystemdService < Service
|
684
|
-
name "systemd_service"
|
685
|
-
supports platform: "unix"
|
686
|
-
desc "Use the systemd_service InSpec audit resource to test if the named service (controlled by systemd) is installed, running and/or enabled."
|
687
|
-
example <<~EXAMPLE
|
688
|
-
# to override service mgmt auto-detection
|
689
|
-
describe systemd_service('service_name') do
|
690
|
-
it { should be_installed }
|
691
|
-
it { should be_enabled }
|
692
|
-
it { should be_running }
|
693
|
-
end
|
694
|
-
|
695
|
-
# to set a non-standard systemctl path
|
696
|
-
describe systemd_service('service_name', '/path/to/systemctl') do
|
697
|
-
it { should be_running }
|
698
|
-
end
|
699
|
-
EXAMPLE
|
700
|
-
|
701
|
-
def select_service_mgmt
|
702
|
-
Systemd.new(inspec, service_ctl)
|
703
|
-
end
|
704
|
-
end
|
705
|
-
|
706
|
-
class UpstartService < Service
|
707
|
-
name "upstart_service"
|
708
|
-
supports platform: "unix"
|
709
|
-
desc "Use the upstart_service InSpec audit resource to test if the named service (controlled by upstart) is installed, running and/or enabled."
|
710
|
-
example <<~EXAMPLE
|
711
|
-
# to override service mgmt auto-detection
|
712
|
-
describe upstart_service('service_name') do
|
713
|
-
it { should be_installed }
|
714
|
-
it { should be_enabled }
|
715
|
-
it { should be_running }
|
716
|
-
end
|
717
|
-
|
718
|
-
# to set a non-standard initctl path
|
719
|
-
describe upstart_service('service_name', '/path/to/initctl') do
|
720
|
-
it { should be_running }
|
721
|
-
end
|
722
|
-
EXAMPLE
|
723
|
-
|
724
|
-
def select_service_mgmt
|
725
|
-
Upstart.new(inspec, service_ctl)
|
726
|
-
end
|
727
|
-
end
|
728
|
-
|
729
|
-
class SysVService < Service
|
730
|
-
name "sysv_service"
|
731
|
-
supports platform: "unix"
|
732
|
-
desc "Use the sysv_service InSpec audit resource to test if the named service (controlled by SysV) is installed, running and/or enabled."
|
733
|
-
example <<~EXAMPLE
|
734
|
-
# to override service mgmt auto-detection
|
735
|
-
describe sysv_service('service_name') do
|
736
|
-
it { should be_installed }
|
737
|
-
it { should be_enabled }
|
738
|
-
it { should be_running }
|
739
|
-
end
|
740
|
-
|
741
|
-
# to set a non-standard service path
|
742
|
-
describe sysv_service('service_name', '/path/to/service') do
|
743
|
-
it { should be_running }
|
744
|
-
end
|
745
|
-
EXAMPLE
|
746
|
-
|
747
|
-
def select_service_mgmt
|
748
|
-
SysV.new(inspec, service_ctl)
|
749
|
-
end
|
750
|
-
end
|
751
|
-
|
752
|
-
class BSDService < Service
|
753
|
-
name "bsd_service"
|
754
|
-
supports platform: "unix"
|
755
|
-
desc "Use the bsd_service InSpec audit resource to test if the named service (controlled by BSD init) is installed, running and/or enabled."
|
756
|
-
example <<~EXAMPLE
|
757
|
-
# to override service mgmt auto-detection
|
758
|
-
describe bsd_service('service_name') do
|
759
|
-
it { should be_installed }
|
760
|
-
it { should be_enabled }
|
761
|
-
it { should be_running }
|
762
|
-
end
|
763
|
-
|
764
|
-
# to set a non-standard service path
|
765
|
-
describe bsd_service('service_name', '/path/to/service') do
|
766
|
-
it { should be_running }
|
767
|
-
end
|
768
|
-
EXAMPLE
|
769
|
-
|
770
|
-
def select_service_mgmt
|
771
|
-
BSDInit.new(inspec, service_ctl)
|
772
|
-
end
|
773
|
-
end
|
774
|
-
|
775
|
-
class LaunchdService < Service
|
776
|
-
name "launchd_service"
|
777
|
-
supports platform: "unix"
|
778
|
-
desc "Use the launchd_service InSpec audit resource to test if the named service (controlled by launchd) is installed, running and/or enabled."
|
779
|
-
example <<~EXAMPLE
|
780
|
-
# to override service mgmt auto-detection
|
781
|
-
describe launchd_service('service_name') do
|
782
|
-
it { should be_installed }
|
783
|
-
it { should be_enabled }
|
784
|
-
it { should be_running }
|
785
|
-
end
|
786
|
-
|
787
|
-
# to set a non-standard launchctl path
|
788
|
-
describe launchd_service('service_name', '/path/to/launchctl') do
|
789
|
-
it { should be_running }
|
790
|
-
end
|
791
|
-
EXAMPLE
|
792
|
-
|
793
|
-
def select_service_mgmt
|
794
|
-
LaunchCtl.new(inspec, service_ctl)
|
795
|
-
end
|
796
|
-
end
|
797
|
-
|
798
|
-
class RunitService < Service
|
799
|
-
name "runit_service"
|
800
|
-
supports platform: "unix"
|
801
|
-
desc "Use the runit_service InSpec audit resource to test if the named service (controlled by runit) is installed, running and/or enabled."
|
802
|
-
example <<~EXAMPLE
|
803
|
-
# to override service mgmt auto-detection
|
804
|
-
describe runit_service('service_name') do
|
805
|
-
it { should be_installed }
|
806
|
-
it { should be_enabled }
|
807
|
-
it { should be_running }
|
808
|
-
end
|
809
|
-
|
810
|
-
# to set a non-standard sv path
|
811
|
-
describe runit_service('service_name', '/path/to/sv') do
|
812
|
-
it { should be_running }
|
813
|
-
end
|
814
|
-
EXAMPLE
|
815
|
-
|
816
|
-
def select_service_mgmt
|
817
|
-
Runit.new(inspec, service_ctl)
|
818
|
-
end
|
819
|
-
end
|
820
|
-
end
|