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,125 +0,0 @@
|
|
1
|
-
require "inspec/resources/file"
|
2
|
-
|
3
|
-
# Usage:
|
4
|
-
# describe bridge('br0') do
|
5
|
-
# it { should exist }
|
6
|
-
# it { should have_interface 'eth0' }
|
7
|
-
# end
|
8
|
-
|
9
|
-
module Inspec::Resources
|
10
|
-
class Bridge < Inspec.resource(1)
|
11
|
-
name "bridge"
|
12
|
-
supports platform: "unix"
|
13
|
-
desc "Use the bridge InSpec audit resource to test basic network bridge properties, such as name, if an interface is defined, and the associations for any defined interface."
|
14
|
-
example <<~EXAMPLE
|
15
|
-
describe bridge 'br0' do
|
16
|
-
it { should exist }
|
17
|
-
it { should have_interface 'eth0' }
|
18
|
-
end
|
19
|
-
EXAMPLE
|
20
|
-
|
21
|
-
def initialize(bridge_name)
|
22
|
-
@bridge_name = bridge_name
|
23
|
-
|
24
|
-
@bridge_provider = nil
|
25
|
-
if inspec.os.linux?
|
26
|
-
@bridge_provider = LinuxBridge.new(inspec)
|
27
|
-
elsif inspec.os.windows?
|
28
|
-
@bridge_provider = WindowsBridge.new(inspec)
|
29
|
-
else
|
30
|
-
return skip_resource "The `bridge` resource is not supported on your OS yet."
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def exists?
|
35
|
-
!bridge_info.nil? && !bridge_info[:name].nil?
|
36
|
-
end
|
37
|
-
|
38
|
-
def has_interface?(interface)
|
39
|
-
return skip_resource "The `bridge` resource does not provide interface detection for Windows yet" if inspec.os.windows?
|
40
|
-
|
41
|
-
bridge_info.nil? ? false : bridge_info[:interfaces].include?(interface)
|
42
|
-
end
|
43
|
-
|
44
|
-
def interfaces
|
45
|
-
bridge_info.nil? ? nil : bridge_info[:interfaces]
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_s
|
49
|
-
"Bridge #{@bridge_name}"
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def bridge_info
|
55
|
-
return @cache if defined?(@cache)
|
56
|
-
|
57
|
-
@cache = @bridge_provider.bridge_info(@bridge_name) unless @bridge_provider.nil?
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
class BridgeDetection
|
62
|
-
attr_reader :inspec
|
63
|
-
def initialize(inspec)
|
64
|
-
@inspec = inspec
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Linux Bridge
|
69
|
-
# If /sys/class/net/{interface}/bridge exists then it must be a bridge
|
70
|
-
# /sys/class/net/{interface}/brif contains the network interfaces
|
71
|
-
# @see http://www.tldp.org/HOWTO/BRIDGE-STP-HOWTO/set-up-the-bridge.html
|
72
|
-
# @see http://unix.stackexchange.com/questions/40560/how-to-know-if-a-network-interface-is-tap-tun-bridge-or-physical
|
73
|
-
class LinuxBridge < BridgeDetection
|
74
|
-
def bridge_info(bridge_name)
|
75
|
-
# read bridge information
|
76
|
-
bridge = inspec.file("/sys/class/net/#{bridge_name}/bridge").directory?
|
77
|
-
return nil unless bridge
|
78
|
-
|
79
|
-
# load interface names
|
80
|
-
interfaces = inspec.command("ls -1 /sys/class/net/#{bridge_name}/brif/")
|
81
|
-
interfaces = interfaces.stdout.chomp.split("\n")
|
82
|
-
{
|
83
|
-
name: bridge_name,
|
84
|
-
interfaces: interfaces,
|
85
|
-
}
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# Windows Bridge
|
90
|
-
# select netadapter by adapter binding for windows
|
91
|
-
# Get-NetAdapterBinding -ComponentID ms_bridge | Get-NetAdapter
|
92
|
-
# @see https://technet.microsoft.com/en-us/library/jj130921(v=wps.630).aspx
|
93
|
-
# RegKeys: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
|
94
|
-
class WindowsBridge < BridgeDetection
|
95
|
-
def bridge_info(bridge_name)
|
96
|
-
# find all bridge adapters
|
97
|
-
cmd = inspec.command("Get-NetAdapterBinding -ComponentID ms_bridge | Get-NetAdapter | Select-Object -Property Name, InterfaceDescription | ConvertTo-Json")
|
98
|
-
|
99
|
-
# filter network interface
|
100
|
-
begin
|
101
|
-
bridges = JSON.parse(cmd.stdout)
|
102
|
-
rescue JSON::ParserError => _e
|
103
|
-
return nil
|
104
|
-
end
|
105
|
-
|
106
|
-
# ensure we have an array of groups
|
107
|
-
bridges = [bridges] unless bridges.is_a?(Array)
|
108
|
-
|
109
|
-
# select the requested interface
|
110
|
-
bridges = bridges.each_with_object([]) do |adapter, adapter_collection|
|
111
|
-
# map object
|
112
|
-
info = {
|
113
|
-
name: adapter["Name"],
|
114
|
-
interfaces: nil,
|
115
|
-
}
|
116
|
-
adapter_collection.push(info) if info[:name].casecmp(bridge_name) == 0
|
117
|
-
end
|
118
|
-
|
119
|
-
return nil if bridges.empty?
|
120
|
-
|
121
|
-
warn "[Possible Error] detected multiple bridges interfaces with the name #{bridge_name}" if bridges.size > 1
|
122
|
-
bridges[0]
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "inspec/resources/command"
|
4
|
-
require "inspec/resources/powershell"
|
5
|
-
|
6
|
-
# Check for Chocolatey packages to be installed
|
7
|
-
module Inspec::Resources
|
8
|
-
class ChocoPkg < Inspec.resource(1)
|
9
|
-
name "chocolatey_package"
|
10
|
-
supports platform: "windows"
|
11
|
-
desc "Use the chocolatey_package InSpec audit resource to test if the named package and/or package version is installed on the system."
|
12
|
-
example <<~EXAMPLE
|
13
|
-
describe chocolatey_package('git') do
|
14
|
-
it { should be_installed }
|
15
|
-
its('version') { should eq '2.15.1' }
|
16
|
-
end
|
17
|
-
EXAMPLE
|
18
|
-
|
19
|
-
attr_reader :package_name
|
20
|
-
|
21
|
-
def initialize(package_name, _opts = {})
|
22
|
-
raise "Chocolatey is not installed" unless inspec.command("choco").exist?
|
23
|
-
|
24
|
-
@package_name = package_name
|
25
|
-
@cache = base_data.update(generate_cache)
|
26
|
-
end
|
27
|
-
|
28
|
-
def installed?
|
29
|
-
@cache[:installed]
|
30
|
-
end
|
31
|
-
|
32
|
-
def info
|
33
|
-
@cache.dup
|
34
|
-
end
|
35
|
-
|
36
|
-
def respond_to_missing?(method_name, *)
|
37
|
-
@cache.key?(method_name) || super
|
38
|
-
end
|
39
|
-
|
40
|
-
def method_missing(method_name, *args, &block)
|
41
|
-
if @cache.key?(method_name)
|
42
|
-
@cache.fetch(method_name)
|
43
|
-
else
|
44
|
-
super
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_s
|
49
|
-
"Chocolatey package #{package_name}"
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def base_data
|
55
|
-
{
|
56
|
-
name: package_name,
|
57
|
-
version: nil,
|
58
|
-
installed: false,
|
59
|
-
type: "chocolatey",
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def generate_cache
|
64
|
-
command = <<-EOH
|
65
|
-
(choco list --local-only --exact --include-programs --limit-output '#{package_name.gsub("'", "\`'")}') -Replace "\\|", "=" | ConvertFrom-StringData | ConvertTo-JSON
|
66
|
-
EOH
|
67
|
-
|
68
|
-
cmd = inspec.powershell(command.strip)
|
69
|
-
|
70
|
-
return {} if cmd.exit_status != 0 || cmd.stdout.strip.empty?
|
71
|
-
|
72
|
-
out = JSON.parse(cmd.stdout)
|
73
|
-
|
74
|
-
{
|
75
|
-
version: out.fetch(package_name),
|
76
|
-
installed: true,
|
77
|
-
}
|
78
|
-
rescue JSON::ParserError, KeyError
|
79
|
-
{}
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# copyright: 2015, Vulcano Security GmbH
|
2
|
-
|
3
|
-
require "inspec/resource"
|
4
|
-
require "inspec/resources/platform"
|
5
|
-
require "inspec/resources/os"
|
6
|
-
|
7
|
-
module Inspec::Resources
|
8
|
-
class Cmd < Inspec.resource(1)
|
9
|
-
name "command"
|
10
|
-
supports platform: "unix"
|
11
|
-
supports platform: "windows"
|
12
|
-
desc "Use the command InSpec audit resource to test an arbitrary command that is run on the system."
|
13
|
-
example <<~EXAMPLE
|
14
|
-
describe command('ls -al /') do
|
15
|
-
its('stdout') { should match /bin/ }
|
16
|
-
its('stderr') { should eq '' }
|
17
|
-
its('exit_status') { should eq 0 }
|
18
|
-
end
|
19
|
-
|
20
|
-
command('ls -al /').exist? will return false. Existence of command should be checked this way.
|
21
|
-
describe command('ls') do
|
22
|
-
it { should exist }
|
23
|
-
end
|
24
|
-
EXAMPLE
|
25
|
-
|
26
|
-
attr_reader :command
|
27
|
-
|
28
|
-
def initialize(cmd, options = {})
|
29
|
-
if cmd.nil?
|
30
|
-
raise "InSpec `command` was called with `nil` as the argument. This is not supported. Please provide a valid command instead."
|
31
|
-
end
|
32
|
-
|
33
|
-
@command = cmd
|
34
|
-
|
35
|
-
if options[:redact_regex]
|
36
|
-
unless options[:redact_regex].is_a?(Regexp)
|
37
|
-
# Make sure command is replaced so sensitive output isn't shown
|
38
|
-
@command = "ERROR"
|
39
|
-
raise Inspec::Exceptions::ResourceFailed,
|
40
|
-
"The `redact_regex` option must be a regular expression"
|
41
|
-
end
|
42
|
-
@redact_regex = options[:redact_regex]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def result
|
47
|
-
@result ||= inspec.backend.run_command(@command)
|
48
|
-
end
|
49
|
-
|
50
|
-
def stdout
|
51
|
-
result.stdout
|
52
|
-
end
|
53
|
-
|
54
|
-
def stderr
|
55
|
-
result.stderr
|
56
|
-
end
|
57
|
-
|
58
|
-
def exit_status
|
59
|
-
result.exit_status.to_i
|
60
|
-
end
|
61
|
-
|
62
|
-
def exist? # rubocop:disable Metrics/AbcSize
|
63
|
-
# silent for mock resources
|
64
|
-
return false if inspec.os.name.nil? || inspec.os.name == "mock"
|
65
|
-
|
66
|
-
if inspec.os.linux?
|
67
|
-
res = if inspec.platform.name == "alpine"
|
68
|
-
inspec.backend.run_command("which \"#{@command}\"")
|
69
|
-
else
|
70
|
-
inspec.backend.run_command("bash -c 'type \"#{@command}\"'")
|
71
|
-
end
|
72
|
-
elsif inspec.os.windows?
|
73
|
-
res = inspec.backend.run_command("Get-Command \"#{@command}\"")
|
74
|
-
elsif inspec.os.unix?
|
75
|
-
res = inspec.backend.run_command("type \"#{@command}\"")
|
76
|
-
else
|
77
|
-
warn "`command(#{@command}).exist?` is not supported on your OS: #{inspec.os[:name]}"
|
78
|
-
return false
|
79
|
-
end
|
80
|
-
res.exit_status.to_i == 0
|
81
|
-
end
|
82
|
-
|
83
|
-
def to_s
|
84
|
-
output = "Command: `#{@command}`"
|
85
|
-
# Redact output if the `redact_regex` option is passed
|
86
|
-
# If no capture groups are passed then `\1` and `\2` are ignored
|
87
|
-
output.gsub!(@redact_regex, '\1REDACTED\2') unless @redact_regex.nil?
|
88
|
-
output
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require "inspec/resources/command"
|
2
|
-
|
3
|
-
# Usage:
|
4
|
-
# describe cpan('DBD::Pg') do
|
5
|
-
# it { should be_installed }
|
6
|
-
# end
|
7
|
-
#
|
8
|
-
|
9
|
-
module Inspec::Resources
|
10
|
-
class CpanPackage < Inspec.resource(1)
|
11
|
-
name "cpan"
|
12
|
-
supports platform: "unix"
|
13
|
-
desc "Use the `cpan` InSpec audit resource to test Perl modules that are installed by system packages or the CPAN installer."
|
14
|
-
example <<~EXAMPLE
|
15
|
-
describe cpan('DBD::Pg') do
|
16
|
-
it { should be_installed }
|
17
|
-
end
|
18
|
-
EXAMPLE
|
19
|
-
|
20
|
-
def initialize(package_name, perl_lib_path = nil)
|
21
|
-
@package_name = package_name
|
22
|
-
@perl_lib_path = perl_lib_path
|
23
|
-
@perl_cmd = "perl"
|
24
|
-
|
25
|
-
# this resource is not supported on Windows
|
26
|
-
return skip_resource "The `cpan` resource is not supported on your OS yet." if inspec.os.windows?
|
27
|
-
return skip_resource "perl not found" unless inspec.command(@perl_cmd).exist?
|
28
|
-
end
|
29
|
-
|
30
|
-
def info
|
31
|
-
return @info if defined?(@info)
|
32
|
-
|
33
|
-
@info = {}
|
34
|
-
@info[:type] = "cpan"
|
35
|
-
@info[:name] = @package_name
|
36
|
-
# set PERL5LIB environment variable if a custom lib path is given
|
37
|
-
lib_path = @perl_lib_path.nil? ? "" : "PERL5LIB=#{@perl_lib_path} "
|
38
|
-
cmd = inspec.command("#{lib_path + @perl_cmd} -le 'eval \"require $ARGV[0]\" and print $ARGV[0]->VERSION or exit 1' #{@package_name}")
|
39
|
-
@info[:installed] = cmd.exit_status == 0
|
40
|
-
return @info unless cmd.exit_status == 0
|
41
|
-
|
42
|
-
@info[:version] = cmd.stdout.strip
|
43
|
-
@info
|
44
|
-
end
|
45
|
-
|
46
|
-
def installed?
|
47
|
-
info[:installed] == true
|
48
|
-
end
|
49
|
-
|
50
|
-
def version
|
51
|
-
info[:version]
|
52
|
-
end
|
53
|
-
|
54
|
-
def to_s
|
55
|
-
"Perl Module #{@package_name}"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require "inspec/resources/command"
|
2
|
-
|
3
|
-
# Usage:
|
4
|
-
# describe cran('DBI') do
|
5
|
-
# it { should be_installed }
|
6
|
-
# end
|
7
|
-
#
|
8
|
-
|
9
|
-
module Inspec::Resources
|
10
|
-
class CranPackage < Inspec.resource(1)
|
11
|
-
name "cran"
|
12
|
-
supports platform: "unix"
|
13
|
-
desc "Use the `cran` InSpec audit resource to test R modules that are installed from CRAN package repository."
|
14
|
-
example <<~EXAMPLE
|
15
|
-
describe cran('DBI') do
|
16
|
-
it { should be_installed }
|
17
|
-
end
|
18
|
-
EXAMPLE
|
19
|
-
|
20
|
-
def initialize(package_name)
|
21
|
-
@package_name = package_name
|
22
|
-
@r_cmd = "Rscript"
|
23
|
-
|
24
|
-
# this resource is not supported on Windows
|
25
|
-
return skip_resource "The `cran` resource is not supported on your OS yet." if inspec.os.windows?
|
26
|
-
return skip_resource "Rscript not found" unless inspec.command(@r_cmd).exist?
|
27
|
-
end
|
28
|
-
|
29
|
-
def info
|
30
|
-
return @info if defined?(@info)
|
31
|
-
|
32
|
-
@info = {}
|
33
|
-
@info[:type] = "cran"
|
34
|
-
@info[:name] = @package_name
|
35
|
-
cmd = inspec.command("#{@r_cmd} -e 'packageVersion(\"#{@package_name}\")'")
|
36
|
-
return @info unless cmd.exit_status == 0
|
37
|
-
|
38
|
-
# Extract package version from Rscript output
|
39
|
-
# Output includes unicode punctuation (backticks) characters like so:
|
40
|
-
# [1] '0.5.1'
|
41
|
-
#
|
42
|
-
# So make sure command output is converted to unicode, as it returns ASCII-8BIT by default
|
43
|
-
utf8_stdout = cmd.stdout.chomp.force_encoding(Encoding::UTF_8)
|
44
|
-
params = /^\[\d+\]\s+(?:['\p{Initial_Punctuation}])(.+)(?:['\p{Final_Punctuation}])$/.match(utf8_stdout)
|
45
|
-
@info[:installed] = !params.nil?
|
46
|
-
return @info unless @info[:installed]
|
47
|
-
|
48
|
-
@info[:version] = params[1]
|
49
|
-
@info
|
50
|
-
end
|
51
|
-
|
52
|
-
def installed?
|
53
|
-
info[:installed] == true
|
54
|
-
end
|
55
|
-
|
56
|
-
def version
|
57
|
-
info[:version]
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_s
|
61
|
-
"R Module #{@package_name}"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,173 +0,0 @@
|
|
1
|
-
require "inspec/resources/file"
|
2
|
-
require "inspec/utils/parser"
|
3
|
-
require "inspec/utils/filter"
|
4
|
-
|
5
|
-
module Inspec::Resources
|
6
|
-
class Crontab < Inspec.resource(1)
|
7
|
-
name "crontab"
|
8
|
-
supports platform: "unix"
|
9
|
-
desc "Use the crontab InSpec audit resource to test the contents of the crontab for a given user which contains information about scheduled tasks owned by that user."
|
10
|
-
example <<~EXAMPLE
|
11
|
-
describe crontab(user: 'root') do
|
12
|
-
its('commands') { should include '/path/to/some/script' }
|
13
|
-
end
|
14
|
-
|
15
|
-
describe crontab('myuser').commands('/home/myuser/build.sh') do
|
16
|
-
its('hours') { should cmp '*' }
|
17
|
-
its('minutes') { should cmp '*' }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe crontab.where({'hour' => '*', 'minute' => '*'}) do
|
21
|
-
its('entries.length') { should cmp '0' }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe crontab.where { command =~ /a partial command string/ } do
|
25
|
-
its('entries.length') { should cmp 1 }
|
26
|
-
end
|
27
|
-
|
28
|
-
describe crontab(path: '/etc/cron.d/some_crontab') do
|
29
|
-
its('commands') { should include '/path/to/some/script' }
|
30
|
-
end
|
31
|
-
EXAMPLE
|
32
|
-
|
33
|
-
attr_reader :params
|
34
|
-
|
35
|
-
include CommentParser
|
36
|
-
|
37
|
-
def initialize(opts = nil)
|
38
|
-
if opts.respond_to?(:fetch)
|
39
|
-
Hash[opts.map { |k, v| [k.to_sym, v] }]
|
40
|
-
@user = opts.fetch(:user, nil)
|
41
|
-
@path = opts.fetch(:path, nil)
|
42
|
-
raise Inspec::Exceptions::ResourceFailed, "A user or path must be supplied." if @user.nil? && @path.nil?
|
43
|
-
raise Inspec::Exceptions::ResourceFailed, "Either user or path must be supplied, not both!" if !@user.nil? && !@path.nil?
|
44
|
-
else
|
45
|
-
@user = opts
|
46
|
-
@path = nil
|
47
|
-
end
|
48
|
-
@params = read_crontab
|
49
|
-
end
|
50
|
-
|
51
|
-
def read_crontab
|
52
|
-
if is_system_crontab?
|
53
|
-
raise Inspec::Exceptions::ResourceFailed, "Supplied crontab path '#{@path}' must exist!" unless inspec.file(@path).exist?
|
54
|
-
|
55
|
-
ct = inspec.file(@path).content
|
56
|
-
else
|
57
|
-
ct = inspec.command(crontab_cmd).stdout
|
58
|
-
end
|
59
|
-
ct.lines.map { |l| parse_crontab_line(l) }.compact
|
60
|
-
end
|
61
|
-
|
62
|
-
def parse_crontab_line(l)
|
63
|
-
data, = parse_comment_line(l, comment_char: "#", standalone_comments: false)
|
64
|
-
return nil if data.nil? || data.empty?
|
65
|
-
|
66
|
-
is_system_crontab? ? parse_system_crontab(data) : parse_user_crontab(data)
|
67
|
-
end
|
68
|
-
|
69
|
-
def crontab_cmd
|
70
|
-
@user.nil? ? "crontab -l" : "crontab -l -u #{@user}"
|
71
|
-
end
|
72
|
-
|
73
|
-
filter = FilterTable.create
|
74
|
-
filter.register_column(:minutes, field: "minute")
|
75
|
-
.register_column(:hours, field: "hour")
|
76
|
-
.register_column(:days, field: "day")
|
77
|
-
.register_column(:months, field: "month")
|
78
|
-
.register_column(:weekdays, field: "weekday")
|
79
|
-
.register_column(:user, field: "user")
|
80
|
-
.register_column(:commands, field: "command")
|
81
|
-
|
82
|
-
# rebuild the crontab line from raw content
|
83
|
-
filter.register_custom_property(:content) do |t, _|
|
84
|
-
t.entries.map do |e|
|
85
|
-
[e.minute, e.hour, e.day, e.month, e.weekday, e.user, e.command].compact.join(" ")
|
86
|
-
end.join("\n")
|
87
|
-
end
|
88
|
-
|
89
|
-
filter.install_filter_methods_on_resource(self, :params)
|
90
|
-
|
91
|
-
def to_s
|
92
|
-
if is_system_crontab?
|
93
|
-
"crontab for path #{@path}"
|
94
|
-
elsif is_user_crontab?
|
95
|
-
"crontab for user #{@user}"
|
96
|
-
else
|
97
|
-
"crontab for current user"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
private
|
102
|
-
|
103
|
-
def is_system_crontab?
|
104
|
-
!@path.nil?
|
105
|
-
end
|
106
|
-
|
107
|
-
def is_user_crontab?
|
108
|
-
!@user.nil?
|
109
|
-
end
|
110
|
-
|
111
|
-
def parse_system_crontab(data)
|
112
|
-
case data
|
113
|
-
when /@hourly .*/
|
114
|
-
elements = data.split(/\s+/, 3)
|
115
|
-
{ "minute" => "0", "hour" => "*", "day" => "*", "month" => "*", "weekday" => "*", "user" => elements.at(1), "command" => elements.at(2) }
|
116
|
-
when /@(midnight|daily) .*/
|
117
|
-
elements = data.split(/\s+/, 3)
|
118
|
-
{ "minute" => "0", "hour" => "0", "day" => "*", "month" => "*", "weekday" => "*", "user" => elements.at(1), "command" => elements.at(2) }
|
119
|
-
when /@weekly .*/
|
120
|
-
elements = data.split(/\s+/, 3)
|
121
|
-
{ "minute" => "0", "hour" => "0", "day" => "*", "month" => "*", "weekday" => "0", "user" => elements.at(1), "command" => elements.at(2) }
|
122
|
-
when /@monthly ./
|
123
|
-
elements = data.split(/\s+/, 3)
|
124
|
-
{ "minute" => "0", "hour" => "0", "day" => "1", "month" => "*", "weekday" => "*", "user" => elements.at(1), "command" => elements.at(2) }
|
125
|
-
when /@(annually|yearly) .*/
|
126
|
-
elements = data.split(/\s+/, 3)
|
127
|
-
{ "minute" => "0", "hour" => "0", "day" => "1", "month" => "1", "weekday" => "*", "user" => elements.at(1), "command" => elements.at(2) }
|
128
|
-
when /@reboot .*/
|
129
|
-
elements = data.split(/\s+/, 3)
|
130
|
-
{ "minute" => "-1", "hour" => "-1", "day" => "-1", "month" => "-1", "weekday" => "-1", "user" => elements.at(1), "command" => elements.at(2) }
|
131
|
-
else
|
132
|
-
elements = data.split(/\s+/, 7)
|
133
|
-
{
|
134
|
-
"minute" => elements.at(0),
|
135
|
-
"hour" => elements.at(1),
|
136
|
-
"day" => elements.at(2),
|
137
|
-
"month" => elements.at(3),
|
138
|
-
"weekday" => elements.at(4),
|
139
|
-
"user" => elements.at(5),
|
140
|
-
"command" => elements.at(6),
|
141
|
-
}
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def parse_user_crontab(data)
|
146
|
-
case data
|
147
|
-
when /@hourly .*/
|
148
|
-
{ "minute" => "0", "hour" => "*", "day" => "*", "month" => "*", "weekday" => "*", "user" => @user, "command" => data.split(/\s+/, 2).at(1) }
|
149
|
-
when /@(midnight|daily) .*/
|
150
|
-
{ "minute" => "0", "hour" => "0", "day" => "*", "month" => "*", "weekday" => "*", "user" => @user, "command" => data.split(/\s+/, 2).at(1) }
|
151
|
-
when /@weekly .*/
|
152
|
-
{ "minute" => "0", "hour" => "0", "day" => "*", "month" => "*", "weekday" => "0", "user" => @user, "command" => data.split(/\s+/, 2).at(1) }
|
153
|
-
when /@monthly ./
|
154
|
-
{ "minute" => "0", "hour" => "0", "day" => "1", "month" => "*", "weekday" => "*", "user" => @user, "command" => data.split(/\s+/, 2).at(1) }
|
155
|
-
when /@(annually|yearly) .*/
|
156
|
-
{ "minute" => "0", "hour" => "0", "day" => "1", "month" => "1", "weekday" => "*", "user" => @user, "command" => data.split(/\s+/, 2).at(1) }
|
157
|
-
when /@reboot .*/
|
158
|
-
{ "minute" => "-1", "hour" => "-1", "day" => "-1", "month" => "-1", "weekday" => "-1", "user" => @user, "command" => data.split(/\s+/, 2).at(1) }
|
159
|
-
else
|
160
|
-
elements = data.split(/\s+/, 6)
|
161
|
-
{
|
162
|
-
"minute" => elements.at(0),
|
163
|
-
"hour" => elements.at(1),
|
164
|
-
"day" => elements.at(2),
|
165
|
-
"month" => elements.at(3),
|
166
|
-
"weekday" => elements.at(4),
|
167
|
-
"user" => @user,
|
168
|
-
"command" => elements.at(5),
|
169
|
-
}
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|