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/docker_test.rb
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
|
|
4
|
-
require_relative 'docker_run'
|
|
5
|
-
require_relative '../lib/inspec'
|
|
6
|
-
#
|
|
7
|
-
# BUGON: These requires are to get around concurrency issues with
|
|
8
|
-
# autoloading in Ruby
|
|
9
|
-
#
|
|
10
|
-
require 'train'
|
|
11
|
-
require 'train/plugins'
|
|
12
|
-
require 'train/plugins/transport'
|
|
13
|
-
require 'train/transports/docker'
|
|
14
|
-
|
|
15
|
-
tests = ARGV
|
|
16
|
-
if tests.empty?
|
|
17
|
-
puts 'Nothing to do.'
|
|
18
|
-
exit 0
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
class DockerTester
|
|
22
|
-
def initialize(tests)
|
|
23
|
-
@tests = tests
|
|
24
|
-
@docker = DockerRunner.new
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def run
|
|
28
|
-
puts ['Running tests:', @tests].flatten.join("\n- ")
|
|
29
|
-
puts ''
|
|
30
|
-
|
|
31
|
-
conf = RSpec.configuration
|
|
32
|
-
reporter = conf.reporter
|
|
33
|
-
results = nil
|
|
34
|
-
|
|
35
|
-
# start reporting loop
|
|
36
|
-
reporter.report(0) do |report|
|
|
37
|
-
results = @docker.run_all do |name, container|
|
|
38
|
-
status = test_container(container, report)
|
|
39
|
-
status.all? ? nil : "Failed to run tests on #{name}"
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# check if we were successful
|
|
44
|
-
failures = results.compact
|
|
45
|
-
failures.each { |f| puts "\033[31;1m#{f}\033[0m\n\n" }
|
|
46
|
-
failures.empty? or fail 'Test failures'
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def test_container(container, report)
|
|
50
|
-
puts "--> run test on docker #{container.id}"
|
|
51
|
-
opts = { 'target' => "docker://#{container.id}" }
|
|
52
|
-
runner = Inspec::Runner.new(opts)
|
|
53
|
-
@tests.each { |test| runner.add_target(test, opts) }
|
|
54
|
-
runner.tests.map { |g| g.run(report) }
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
DockerTester.new(tests).run
|
data/test/functional/helper.rb
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
|
|
7
|
-
require 'minitest/hell'
|
|
8
|
-
class Minitest::Test
|
|
9
|
-
parallelize_me!
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
class Module
|
|
13
|
-
include Minitest::Spec::DSL
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
module FunctionalHelper
|
|
17
|
-
let(:repo_path) { File.expand_path(File.join( __FILE__, '..', '..', '..')) }
|
|
18
|
-
let(:exec_inspec) { File.join(repo_path, 'bin', 'inspec') }
|
|
19
|
-
let(:profile_path) { File.join(repo_path, 'test', 'unit', 'mock', 'profiles') }
|
|
20
|
-
let(:examples_path) { File.join(repo_path, 'examples') }
|
|
21
|
-
|
|
22
|
-
let(:example_profile) { File.join(examples_path, 'profile') }
|
|
23
|
-
let(:example_control) { File.join(example_profile, 'controls', 'example.rb') }
|
|
24
|
-
let(:inheritance_profile) { File.join(examples_path, 'profile') }
|
|
25
|
-
|
|
26
|
-
let(:dst) {
|
|
27
|
-
# create a temporary path, but we only want an auto-clean helper
|
|
28
|
-
# so remove the file and give back the path
|
|
29
|
-
res = Tempfile.new('inspec-shred')
|
|
30
|
-
FileUtils.rm(res.path)
|
|
31
|
-
TMP_CACHE[res.path] = res
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
def inspec(commandline)
|
|
35
|
-
CMD.run_command("#{exec_inspec} #{commandline}")
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
require 'functional/helper'
|
|
6
|
-
|
|
7
|
-
describe 'example inheritance profile' do
|
|
8
|
-
include FunctionalHelper
|
|
9
|
-
let(:path) { File.join(examples_path, 'inheritance') }
|
|
10
|
-
|
|
11
|
-
it 'check succeeds with --profiles-path' do
|
|
12
|
-
out = inspec('check ' + path + ' --profiles-path ' + examples_path)
|
|
13
|
-
out.stderr.must_equal ''
|
|
14
|
-
out.stdout.must_match /Valid.*true/
|
|
15
|
-
out.exit_status.must_equal 0
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'check succeeds without --profiles-path using inspec.yml' do
|
|
19
|
-
out = inspec('check ' + path)
|
|
20
|
-
out.stderr.must_equal ''
|
|
21
|
-
out.stdout.must_match /Valid.*true/
|
|
22
|
-
out.exit_status.must_equal 0
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'archive is successful with --profiles-path' do
|
|
26
|
-
out = inspec('archive ' + path + ' --output ' + dst.path + ' --profiles-path ' + examples_path)
|
|
27
|
-
out.stderr.must_equal ''
|
|
28
|
-
out.stdout.must_include 'Generate archive '+dst.path
|
|
29
|
-
out.stdout.must_include 'Finished archive generation.'
|
|
30
|
-
out.exit_status.must_equal 0
|
|
31
|
-
File.exist?(dst.path).must_equal true
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it 'archive is successful without --profiles-path using inspec.yml' do
|
|
35
|
-
out = inspec('archive ' + path + ' --output ' + dst.path)
|
|
36
|
-
out.stderr.must_equal ''
|
|
37
|
-
out.stdout.must_include 'Generate archive '+dst.path
|
|
38
|
-
out.stdout.must_include 'Finished archive generation.'
|
|
39
|
-
out.exit_status.must_equal 0
|
|
40
|
-
File.exist?(dst.path).must_equal true
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'read the profile json with --profiles-path' do
|
|
44
|
-
out = inspec('json ' + path + ' --profiles-path '+examples_path)
|
|
45
|
-
out.stderr.must_equal ''
|
|
46
|
-
out.exit_status.must_equal 0
|
|
47
|
-
s = out.stdout
|
|
48
|
-
hm = JSON.load(s)
|
|
49
|
-
hm['name'].must_equal 'inheritance'
|
|
50
|
-
hm['controls'].length.must_equal 3
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it 'read the profile json without --profiles-path using inspec.yml' do
|
|
54
|
-
out = inspec('json ' + path)
|
|
55
|
-
out.stderr.must_equal ''
|
|
56
|
-
out.exit_status.must_equal 0
|
|
57
|
-
s = out.stdout
|
|
58
|
-
hm = JSON.load(s)
|
|
59
|
-
hm['name'].must_equal 'inheritance'
|
|
60
|
-
hm['controls'].length.must_equal 3
|
|
61
|
-
end
|
|
62
|
-
end
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
require 'functional/helper'
|
|
6
|
-
|
|
7
|
-
describe 'inspec archive' do
|
|
8
|
-
include FunctionalHelper
|
|
9
|
-
|
|
10
|
-
it 'archive is successful' do
|
|
11
|
-
out = inspec('archive ' + example_profile + ' --overwrite')
|
|
12
|
-
out.exit_status.must_equal 0
|
|
13
|
-
out.stdout.must_match /Generate archive [^ ]*profile.tar.gz/
|
|
14
|
-
out.stdout.must_include 'Finished archive generation.'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'archives to output file' do
|
|
18
|
-
out = inspec('archive ' + example_profile + ' --output ' + dst.path)
|
|
19
|
-
out.stderr.must_equal ''
|
|
20
|
-
out.stdout.must_include 'Generate archive '+dst.path
|
|
21
|
-
out.stdout.must_include 'Finished archive generation.'
|
|
22
|
-
out.exit_status.must_equal 0
|
|
23
|
-
File.exist?(dst.path).must_equal true
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'auto-archives when no --output is given' do
|
|
27
|
-
auto_dst = File.join(repo_path, 'profile.tar.gz')
|
|
28
|
-
out = inspec('archive ' + example_profile + ' --overwrite')
|
|
29
|
-
out.stderr.must_equal ''
|
|
30
|
-
out.stdout.must_include 'Generate archive '+auto_dst
|
|
31
|
-
out.stdout.must_include 'Finished archive generation.'
|
|
32
|
-
out.exit_status.must_equal 0
|
|
33
|
-
File.exist?(auto_dst).must_equal true
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'archive on invalid archive' do
|
|
37
|
-
out = inspec('archive /proc --output ' + dst.path)
|
|
38
|
-
# out.stdout.must_equal '' => we have partial stdout output right now
|
|
39
|
-
out.stderr.must_include "Don't understand inspec profile in \"/proc\""
|
|
40
|
-
out.exit_status.must_equal 1
|
|
41
|
-
File.exist?(dst.path).must_equal false
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'archive wont overwrite existing files' do
|
|
45
|
-
x = rand.to_s
|
|
46
|
-
File.write(dst.path, x)
|
|
47
|
-
out = inspec('archive ' + example_profile + ' --output ' + dst.path)
|
|
48
|
-
out.stderr.must_equal '' # uh...
|
|
49
|
-
out.stdout.must_include "Archive #{dst.path} exists already. Use --overwrite."
|
|
50
|
-
out.exit_status.must_equal 1
|
|
51
|
-
File.read(dst.path).must_equal x
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'archive will overwrite files if necessary' do
|
|
55
|
-
x = rand.to_s
|
|
56
|
-
File.write(dst.path, x)
|
|
57
|
-
out = inspec('archive ' + example_profile + ' --output ' + dst.path + ' --overwrite')
|
|
58
|
-
out.stderr.must_equal ''
|
|
59
|
-
out.stdout.must_include 'Generate archive '+dst.path
|
|
60
|
-
out.exit_status.must_equal 0
|
|
61
|
-
File.read(dst.path).wont_equal x
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it 'creates valid tar.gz archives' do
|
|
65
|
-
out = inspec('archive ' + example_profile + ' --output ' + dst.path + ' --tar')
|
|
66
|
-
out.stderr.must_equal ''
|
|
67
|
-
out.stdout.must_include 'Generate archive '+dst.path
|
|
68
|
-
out.exit_status.must_equal 0
|
|
69
|
-
t = Zlib::GzipReader.open(dst.path)
|
|
70
|
-
Gem::Package::TarReader.new(t).entries.map(&:header).map(&:name).must_include 'inspec.yml'
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it 'creates valid zip archives' do
|
|
74
|
-
out = inspec('archive ' + example_profile + ' --output ' + dst.path + ' --zip')
|
|
75
|
-
out.stderr.must_equal ''
|
|
76
|
-
out.stdout.must_include 'Generate archive '+dst.path
|
|
77
|
-
out.exit_status.must_equal 0
|
|
78
|
-
Zip::File.new(dst.path).entries.map(&:name).must_include 'inspec.yml'
|
|
79
|
-
end
|
|
80
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
require 'functional/helper'
|
|
6
|
-
|
|
7
|
-
# basic testing without availability of any server
|
|
8
|
-
describe 'inspec compliance' do
|
|
9
|
-
include FunctionalHelper
|
|
10
|
-
|
|
11
|
-
it 'help' do
|
|
12
|
-
out = inspec('compliance help')
|
|
13
|
-
out.exit_status.must_equal 0
|
|
14
|
-
out.stdout.must_include 'inspec compliance exec PROFILE'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# ensure we are logged out
|
|
18
|
-
it 'logout' do
|
|
19
|
-
out = inspec('compliance logout')
|
|
20
|
-
out.exit_status.must_equal 0
|
|
21
|
-
out.stdout.must_include ''
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'login server url missing' do
|
|
25
|
-
out = inspec('compliance login')
|
|
26
|
-
#TODO: we need to convince thor that this is an error
|
|
27
|
-
out.exit_status.must_equal 0
|
|
28
|
-
out.stderr.must_include 'ERROR: "inspec login" was called with no arguments'
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'login server with missing parameters' do
|
|
32
|
-
out = inspec('compliance login http://example.com')
|
|
33
|
-
out.exit_status.must_equal 1
|
|
34
|
-
#TODO: inspec should really use stderr for errors
|
|
35
|
-
out.stdout.must_include 'Please run `inspec compliance login` with options'
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'inspec compliance profiles without authentication' do
|
|
39
|
-
out = inspec('compliance profile')
|
|
40
|
-
out.stdout.must_include 'You need to login first with `inspec compliance login`'
|
|
41
|
-
out.exit_status.must_equal 0
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'try to upload a profile without directory' do
|
|
45
|
-
out = inspec('compliance upload')
|
|
46
|
-
out.stderr.must_include 'ERROR: "inspec upload" was called with no arguments'
|
|
47
|
-
out.exit_status.must_equal 0
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'try to upload a profile a non-existing path' do
|
|
51
|
-
out = inspec('compliance upload /path/to/dir')
|
|
52
|
-
out.stdout.must_include 'You need to login first with `inspec compliance login`'
|
|
53
|
-
out.exit_status.must_equal 0
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it 'logout' do
|
|
57
|
-
out = inspec('compliance logout')
|
|
58
|
-
out.exit_status.must_equal 0
|
|
59
|
-
out.stdout.must_include ''
|
|
60
|
-
end
|
|
61
|
-
end
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
require 'functional/helper'
|
|
6
|
-
|
|
7
|
-
describe 'inspec exec with json formatter' do
|
|
8
|
-
include FunctionalHelper
|
|
9
|
-
|
|
10
|
-
it 'can execute a simple file with the json formatter' do
|
|
11
|
-
out = inspec('exec ' + example_control + ' --format json')
|
|
12
|
-
out.stderr.must_equal ''
|
|
13
|
-
out.exit_status.must_equal 0
|
|
14
|
-
JSON.load(out.stdout).must_be_kind_of Hash
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'can execute the profile with the json formatter' do
|
|
18
|
-
out = inspec('exec ' + example_profile + ' --format json')
|
|
19
|
-
out.stderr.must_equal ''
|
|
20
|
-
out.exit_status.must_equal 0
|
|
21
|
-
JSON.load(out.stdout).must_be_kind_of Hash
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe 'execute a profile with json formatting' do
|
|
25
|
-
let(:json) { JSON.load(inspec('exec ' + example_profile + ' --format json').stdout) }
|
|
26
|
-
let(:profile) { json['profiles']['profile'] }
|
|
27
|
-
let(:controls) { profile['controls'] }
|
|
28
|
-
let(:ex1) { controls['tmp-1.0'] }
|
|
29
|
-
let(:ex2) {
|
|
30
|
-
k = controls.keys.find { |x| x =~ /generated/ }
|
|
31
|
-
controls[k]
|
|
32
|
-
}
|
|
33
|
-
let(:ex3) { profile['controls']['gordon-1.0'] }
|
|
34
|
-
let(:check_result) {
|
|
35
|
-
ex3['results'].find { |x| x['resource'] == 'gordon_config' }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
it 'has all the metadata' do
|
|
39
|
-
actual = profile.dup
|
|
40
|
-
key = actual.delete('controls').keys
|
|
41
|
-
.find { |x| x =~ /generated from example.rb/ }
|
|
42
|
-
actual.must_equal({
|
|
43
|
-
"name" => "profile",
|
|
44
|
-
"title" => "InSpec Example Profile",
|
|
45
|
-
"maintainer" => "Chef Software, Inc.",
|
|
46
|
-
"copyright" => "Chef Software, Inc.",
|
|
47
|
-
"copyright_email" => "support@chef.io",
|
|
48
|
-
"license" => "Apache 2 license",
|
|
49
|
-
"summary" => "Demonstrates the use of InSpec Compliance Profile",
|
|
50
|
-
"version" => "1.0.0",
|
|
51
|
-
"supports" => [{"os-family" => "unix"}],
|
|
52
|
-
"groups" => {
|
|
53
|
-
"controls/meta.rb" => {"title"=>"SSH Server Configuration", "controls"=>["ssh-1"]},
|
|
54
|
-
"controls/example.rb" => {"title"=>"/tmp profile", "controls"=>["tmp-1.0", key]},
|
|
55
|
-
"controls/gordon.rb" => {"title"=>"Gordon Config Checks", "controls"=>["gordon-1.0"]},
|
|
56
|
-
},
|
|
57
|
-
"attributes" => []
|
|
58
|
-
})
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it 'must have 4 controls' do
|
|
62
|
-
controls.length.must_equal 4
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it 'has an id for every control' do
|
|
66
|
-
controls.keys.find(&:nil?).must_be :nil?
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it 'has no missing checks' do
|
|
70
|
-
json['other_checks'].must_equal([])
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it 'has results for every control' do
|
|
74
|
-
ex1['results'].length.must_equal 1
|
|
75
|
-
ex2['results'].length.must_equal 1
|
|
76
|
-
ex3['results'].length.must_equal 2
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it 'has the right result for tmp-1.0' do
|
|
80
|
-
actual = ex1.dup
|
|
81
|
-
|
|
82
|
-
src = actual.delete('source_location')
|
|
83
|
-
src['ref'].must_match %r{examples/profile/controls/example.rb$}
|
|
84
|
-
src['line'].must_equal 8
|
|
85
|
-
|
|
86
|
-
result = actual.delete('results')[0]
|
|
87
|
-
result.wont_be :nil?
|
|
88
|
-
result['status'].must_equal 'passed'
|
|
89
|
-
result['code_desc'].must_equal 'File /tmp should be directory'
|
|
90
|
-
result['run_time'].wont_be :nil?
|
|
91
|
-
result['start_time'].wont_be :nil?
|
|
92
|
-
|
|
93
|
-
actual.must_equal({
|
|
94
|
-
"title" => "Create /tmp directory",
|
|
95
|
-
"desc" => "An optional description...",
|
|
96
|
-
"impact" => 0.7,
|
|
97
|
-
"refs" => [
|
|
98
|
-
{
|
|
99
|
-
"url" => "http://...",
|
|
100
|
-
"ref" => "Document A-12"
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
"tags" => {
|
|
104
|
-
"data" => "temp data",
|
|
105
|
-
"security" => nil
|
|
106
|
-
},
|
|
107
|
-
"code" => "control \"tmp-1.0\" do # A unique ID for this control\n impact 0.7 # The criticality, if this control fails.\n title \"Create /tmp directory\" # A human-readable title\n desc \"An optional description...\" # Describe why this is needed\n tag data: \"temp data\" # A tag allows you to associate key information\n tag \"security\" # to the test\n ref \"Document A-12\", url: 'http://...' # Additional references\n\n describe file('/tmp') do # The actual test\n it { should be_directory }\n end\nend\n",
|
|
108
|
-
})
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
describe 'with a profile that is not supported on this OS/platform' do
|
|
113
|
-
let(:out) { inspec('exec ' + File.join(profile_path, 'skippy-profile-os') + ' --format json') }
|
|
114
|
-
let(:json) { JSON.load(out.stdout) }
|
|
115
|
-
|
|
116
|
-
# TODO: failure handling in json formatters...
|
|
117
|
-
|
|
118
|
-
it 'never runs the actual resource' do
|
|
119
|
-
File.exist?('/tmp/inspec_test_DONT_CREATE').must_equal false
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
require 'functional/helper'
|
|
6
|
-
|
|
7
|
-
describe 'inspec exec' do
|
|
8
|
-
include FunctionalHelper
|
|
9
|
-
|
|
10
|
-
it 'can execute the profile with the mini json formatter' do
|
|
11
|
-
out = inspec('exec ' + example_profile + ' --format json-min')
|
|
12
|
-
out.stderr.must_equal ''
|
|
13
|
-
out.exit_status.must_equal 0
|
|
14
|
-
JSON.load(out.stdout).must_be_kind_of Hash
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'can execute a simple file with the mini json formatter' do
|
|
18
|
-
out = inspec('exec ' + example_control + ' --format json-min')
|
|
19
|
-
out.stderr.must_equal ''
|
|
20
|
-
out.exit_status.must_equal 0
|
|
21
|
-
JSON.load(out.stdout).must_be_kind_of Hash
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe 'execute a profile with mini json formatting' do
|
|
25
|
-
let(:json) { JSON.load(inspec('exec ' + example_profile + ' --format json-min').stdout) }
|
|
26
|
-
let(:controls) { json['controls'] }
|
|
27
|
-
let(:ex1) { controls.find{|x| x['id'] == 'tmp-1.0'} }
|
|
28
|
-
let(:ex2) { controls.find{|x| x['id'] =~ /generated/} }
|
|
29
|
-
let(:ex3) { controls.find{|x| x['id'] == 'gordon-1.0'} }
|
|
30
|
-
|
|
31
|
-
it 'must have 5 examples' do
|
|
32
|
-
json['controls'].length.must_equal 5
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'has an id' do
|
|
36
|
-
controls.find { |ex| !ex.key? 'id' }.must_be :nil?
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'has a profile_id' do
|
|
40
|
-
controls.find { |ex| !ex.key? 'profile_id' }.must_be :nil?
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'has a code_desc' do
|
|
44
|
-
ex1['code_desc'].must_equal 'File /tmp should be directory'
|
|
45
|
-
controls.find { |ex| !ex.key? 'code_desc' }.must_be :nil?
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'has a status' do
|
|
49
|
-
ex1['status'].must_equal 'passed'
|
|
50
|
-
ex3['status'].must_equal 'skipped'
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it 'has a skip_message' do
|
|
54
|
-
ex1['skip_message'].must_be :nil?
|
|
55
|
-
ex3['skip_message'].must_equal "Can't find file \"/tmp/gordon/config.yaml\""
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
end
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
require 'functional/helper'
|
|
6
|
-
|
|
7
|
-
describe 'inspec exec' do
|
|
8
|
-
include FunctionalHelper
|
|
9
|
-
|
|
10
|
-
it 'can execute the profile' do
|
|
11
|
-
out = inspec('exec ' + example_profile)
|
|
12
|
-
out.stderr.must_equal ''
|
|
13
|
-
out.exit_status.must_equal 0
|
|
14
|
-
stdout = out.stdout.force_encoding(Encoding::UTF_8)
|
|
15
|
-
stdout.must_include "\n\e[32m ✔ ssh-1: Allow only SSH Protocol 2\e[0m\n"
|
|
16
|
-
stdout.must_include "\n\e[32m ✔ tmp-1.0: Create /tmp directory\e[0m\n"
|
|
17
|
-
stdout.must_include "
|
|
18
|
-
\e[37m ○ gordon-1.0: Verify the version number of Gordon (1 skipped)\e[0m
|
|
19
|
-
\e[37m Can't find file \"/tmp/gordon/config.yaml\"\e[0m
|
|
20
|
-
"
|
|
21
|
-
stdout.must_include "\nSummary: \e[32m4 successful\e[0m, \e[31m0 failures\e[0m, \e[37m1 skipped\e[0m\n"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'executes a minimum metadata-only profile' do
|
|
25
|
-
out = inspec('exec ' + File.join(profile_path, 'simple-metadata'))
|
|
26
|
-
out.stderr.must_equal ''
|
|
27
|
-
out.exit_status.must_equal 0
|
|
28
|
-
out.stdout.must_equal "
|
|
29
|
-
Profile: yumyum profile
|
|
30
|
-
Version: unknown
|
|
31
|
-
Target: local://
|
|
32
|
-
|
|
33
|
-
No tests executed.\e[0m
|
|
34
|
-
|
|
35
|
-
Summary: \e[32m0 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[0m
|
|
36
|
-
"
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'executes a metadata-only profile' do
|
|
40
|
-
out = inspec('exec ' + File.join(profile_path, 'complete-metadata'))
|
|
41
|
-
out.stderr.must_equal ''
|
|
42
|
-
out.exit_status.must_equal 0
|
|
43
|
-
out.stdout.must_equal "
|
|
44
|
-
Profile: title (name)
|
|
45
|
-
Version: 1.2.3
|
|
46
|
-
Target: local://
|
|
47
|
-
|
|
48
|
-
No tests executed.\e[0m
|
|
49
|
-
|
|
50
|
-
Summary: \e[32m0 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[0m
|
|
51
|
-
"
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'executes a specs-only profile' do
|
|
55
|
-
out = inspec('exec ' + File.join(profile_path, 'spec_only'))
|
|
56
|
-
out.stderr.must_equal ''
|
|
57
|
-
out.exit_status.must_equal 1
|
|
58
|
-
out.stdout.force_encoding(Encoding::UTF_8).must_equal "
|
|
59
|
-
Target: local://
|
|
60
|
-
|
|
61
|
-
\e[32m ✔ working should eq \"working\"\e[0m
|
|
62
|
-
\e[37m ○ skippy This will be skipped intentionally.\e[0m
|
|
63
|
-
\e[31m ✖ failing should eq \"as intended\" (
|
|
64
|
-
expected: \"as intended\"
|
|
65
|
-
got: \"failing\"
|
|
66
|
-
|
|
67
|
-
(compared using ==)
|
|
68
|
-
)\e[0m
|
|
69
|
-
|
|
70
|
-
Summary: \e[32m1 successful\e[0m, \e[31m1 failures\e[0m, \e[37m1 skipped\e[0m
|
|
71
|
-
"
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it 'executes only specified controls' do
|
|
75
|
-
out = inspec('exec ' + example_profile + ' --controls tmp-1.0')
|
|
76
|
-
out.stderr.must_equal ''
|
|
77
|
-
out.exit_status.must_equal 0
|
|
78
|
-
out.stdout.must_include "\nSummary: \e[32m1 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[0m\n"
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it 'can execute a simple file with the default formatter' do
|
|
82
|
-
out = inspec('exec ' + example_control)
|
|
83
|
-
out.stderr.must_equal ''
|
|
84
|
-
out.exit_status.must_equal 0
|
|
85
|
-
out.stdout.must_include "\nSummary: \e[32m2 successful\e[0m, \e[31m0 failures\e[0m, \e[37m0 skipped\e[0m\n"
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
describe 'with a profile that is not supported on this OS/platform' do
|
|
89
|
-
let(:out) { inspec('exec ' + File.join(profile_path, 'skippy-profile-os')) }
|
|
90
|
-
let(:json) { JSON.load(out.stdout) }
|
|
91
|
-
|
|
92
|
-
it 'exits with an error' do
|
|
93
|
-
out.stderr.must_match /^This OS\/platform \(.+\) is not supported by this profile.$/
|
|
94
|
-
out.exit_status.must_equal 1
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
describe 'with a profile that is supported on this version of inspec' do
|
|
99
|
-
let(:out) { inspec('exec ' + File.join(profile_path, 'supported_inspec')) }
|
|
100
|
-
|
|
101
|
-
it 'exits cleanly' do
|
|
102
|
-
out.stderr.must_equal ''
|
|
103
|
-
out.exit_status.must_equal 0
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
describe 'with a profile that is not supported on this version of inspec' do
|
|
108
|
-
let(:out) { inspec('exec ' + File.join(profile_path, 'unsupported_inspec')) }
|
|
109
|
-
|
|
110
|
-
it 'does not support this profile' do
|
|
111
|
-
out.exit_status.must_equal 1
|
|
112
|
-
out.stderr.must_equal "This profile requires InSpec version >= 99.0.0. You are running InSpec v#{Inspec::VERSION}.\n"
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
describe 'with a profile that loads a library and reference' do
|
|
117
|
-
let(:out) { inspec('exec ' + File.join(profile_path, 'library')) }
|
|
118
|
-
|
|
119
|
-
it 'executes the profile without error' do
|
|
120
|
-
out.exit_status.must_equal 0
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|