inspec 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -2
- data/Gemfile +1 -0
- data/README.md +21 -2
- data/Rakefile +1 -1
- data/bin/inspec +25 -3
- data/bin/os +23 -0
- data/docs/dsl_resource.rst +90 -0
- data/docs/profiles.rst +167 -0
- data/docs/resources.rst +79 -0
- data/examples/README.md +1 -0
- data/examples/kitchen-ansible/.kitchen/logs/default-centos-71.log +0 -0
- data/examples/kitchen-ansible/.kitchen/logs/default-ubuntu-1204.log +0 -0
- data/examples/kitchen-ansible/.kitchen/logs/default-ubuntu-1404.log +432 -0
- data/examples/kitchen-ansible/.kitchen/logs/kitchen.log +10 -0
- data/examples/kitchen-ansible/Gemfile.lock +154 -0
- data/examples/kitchen-chef/.kitchen/default-centos-71.yml +6 -0
- data/examples/kitchen-chef/.kitchen/default-ubuntu-1204.yml +6 -0
- data/examples/kitchen-chef/.kitchen/default-ubuntu-1404.yml +6 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/id +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/Vagrantfile +9 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/Vagrantfile +9 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/Vagrantfile +9 -0
- data/examples/kitchen-chef/.kitchen/logs/default-centos-71.log +4 -0
- data/examples/kitchen-chef/.kitchen/logs/default-ubuntu-1204.log +4 -0
- data/examples/kitchen-chef/.kitchen/logs/default-ubuntu-1404.log +4 -0
- data/examples/kitchen-chef/.kitchen/logs/kitchen.log +8 -0
- data/examples/kitchen-chef/Berksfile.lock +11 -0
- data/examples/kitchen-chef/Gemfile.lock +223 -0
- data/examples/kitchen-puppet/.bundle/config +2 -0
- data/examples/kitchen-puppet/.kitchen/logs/default-centos-71.log +0 -0
- data/examples/kitchen-puppet/.kitchen/logs/default-ubuntu-1204.log +0 -0
- data/examples/kitchen-puppet/.kitchen/logs/default-ubuntu-1404.log +306 -0
- data/examples/kitchen-puppet/.kitchen/logs/kitchen.log +10 -0
- data/examples/kitchen-puppet/.librarian/puppet/config +2 -0
- data/examples/kitchen-puppet/Gemfile.lock +174 -0
- data/examples/kitchen-puppet/Puppetfile.lock +2 -0
- data/examples/profile/README.md +30 -0
- data/examples/profile/controls/example.rb +14 -0
- data/examples/profile/controls/gordon.rb +20 -0
- data/examples/profile/inspec.yml +10 -0
- data/examples/profile/libraries/.DS_Store +0 -0
- data/examples/profile/libraries/gordon_config.rb +17 -0
- data/examples/test-kitchen/.kitchen/logs/default-centos-71.log +5 -0
- data/examples/test-kitchen/.kitchen/logs/default-ubuntu-1204.log +5 -0
- data/examples/test-kitchen/.kitchen/logs/default-ubuntu-1404.log +5 -0
- data/examples/test-kitchen/.kitchen/logs/kitchen.log +5 -0
- data/examples/test-kitchen/Berksfile.lock +11 -0
- data/examples/test-kitchen/Gemfile.lock +233 -0
- data/inspec.gemspec +1 -1
- data/lib/.DS_Store +0 -0
- data/lib/inspec/archive/tar.rb +29 -0
- data/lib/inspec/archive/zip.rb +19 -0
- data/lib/inspec/metadata.rb +110 -15
- data/lib/inspec/profile.rb +88 -19
- data/lib/inspec/profile_context.rb +10 -4
- data/lib/inspec/resource.rb +1 -0
- data/lib/inspec/runner.rb +21 -4
- data/lib/inspec/targets.rb +2 -1
- data/lib/inspec/targets/archive.rb +39 -0
- data/lib/inspec/targets/core.rb +2 -2
- data/lib/inspec/targets/dir.rb +18 -2
- data/lib/inspec/targets/file.rb +4 -0
- data/lib/inspec/targets/folder.rb +21 -11
- data/lib/inspec/targets/tar.rb +36 -5
- data/lib/inspec/targets/url.rb +45 -13
- data/lib/inspec/targets/zip.rb +22 -15
- data/lib/inspec/version.rb +1 -1
- data/lib/matchers/matchers.rb +30 -0
- data/lib/resources/certificate.rb +0 -0
- data/lib/resources/etc_group.rb +1 -1
- data/lib/resources/file.rb +28 -3
- data/lib/resources/mount.rb +57 -0
- data/lib/resources/passwd.rb +1 -1
- data/lib/resources/private_key.rb +0 -0
- data/lib/resources/user.rb +3 -2
- data/lib/utils/hash.rb +29 -1
- data/lib/utils/parser.rb +34 -1
- data/lib/utils/simpleconfig.rb +1 -1
- data/test/chefdk/.gitignore +16 -0
- data/test/chefdk/.kitchen.yml +27 -0
- data/test/chefdk/Policyfile.rb +16 -0
- data/test/chefdk/README.md +4 -0
- data/test/chefdk/chefignore +100 -0
- data/test/chefdk/metadata.rb +7 -0
- data/test/chefdk/recipes/default.rb +5 -0
- data/test/chefdk/spec/spec_helper.rb +2 -0
- data/test/chefdk/spec/unit/recipes/default_spec.rb +20 -0
- data/test/chefdk/test/integration/default/serverspec/default_spec.rb +9 -0
- data/test/chefdk/test/integration/helpers/serverspec/spec_helper.rb +8 -0
- data/test/helper.rb +3 -1
- data/test/integration/.DS_Store +0 -0
- data/test/integration/.kitchen.ec2.yml +67 -0
- data/test/integration/.kitchen.local.yml +68 -0
- data/test/integration/.kitchen/default-aws-linux.yml +4 -0
- data/test/integration/.kitchen/default-centos-511.yml +6 -0
- data/test/integration/.kitchen/default-centos-67.yml +6 -0
- data/test/integration/.kitchen/default-centos-7.yml +4 -0
- data/test/integration/.kitchen/default-centos-71.yml +6 -0
- data/test/integration/.kitchen/default-debian-6010.yml +6 -0
- data/test/integration/.kitchen/default-debian-78.yml +6 -0
- data/test/integration/.kitchen/default-debian-8.yml +4 -0
- data/test/integration/.kitchen/default-debian-81.yml +6 -0
- data/test/integration/.kitchen/default-fedora-21.yml +6 -0
- data/test/integration/.kitchen/default-fedora-22.yml +4 -0
- data/test/integration/.kitchen/default-freebsd-102.yml +6 -0
- data/test/integration/.kitchen/default-freebsd-93.yml +6 -0
- data/test/integration/.kitchen/default-opensuse-132-x86-64.yml +6 -0
- data/test/integration/.kitchen/default-redhat-65.yml +4 -0
- data/test/integration/.kitchen/default-redhat-71.yml +4 -0
- data/test/integration/.kitchen/default-suse-11sp3.yml +4 -0
- data/test/integration/.kitchen/default-suse-12.yml +4 -0
- data/test/integration/.kitchen/default-ubuntu-1004.yml +6 -0
- data/test/integration/.kitchen/default-ubuntu-1204.yml +4 -0
- data/test/integration/.kitchen/default-ubuntu-1404.yml +4 -0
- data/test/integration/.kitchen/default-ubuntu-1510.yml +4 -0
- data/test/integration/.kitchen/default-windows-2012.yml +5 -0
- data/test/integration/.kitchen/default-windows-2012r2.yml +6 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67-i386/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/Vagrantfile +9 -0
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-new-ubuntu-1404/Vagrantfile +9 -0
- data/test/integration/.kitchen/logs/default-aws-linux.log +0 -0
- data/test/integration/.kitchen/logs/default-centos-511-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-centos-511.log +0 -0
- data/test/integration/.kitchen/logs/default-centos-67-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-centos-67.log +0 -0
- data/test/integration/.kitchen/logs/default-centos-7.log +0 -0
- data/test/integration/.kitchen/logs/default-centos-71.log +0 -0
- data/test/integration/.kitchen/logs/default-debian-6010-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-debian-6010.log +0 -0
- data/test/integration/.kitchen/logs/default-debian-78-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-debian-78.log +0 -0
- data/test/integration/.kitchen/logs/default-debian-8.log +0 -0
- data/test/integration/.kitchen/logs/default-debian-81-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-debian-81.log +0 -0
- data/test/integration/.kitchen/logs/default-fedora-21-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-fedora-21.log +0 -0
- data/test/integration/.kitchen/logs/default-fedora-22.log +0 -0
- data/test/integration/.kitchen/logs/default-freebsd-102.log +0 -0
- data/test/integration/.kitchen/logs/default-freebsd-93.log +0 -0
- data/test/integration/.kitchen/logs/default-mint-172-cinnamon.log +0 -0
- data/test/integration/.kitchen/logs/default-opensuse-132-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-opensuse-132-x86-64.log +0 -0
- data/test/integration/.kitchen/logs/default-redhat-65.log +0 -0
- data/test/integration/.kitchen/logs/default-redhat-71.log +0 -0
- data/test/integration/.kitchen/logs/default-suse-11sp3.log +0 -0
- data/test/integration/.kitchen/logs/default-suse-12.log +0 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1004-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1004.log +0 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1204-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1204.log +23 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1404-i386.log +0 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1404.log +0 -0
- data/test/integration/.kitchen/logs/default-ubuntu-1510.log +0 -0
- data/test/integration/.kitchen/logs/default-windows-2012.log +0 -0
- data/test/integration/.kitchen/logs/default-windows-2012r2.log +0 -0
- data/test/integration/.kitchen/logs/kitchen.log +3 -0
- data/test/integration/.kitchen/logs/new-centos-511-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-centos-511.log +0 -0
- data/test/integration/.kitchen/logs/new-centos-67-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-centos-67.log +0 -0
- data/test/integration/.kitchen/logs/new-centos-71.log +0 -0
- data/test/integration/.kitchen/logs/new-debian-6010-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-debian-6010.log +0 -0
- data/test/integration/.kitchen/logs/new-debian-78-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-debian-78.log +0 -0
- data/test/integration/.kitchen/logs/new-debian-81-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-debian-81.log +0 -0
- data/test/integration/.kitchen/logs/new-fedora-21-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-fedora-21.log +0 -0
- data/test/integration/.kitchen/logs/new-fedora-22.log +0 -0
- data/test/integration/.kitchen/logs/new-freebsd-102.log +0 -0
- data/test/integration/.kitchen/logs/new-freebsd-93.log +0 -0
- data/test/integration/.kitchen/logs/new-opensuse-132-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-opensuse-132-x86-64.log +0 -0
- data/test/integration/.kitchen/logs/new-ubuntu-1004-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-ubuntu-1004.log +0 -0
- data/test/integration/.kitchen/logs/new-ubuntu-1204-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-ubuntu-1204.log +0 -0
- data/test/integration/.kitchen/logs/new-ubuntu-1404-i386.log +0 -0
- data/test/integration/.kitchen/logs/new-ubuntu-1404.log +3 -0
- data/test/integration/.kitchen/logs/test-centos-511-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-centos-511.log +0 -0
- data/test/integration/.kitchen/logs/test-centos-67-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-centos-67.log +0 -0
- data/test/integration/.kitchen/logs/test-centos-71.log +0 -0
- data/test/integration/.kitchen/logs/test-debian-6010-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-debian-6010.log +0 -0
- data/test/integration/.kitchen/logs/test-debian-78-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-debian-78.log +0 -0
- data/test/integration/.kitchen/logs/test-debian-81-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-debian-81.log +0 -0
- data/test/integration/.kitchen/logs/test-fedora-21-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-fedora-21.log +0 -0
- data/test/integration/.kitchen/logs/test-fedora-22.log +0 -0
- data/test/integration/.kitchen/logs/test-freebsd-102.log +0 -0
- data/test/integration/.kitchen/logs/test-freebsd-93.log +0 -0
- data/test/integration/.kitchen/logs/test-opensuse-132-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-opensuse-132-x86-64.log +0 -0
- data/test/integration/.kitchen/logs/test-ubuntu-1004-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-ubuntu-1004.log +0 -0
- data/test/integration/.kitchen/logs/test-ubuntu-1204-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-ubuntu-1204.log +0 -0
- data/test/integration/.kitchen/logs/test-ubuntu-1404-i386.log +0 -0
- data/test/integration/.kitchen/logs/test-ubuntu-1404.log +0 -0
- data/test/integration/.kitchen/new-ubuntu-1404.yml +1 -0
- data/test/integration/Berksfile.lock +11 -0
- data/test/integration/TODO.md +15 -0
- data/test/integration/cookbooks/os_prepare/recipes/default.rb +1 -0
- data/test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb +13 -6
- data/test/integration/cookbooks/os_prepare/recipes/mount.rb +29 -0
- data/test/integration/test/.DS_Store +0 -0
- data/test/integration/test/integration/.DS_Store +0 -0
- data/test/integration/test/integration/default/.DS_Store +0 -0
- data/test/integration/test/integration/default/certificate_spec.rb +7 -0
- data/test/integration/test/integration/default/csv_spec.rb +7 -1
- data/test/integration/test/integration/default/file_spec.rb +29 -0
- data/test/integration/test/integration/default/ini_spec.rb +7 -1
- data/test/integration/test/integration/default/json_spec.rb +7 -1
- data/test/integration/test/integration/default/mount_spec.rb +10 -0
- data/test/integration/test/integration/default/yaml_spec.rb +7 -1
- data/test/serverspec/.kitchen.yml +18 -0
- data/test/serverspec/.kitchen/default-ubuntu-1404.yml +6 -0
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +1 -0
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +1 -0
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +1 -0
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +1 -0
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +27 -0
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +1 -0
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/Vagrantfile +9 -0
- data/test/serverspec/.kitchen/logs/default-ubuntu-1404.log +2 -0
- data/test/serverspec/.kitchen/logs/kitchen.log +3 -0
- data/test/serverspec/Berksfile +3 -0
- data/test/serverspec/Berksfile.lock +5 -0
- data/test/serverspec/TODO.md +2 -0
- data/test/serverspec/test/integration/default/serverspec/os_spec.rb +25 -0
- data/test/serverspec/test/integration/default/serverspec/spec_helper.rb +48 -0
- data/test/serverspec/test/integration/default/serverspec/sysctl_spec.rb +37 -0
- data/test/unit/metadata_test.rb +69 -0
- data/test/unit/mock/cmd/mount +1 -0
- data/test/unit/mock/cmd/mount-multiple +2 -0
- data/test/unit/mock/profiles/complete-meta/metadata.rb +7 -0
- data/test/unit/mock/profiles/complete-meta/test/.gitkeep +0 -0
- data/test/unit/mock/profiles/complete-profile/controls/filesystem_spec.rb +16 -0
- data/test/unit/mock/profiles/complete-profile/inspec.yml +10 -0
- data/test/unit/profile_context_test.rb +2 -2
- data/test/unit/profile_test.rb +63 -6
- data/test/unit/resources/file_test.rb +4 -0
- data/test/unit/resources/mount_test.rb +26 -0
- data/test/unit/utils/{content_parser_test.rb → passwd_parser_test.rb} +2 -2
- metadata +588 -5
data/lib/inspec/targets.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Dominik Richter
|
3
|
+
# author: Christoph Hartmann
|
4
|
+
|
5
|
+
require 'rubygems/package'
|
6
|
+
require 'zlib'
|
7
|
+
|
8
|
+
module Inspec::Targets
|
9
|
+
class ArchiveHelper
|
10
|
+
def resolve(target, _opts = {})
|
11
|
+
files, rootdir = structure(target)
|
12
|
+
|
13
|
+
# remove trailing slashes
|
14
|
+
files = files.collect { |f| f.chomp('/') }
|
15
|
+
|
16
|
+
# remove leading directory
|
17
|
+
files = files.collect { |f|
|
18
|
+
Pathname(f).relative_path_from(Pathname(rootdir)).to_s
|
19
|
+
}
|
20
|
+
|
21
|
+
helper = DirsHelper.get_handler(files)
|
22
|
+
if helper.nil?
|
23
|
+
fail "Don't know how to handle folder #{target}"
|
24
|
+
end
|
25
|
+
|
26
|
+
# get all test file contents
|
27
|
+
raw_files = helper.get_filenames(files)
|
28
|
+
tests = content(target, raw_files, rootdir, base_folder: target)
|
29
|
+
|
30
|
+
libs = []
|
31
|
+
if helper.respond_to? :get_libraries
|
32
|
+
raw_libs = helper.get_libraries(files)
|
33
|
+
libs = content(target, raw_libs, rootdir, base_folder: target, as: :library)
|
34
|
+
end
|
35
|
+
|
36
|
+
libs + tests
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/inspec/targets/core.rb
CHANGED
@@ -14,13 +14,13 @@ module Inspec
|
|
14
14
|
end.flatten
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.resolve(targets)
|
17
|
+
def self.resolve(targets, opts = {})
|
18
18
|
Array(targets).map do |target|
|
19
19
|
handler = modules.values.find { |m| m.handles?(target) }
|
20
20
|
if handler.nil?
|
21
21
|
fail "Don't know how to handle target: #{target}"
|
22
22
|
end
|
23
|
-
handler.resolve(target)
|
23
|
+
handler.resolve(target, opts)
|
24
24
|
end.flatten
|
25
25
|
end
|
26
26
|
end
|
data/lib/inspec/targets/dir.rb
CHANGED
@@ -4,9 +4,20 @@
|
|
4
4
|
|
5
5
|
module Inspec::Targets
|
6
6
|
module DirsHelper
|
7
|
+
# InSpec profile Loader
|
8
|
+
# Previous versions used the `test` directory instead of the new `controls`
|
9
|
+
# directory. Usage of the test directory is deprecated and not recommended
|
10
|
+
# anymore. Support for `test` will be removed in InSpec 1.0
|
11
|
+
# TODO: remove `test` support for InSpec 1.0
|
7
12
|
class ProfileDir
|
8
13
|
def handles?(paths)
|
9
|
-
|
14
|
+
(
|
15
|
+
!paths.grep(/^controls/).empty? ||
|
16
|
+
!paths.grep(/^test/).empty?
|
17
|
+
) && (
|
18
|
+
paths.include?('inspec.yml') ||
|
19
|
+
paths.include?('metadata.rb')
|
20
|
+
)
|
10
21
|
end
|
11
22
|
|
12
23
|
def get_libraries(paths)
|
@@ -17,9 +28,14 @@ module Inspec::Targets
|
|
17
28
|
|
18
29
|
def get_filenames(paths)
|
19
30
|
paths.find_all do |path|
|
20
|
-
path.start_with?('test') && path.end_with?('.rb')
|
31
|
+
(path.start_with?('controls') || path.start_with?('test')) && path.end_with?('.rb')
|
21
32
|
end
|
22
33
|
end
|
34
|
+
|
35
|
+
def get_metadata(paths)
|
36
|
+
return 'inspec.yml' if paths.include?('inspec.yml')
|
37
|
+
return 'metadata.rb' if paths.include?('metadata.rb')
|
38
|
+
end
|
23
39
|
end
|
24
40
|
|
25
41
|
class ChefAuditDir
|
data/lib/inspec/targets/file.rb
CHANGED
@@ -11,7 +11,7 @@ module Inspec::Targets
|
|
11
11
|
File.directory?(target)
|
12
12
|
end
|
13
13
|
|
14
|
-
def resolve(target)
|
14
|
+
def resolve(target, _opts = {})
|
15
15
|
# find all files in the folder
|
16
16
|
files = Dir[File.join(target, '**', '*')]
|
17
17
|
# remove the prefix
|
@@ -25,17 +25,27 @@ module Inspec::Targets
|
|
25
25
|
|
26
26
|
# get all test file contents
|
27
27
|
file_handler = Inspec::Targets.modules['file']
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
res = {
|
29
|
+
test: collect(helper, files, :get_filenames),
|
30
|
+
library: collect(helper, files, :get_libraries),
|
31
|
+
metadata: collect(helper, files, :get_metadata),
|
32
|
+
}.map { |as, list|
|
33
|
+
file_handler.resolve_all(list, base_folder: target, as: as)
|
34
|
+
}
|
35
|
+
|
36
|
+
# flatten the outer list layer
|
37
|
+
res.inject(&:+)
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
'Folder Loader'
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
37
45
|
|
38
|
-
|
46
|
+
def collect(helper, files, getter)
|
47
|
+
return [] unless helper.respond_to? getter
|
48
|
+
helper.method(getter).call(files)
|
39
49
|
end
|
40
50
|
end
|
41
51
|
|
data/lib/inspec/targets/tar.rb
CHANGED
@@ -4,25 +4,50 @@
|
|
4
4
|
|
5
5
|
require 'rubygems/package'
|
6
6
|
require 'zlib'
|
7
|
+
require 'inspec/targets/archive'
|
7
8
|
|
8
9
|
module Inspec::Targets
|
9
|
-
class TarHelper
|
10
|
+
class TarHelper < ArchiveHelper
|
11
|
+
def handles?(target)
|
12
|
+
File.file?(target) and (
|
13
|
+
target.end_with?('.tar.gz') ||
|
14
|
+
target.end_with?('.tgz')
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
10
18
|
def structure(input)
|
11
19
|
files = []
|
20
|
+
rootdir = ''
|
12
21
|
Gem::Package::TarReader.new(Zlib::GzipReader.open input) do |tar|
|
13
22
|
files = tar.map(&:full_name)
|
14
23
|
end
|
15
|
-
|
24
|
+
|
25
|
+
# find root dir of profile
|
26
|
+
files.each { |f|
|
27
|
+
pn = Pathname(f)
|
28
|
+
rootdir = pn.dirname.to_s if pn.basename.to_s == 'inspec.yml' || pn.basename.to_s == 'metadata.rb'
|
29
|
+
}
|
30
|
+
|
31
|
+
# stores the rootdir of metadata.rb or inspec.yml
|
32
|
+
rootdir += '/' if !rootdir.empty?
|
33
|
+
[files, rootdir]
|
16
34
|
end
|
17
35
|
|
18
|
-
def content(input)
|
19
|
-
content =
|
36
|
+
def content(input, files, rootdir = nil, opts = {})
|
37
|
+
content = []
|
20
38
|
Gem::Package::TarReader.new(Zlib::GzipReader.open input) do |tar|
|
21
39
|
tar.each do |entry|
|
22
40
|
if entry.directory?
|
23
41
|
# nothing to do
|
24
42
|
elsif entry.file?
|
25
|
-
|
43
|
+
if files.include?(entry.full_name.gsub(rootdir, ''))
|
44
|
+
h = {
|
45
|
+
content: entry.read,
|
46
|
+
type: opts[:as] || :test,
|
47
|
+
# ref: File.join(input, entry.name),
|
48
|
+
}
|
49
|
+
content.push(h)
|
50
|
+
end
|
26
51
|
elsif entry.header.typeflag == '2'
|
27
52
|
# ignore symlinks for now
|
28
53
|
end
|
@@ -30,5 +55,11 @@ module Inspec::Targets
|
|
30
55
|
end
|
31
56
|
content
|
32
57
|
end
|
58
|
+
|
59
|
+
def to_s
|
60
|
+
'tar.gz Loader'
|
61
|
+
end
|
33
62
|
end
|
63
|
+
|
64
|
+
Inspec::Targets.add_module('tar', TarHelper.new)
|
34
65
|
end
|
data/lib/inspec/targets/url.rb
CHANGED
@@ -15,24 +15,56 @@ module Inspec::Targets
|
|
15
15
|
%{ http https }.include? uri.scheme
|
16
16
|
end
|
17
17
|
|
18
|
-
def resolve(target)
|
19
|
-
|
20
|
-
|
18
|
+
def resolve(target, opts = {})
|
19
|
+
# abort if the target does not start with http or https
|
20
|
+
return nil unless target.start_with? 'https://' or target.start_with? 'http://'
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
# support for github https url
|
23
|
+
if target.start_with? 'https://github.com' and target.end_with? '.git'
|
24
|
+
url = target.sub(/.git$/, '') + '/archive/master.tar.gz'
|
25
|
+
else
|
26
|
+
url = target
|
27
|
+
end
|
28
|
+
|
29
|
+
resolve_zip(url, opts)
|
24
30
|
end
|
25
31
|
|
26
|
-
def resolve_zip(url)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
def resolve_zip(url, opts)
|
33
|
+
archive = Tempfile.new(['inspec-dl-', '.tar.gz'])
|
34
|
+
archive.binmode
|
35
|
+
|
36
|
+
remote = open(
|
37
|
+
url,
|
38
|
+
http_basic_authentication: [opts['user'] || '', opts['password'] || ''],
|
39
|
+
)
|
40
|
+
|
41
|
+
# download content
|
42
|
+
archive.write(remote.read)
|
43
|
+
archive.rewind
|
44
|
+
archive.close
|
45
|
+
|
46
|
+
content_type = remote.meta['content-type']
|
47
|
+
# replace extension with zip if we detected a zip content type
|
48
|
+
if ['application/x-zip-compressed', 'application/zip'].include?(content_type)
|
49
|
+
# rename file for proper detection in DirHelper
|
50
|
+
pn = Pathname.new(archive.path)
|
51
|
+
new_path = pn.dirname.join(pn.basename.to_s.gsub('tar.gz', 'zip'))
|
52
|
+
File.rename(pn.to_s, new_path.to_s)
|
53
|
+
|
54
|
+
content = ZipHelper.new.resolve(new_path)
|
55
|
+
File.unlink(new_path)
|
56
|
+
# use tar helper as default
|
57
|
+
elsif ['application/x-gzip', 'application/gzip'].include?(content_type)
|
58
|
+
content = TarHelper.new.resolve(archive.path)
|
59
|
+
archive.unlink
|
60
|
+
end
|
61
|
+
|
34
62
|
content
|
35
63
|
end
|
64
|
+
|
65
|
+
def to_s
|
66
|
+
'URL Loader'
|
67
|
+
end
|
36
68
|
end
|
37
69
|
|
38
70
|
Inspec::Targets.add_module('url', UrlHelper.new)
|
data/lib/inspec/targets/zip.rb
CHANGED
@@ -4,16 +4,23 @@
|
|
4
4
|
|
5
5
|
require 'zip'
|
6
6
|
require 'inspec/targets/dir'
|
7
|
+
require 'inspec/targets/archive'
|
7
8
|
|
8
9
|
module Inspec::Targets
|
9
|
-
class ZipHelper
|
10
|
-
def
|
10
|
+
class ZipHelper < ArchiveHelper
|
11
|
+
def handles?(target)
|
12
|
+
File.file?(target) and target.end_with?('.zip')
|
13
|
+
end
|
14
|
+
|
15
|
+
def content(input, files, rootdir = nil, opts = {})
|
11
16
|
content = []
|
12
17
|
::Zip::InputStream.open(input) do |io|
|
13
18
|
while (entry = io.get_next_entry)
|
19
|
+
next if !files.include?(entry.name.gsub(rootdir, ''))
|
14
20
|
h = {
|
15
21
|
content: io.read,
|
16
|
-
|
22
|
+
type: opts[:as] || :test,
|
23
|
+
# ref: File.join(input, entry.name),
|
17
24
|
}
|
18
25
|
content.push(h)
|
19
26
|
end
|
@@ -23,25 +30,25 @@ module Inspec::Targets
|
|
23
30
|
|
24
31
|
def structure(input)
|
25
32
|
files = []
|
33
|
+
rootdir = ''
|
34
|
+
|
26
35
|
::Zip::InputStream.open(input) do |io|
|
27
36
|
while (entry = io.get_next_entry)
|
37
|
+
pn = Pathname(entry.name)
|
38
|
+
rootdir = pn.dirname.to_s if pn.basename.to_s == 'inspec.yml' || pn.basename.to_s == 'metadata.rb'
|
28
39
|
files.push(entry.name)
|
29
40
|
end
|
30
41
|
end
|
31
|
-
|
42
|
+
|
43
|
+
# stores the rootdir of metadata.rb or inspec.yml
|
44
|
+
rootdir += '/' if !rootdir.empty?
|
45
|
+
[files, rootdir]
|
32
46
|
end
|
33
47
|
|
34
|
-
def
|
35
|
-
|
36
|
-
helper = DirsHelper.get_handler(files)
|
37
|
-
if helper.nil?
|
38
|
-
fail "Don't know how to handle folder #{path}"
|
39
|
-
end
|
40
|
-
# get all file contents
|
41
|
-
# @TODO
|
42
|
-
_file_handler = Inspec::Targets.modules['file']
|
43
|
-
test_files = helper.get_filenames(files)
|
44
|
-
content(path, test_files)
|
48
|
+
def to_s
|
49
|
+
'zip Loader'
|
45
50
|
end
|
46
51
|
end
|
52
|
+
|
53
|
+
Inspec::Targets.add_module('zip', ZipHelper.new)
|
47
54
|
end
|
data/lib/inspec/version.rb
CHANGED
data/lib/matchers/matchers.rb
CHANGED
@@ -271,3 +271,33 @@ RSpec::Matchers.define :cmp do |expected|
|
|
271
271
|
"\nexpected: value != #{expected}\n got: #{actual}\n\n(compared using `cmp` matcher)\n"
|
272
272
|
end
|
273
273
|
end
|
274
|
+
|
275
|
+
# user resource matcher for serverspec compatibility
|
276
|
+
# This matcher will be deprecated in future
|
277
|
+
RSpec::Matchers.define :be_mounted do
|
278
|
+
match do |path|
|
279
|
+
if !@options.nil?
|
280
|
+
path.mounted?(@options, @identical)
|
281
|
+
else
|
282
|
+
path.mounted?
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
chain :with do |attr|
|
287
|
+
@options = attr
|
288
|
+
@identical = false
|
289
|
+
end
|
290
|
+
|
291
|
+
chain :only_with do |attr|
|
292
|
+
@options = attr
|
293
|
+
@identical = true
|
294
|
+
end
|
295
|
+
|
296
|
+
failure_message do |path|
|
297
|
+
if !@options.nil?
|
298
|
+
"\n#{path} is not mounted with the options\n expected: #{@options}\n got: #{path.mount_options}\n"
|
299
|
+
else
|
300
|
+
"\n#{path} is not mounted\n"
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
File without changes
|
data/lib/resources/etc_group.rb
CHANGED
@@ -26,7 +26,7 @@ require 'utils/parser'
|
|
26
26
|
|
27
27
|
class EtcGroup < Inspec.resource(1)
|
28
28
|
include Converter
|
29
|
-
include
|
29
|
+
include CommentParser
|
30
30
|
|
31
31
|
name 'etc_group'
|
32
32
|
desc 'Use the etc_group InSpec audit resource to test groups that are defined on Linux and UNIX platforms. The /etc/group file stores details about each group---group name, password, group identifier, along with a comma-separate list of users that belong to the group.'
|
data/lib/resources/file.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# license: All rights reserved
|
6
6
|
|
7
7
|
module Inspec::Resources
|
8
|
-
class File < Inspec.resource(1)
|
8
|
+
class File < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
|
9
9
|
name 'file'
|
10
10
|
desc 'Use the file InSpec audit resource to test all system file types, including files, directories, symbolic links, named pipes, sockets, character devices, block devices, and doors.'
|
11
11
|
example "
|
@@ -18,8 +18,9 @@ module Inspec::Resources
|
|
18
18
|
its('mode') { should eq 0644 }
|
19
19
|
end
|
20
20
|
"
|
21
|
+
include MountParser
|
21
22
|
|
22
|
-
attr_reader :file, :path
|
23
|
+
attr_reader :file, :path, :mount_options
|
23
24
|
def initialize(path)
|
24
25
|
@path = path
|
25
26
|
@file = inspec.backend.file(@path)
|
@@ -28,7 +29,7 @@ module Inspec::Resources
|
|
28
29
|
%w{
|
29
30
|
type exist? file? block_device? character_device? socket? directory?
|
30
31
|
symlink? pipe? mode mode? owner owned_by? group grouped_into? link_target
|
31
|
-
link_path linked_to? content mtime size selinux_label
|
32
|
+
link_path linked_to? content mtime size selinux_label immutable?
|
32
33
|
product_version file_version version? md5sum sha256sum
|
33
34
|
}.each do |m|
|
34
35
|
define_method m.to_sym do |*args|
|
@@ -58,6 +59,30 @@ module Inspec::Resources
|
|
58
59
|
file_permission_granted?('x', by_usergroup, by_specific_user)
|
59
60
|
end
|
60
61
|
|
62
|
+
def mounted?(expected_options = nil, identical = false)
|
63
|
+
mounted = file.mounted
|
64
|
+
|
65
|
+
# return if no additional parameters have been provided
|
66
|
+
return file.mounted? if expected_options.nil?
|
67
|
+
|
68
|
+
# deprecation warning, this functionality will be removed in future version
|
69
|
+
warn "[DEPRECATION] `be_mounted.with and be_mounted.only_with` are deprecated. Please use `mount('#{path}')` instead."
|
70
|
+
|
71
|
+
# we cannot read mount data on non-Linux systems
|
72
|
+
return nil if !inspec.os.linux?
|
73
|
+
|
74
|
+
# parse content if we are on linux
|
75
|
+
@mount_options ||= parse_mount_options(mounted.stdout, true)
|
76
|
+
|
77
|
+
if identical
|
78
|
+
# check if the options should be identical
|
79
|
+
@mount_options == expected_options
|
80
|
+
else
|
81
|
+
# otherwise compare the selected values
|
82
|
+
@mount_options.contains(expected_options)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
61
86
|
def to_s
|
62
87
|
"File #{path}"
|
63
88
|
end
|