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
data/test/unit/profile_test.rb
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/profile_context'
|
|
7
|
-
|
|
8
|
-
describe Inspec::Profile do
|
|
9
|
-
let(:logger) { Minitest::Mock.new }
|
|
10
|
-
let(:home) { MockLoader.home }
|
|
11
|
-
|
|
12
|
-
describe 'with an empty profile' do
|
|
13
|
-
let(:profile) { MockLoader.load_profile('empty-metadata') }
|
|
14
|
-
|
|
15
|
-
it 'has no metadata' do
|
|
16
|
-
profile.params[:name].must_be_nil
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'has no controls' do
|
|
20
|
-
profile.params[:controls].must_equal({})
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe 'with an empty profile (legacy mode)' do
|
|
25
|
-
let(:profile) { MockLoader.load_profile('legacy-empty-metadata') }
|
|
26
|
-
|
|
27
|
-
it 'has no metadata' do
|
|
28
|
-
profile.params[:name].must_be_nil
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'has no controls' do
|
|
32
|
-
profile.params[:controls].must_equal({})
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe 'with simple metadata in profile' do
|
|
37
|
-
let(:profile_id) { 'simple-metadata' }
|
|
38
|
-
let(:profile) { MockLoader.load_profile(profile_id) }
|
|
39
|
-
|
|
40
|
-
it 'has metadata' do
|
|
41
|
-
profile.params[:name].must_equal 'yumyum profile'
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'has no controls' do
|
|
45
|
-
profile.params[:controls].must_equal({})
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'can overwrite the profile ID' do
|
|
49
|
-
testID = rand.to_s
|
|
50
|
-
res = MockLoader.load_profile(profile_id, id: testID)
|
|
51
|
-
res.params[:name].must_equal testID
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe 'with simple metadata in profile (legacy mode)' do
|
|
56
|
-
let(:profile) { MockLoader.load_profile('legacy-simple-metadata') }
|
|
57
|
-
|
|
58
|
-
it 'has metadata' do
|
|
59
|
-
profile.params[:name].must_equal 'metadata profile'
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it 'has no controls' do
|
|
63
|
-
profile.params[:controls].must_equal({})
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe 'when checking' do
|
|
68
|
-
describe 'an empty profile' do
|
|
69
|
-
let(:profile_id) { 'empty-metadata' }
|
|
70
|
-
|
|
71
|
-
it 'prints loads of warnings' do
|
|
72
|
-
logger.expect :info, nil, ["Checking profile in #{home}/mock/profiles/#{profile_id}"]
|
|
73
|
-
logger.expect :error, nil, ["Missing profile name in inspec.yml"]
|
|
74
|
-
logger.expect :error, nil, ["Missing profile version in inspec.yml"]
|
|
75
|
-
logger.expect :warn, nil, ["Missing profile title in inspec.yml"]
|
|
76
|
-
logger.expect :warn, nil, ["Missing profile summary in inspec.yml"]
|
|
77
|
-
logger.expect :warn, nil, ["Missing profile maintainer in inspec.yml"]
|
|
78
|
-
logger.expect :warn, nil, ["Missing profile copyright in inspec.yml"]
|
|
79
|
-
logger.expect :warn, nil, ['No controls or tests were defined.']
|
|
80
|
-
|
|
81
|
-
result = MockLoader.load_profile(profile_id, {logger: logger}).check
|
|
82
|
-
# verify logger output
|
|
83
|
-
logger.verify
|
|
84
|
-
|
|
85
|
-
# verify hash result
|
|
86
|
-
result[:summary][:valid].must_equal false
|
|
87
|
-
result[:summary][:location].must_equal "#{home}/mock/profiles/#{profile_id}"
|
|
88
|
-
result[:summary][:profile].must_equal nil
|
|
89
|
-
result[:summary][:controls].must_equal 0
|
|
90
|
-
result[:errors].length.must_equal 2
|
|
91
|
-
result[:warnings].length.must_equal 5
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
describe 'an empty profile (legacy mode)' do
|
|
96
|
-
let(:profile_id) { 'legacy-empty-metadata' }
|
|
97
|
-
|
|
98
|
-
it 'prints loads of warnings' do
|
|
99
|
-
metadata_rb = "#{home}/mock/profiles/#{profile_id}/metadata.rb"
|
|
100
|
-
logger.expect :info, nil, ["Checking profile in #{home}/mock/profiles/#{profile_id}"]
|
|
101
|
-
logger.expect :error, nil, ["Missing profile name in metadata.rb"]
|
|
102
|
-
logger.expect :warn, nil, ['The use of `metadata.rb` is deprecated. Use `inspec.yml`.']
|
|
103
|
-
logger.expect :error, nil, ["Missing profile version in metadata.rb"]
|
|
104
|
-
logger.expect :warn, nil, ["Missing profile title in metadata.rb"]
|
|
105
|
-
logger.expect :warn, nil, ["Missing profile summary in metadata.rb"]
|
|
106
|
-
logger.expect :warn, nil, ["Missing profile maintainer in metadata.rb"]
|
|
107
|
-
logger.expect :warn, nil, ["Missing profile copyright in metadata.rb"]
|
|
108
|
-
logger.expect :warn, nil, ['No controls or tests were defined.']
|
|
109
|
-
|
|
110
|
-
result = MockLoader.load_profile(profile_id, {logger: logger}).check
|
|
111
|
-
# verify logger output
|
|
112
|
-
logger.verify
|
|
113
|
-
|
|
114
|
-
# verify hash result
|
|
115
|
-
result[:summary][:valid].must_equal false
|
|
116
|
-
result[:summary][:location].must_equal "#{home}/mock/profiles/#{profile_id}"
|
|
117
|
-
result[:summary][:profile].must_equal nil
|
|
118
|
-
result[:summary][:controls].must_equal 0
|
|
119
|
-
result[:errors].length.must_equal 2
|
|
120
|
-
result[:warnings].length.must_equal 6
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
describe 'a complete metadata profile' do
|
|
125
|
-
let(:profile_id) { 'complete-metadata' }
|
|
126
|
-
let(:profile) { MockLoader.load_profile(profile_id, {logger: logger}) }
|
|
127
|
-
|
|
128
|
-
it 'prints ok messages' do
|
|
129
|
-
logger.expect :info, nil, ["Checking profile in #{home}/mock/profiles/#{profile_id}"]
|
|
130
|
-
logger.expect :info, nil, ['Metadata OK.']
|
|
131
|
-
logger.expect :warn, nil, ['No controls or tests were defined.']
|
|
132
|
-
|
|
133
|
-
result = profile.check
|
|
134
|
-
|
|
135
|
-
# verify logger output
|
|
136
|
-
logger.verify
|
|
137
|
-
|
|
138
|
-
# verify hash result
|
|
139
|
-
result[:summary][:valid].must_equal true
|
|
140
|
-
result[:summary][:location].must_equal "#{home}/mock/profiles/#{profile_id}"
|
|
141
|
-
result[:summary][:profile].must_equal 'name'
|
|
142
|
-
result[:summary][:controls].must_equal 0
|
|
143
|
-
result[:errors].length.must_equal 0
|
|
144
|
-
result[:warnings].length.must_equal 1
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
describe 'a complete metadata profile (legacy mode)' do
|
|
149
|
-
let(:profile_id) { 'legacy-complete-metadata' }
|
|
150
|
-
let(:profile) { MockLoader.load_profile(profile_id, {logger: logger}) }
|
|
151
|
-
|
|
152
|
-
it 'prints ok messages' do
|
|
153
|
-
logger.expect :info, nil, ["Checking profile in #{home}/mock/profiles/#{profile_id}"]
|
|
154
|
-
logger.expect :warn, nil, ['The use of `metadata.rb` is deprecated. Use `inspec.yml`.']
|
|
155
|
-
logger.expect :info, nil, ['Metadata OK.']
|
|
156
|
-
# NB we only look at content that is loaded, i.e., there're no empty directories anymore
|
|
157
|
-
# logger.expect :warn, nil, ["Profile uses deprecated `test` directory, rename it to `controls`."]
|
|
158
|
-
logger.expect :warn, nil, ['No controls or tests were defined.']
|
|
159
|
-
|
|
160
|
-
result = profile.check
|
|
161
|
-
|
|
162
|
-
# verify logger output
|
|
163
|
-
logger.verify
|
|
164
|
-
|
|
165
|
-
# verify hash result
|
|
166
|
-
result[:summary][:valid].must_equal true
|
|
167
|
-
result[:summary][:location].must_equal "#{home}/mock/profiles/#{profile_id}"
|
|
168
|
-
result[:summary][:profile].must_equal 'name'
|
|
169
|
-
result[:summary][:controls].must_equal 0
|
|
170
|
-
result[:errors].length.must_equal 0
|
|
171
|
-
result[:warnings].length.must_equal 2
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it 'doesnt have constraints on supported systems' do
|
|
175
|
-
profile.metadata.params[:supports].must_equal([])
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
describe 'a complete metadata profile with controls' do
|
|
180
|
-
let(:profile_id) { 'complete-profile' }
|
|
181
|
-
|
|
182
|
-
it 'prints ok messages and counts the controls' do
|
|
183
|
-
logger.expect :info, nil, ["Checking profile in #{home}/mock/profiles/#{profile_id}"]
|
|
184
|
-
logger.expect :info, nil, ['Metadata OK.']
|
|
185
|
-
logger.expect :info, nil, ['Found 1 controls.']
|
|
186
|
-
logger.expect :info, nil, ['Control definitions OK.']
|
|
187
|
-
|
|
188
|
-
result = MockLoader.load_profile(profile_id, {logger: logger}).check
|
|
189
|
-
# verify logger output
|
|
190
|
-
logger.verify
|
|
191
|
-
|
|
192
|
-
# verify hash result
|
|
193
|
-
result[:summary][:valid].must_equal true
|
|
194
|
-
result[:summary][:location].must_equal "#{home}/mock/profiles/#{profile_id}"
|
|
195
|
-
result[:summary][:profile].must_equal 'complete'
|
|
196
|
-
result[:summary][:controls].must_equal 1
|
|
197
|
-
result[:errors].length.must_equal 0
|
|
198
|
-
result[:warnings].length.must_equal 0
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
describe 'a complete metadata profile with controls in a tarball' do
|
|
203
|
-
let(:profile_id) { 'complete-profile' }
|
|
204
|
-
let(:profile_path) { MockLoader.profile_tgz(profile_id) }
|
|
205
|
-
let(:profile) { MockLoader.load_profile(profile_path, {logger: logger}) }
|
|
206
|
-
|
|
207
|
-
it 'prints ok messages and counts the controls' do
|
|
208
|
-
logger.expect :info, nil, ["Checking profile in #{home}/mock/profiles/#{profile_id}"]
|
|
209
|
-
logger.expect :info, nil, ['Metadata OK.']
|
|
210
|
-
logger.expect :info, nil, ['Found 1 controls.']
|
|
211
|
-
logger.expect :info, nil, ['Control definitions OK.']
|
|
212
|
-
|
|
213
|
-
result = MockLoader.load_profile(profile_id, {logger: logger}).check
|
|
214
|
-
# verify logger output
|
|
215
|
-
logger.verify
|
|
216
|
-
|
|
217
|
-
# verify hash result
|
|
218
|
-
result[:summary][:valid].must_equal true
|
|
219
|
-
result[:summary][:location].must_equal "#{home}/mock/profiles/#{profile_id}"
|
|
220
|
-
result[:summary][:profile].must_equal 'complete'
|
|
221
|
-
result[:summary][:controls].must_equal 1
|
|
222
|
-
result[:errors].length.must_equal 0
|
|
223
|
-
result[:warnings].length.must_equal 0
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
describe 'a complete metadata profile with controls in zipfile' do
|
|
228
|
-
let(:profile_id) { 'complete-profile' }
|
|
229
|
-
let(:profile_path) { MockLoader.profile_zip(profile_id) }
|
|
230
|
-
let(:profile) { MockLoader.load_profile(profile_path, {logger: logger}) }
|
|
231
|
-
|
|
232
|
-
it 'prints ok messages and counts the controls' do
|
|
233
|
-
logger.expect :info, nil, ["Checking profile in #{home}/mock/profiles/#{profile_id}"]
|
|
234
|
-
logger.expect :info, nil, ['Metadata OK.']
|
|
235
|
-
logger.expect :info, nil, ['Found 1 controls.']
|
|
236
|
-
logger.expect :info, nil, ['Control definitions OK.']
|
|
237
|
-
|
|
238
|
-
result = MockLoader.load_profile(profile_id, {logger: logger}).check
|
|
239
|
-
# verify logger output
|
|
240
|
-
logger.verify
|
|
241
|
-
|
|
242
|
-
# verify hash result
|
|
243
|
-
result[:summary][:valid].must_equal true
|
|
244
|
-
result[:summary][:location].must_equal "#{home}/mock/profiles/#{profile_id}"
|
|
245
|
-
result[:summary][:profile].must_equal 'complete'
|
|
246
|
-
result[:summary][:controls].must_equal 1
|
|
247
|
-
result[:errors].length.must_equal 0
|
|
248
|
-
result[:warnings].length.must_equal 0
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Stephan Renatus
|
|
3
|
-
|
|
4
|
-
require 'helper'
|
|
5
|
-
|
|
6
|
-
describe 'Inspec::Resources::ApacheConf' do
|
|
7
|
-
let(:resource) { load_resource('apache_conf') }
|
|
8
|
-
|
|
9
|
-
it 'verify content is a string' do
|
|
10
|
-
_(resource.content).must_be_kind_of String
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'verify params is a hashmap' do
|
|
14
|
-
_(resource.params).must_be_kind_of Hash
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'reads values in apache2.conf' do
|
|
18
|
-
_(resource.params('ServerRoot')).must_equal ['"/etc/apache2"']
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'reads values in from the direct include ports.conf' do
|
|
22
|
-
_(resource.params('Listen').sort).must_equal ['443', '80']
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'reads values in from wildcard include serve-cgi-bin.conf' do
|
|
26
|
-
# TODO(sr) currently, the parser only merges parameter across separate
|
|
27
|
-
# source files, not in one file
|
|
28
|
-
_(resource.params('Define')).must_equal ['ENABLE_USR_LIB_CGI_BIN',
|
|
29
|
-
'ENABLE_USR_LIB_CGI_BIN']
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe 'Inspec::Resources::AptRepo' do
|
|
9
|
-
|
|
10
|
-
it 'check apt on ubuntu' do
|
|
11
|
-
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/')
|
|
12
|
-
_(resource.exists?).must_equal true
|
|
13
|
-
_(resource.enabled?).must_equal true
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'check apt on ubuntu with ppa' do
|
|
17
|
-
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'ubuntu-wine/ppa')
|
|
18
|
-
_(resource.exists?).must_equal true
|
|
19
|
-
_(resource.enabled?).must_equal true
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it 'check apt on ubuntu with ppa' do
|
|
23
|
-
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'ppa:ubuntu-wine/ppa')
|
|
24
|
-
_(resource.exists?).must_equal true
|
|
25
|
-
_(resource.enabled?).must_equal true
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'check apt on debian' do
|
|
29
|
-
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/')
|
|
30
|
-
_(resource.exists?).must_equal true
|
|
31
|
-
_(resource.enabled?).must_equal true
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it 'check apt on unknown os' do
|
|
35
|
-
resource = MockLoader.new(:undefined).load_resource('apt', 'ubuntu-wine/ppa')
|
|
36
|
-
_(resource.exists?).must_equal false
|
|
37
|
-
_(resource.enabled?).must_equal false
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# check ppa resource
|
|
41
|
-
it 'check apt on ubuntu' do
|
|
42
|
-
resource = MockLoader.new(:ubuntu1504).load_resource('ppa', 'ubuntu-wine/ppa')
|
|
43
|
-
_(resource.exists?).must_equal true
|
|
44
|
-
_(resource.enabled?).must_equal true
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe 'Inspec::Resources::AuditPolicy' do
|
|
9
|
-
it 'check audit policy parsing' do
|
|
10
|
-
resource = MockLoader.new(:windows).load_resource('audit_policy')
|
|
11
|
-
_(resource.send('User Account Management')).must_equal 'Success'
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe 'Inspec::Resources::AuditDaemonConf' do
|
|
9
|
-
it 'check audit daemon config parsing' do
|
|
10
|
-
resource = MockLoader.new(:windows).load_resource('auditd_conf')
|
|
11
|
-
_(resource.space_left_action).must_equal 'SYSLOG'
|
|
12
|
-
_(resource.action_mail_acct).must_equal 'root'
|
|
13
|
-
_(resource.tcp_listen_queue).must_equal '5'
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe 'Inspec::Resources::AuditDaemonRules' do
|
|
9
|
-
it 'auditd_rules interface' do
|
|
10
|
-
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
|
11
|
-
_(resource.send('lines')).must_equal [
|
|
12
|
-
'-a always,exit -F arch=b64 -S open,openat -F exit=-EACCES -F key=access',
|
|
13
|
-
'-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat -F auid>=500 f24!=0 -F key=perm_mod',
|
|
14
|
-
'-w /etc/ssh/sshd_config -p rwxa -k CFG_sshd_config',
|
|
15
|
-
]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'auditd_rules syscall interface' do
|
|
19
|
-
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
|
20
|
-
_(resource.send('syscall', 'open').send('rules')).must_equal [
|
|
21
|
-
{:syscall=>"open", :list=>"exit", :action=>"always", :fields=>["arch=b64", "exit=-EACCES", "key=access"], :arch=>"b64", :exit=>"-EACCES", :key=>"access"}
|
|
22
|
-
]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'auditd_rules syscall query chaining' do
|
|
26
|
-
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
|
27
|
-
_(resource.send('syscall', 'open').field('key', 'access').send('rules')).must_equal [
|
|
28
|
-
{:syscall=>"open", :list=>"exit", :action=>"always", :fields=>["arch=b64", "exit=-EACCES", "key=access"], :arch=>"b64", :exit=>"-EACCES", :key=>"access"}
|
|
29
|
-
]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'auditd_rules syscall query chaining with short syntax' do
|
|
33
|
-
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
|
34
|
-
_(resource.send('syscall', 'open').key('access').list('exit').send('rules')).must_equal [
|
|
35
|
-
{:syscall=>"open", :list=>"exit", :action=>"always", :fields=>["arch=b64", "exit=-EACCES", "key=access"], :arch=>"b64", :exit=>"-EACCES", :key=>"access"}
|
|
36
|
-
]
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'check auditd_rules syscall query chaining empty results' do
|
|
40
|
-
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
|
41
|
-
_(resource.send('syscall', 'open').field('key', 'access').field('foo', 'bar').send('rules')).must_equal []
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
it 'check auditd_rules file interface' do
|
|
46
|
-
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
|
47
|
-
_(resource.send('file', '/etc/ssh/sshd_config').send('rules')).must_equal [
|
|
48
|
-
{ file: '/etc/ssh/sshd_config', key: 'CFG_sshd_config', permissions: 'rwxa'},
|
|
49
|
-
]
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it 'check auditd_rules key interface' do
|
|
53
|
-
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
|
54
|
-
_(resource.send('key', 'CFG_sshd_config').send('rules')).must_equal [
|
|
55
|
-
{ file: '/etc/ssh/sshd_config', key: 'CFG_sshd_config', permissions: 'rwxa'},
|
|
56
|
-
]
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'check auditd_rules status interface' do
|
|
60
|
-
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
|
61
|
-
_(resource.send('status')).must_equal({
|
|
62
|
-
'enabled' => '1',
|
|
63
|
-
'flag' => '2',
|
|
64
|
-
'pid' => '547',
|
|
65
|
-
'rate_limit' => '0',
|
|
66
|
-
'backlog_limit' => '8192',
|
|
67
|
-
'lost' => '0',
|
|
68
|
-
'backlog' => '0',
|
|
69
|
-
'loginuid_immutable' => '0 unlocked',
|
|
70
|
-
})
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it 'check auditd_rules status interface querying a key' do
|
|
74
|
-
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
|
75
|
-
_(resource.send('status', 'enabled')).must_equal('1')
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# TODO(sr) figure out how to feed resource the legacy auditctl mock cmd output
|
|
79
|
-
# it 'check legacy audit policy parsing' do
|
|
80
|
-
# resource = MockLoader.new(:undefined).load_resource('auditd_rules')
|
|
81
|
-
# _(resource.send('LIST_RULES')).must_equal [
|
|
82
|
-
# 'exit,always syscall=rmdir,unlink',
|
|
83
|
-
# 'exit,always auid=1001 (0x3e9) syscall=open',
|
|
84
|
-
# 'exit,always watch=/etc/group perm=wa',
|
|
85
|
-
# 'exit,always watch=/etc/passwd perm=wa',
|
|
86
|
-
# 'exit,always watch=/etc/shadow perm=wa',
|
|
87
|
-
# 'exit,always watch=/etc/sudoers perm=wa',
|
|
88
|
-
# 'exit,always watch=/etc/secret_directory perm=r',
|
|
89
|
-
# ]
|
|
90
|
-
# end
|
|
91
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe Inspec::Resources::Bash do
|
|
9
|
-
let(:x) { rand.to_s }
|
|
10
|
-
let(:resource) { load_resource('bash', '$("'+x+'")') }
|
|
11
|
-
|
|
12
|
-
it 'prints as a bash command' do
|
|
13
|
-
resource.to_s.must_equal 'Bash command $("'+x+'")'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'wraps the command' do
|
|
17
|
-
resource.command.must_equal "bash -c \\$\\(\\\"#{x}\\\"\\)"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'can specify an executable path' do
|
|
21
|
-
resource = load_resource('bash', '$("'+x+'")', path: '/bin/bash')
|
|
22
|
-
resource.command.must_equal "/bin/bash -c \\$\\(\\\"#{x}\\\"\\)"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'can specify a arguments' do
|
|
26
|
-
resource = load_resource('bash', '$("'+x+'")', args: '-x -c')
|
|
27
|
-
resource.command.must_equal "bash -x -c \\$\\(\\\"#{x}\\\"\\)"
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe 'Inspec::Resources::Bond' do
|
|
9
|
-
|
|
10
|
-
it 'check linux bond on ubuntu' do
|
|
11
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('bond', 'bond0')
|
|
12
|
-
# bond must be available
|
|
13
|
-
resource.exist?.must_equal true
|
|
14
|
-
# eth0 is part of bond
|
|
15
|
-
_(resource.has_interface?('eth0')).must_equal true
|
|
16
|
-
_(resource.has_interface?('eth1')).must_equal false
|
|
17
|
-
_(resource.has_interface?('eth2')).must_equal true
|
|
18
|
-
# get all interfaces
|
|
19
|
-
_(resource.interfaces).must_equal %w{eth0 eth2}
|
|
20
|
-
# get proc content
|
|
21
|
-
_(resource.content).wont_equal nil
|
|
22
|
-
_(resource.content).wont_equal ''
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe 'Inspec::Resources::Bridge' do
|
|
9
|
-
|
|
10
|
-
it 'check linux bridge on ubuntu' do
|
|
11
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('bridge', 'br0')
|
|
12
|
-
_(resource.exists?).must_equal true
|
|
13
|
-
|
|
14
|
-
# check network interfaced attached to bridge
|
|
15
|
-
_(resource.has_interface?('eth0')).must_equal false
|
|
16
|
-
_(resource.has_interface?('eth1')).must_equal true
|
|
17
|
-
_(resource.has_interface?('eth2')).must_equal true
|
|
18
|
-
|
|
19
|
-
# get associated interfaces
|
|
20
|
-
_(resource.interfaces).must_equal %w{eth1 eth2}
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'check linux bridge on centos 7' do
|
|
24
|
-
resource = MockLoader.new(:centos7).load_resource('bridge', 'br0')
|
|
25
|
-
_(resource.exists?).must_equal true
|
|
26
|
-
|
|
27
|
-
# check network interfaced attached to bridge
|
|
28
|
-
_(resource.has_interface?('eth0')).must_equal false
|
|
29
|
-
_(resource.has_interface?('eth1')).must_equal true
|
|
30
|
-
_(resource.has_interface?('eth2')).must_equal true
|
|
31
|
-
|
|
32
|
-
# get associated interfaces
|
|
33
|
-
_(resource.interfaces).must_equal %w{eth1 eth2}
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'check windows bridge' do
|
|
37
|
-
resource = MockLoader.new(:windows).load_resource('bridge', 'Network Bridge')
|
|
38
|
-
_(resource.exists?).must_equal true
|
|
39
|
-
|
|
40
|
-
# get associated interfaces is not supported on windows
|
|
41
|
-
_(resource.interfaces).must_equal nil
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'check bridge on unsupported os' do
|
|
45
|
-
resource = MockLoader.new(:undefined).load_resource('bridge', 'br0')
|
|
46
|
-
_(resource.exists?).must_equal false
|
|
47
|
-
|
|
48
|
-
# check network interfaced attached to bridge
|
|
49
|
-
_(resource.has_interface?('eth0')).must_equal false
|
|
50
|
-
_(resource.has_interface?('eth1')).must_equal false
|
|
51
|
-
_(resource.has_interface?('eth2')).must_equal false
|
|
52
|
-
|
|
53
|
-
# get associated interfaces
|
|
54
|
-
_(resource.interfaces).must_equal nil
|
|
55
|
-
end
|
|
56
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe 'Inspec::Resources::CSV' do
|
|
9
|
-
describe 'when loading a valid csv' do
|
|
10
|
-
let (:resource) { load_resource('csv', 'example.csv') }
|
|
11
|
-
let (:params) {
|
|
12
|
-
{}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
it 'captures an array of params' do
|
|
16
|
-
_(resource.params).must_be_kind_of Array
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'gets all value lines' do
|
|
20
|
-
_(resource.params.length).must_equal 3
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'captures a hashmap of entries of a line' do
|
|
24
|
-
_(resource.params[0]).must_be_kind_of Hash
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it 'gets params by header fields' do
|
|
28
|
-
_(resource.params[0]['addressable']).must_equal 'ast'
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'retrieves nil if a param is missing' do
|
|
32
|
-
_(resource.params[0]['missing']).must_be_nil
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe 'Inspec::Resources::EtcGroup' do
|
|
9
|
-
let(:resource) { load_resource('etc_group') }
|
|
10
|
-
|
|
11
|
-
it 'verify /etc/group config parsing' do
|
|
12
|
-
_(resource.gids).must_equal [0, 33]
|
|
13
|
-
_(resource.groups).must_equal %w{ root www-data }
|
|
14
|
-
_(resource.users).must_equal %w{ www-data root }
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'verify group filter with no users' do
|
|
18
|
-
root_filter = resource.where(name: 'root')
|
|
19
|
-
_(root_filter.gids).must_equal [0]
|
|
20
|
-
_(root_filter.groups).must_equal ['root']
|
|
21
|
-
_(root_filter.users).must_equal []
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'verify group filter with users' do
|
|
25
|
-
www_filter = resource.where(name: 'www-data')
|
|
26
|
-
_(www_filter.gids).must_equal [33]
|
|
27
|
-
_(www_filter.groups).must_equal ['www-data']
|
|
28
|
-
_(www_filter.users).must_equal ['www-data', 'root']
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'verify group filter with wrong group' do
|
|
32
|
-
wrong_filter = resource.where(name: 'wrong_group')
|
|
33
|
-
_(wrong_filter.gids).must_equal []
|
|
34
|
-
_(wrong_filter.groups).must_equal []
|
|
35
|
-
_(wrong_filter.users).must_equal []
|
|
36
|
-
end
|
|
37
|
-
end
|