inspec 0.30.0 → 0.31.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,10 +0,0 @@
|
|
1
|
-
name: complete
|
2
|
-
title: complete example profile
|
3
|
-
maintainer: Chef Software, Inc.
|
4
|
-
copyright: Chef Software, Inc.
|
5
|
-
copyright_email: support@chef.io
|
6
|
-
license: Proprietary, All rights reserved
|
7
|
-
summary: Testing stub
|
8
|
-
version: 1.0.0
|
9
|
-
supports:
|
10
|
-
- os-family: linux
|
@@ -1,10 +0,0 @@
|
|
1
|
-
name: complete
|
2
|
-
title: complete example profile
|
3
|
-
maintainer: Chef Software, Inc.
|
4
|
-
copyright: Chef Software, Inc.
|
5
|
-
copyright_email: support@chef.io
|
6
|
-
license: Proprietary, All rights reserved
|
7
|
-
summary: Testing stub
|
8
|
-
version: 1.0.0
|
9
|
-
supports:
|
10
|
-
- os-family: linux
|
@@ -1 +0,0 @@
|
|
1
|
-
name: yumyum profile
|
data/test/unit/objects_test.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Dominik Richter
|
3
|
-
# author: Christoph Hartmann
|
4
|
-
|
5
|
-
require 'helper'
|
6
|
-
require 'inspec/objects'
|
7
|
-
|
8
|
-
describe 'Objects' do
|
9
|
-
describe 'Test' do
|
10
|
-
let(:obj) { Inspec::Test.new }
|
11
|
-
it 'constructs a simple resource+argument' do
|
12
|
-
obj.qualifier = [['resource'], ['arg']]
|
13
|
-
obj.to_ruby.must_equal "
|
14
|
-
describe resource do
|
15
|
-
its(\"arg\") { should }
|
16
|
-
end
|
17
|
-
".strip
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'constructs a simple resource+argument with to_s' do
|
21
|
-
obj.qualifier = [['resource'], ['to_s']]
|
22
|
-
obj.to_ruby.must_equal "
|
23
|
-
describe resource.to_s do
|
24
|
-
it { should }
|
25
|
-
end
|
26
|
-
".strip
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'constructs a simple resource+argument with to_i' do
|
30
|
-
obj.qualifier = [['resource'], ['to_i']]
|
31
|
-
obj.to_ruby.must_equal "
|
32
|
-
describe resource.to_i do
|
33
|
-
it { should }
|
34
|
-
end
|
35
|
-
".strip
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'constructs a simple resource+argument with array accessors' do
|
39
|
-
obj.qualifier = [['resource'], ['name[2]']]
|
40
|
-
obj.to_ruby.must_equal "
|
41
|
-
describe resource.name[2] do
|
42
|
-
it { should }
|
43
|
-
end
|
44
|
-
".strip
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'constructs a simple resource+argument with method calls' do
|
48
|
-
obj.qualifier = [['resource'], ['hello', 'world']]
|
49
|
-
obj.to_ruby.must_equal "
|
50
|
-
describe resource.hello(\"world\") do
|
51
|
-
it { should }
|
52
|
-
end
|
53
|
-
".strip
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'constructs a simple resource+argument with method calls' do
|
57
|
-
obj.qualifier = [['resource'], [:world]]
|
58
|
-
obj.to_ruby.must_equal "
|
59
|
-
describe resource do
|
60
|
-
its(\"world\") { should }
|
61
|
-
end
|
62
|
-
".strip
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/test/unit/plugin_test.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Christoph Hartmann
|
3
|
-
# author: Dominik Richter
|
4
|
-
|
5
|
-
# TODO: do not use helper, since all plugins are loaded statically
|
6
|
-
require 'minitest/autorun'
|
7
|
-
require 'minitest/spec'
|
8
|
-
require 'mocha/setup'
|
9
|
-
|
10
|
-
require 'inspec/plugins/cli'
|
11
|
-
require 'thor'
|
12
|
-
|
13
|
-
describe 'plugin system' do
|
14
|
-
describe 'with an empty profile' do
|
15
|
-
let(:cli_reg) { Inspec::Plugins::CLI }
|
16
|
-
|
17
|
-
before do
|
18
|
-
# since the registry is a global singleton, clean it before using
|
19
|
-
cli_reg.subcommands.clear
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'is empty' do
|
23
|
-
cli_reg.subcommands.must_equal({})
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'stores one cli plugin' do
|
27
|
-
plugin = {
|
28
|
-
klass: Thor.new,
|
29
|
-
subcommand_name: 'my_cmd',
|
30
|
-
usage: 'usage my_cmd',
|
31
|
-
description: 'desc of my_cmd',
|
32
|
-
options: { test: 1 }
|
33
|
-
}
|
34
|
-
cli_reg.add_subcommand(
|
35
|
-
plugin[:klass],
|
36
|
-
plugin[:subcommand_name],
|
37
|
-
plugin[:usage],
|
38
|
-
plugin[:description],
|
39
|
-
plugin[:options]
|
40
|
-
)
|
41
|
-
cli_reg.subcommands['my_cmd'].must_equal(plugin)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Inspec::Plugins::Resource do
|
4
|
-
let(:base) { Inspec::Plugins::Resource }
|
5
|
-
|
6
|
-
describe '#name' do
|
7
|
-
it "won't register a nil resource" do
|
8
|
-
Class.new(base) do name nil; end
|
9
|
-
Inspec::Resource.registry.keys.wont_include nil
|
10
|
-
Inspec::Resource.registry.keys.wont_include ''
|
11
|
-
end
|
12
|
-
|
13
|
-
it "will register a valid name" do
|
14
|
-
Class.new(base) do name 'hello'; end
|
15
|
-
Inspec::Resource.registry['hello'].wont_be :nil?
|
16
|
-
end
|
17
|
-
|
18
|
-
it "will create a good class name" do
|
19
|
-
Class.new(base) do name 'hello_world'; end
|
20
|
-
Inspec::Resource.registry['hello_world'].to_s
|
21
|
-
.must_equal 'Inspec::Resource::Registry::HelloWorld'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def create(&block)
|
26
|
-
random_name = (0...50).map { (65 + rand(26)).chr }.join
|
27
|
-
Class.new(base) do
|
28
|
-
name random_name
|
29
|
-
instance_eval &block
|
30
|
-
end
|
31
|
-
Inspec::Resource.registry[random_name]
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#desc' do
|
35
|
-
it "will register a description" do
|
36
|
-
expected = rand.to_s
|
37
|
-
create { desc expected }.desc.must_equal expected
|
38
|
-
end
|
39
|
-
|
40
|
-
it "can change the description" do
|
41
|
-
c = create { desc rand.to_s }
|
42
|
-
c.desc(x = rand.to_s)
|
43
|
-
c.desc.must_equal x
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#example' do
|
48
|
-
it "will register a description" do
|
49
|
-
expected = rand.to_s
|
50
|
-
create { example expected }.example.must_equal expected
|
51
|
-
end
|
52
|
-
|
53
|
-
it "can change the description" do
|
54
|
-
c = create { example rand.to_s }
|
55
|
-
c.example(x = rand.to_s)
|
56
|
-
c.example.must_equal x
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,345 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Dominik Richter
|
3
|
-
# author: Christoph Hartmann
|
4
|
-
|
5
|
-
require 'helper'
|
6
|
-
require 'inspec/profile_context'
|
7
|
-
|
8
|
-
class Module
|
9
|
-
include Minitest::Spec::DSL
|
10
|
-
end
|
11
|
-
|
12
|
-
module DescribeOneTest
|
13
|
-
it 'loads an empty describe.one' do
|
14
|
-
profile.load(format(context_format, 'describe.one'))
|
15
|
-
get_checks.must_equal([])
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'loads an empty describe.one block' do
|
19
|
-
profile.load(format(context_format, 'describe.one do; end'))
|
20
|
-
get_checks.must_equal([['describe.one', [], nil]])
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'loads a simple describe.one block' do
|
24
|
-
profile.load(format(context_format, '
|
25
|
-
describe.one do
|
26
|
-
describe true do; it { should eq true }; end
|
27
|
-
end'))
|
28
|
-
c = get_checks[0]
|
29
|
-
c[0].must_equal 'describe.one'
|
30
|
-
childs = c[1]
|
31
|
-
childs.length.must_equal 1
|
32
|
-
childs[0][0].must_equal 'describe'
|
33
|
-
childs[0][1].must_equal [true]
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'loads a complex describe.one block' do
|
37
|
-
profile.load(format(context_format, '
|
38
|
-
describe.one do
|
39
|
-
describe 0 do; it { should eq true }; end
|
40
|
-
describe 1 do; it { should eq true }; end
|
41
|
-
describe 2 do; it { should eq true }; end
|
42
|
-
end'))
|
43
|
-
c = get_checks[0]
|
44
|
-
c[0].must_equal 'describe.one'
|
45
|
-
childs = c[1]
|
46
|
-
childs.length.must_equal 3
|
47
|
-
childs.each_with_index do |ci, idx|
|
48
|
-
ci[0].must_equal 'describe'
|
49
|
-
ci[1].must_equal [idx]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe Inspec::ProfileContext do
|
55
|
-
let(:backend) { MockLoader.new.backend }
|
56
|
-
let(:profile) { Inspec::ProfileContext.new(nil, backend, {}) }
|
57
|
-
|
58
|
-
def get_rule
|
59
|
-
profile.rules.values[0]
|
60
|
-
end
|
61
|
-
|
62
|
-
def get_checks
|
63
|
-
Inspec::Rule.prepare_checks(get_rule)
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'must be able to load empty content' do
|
67
|
-
profile.load('', 'dummy', 1).must_be_nil
|
68
|
-
end
|
69
|
-
|
70
|
-
describe 'its default DSL' do
|
71
|
-
def load(call)
|
72
|
-
proc { profile.load(call) }
|
73
|
-
end
|
74
|
-
|
75
|
-
let(:context_format) { '%s' }
|
76
|
-
|
77
|
-
include DescribeOneTest
|
78
|
-
|
79
|
-
it 'must provide os resource' do
|
80
|
-
load('print os[:family]').must_output 'debian'
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'must provide file resource' do
|
84
|
-
load('print file("").type').must_output 'unknown'
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'must provide command resource' do
|
88
|
-
load('print command("").stdout').must_output ''
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'supports empty describe calls' do
|
92
|
-
load('describe').must_output ''
|
93
|
-
profile.rules.keys.length.must_equal 1
|
94
|
-
profile.rules.keys[0].must_match /^\(generated from \(eval\):1 [0-9a-f]+\)$/
|
95
|
-
profile.rules.values[0].must_be_kind_of Inspec::Rule
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'provides the describe keyword in the global DSL' do
|
99
|
-
load('describe true do; it { should_eq true }; end')
|
100
|
-
.must_output ''
|
101
|
-
profile.rules.keys.length.must_equal 1
|
102
|
-
profile.rules.keys[0].must_match /^\(generated from \(eval\):1 [0-9a-f]+\)$/
|
103
|
-
profile.rules.values[0].must_be_kind_of Inspec::Rule
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'loads multiple computed calls to describe correctly' do
|
107
|
-
load("%w{1 2 3}.each do\ndescribe true do; it { should_eq true }; end\nend")
|
108
|
-
.must_output ''
|
109
|
-
profile.rules.keys.length.must_equal 3
|
110
|
-
[0, 1, 2].each do |i|
|
111
|
-
profile.rules.keys[i].must_match /^\(generated from \(eval\):2 [0-9a-f]+\)$/
|
112
|
-
profile.rules.values[i].must_be_kind_of Inspec::Rule
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'does not provide the expect keyword in the global DLS' do
|
117
|
-
load('expect(true).to_eq true').must_raise NoMethodError
|
118
|
-
end
|
119
|
-
|
120
|
-
describe 'global only_if' do
|
121
|
-
let(:if_true) { "only_if { true }\n" }
|
122
|
-
let(:if_false) { "only_if { false }\n" }
|
123
|
-
let(:describe) { "describe nil do its(:to_i) { should eq rand } end\n" }
|
124
|
-
let(:control) { "control 1 do\n#{describe}end" }
|
125
|
-
|
126
|
-
it 'provides the keyword' do
|
127
|
-
profile.load(if_true)
|
128
|
-
profile.rules.must_equal({})
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'doesnt affect controls when positive' do
|
132
|
-
profile.load(if_true + 'control 1')
|
133
|
-
profile.rules.values[0].must_be_kind_of Inspec::Rule
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'doesnt remove controls when negative' do
|
137
|
-
profile.load(if_false + 'control 1')
|
138
|
-
profile.rules.values[0].must_be_kind_of Inspec::Rule
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'alters controls when positive' do
|
142
|
-
profile.load(if_false + control)
|
143
|
-
get_checks.length.must_equal 1
|
144
|
-
get_checks[0][1][0].resource_skipped.must_equal 'Skipped control due to only_if condition.'
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'alters non-controls when positive' do
|
148
|
-
profile.load(if_false + describe)
|
149
|
-
get_checks.length.must_equal 1
|
150
|
-
get_checks[0][1][0].resource_skipped.must_equal 'Skipped control due to only_if condition.'
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'doesnt alter controls when negative' do
|
154
|
-
profile.load(if_true + control)
|
155
|
-
get_checks.length.must_equal 1
|
156
|
-
get_checks[0][1][0].must_be_nil
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'doesnt alter non-controls when negative' do
|
160
|
-
profile.load(if_true + describe)
|
161
|
-
get_checks.length.must_equal 1
|
162
|
-
get_checks[0][1][0].must_be_nil
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'doesnt overwrite falsy only_ifs' do
|
166
|
-
profile.load(if_false + if_true + control)
|
167
|
-
get_checks.length.must_equal 1
|
168
|
-
get_checks[0][1][0].resource_skipped.must_equal 'Skipped control due to only_if condition.'
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'doesnt overwrite falsy only_ifs' do
|
172
|
-
profile.load(if_true + if_false + control)
|
173
|
-
get_checks.length.must_equal 1
|
174
|
-
get_checks[0][1][0].resource_skipped.must_equal 'Skipped control due to only_if condition.'
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'provides the control keyword in the global DSL' do
|
179
|
-
profile.load('control 1')
|
180
|
-
profile.rules.keys.must_equal ['1']
|
181
|
-
profile.rules.values[0].must_be_kind_of Inspec::Rule
|
182
|
-
end
|
183
|
-
|
184
|
-
it 'provides the rule keyword in the global DSL (legacy mode)' do
|
185
|
-
profile.load('rule 1')
|
186
|
-
profile.rules.keys.must_equal ['1']
|
187
|
-
profile.rules.values[0].must_be_kind_of Inspec::Rule
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
describe 'rule DSL' do
|
192
|
-
let(:rule_id) { rand.to_s }
|
193
|
-
let(:context_format) { "rule #{rule_id.inspect} do\n%s\nend" }
|
194
|
-
|
195
|
-
def get_rule
|
196
|
-
profile.rules[rule_id]
|
197
|
-
end
|
198
|
-
|
199
|
-
include DescribeOneTest
|
200
|
-
|
201
|
-
it 'doesnt add any checks if none are provided' do
|
202
|
-
profile.load("rule #{rule_id.inspect}")
|
203
|
-
rule = profile.rules[rule_id]
|
204
|
-
::Inspec::Rule.prepare_checks(rule).must_equal([])
|
205
|
-
end
|
206
|
-
|
207
|
-
describe 'supports empty describe blocks' do
|
208
|
-
it 'doesnt crash, but doesnt add anything either' do
|
209
|
-
profile.load(format(context_format, 'describe'))
|
210
|
-
profile.rules.keys.must_include(rule_id)
|
211
|
-
get_checks.must_equal([])
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
describe 'adds a check via describe' do
|
216
|
-
let(:check) {
|
217
|
-
profile.load(format(context_format,
|
218
|
-
"describe os[:family] { it { must_equal 'debian' } }"
|
219
|
-
))
|
220
|
-
get_checks[0]
|
221
|
-
}
|
222
|
-
|
223
|
-
it 'registers the check with describe' do
|
224
|
-
check[0].must_equal 'describe'
|
225
|
-
end
|
226
|
-
|
227
|
-
it 'registers the check with the describe argument' do
|
228
|
-
check[1].must_equal %w{debian}
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'registers the check with the provided proc' do
|
232
|
-
check[2].must_be_kind_of Proc
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
describe 'adds a check via expect' do
|
237
|
-
let(:check) {
|
238
|
-
profile.load(format(context_format,
|
239
|
-
"expect(os[:family]).to eq('debian')"
|
240
|
-
))
|
241
|
-
get_checks[0]
|
242
|
-
}
|
243
|
-
|
244
|
-
it 'registers the check with describe' do
|
245
|
-
check[0].must_equal 'expect'
|
246
|
-
end
|
247
|
-
|
248
|
-
it 'registers the check with the describe argument' do
|
249
|
-
check[1].must_equal %w{debian}
|
250
|
-
end
|
251
|
-
|
252
|
-
it 'registers the check with the provided proc' do
|
253
|
-
check[2].must_be_kind_of Inspec::Expect
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
describe 'adds a check via describe + expect' do
|
258
|
-
let(:check) {
|
259
|
-
profile.load(format(context_format,
|
260
|
-
"describe 'the actual test' do
|
261
|
-
expect(os[:family]).to eq('debian')
|
262
|
-
end"
|
263
|
-
))
|
264
|
-
get_checks[0]
|
265
|
-
}
|
266
|
-
|
267
|
-
it 'registers the check with describe' do
|
268
|
-
check[0].must_equal 'describe'
|
269
|
-
end
|
270
|
-
|
271
|
-
it 'registers the check with the describe argument' do
|
272
|
-
check[1].must_equal ['the actual test']
|
273
|
-
end
|
274
|
-
|
275
|
-
it 'registers the check with the provided proc' do
|
276
|
-
check[2].must_be_kind_of Proc
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
describe 'with only_if' do
|
281
|
-
it 'provides the only_if keyword' do
|
282
|
-
profile.load(format(context_format, 'only_if'))
|
283
|
-
get_checks.must_equal([])
|
284
|
-
end
|
285
|
-
|
286
|
-
it 'skips with only_if == false' do
|
287
|
-
profile.load(format(context_format, 'only_if { false }'))
|
288
|
-
get_checks.length.must_equal 1
|
289
|
-
get_checks[0][1][0].resource_skipped.must_equal 'Skipped control due to only_if condition.'
|
290
|
-
end
|
291
|
-
|
292
|
-
it 'does nothing with only_if == false' do
|
293
|
-
profile.load(format(context_format, 'only_if { true }'))
|
294
|
-
get_checks.length.must_equal 0
|
295
|
-
end
|
296
|
-
|
297
|
-
it 'doesnt overwrite falsy only_ifs' do
|
298
|
-
profile.load(format(context_format, "only_if { false }\nonly_if { true }"))
|
299
|
-
get_checks.length.must_equal 1
|
300
|
-
get_checks[0][1][0].resource_skipped.must_equal 'Skipped control due to only_if condition.'
|
301
|
-
end
|
302
|
-
|
303
|
-
it 'doesnt overwrite falsy only_ifs' do
|
304
|
-
profile.load(format(context_format, "only_if { true }\nonly_if { false }"))
|
305
|
-
get_checks.length.must_equal 1
|
306
|
-
get_checks[0][1][0].resource_skipped.must_equal 'Skipped control due to only_if condition.'
|
307
|
-
end
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
describe 'library loading' do
|
312
|
-
it 'supports simple ruby require statements' do
|
313
|
-
# Please note: we do discourage the use of Gems in inspec resources at
|
314
|
-
# this time. Resources should be well packaged whenever possible.
|
315
|
-
proc { profile.load('Net::POP3') }.must_raise NameError
|
316
|
-
profile.load_libraries([['require "net/pop"', 'libraries/a.rb']])
|
317
|
-
profile.load('Net::POP3').to_s.must_equal 'Net::POP3'
|
318
|
-
end
|
319
|
-
|
320
|
-
it 'supports loading across the library' do
|
321
|
-
profile.load_libraries([
|
322
|
-
["require 'a'\nA", 'libraries/b.rb'],
|
323
|
-
['module A; end', 'libraries/a.rb']
|
324
|
-
])
|
325
|
-
profile.load('A').to_s.must_equal 'A'
|
326
|
-
end
|
327
|
-
|
328
|
-
it 'fails loading if reference error occur' do
|
329
|
-
proc {
|
330
|
-
profile.load_libraries([
|
331
|
-
["require 'a'\nB", 'libraries/b.rb'],
|
332
|
-
['module A; end', 'libraries/a.rb']
|
333
|
-
])
|
334
|
-
}.must_raise NameError
|
335
|
-
end
|
336
|
-
|
337
|
-
it 'fails loading if a reference dependency isnt found' do
|
338
|
-
proc {
|
339
|
-
profile.load_libraries([
|
340
|
-
["require 'a'\nA", 'libraries/b.rb'],
|
341
|
-
])
|
342
|
-
}.must_raise LoadError
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|