inspec 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -2
- data/Gemfile +2 -1
- data/docs/cli.rst +1 -17
- data/docs/resources.rst +128 -0
- data/docs/shell.rst +130 -0
- data/inspec.gemspec +3 -4
- data/lib/bundles/inspec-compliance/.kitchen.yml +0 -1
- data/lib/bundles/inspec-compliance/README.md +8 -3
- data/lib/bundles/inspec-compliance/api.rb +21 -6
- data/lib/bundles/inspec-compliance/bootstrap.sh +13 -9
- data/lib/bundles/inspec-compliance/cli.rb +23 -19
- data/lib/bundles/inspec-compliance/target.rb +1 -0
- data/lib/bundles/inspec-compliance/test/integration/default/cli.rb +42 -5
- data/lib/bundles/inspec-init/cli.rb +9 -0
- data/lib/bundles/inspec-supermarket/cli.rb +9 -0
- data/lib/bundles/inspec-supermarket/target.rb +2 -1
- data/lib/fetchers/local.rb +5 -2
- data/lib/fetchers/url.rb +1 -0
- data/lib/inspec/base_cli.rb +2 -1
- data/lib/inspec/cli.rb +14 -5
- data/lib/inspec/dependencies/dependency_set.rb +38 -0
- data/lib/inspec/dependencies/requirement.rb +103 -0
- data/lib/inspec/{dependencies.rb → dependencies/resolver.rb} +13 -132
- data/lib/inspec/dependencies/vendor_index.rb +98 -0
- data/lib/inspec/plugins/source_reader.rb +4 -0
- data/lib/inspec/profile.rb +2 -2
- data/lib/inspec/resource.rb +2 -0
- data/lib/inspec/runner.rb +13 -1
- data/lib/inspec/runner_mock.rb +4 -0
- data/lib/inspec/runner_rspec.rb +6 -2
- data/lib/inspec/shell.rb +22 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/iis_site.rb +107 -0
- data/lib/resources/port.rb +11 -4
- data/lib/resources/ssh_conf.rb +10 -2
- data/lib/resources/ssl.rb +94 -0
- data/lib/resources/xinetd.rb +11 -2
- data/lib/utils/parser.rb +6 -1
- metadata +17 -561
- data/lib/utils/hash_map.rb +0 -37
- data/tasks/maintainers.rb +0 -213
- data/test/bench/startup/startup.flat.txt +0 -1005
- data/test/bench/startup/startup.graph.html +0 -71958
- data/test/bench/startup/startup.grind.dat +0 -101602
- data/test/bench/startup/startup.stack.html +0 -24516
- data/test/bench/startup.flat.txt +0 -998
- data/test/bench/startup.graph.html +0 -71420
- data/test/bench/startup.grind.dat +0 -103554
- data/test/bench/startup.stack.html +0 -25015
- data/test/cookbooks/os_prepare/attributes/default.rb +0 -2
- data/test/cookbooks/os_prepare/files/empty.iso +0 -0
- data/test/cookbooks/os_prepare/files/example.csv +0 -7
- data/test/cookbooks/os_prepare/files/example.ini +0 -6
- data/test/cookbooks/os_prepare/files/example.json +0 -12
- data/test/cookbooks/os_prepare/files/example.yml +0 -7
- data/test/cookbooks/os_prepare/metadata.rb +0 -13
- data/test/cookbooks/os_prepare/recipes/_runit_service_centos.rb +0 -34
- data/test/cookbooks/os_prepare/recipes/_upstart_service_centos.rb +0 -25
- data/test/cookbooks/os_prepare/recipes/apache.rb +0 -14
- data/test/cookbooks/os_prepare/recipes/apt.rb +0 -20
- data/test/cookbooks/os_prepare/recipes/auditctl.rb +0 -8
- data/test/cookbooks/os_prepare/recipes/default.rb +0 -29
- data/test/cookbooks/os_prepare/recipes/file.rb +0 -46
- data/test/cookbooks/os_prepare/recipes/iptables.rb +0 -13
- data/test/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb +0 -34
- data/test/cookbooks/os_prepare/recipes/mount.rb +0 -33
- data/test/cookbooks/os_prepare/recipes/package.rb +0 -25
- data/test/cookbooks/os_prepare/recipes/postgres.rb +0 -20
- data/test/cookbooks/os_prepare/recipes/prep_container.rb +0 -15
- data/test/cookbooks/os_prepare/recipes/registry_key.rb +0 -87
- data/test/cookbooks/os_prepare/recipes/service.rb +0 -19
- data/test/cookbooks/os_prepare/templates/default/sv-default-svlog-run.erb +0 -2
- data/test/docker_run.rb +0 -162
- data/test/docker_test.rb +0 -58
- data/test/functional/helper.rb +0 -37
- data/test/functional/inheritance_test.rb +0 -62
- data/test/functional/inspec_archive_test.rb +0 -80
- data/test/functional/inspec_compliance_test.rb +0 -61
- data/test/functional/inspec_exec_json_test.rb +0 -122
- data/test/functional/inspec_exec_jsonmin_test.rb +0 -59
- data/test/functional/inspec_exec_test.rb +0 -123
- data/test/functional/inspec_json_profile_test.rb +0 -103
- data/test/functional/inspec_test.rb +0 -91
- data/test/helper.rb +0 -329
- data/test/integration/default/_debug_spec.rb +0 -8
- data/test/integration/default/apache_conf_spec.rb +0 -21
- data/test/integration/default/apt_spec.rb +0 -37
- data/test/integration/default/auditd_rules_spec.rb +0 -32
- data/test/integration/default/cmp_matcher_spec.rb +0 -115
- data/test/integration/default/csv_spec.rb +0 -11
- data/test/integration/default/etc_group_spec.rb +0 -29
- data/test/integration/default/file_spec.rb +0 -195
- data/test/integration/default/group_spec.rb +0 -59
- data/test/integration/default/ini_spec.rb +0 -11
- data/test/integration/default/iptables_spec.rb +0 -29
- data/test/integration/default/json_spec.rb +0 -11
- data/test/integration/default/kernel_module_spec.rb +0 -23
- data/test/integration/default/kernel_parameter_spec.rb +0 -60
- data/test/integration/default/mount_spec.rb +0 -19
- data/test/integration/default/os_spec.rb +0 -13
- data/test/integration/default/package_spec.rb +0 -30
- data/test/integration/default/port_spec.rb +0 -27
- data/test/integration/default/postgres_session_spec.rb +0 -13
- data/test/integration/default/powershell_spec.rb +0 -42
- data/test/integration/default/registry_key_spec.rb +0 -109
- data/test/integration/default/secpol_spec.rb +0 -11
- data/test/integration/default/service_spec.rb +0 -128
- data/test/integration/default/user_spec.rb +0 -96
- data/test/integration/default/vbscript_spec.rb +0 -22
- data/test/integration/default/wmi_spec.rb +0 -66
- data/test/integration/default/yaml_spec.rb +0 -11
- data/test/resource/command_test.rb +0 -33
- data/test/resource/dsl_test.rb +0 -45
- data/test/resource/file_test.rb +0 -146
- data/test/resource/ssh_config.rb +0 -9
- data/test/resource/sshd_config.rb +0 -9
- data/test/test-extra.yaml +0 -11
- data/test/test.yaml +0 -11
- data/test/unit/control_test.rb +0 -58
- data/test/unit/fetchers/local_test.rb +0 -67
- data/test/unit/fetchers/mock_test.rb +0 -43
- data/test/unit/fetchers/tar_test.rb +0 -36
- data/test/unit/fetchers/url_test.rb +0 -152
- data/test/unit/fetchers/zip_test.rb +0 -36
- data/test/unit/fetchers_test.rb +0 -65
- data/test/unit/metadata_test.rb +0 -137
- data/test/unit/mock/cmd/$env-PATH +0 -1
- data/test/unit/mock/cmd/Get-NetAdapter +0 -24
- data/test/unit/mock/cmd/GetUserAccount +0 -33
- data/test/unit/mock/cmd/GetWin32Group +0 -23
- data/test/unit/mock/cmd/Resolve-DnsName +0 -26
- data/test/unit/mock/cmd/Test-NetConnection +0 -4
- data/test/unit/mock/cmd/auditctl +0 -3
- data/test/unit/mock/cmd/auditctl-legacy +0 -7
- data/test/unit/mock/cmd/auditctl-s +0 -8
- data/test/unit/mock/cmd/auditpol +0 -2
- data/test/unit/mock/cmd/brew-info-jq +0 -1
- data/test/unit/mock/cmd/chage-l-root +0 -7
- data/test/unit/mock/cmd/dpkg-s-curl +0 -21
- data/test/unit/mock/cmd/dscl +0 -5
- data/test/unit/mock/cmd/env +0 -1
- data/test/unit/mock/cmd/etc-apt +0 -7
- data/test/unit/mock/cmd/find-apache2-conf-enabled +0 -1
- data/test/unit/mock/cmd/find-apache2-ports-conf +0 -1
- data/test/unit/mock/cmd/find-etc-rc-d-name-S +0 -12
- data/test/unit/mock/cmd/find-net-interface +0 -9
- data/test/unit/mock/cmd/find-xinetd.d +0 -2
- data/test/unit/mock/cmd/gem-list-local-a-q-rubocop +0 -1
- data/test/unit/mock/cmd/get-net-tcpconnection +0 -24
- data/test/unit/mock/cmd/get-netadapter-binding-bridge +0 -4
- data/test/unit/mock/cmd/get-package-firefox +0 -30
- data/test/unit/mock/cmd/get-package-ruby +0 -18
- data/test/unit/mock/cmd/get-service-dhcp +0 -10
- data/test/unit/mock/cmd/get-windows-feature +0 -7
- data/test/unit/mock/cmd/get-wmiobject +0 -9
- data/test/unit/mock/cmd/getent-hosts-example.com +0 -1
- data/test/unit/mock/cmd/getent-passwd-jfolmer +0 -1
- data/test/unit/mock/cmd/getent-passwd-root +0 -1
- data/test/unit/mock/cmd/hpux-netstat-inet +0 -10
- data/test/unit/mock/cmd/hpux-netstat-inet6 +0 -11
- data/test/unit/mock/cmd/id-chartmann +0 -1
- data/test/unit/mock/cmd/id-jfolmer +0 -1
- data/test/unit/mock/cmd/id-root +0 -1
- data/test/unit/mock/cmd/initctl--version +0 -5
- data/test/unit/mock/cmd/initctl-show-config-ssh +0 -3
- data/test/unit/mock/cmd/initctl-status-ssh +0 -1
- data/test/unit/mock/cmd/iptables-s +0 -6
- data/test/unit/mock/cmd/launchctl-list +0 -3
- data/test/unit/mock/cmd/logins-x +0 -4
- data/test/unit/mock/cmd/ls-1-etc-init.d +0 -2
- data/test/unit/mock/cmd/ls-sys-class-net-br +0 -2
- data/test/unit/mock/cmd/lsmod +0 -2
- data/test/unit/mock/cmd/lsof-nP-i-FpctPn +0 -63
- data/test/unit/mock/cmd/mount +0 -1
- data/test/unit/mock/cmd/mount-multiple +0 -2
- data/test/unit/mock/cmd/netstat-an.utf8 +0 -13
- data/test/unit/mock/cmd/netstat-tulpen +0 -6
- data/test/unit/mock/cmd/npm-ls-g--json-bower +0 -9
- data/test/unit/mock/cmd/pacman-qi-curl +0 -21
- data/test/unit/mock/cmd/ping-example.com +0 -6
- data/test/unit/mock/cmd/pip-show-jinja2 +0 -11
- data/test/unit/mock/cmd/pkg-info-system-file-system-zfs +0 -8
- data/test/unit/mock/cmd/pkginfo-l-SUNWzfsr +0 -7
- data/test/unit/mock/cmd/ps-aux +0 -5
- data/test/unit/mock/cmd/ps-auxZ +0 -3
- data/test/unit/mock/cmd/pw-usershow-root-7 +0 -1
- data/test/unit/mock/cmd/reg_schedule +0 -6
- data/test/unit/mock/cmd/rpm-qia-curl +0 -24
- data/test/unit/mock/cmd/s11-netstat-an-finet-finet6 +0 -32
- data/test/unit/mock/cmd/sbin_sysctl +0 -1
- data/test/unit/mock/cmd/secedit-export +0 -7
- data/test/unit/mock/cmd/service-e +0 -2
- data/test/unit/mock/cmd/service-sendmail-onestatus +0 -3
- data/test/unit/mock/cmd/service-sshd-status +0 -1
- data/test/unit/mock/cmd/sockstat +0 -5
- data/test/unit/mock/cmd/success +0 -0
- data/test/unit/mock/cmd/swlist-l-product +0 -1
- data/test/unit/mock/cmd/systemctl-show-all-dbus +0 -6
- data/test/unit/mock/cmd/systemctl-show-all-sshd +0 -7
- data/test/unit/mock/cmd/win32_product +0 -8
- data/test/unit/mock/cmd/yum-repolist-all +0 -52
- data/test/unit/mock/files/apache2.conf +0 -14
- data/test/unit/mock/files/auditd.conf +0 -4
- data/test/unit/mock/files/bond0 +0 -37
- data/test/unit/mock/files/etcgroup +0 -3
- data/test/unit/mock/files/example.csv +0 -6
- data/test/unit/mock/files/grub.conf +0 -21
- data/test/unit/mock/files/inetd.conf +0 -2
- data/test/unit/mock/files/kitchen.yml +0 -7
- data/test/unit/mock/files/limits.conf +0 -5
- data/test/unit/mock/files/login.defs +0 -5
- data/test/unit/mock/files/mysql.conf +0 -8
- data/test/unit/mock/files/mysql2.conf +0 -2
- data/test/unit/mock/files/ntp.conf +0 -5
- data/test/unit/mock/files/passwd +0 -2
- data/test/unit/mock/files/policyfile.lock.json +0 -12
- data/test/unit/mock/files/ports.conf +0 -6
- data/test/unit/mock/files/rootwrap.conf +0 -7
- data/test/unit/mock/files/serve-cgi-bin.conf +0 -20
- data/test/unit/mock/files/shadow +0 -2
- data/test/unit/mock/files/ssh_config +0 -5
- data/test/unit/mock/files/sshd_config +0 -7
- data/test/unit/mock/files/sysctl.conf +0 -7
- data/test/unit/mock/files/xinetd.conf +0 -9
- data/test/unit/mock/files/xinetd.d/.gitkeep +0 -0
- data/test/unit/mock/files/xinetd.d_chargen-dgram +0 -9
- data/test/unit/mock/files/xinetd.d_chargen-stream +0 -9
- data/test/unit/mock/profiles/complete-metadata/inspec.yml +0 -7
- data/test/unit/mock/profiles/complete-profile/controls/filesystem_spec.rb +0 -16
- data/test/unit/mock/profiles/complete-profile/inspec.yml +0 -10
- data/test/unit/mock/profiles/complete-profile/libraries/testlib.rb +0 -1
- data/test/unit/mock/profiles/empty-metadata/inspec.yml +0 -0
- data/test/unit/mock/profiles/legacy-complete-metadata/metadata.rb +0 -7
- data/test/unit/mock/profiles/legacy-complete-metadata/test/.gitkeep +0 -0
- data/test/unit/mock/profiles/legacy-empty-metadata/controls/.gitkeep +0 -0
- data/test/unit/mock/profiles/legacy-empty-metadata/metadata.rb +0 -0
- data/test/unit/mock/profiles/legacy-simple-metadata/metadata.rb +0 -1
- data/test/unit/mock/profiles/legacy-simple-metadata/test/.gitkeep +0 -0
- data/test/unit/mock/profiles/library/controls/filesystem_spec.rb +0 -7
- data/test/unit/mock/profiles/library/inspec.yml +0 -10
- data/test/unit/mock/profiles/library/libraries/gordonlib.rb +0 -2
- data/test/unit/mock/profiles/library/libraries/testlib.rb +0 -12
- data/test/unit/mock/profiles/resource-tiny/inspec.yml +0 -10
- data/test/unit/mock/profiles/resource-tiny/libraries/resource.rb +0 -3
- data/test/unit/mock/profiles/simple-metadata/inspec.yml +0 -1
- data/test/unit/mock/profiles/skippy-profile-os/controls/one.rb +0 -3
- data/test/unit/mock/profiles/skippy-profile-os/inspec.yml +0 -5
- data/test/unit/mock/profiles/spec_only/specfile.rb +0 -11
- data/test/unit/mock/profiles/supported_inspec/inspec.yml +0 -2
- data/test/unit/mock/profiles/unsupported_inspec/inspec.yml +0 -2
- data/test/unit/objects_test.rb +0 -65
- data/test/unit/plugin_test.rb +0 -44
- data/test/unit/plugins/resource_test.rb +0 -60
- data/test/unit/profile_context_test.rb +0 -345
- data/test/unit/profile_test.rb +0 -252
- data/test/unit/resources/apache_conf_test.rb +0 -31
- data/test/unit/resources/apt_test.rb +0 -46
- data/test/unit/resources/audit_policy_test.rb +0 -13
- data/test/unit/resources/auditd_conf_test.rb +0 -15
- data/test/unit/resources/auditd_rules_test.rb +0 -91
- data/test/unit/resources/bash_test.rb +0 -29
- data/test/unit/resources/bond_test.rb +0 -24
- data/test/unit/resources/bridge_test.rb +0 -56
- data/test/unit/resources/csv_test.rb +0 -35
- data/test/unit/resources/etc_group_test.rb +0 -37
- data/test/unit/resources/file_test.rb +0 -202
- data/test/unit/resources/gem_test.rb +0 -20
- data/test/unit/resources/group_test.rb +0 -96
- data/test/unit/resources/grub_conf_test.rb +0 -29
- data/test/unit/resources/host_test.rb +0 -38
- data/test/unit/resources/inetd_conf_test.rb +0 -15
- data/test/unit/resources/ini_test.rb +0 -16
- data/test/unit/resources/interface_test.rb +0 -54
- data/test/unit/resources/iptables_test.rb +0 -35
- data/test/unit/resources/json_test.rb +0 -36
- data/test/unit/resources/kernel_module_test.rb +0 -23
- data/test/unit/resources/kernel_parameter_test.rb +0 -13
- data/test/unit/resources/limits_conf_test.rb +0 -14
- data/test/unit/resources/login_def_test.rb +0 -16
- data/test/unit/resources/mount_test.rb +0 -26
- data/test/unit/resources/mysql_conf_test.rb +0 -14
- data/test/unit/resources/npm_test.rb +0 -20
- data/test/unit/resources/ntp_conf_test.rb +0 -16
- data/test/unit/resources/oneget_test.rb +0 -45
- data/test/unit/resources/os_env_test.rb +0 -18
- data/test/unit/resources/os_test.rb +0 -40
- data/test/unit/resources/package_test.rb +0 -87
- data/test/unit/resources/parse_config_test.rb +0 -26
- data/test/unit/resources/passwd_test.rb +0 -111
- data/test/unit/resources/pip_test.rb +0 -15
- data/test/unit/resources/port_test.rb +0 -165
- data/test/unit/resources/powershell_test.rb +0 -32
- data/test/unit/resources/processes_test.rb +0 -72
- data/test/unit/resources/registry_key_test.rb +0 -18
- data/test/unit/resources/security_policy_test.rb +0 -16
- data/test/unit/resources/service_test.rb +0 -305
- data/test/unit/resources/shadow_test.rb +0 -67
- data/test/unit/resources/ssh_conf_test.rb +0 -33
- data/test/unit/resources/user_test.rb +0 -124
- data/test/unit/resources/vbscript_test.rb +0 -18
- data/test/unit/resources/windows_feature.rb +0 -17
- data/test/unit/resources/wmi_test.rb +0 -42
- data/test/unit/resources/xinetd_test.rb +0 -60
- data/test/unit/resources/yaml_test.rb +0 -34
- data/test/unit/resources/yum_test.rb +0 -68
- data/test/unit/shell_detector_test.rb +0 -78
- data/test/unit/source_reader_test.rb +0 -17
- data/test/unit/source_readers/flat_test.rb +0 -61
- data/test/unit/source_readers/inspec_test.rb +0 -38
- data/test/unit/utils/filter_array_test.rb +0 -59
- data/test/unit/utils/filter_table_test.rb +0 -177
- data/test/unit/utils/find_files_test.rb +0 -23
- data/test/unit/utils/passwd_parser_test.rb +0 -32
- data/test/unit/utils/simpleconfig_test.rb +0 -80
- data/test/unit/utils/solaris_netstat_parser.rb +0 -124
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
unless os.windows?
|
|
4
|
-
STDERR.puts "\033[1;33mTODO: Not running #{__FILE__} because we are not on Windows.\033[0m"
|
|
5
|
-
return
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
script = <<-EOH
|
|
9
|
-
Write-Output 'hello'
|
|
10
|
-
EOH
|
|
11
|
-
|
|
12
|
-
# Write-Output comes with a newline
|
|
13
|
-
describe powershell(script) do
|
|
14
|
-
its('stdout') { should eq "hello\r\n" }
|
|
15
|
-
its('stderr') { should eq '' }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# remove whitespace \r\n from stdout
|
|
19
|
-
describe powershell(script) do
|
|
20
|
-
its('strip') { should eq "hello" }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# legacy test with `script` resource
|
|
24
|
-
describe script(script) do
|
|
25
|
-
its('stdout') { should eq "hello\r\n" }
|
|
26
|
-
its('stderr') { should eq '' }
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# -NoNewLine only works in powershell 5
|
|
30
|
-
# @see https://blogs.technet.microsoft.com/heyscriptingguy/2015/08/07/the-powershell-5-nonewline-parameter/
|
|
31
|
-
describe powershell("'hello' | Write-Host -NoNewLine") do
|
|
32
|
-
its('stdout') { should eq 'hello' }
|
|
33
|
-
its('stderr') { should eq '' }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# test stderr
|
|
37
|
-
describe powershell("Write-Error \"error\"") do
|
|
38
|
-
its('stdout') { should eq '' }
|
|
39
|
-
# this is an xml error for now, if the script is run via WinRM
|
|
40
|
-
# @see https://github.com/WinRb/WinRM/issues/106
|
|
41
|
-
# its('stderr') { should eq 'error' }
|
|
42
|
-
end
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
unless os.windows?
|
|
4
|
-
STDERR.puts "\033[1;33mTODO: Not running #{__FILE__} because we are not on Windows.\033[0m"
|
|
5
|
-
return
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
describe registry_key('HKLM\System\Test') do
|
|
9
|
-
it { should exist }
|
|
10
|
-
it { should have_value('test') }
|
|
11
|
-
it { should have_property('binary value', :binary) }
|
|
12
|
-
it { should have_property('Binary value', :binary) }
|
|
13
|
-
it { should have_property('string value') }
|
|
14
|
-
it { should have_property('String value') }
|
|
15
|
-
it { should have_property('dword value', :dword) }
|
|
16
|
-
it { should have_property_value('multistring value', :multi_string, ['test', 'multi','string','data']) }
|
|
17
|
-
it { should have_property_value('Multistring Value', :multi_string, ['test', 'multi','string','data']) }
|
|
18
|
-
it { should have_property_value('qword value', :qword, 0) }
|
|
19
|
-
it { should have_property_value('Qword value', :qword, 0) }
|
|
20
|
-
it { should have_property_value('binary value', :binary, 'dfa0f066') }
|
|
21
|
-
it { should have_property_value('Binary value', :binary, 'dfa0f066') }
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# serverspec compatability
|
|
25
|
-
describe windows_registry_key('HKLM\System\Test') do
|
|
26
|
-
it { should exist }
|
|
27
|
-
it { should have_value('test') }
|
|
28
|
-
it { should have_property('string value') }
|
|
29
|
-
it { should have_property('binary value', :type_binary) }
|
|
30
|
-
it { should have_property('dword value', :type_dword) }
|
|
31
|
-
it { should have_property_value('multistring value', :type_multistring, ['test', 'multi','string','data']) }
|
|
32
|
-
it { should have_property_value('qword value', :type_qword, 0) }
|
|
33
|
-
it { should have_property_value('binary value', :type_binary, 'dfa0f066') }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe registry_key('HKLM\Software\Policies\Microsoft\Windows\EventLog\System') do
|
|
37
|
-
it { should exist }
|
|
38
|
-
its('MaxSize') { should_not eq nil }
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe registry_key('HKLM\System\CurrentControlSet\Control\Session Manager') do
|
|
42
|
-
it { should exist }
|
|
43
|
-
it { should_not have_property_value('SafeDllSearchMode', :type_dword, 0) }
|
|
44
|
-
# case-insensitive test
|
|
45
|
-
it { should_not have_property_value('safedllsearchmode', :type_dword, 0) }
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
describe registry_key('HKLM\System\CurrentControlSet\Services\LanManServer\Parameters') do
|
|
49
|
-
it { should exist }
|
|
50
|
-
its('NullSessionShares') { should eq [''] }
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe registry_key('HKLM\Software\Policies\Microsoft\Internet Explorer\Main') do
|
|
54
|
-
it { should exist }
|
|
55
|
-
its('Isolation64Bit') { should eq 1 }
|
|
56
|
-
# check that its is case-insensitive
|
|
57
|
-
its('isolation64bit') { should eq 1 }
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe registry_key('HKLM\System\CurrentControlSet\Control\Lsa\MSV1_0') do
|
|
61
|
-
it { should exist }
|
|
62
|
-
its('NTLMMinServerSec') { should eq 537_395_200 }
|
|
63
|
-
its('NtlmMinServerSec') { should eq 537_395_200 }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
describe registry_key('HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services') do
|
|
67
|
-
it { should exist }
|
|
68
|
-
its('MinEncryptionLevel') { should eq 3 }
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# test option hash
|
|
72
|
-
describe registry_key({
|
|
73
|
-
hive: 'HKLM',
|
|
74
|
-
key: 'SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services'
|
|
75
|
-
}) do
|
|
76
|
-
it { should exist }
|
|
77
|
-
its('MinEncryptionLevel') { should eq 3 }
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
describe registry_key({
|
|
81
|
-
hive: 'HKEY_LOCAL_MACHINE',
|
|
82
|
-
key: 'SOFTWARE\Microsoft\SystemCertificates\Root\Certificates\8C941B34EA1EA6ED9AE2BC54CF687252B4C9B561'
|
|
83
|
-
}) do
|
|
84
|
-
it { should exist }
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# test regular expressions in our match
|
|
88
|
-
describe registry_key({
|
|
89
|
-
hive: 'HKEY_LOCAL_MACHINE',
|
|
90
|
-
key: 'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
|
|
91
|
-
}) do
|
|
92
|
-
its('ProductName') { should match /^[a-zA-Z0-9\(\)\s]*2012\s[rR]2[a-zA-Z0-9\(\)\s]*$/ }
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# verify all children via a regular expression
|
|
96
|
-
control 'regex-test' do
|
|
97
|
-
title "Ensure 'Always install with elevated privileges' is set to 'Disabled'"
|
|
98
|
-
children = registry_key({
|
|
99
|
-
hive: 'HKEY_USERS'
|
|
100
|
-
}).children(/^S-1-5-21-[0-9]+-[0-9]+-[0-9]+-[0-9]{3,}\\Software\\Policies\\Microsoft\\Windows\\Installer/)
|
|
101
|
-
describe children do
|
|
102
|
-
it { should_not eq []}
|
|
103
|
-
end
|
|
104
|
-
children.each { |key|
|
|
105
|
-
describe registry_key(key) do
|
|
106
|
-
its('AlwaysInstallElevated') { should cmp 0 }
|
|
107
|
-
end
|
|
108
|
-
}
|
|
109
|
-
end
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
unless os.windows?
|
|
4
|
-
STDERR.puts "\033[1;33mTODO: Not running #{__FILE__} because we are not on Windows.\033[0m"
|
|
5
|
-
return
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
describe security_policy do
|
|
9
|
-
its('EnableAdminAccount') { should eq 1 }
|
|
10
|
-
its('EnableGuestAccount') { should eq 0 }
|
|
11
|
-
end
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
if ENV['DOCKER']
|
|
3
|
-
STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
|
|
4
|
-
return
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
# based on operating system we select the available service
|
|
8
|
-
if ['centos', 'fedora', 'freebsd', 'opensuse'].include?(os[:family])
|
|
9
|
-
# CentOS, Fedora
|
|
10
|
-
unavailable_service = 'ssh'
|
|
11
|
-
available_service = 'sshd'
|
|
12
|
-
elsif ['debian'].include?(os[:family])
|
|
13
|
-
# Debian
|
|
14
|
-
unavailable_service = 'clamav'
|
|
15
|
-
available_service = 'ssh'
|
|
16
|
-
elsif ['ubuntu'].include?(os[:family])
|
|
17
|
-
# Ubuntu
|
|
18
|
-
unavailable_service = 'sshd'
|
|
19
|
-
available_service = 'ssh'
|
|
20
|
-
elsif os.windows?
|
|
21
|
-
# Ubuntu
|
|
22
|
-
unavailable_service = 'sshd'
|
|
23
|
-
available_service = 'dhcp'
|
|
24
|
-
elsif ['aix'].include?(os[:family])
|
|
25
|
-
unavailable_service = 'clamav'
|
|
26
|
-
available_service = 'xntpd'
|
|
27
|
-
elsif os.solaris?
|
|
28
|
-
unavailable_service = 'clamav'
|
|
29
|
-
available_service = 'ssh'
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe service(unavailable_service) do
|
|
33
|
-
it { should_not be_enabled }
|
|
34
|
-
it { should_not be_installed }
|
|
35
|
-
it { should_not be_running }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe service(available_service) do
|
|
39
|
-
it { should be_enabled }
|
|
40
|
-
it { should be_installed }
|
|
41
|
-
it { should be_running }
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# extra test for ubuntu upstart with systemv service
|
|
45
|
-
if os[:family] == 'ubuntu' && os[:release] == '12.04'
|
|
46
|
-
describe upstart_service('ssh') do
|
|
47
|
-
it { should be_enabled }
|
|
48
|
-
it { should be_installed }
|
|
49
|
-
it { should be_running }
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# extra tests for alt. runit on centos with runit_service
|
|
54
|
-
if os[:family] == 'centos' && os[:release].to_i >= 6
|
|
55
|
-
describe runit_service('running-runit-service') do
|
|
56
|
-
it { should be_enabled }
|
|
57
|
-
it { should be_installed }
|
|
58
|
-
it { should be_running }
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe runit_service('not-running-runit-service') do
|
|
62
|
-
it { should be_enabled }
|
|
63
|
-
it { should be_installed }
|
|
64
|
-
it { should_not be_running }
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe runit_service('not-enabled-runit-service') do
|
|
68
|
-
it { should_not be_enabled }
|
|
69
|
-
it { should be_installed }
|
|
70
|
-
it { should_not be_running }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# alt. ctl location
|
|
74
|
-
describe runit_service('running-runit-service', '/opt/chef/embedded/sbin/sv') do
|
|
75
|
-
it { should be_enabled }
|
|
76
|
-
it { should be_installed }
|
|
77
|
-
it { should be_running }
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
describe runit_service('unknown') do
|
|
81
|
-
it { should_not be_enabled }
|
|
82
|
-
it { should_not be_installed }
|
|
83
|
-
it { should_not be_running }
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
describe upstart_service('upstart-running') do
|
|
87
|
-
it { should_not be_enabled }
|
|
88
|
-
it { should be_installed }
|
|
89
|
-
it { should be_running }
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
describe upstart_service('upstart-enabled-and-running') do
|
|
93
|
-
it { should be_enabled }
|
|
94
|
-
it { should be_installed }
|
|
95
|
-
it { should be_running }
|
|
96
|
-
its('type') { should be 'upstart' }
|
|
97
|
-
its('name') { should be 'upstart-enabled-and-running' }
|
|
98
|
-
its('description') { should be nil }
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
describe upstart_service('upstart-enabled-not-running') do
|
|
102
|
-
it { should be_enabled }
|
|
103
|
-
it { should be_installed }
|
|
104
|
-
it { should_not be_running }
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
describe upstart_service('unknown') do
|
|
108
|
-
it { should_not be_enabled }
|
|
109
|
-
it { should_not be_installed }
|
|
110
|
-
it { should_not be_running }
|
|
111
|
-
its('type') { should be nil }
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# extra tests for sys-v runlevels
|
|
116
|
-
if os[:family] == 'centos' && os[:release].to_i <= 6
|
|
117
|
-
describe service('sshd').runlevels do
|
|
118
|
-
its('keys') { should include(2) }
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
describe service('sshd').runlevels(2, 4) do
|
|
122
|
-
it { should be_enabled }
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
describe service('sshd').runlevels(0, 1) do
|
|
126
|
-
it { should_not be_enabled }
|
|
127
|
-
end
|
|
128
|
-
end
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
if ['centos', 'redhat', 'fedora', 'opensuse', 'debian', 'ubuntu'].include?(os[:family])
|
|
4
|
-
userinfo = {
|
|
5
|
-
name: 'root',
|
|
6
|
-
group: 'root',
|
|
7
|
-
uid: 0,
|
|
8
|
-
gid: 0,
|
|
9
|
-
groups: ["root"],
|
|
10
|
-
home: '/root',
|
|
11
|
-
shell: '/bin/bash',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
# different groupset for centos 5
|
|
15
|
-
userinfo[:groups] = ["root", "bin", "daemon", "sys", "adm", "disk", "wheel"] \
|
|
16
|
-
if os[:release].to_i == 5
|
|
17
|
-
elsif ['freebsd'].include?(os[:family])
|
|
18
|
-
userinfo = {
|
|
19
|
-
name: 'root',
|
|
20
|
-
group: 'wheel',
|
|
21
|
-
uid: 0,
|
|
22
|
-
gid: 0,
|
|
23
|
-
groups: "wheel", # at least this group should be there
|
|
24
|
-
home: '/root',
|
|
25
|
-
shell: '/bin/csh',
|
|
26
|
-
}
|
|
27
|
-
elsif os.windows?
|
|
28
|
-
userinfo = {
|
|
29
|
-
name: 'Administrator',
|
|
30
|
-
group: nil,
|
|
31
|
-
uid: nil,
|
|
32
|
-
gid: nil,
|
|
33
|
-
groups: nil,
|
|
34
|
-
home: nil,
|
|
35
|
-
shell: nil,
|
|
36
|
-
}
|
|
37
|
-
elsif os[:family] == 'aix'
|
|
38
|
-
userinfo = {
|
|
39
|
-
name: 'bin',
|
|
40
|
-
group: 'bin',
|
|
41
|
-
uid: 2,
|
|
42
|
-
gid: 2,
|
|
43
|
-
groups: "adm", # at least this group should be there
|
|
44
|
-
home: '/bin',
|
|
45
|
-
shell: nil,
|
|
46
|
-
#mindays: 0,
|
|
47
|
-
#maxdays: 0,
|
|
48
|
-
warndays: 0,
|
|
49
|
-
}
|
|
50
|
-
elsif os.solaris?
|
|
51
|
-
if os[:release].to_i > 10
|
|
52
|
-
userinfo = {
|
|
53
|
-
name: 'root',
|
|
54
|
-
group: 'root',
|
|
55
|
-
uid: 0,
|
|
56
|
-
gid: 0,
|
|
57
|
-
groups: "sys", # at least this group should be there
|
|
58
|
-
home: '/root',
|
|
59
|
-
shell: '/usr/bin/bash',
|
|
60
|
-
}
|
|
61
|
-
else
|
|
62
|
-
userinfo = {
|
|
63
|
-
name: 'root',
|
|
64
|
-
group: 'root',
|
|
65
|
-
uid: 0,
|
|
66
|
-
gid: 0,
|
|
67
|
-
groups: "sys", # at least this group should be there
|
|
68
|
-
home: '/',
|
|
69
|
-
shell: '/sbin/sh',
|
|
70
|
-
}
|
|
71
|
-
end
|
|
72
|
-
else
|
|
73
|
-
userinfo = {}
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
if os.windows?
|
|
77
|
-
describe user(userinfo[:name]) do
|
|
78
|
-
it { should exist }
|
|
79
|
-
end
|
|
80
|
-
else
|
|
81
|
-
describe user(userinfo[:name]) do
|
|
82
|
-
it { should exist }
|
|
83
|
-
userinfo.each do |k, v|
|
|
84
|
-
next if k.to_sym == :name
|
|
85
|
-
|
|
86
|
-
# check that the user is part of the groups
|
|
87
|
-
if k.to_s == 'groups'
|
|
88
|
-
# TODO: do not run those tests on docker yet
|
|
89
|
-
its(k) { should include v } unless ENV['DOCKER']
|
|
90
|
-
# default eq comparison
|
|
91
|
-
else
|
|
92
|
-
its(k) { should eq v }
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
return unless os.windows?
|
|
4
|
-
|
|
5
|
-
# script that may have multiple lines
|
|
6
|
-
vbscript = <<-EOH
|
|
7
|
-
WScript.Echo "hello"
|
|
8
|
-
EOH
|
|
9
|
-
|
|
10
|
-
describe vbscript(vbscript) do
|
|
11
|
-
its('stdout') { should eq "hello\r\n" }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# remove whitespace \r\n from stdout
|
|
15
|
-
describe vbscript(vbscript) do
|
|
16
|
-
its('strip') { should eq "hello" }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# ensure that we do not require a newline
|
|
20
|
-
describe vbscript("Wscript.Stdout.Write \"hello\"") do
|
|
21
|
-
its('stdout') { should eq 'hello' }
|
|
22
|
-
end
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
unless os.windows?
|
|
4
|
-
STDERR.puts "\033[1;33mTODO: Not running #{__FILE__} because we are not on Windows.\033[0m"
|
|
5
|
-
return
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
# Get-WmiObject win32_service or Get-WmiObject -class win32_service
|
|
9
|
-
# returns an array of service objects
|
|
10
|
-
describe wmi({class: 'win32_service'}) do
|
|
11
|
-
its('DisplayName') { should include 'Windows Remote Management (WS-Management)'}
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# Use win32_service with filter, it returns a single service object
|
|
15
|
-
describe wmi({
|
|
16
|
-
class: 'win32_service',
|
|
17
|
-
filter: "name like '%winrm%'"
|
|
18
|
-
}) do
|
|
19
|
-
its('Status') { should cmp 'ok' }
|
|
20
|
-
its('State') { should cmp 'Running' }
|
|
21
|
-
its('ExitCode') { should cmp 0 }
|
|
22
|
-
its('DisplayName') { should eq 'Windows Remote Management (WS-Management)'}
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# TODO: this works on domain controllers only
|
|
26
|
-
describe wmi({
|
|
27
|
-
class: 'RSOP_SecuritySettingNumeric',
|
|
28
|
-
namespace: 'root\\rsop\\computer',
|
|
29
|
-
filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1'
|
|
30
|
-
}) do
|
|
31
|
-
its('Setting') { should eq 1 }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# new syntax
|
|
35
|
-
describe wmi({
|
|
36
|
-
namespace: 'root\rsop\computer',
|
|
37
|
-
query: "SELECT Setting FROM RSOP_SecuritySettingBoolean WHERE KeyName='LSAAnonymousNameLookup' AND Precedence=1"
|
|
38
|
-
}) do
|
|
39
|
-
its('Setting') { should eq false }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
describe wmi({
|
|
43
|
-
namespace: 'root\cimv2',
|
|
44
|
-
query: 'SELECT filesystem FROM win32_logicaldisk WHERE drivetype=3'
|
|
45
|
-
}).params.values.join do
|
|
46
|
-
it { should eq 'NTFS' }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# deprecated syntax
|
|
50
|
-
describe wmi('win32_service') do
|
|
51
|
-
its('DisplayName') { should include 'Windows Remote Management (WS-Management)'}
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe wmi('RSOP_SecuritySettingNumeric', {
|
|
55
|
-
namespace: 'root\\rsop\\computer',
|
|
56
|
-
filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1'
|
|
57
|
-
}) do
|
|
58
|
-
its('Setting') { should eq 1 }
|
|
59
|
-
its('setting') { should eq 1 }
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe wmi('win32_service', {
|
|
63
|
-
filter: "name like '%winrm%'"
|
|
64
|
-
}) do
|
|
65
|
-
its('DisplayName') { should eq 'Windows Remote Management (WS-Management)'}
|
|
66
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
describe command('echo hello') do
|
|
6
|
-
its('stdout') { should eq "hello\n" }
|
|
7
|
-
its('stderr') { should eq '' }
|
|
8
|
-
its('exit_status') { should eq 0 }
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe command('>&2 echo error') do
|
|
12
|
-
its('stdout') { should eq '' }
|
|
13
|
-
its('stderr') { should eq "error\n" }
|
|
14
|
-
its('exit_status') { should eq 0 }
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
describe command('exit 123') do
|
|
18
|
-
its('stdout') { should eq '' }
|
|
19
|
-
its('stderr') { should eq '' }
|
|
20
|
-
its('exit_status') { should eq 123 }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe command('/bin/sh').exist? do
|
|
24
|
-
it { should eq true }
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe command('sh').exist? do
|
|
28
|
-
it { should eq true }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe command('this is not existing').exist? do
|
|
32
|
-
it { should eq false }
|
|
33
|
-
end
|
data/test/resource/dsl_test.rb
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
describe command('echo hello') do
|
|
6
|
-
its('stdout') { should eq "hello\n" }
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
describe 'describe + it + expect' do
|
|
10
|
-
it 'should echo something' do
|
|
11
|
-
out = rand.to_s
|
|
12
|
-
expect(command("echo -n #{out}").stdout).to eq(out)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe 'describe and expect without it' do
|
|
17
|
-
it 'will raise an error' do
|
|
18
|
-
expect(proc{
|
|
19
|
-
describe rand.to_s do
|
|
20
|
-
expect(true).to eq(true)
|
|
21
|
-
end
|
|
22
|
-
}).to raise_error StandardError
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
rule 'rule + describe' do
|
|
27
|
-
out = rand.to_s
|
|
28
|
-
describe command("echo -n #{out}") do
|
|
29
|
-
its('stdout') { should eq out }
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
rule 'rule + describe + it + expect' do
|
|
34
|
-
out = rand.to_s
|
|
35
|
-
describe 'a rule' do
|
|
36
|
-
it 'must echo something' do
|
|
37
|
-
expect(command("echo -n #{out}").stdout).to eq(out)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
rule 'rule + expect only' do
|
|
43
|
-
out = rand.to_s
|
|
44
|
-
expect(command("echo -n #{out}").stdout).to eq(out)
|
|
45
|
-
end
|