inspec 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/CHANGELOG.md +23 -2
- data/Gemfile +1 -1
- data/Rakefile +15 -1
- data/docs/resources.rst +1 -1
- data/examples/profile/controls/gordon.rb +1 -1
- data/examples/resource/controls/tiny.rb +3 -0
- data/examples/resource/inspec.yml +10 -0
- data/examples/resource/libraries/tiny.rb +3 -0
- data/lib/inspec/dsl.rb +17 -17
- data/lib/inspec/metadata.rb +3 -8
- data/lib/inspec/plugins/resource.rb +1 -1
- data/lib/inspec/profile.rb +3 -2
- data/lib/inspec/profile_context.rb +2 -2
- data/lib/inspec/rule.rb +7 -7
- data/lib/inspec/shell.rb +5 -8
- data/lib/inspec/targets/dir.rb +1 -1
- data/lib/inspec/targets/tar.rb +3 -6
- data/lib/inspec/targets/url.rb +15 -9
- data/lib/inspec/targets/url.rb.orig +87 -0
- data/lib/inspec/version.rb +1 -1
- data/lib/matchers/matchers.rb +1 -1
- data/lib/resources/audit_policy.rb +1 -1
- data/lib/resources/command.rb +3 -3
- data/lib/resources/etc_group.rb +1 -1
- data/lib/resources/file.rb +4 -3
- data/lib/resources/group.rb +14 -18
- data/lib/resources/iptables.rb +1 -1
- data/lib/resources/json.rb +4 -6
- data/lib/resources/kernel_parameter.rb +1 -1
- data/lib/resources/os.rb +1 -1
- data/lib/resources/package.rb +20 -2
- data/lib/resources/passwd.rb +1 -1
- data/lib/resources/port.rb +112 -42
- data/lib/resources/postgres_conf.rb +1 -1
- data/lib/resources/postgres_session.rb +2 -2
- data/lib/resources/registry_key.rb +2 -1
- data/lib/resources/security_policy.rb +2 -2
- data/lib/resources/service.rb +50 -1
- data/lib/resources/user.rb +45 -0
- data/lib/resources/yum.rb +2 -2
- data/lib/utils/convert.rb +1 -1
- data/lib/utils/find_files.rb +3 -3
- data/lib/utils/parser.rb +2 -2
- data/tasks/maintainers.rb +6 -6
- data/test/helper.rb +4 -2
- data/test/integration/cookbooks/os_prepare/recipes/file.rb +9 -2
- data/test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb +8 -2
- data/test/integration/test/integration/default/etc_group_spec.rb +22 -0
- data/test/integration/test/integration/default/file_spec.rb +10 -1
- data/test/integration/test/integration/default/group_spec.rb +17 -0
- data/test/integration/test/integration/default/package_spec.rb +10 -4
- data/test/integration/test/integration/default/port_spec.rb +6 -0
- data/test/integration/test/integration/default/service_spec.rb +3 -0
- data/test/integration/test/integration/default/user_spec.rb +26 -16
- data/test/unit/metadata_test.rb +24 -0
- data/test/unit/mock/cmd/lsof-nP-i-FpctPn +63 -0
- data/test/unit/mock/cmd/netstat-tulpen +1 -0
- data/test/unit/mock/cmd/systemctl-show-all-sshd +1 -1
- data/test/unit/mock/profiles/complete-meta/metadata.rb +1 -1
- data/test/unit/mock/profiles/custom-resource/libraries/resource.rb +3 -0
- data/test/unit/mock/profiles/custom-resource/metadata.rb +7 -0
- data/{examples/kitchen-ansible/.kitchen/logs/default-centos-71.log → test/unit/mock/profiles/custom-resource/test/.gitkeep} +0 -0
- data/test/unit/profile_test.rb +6 -2
- data/test/unit/resources/port_test.rb +8 -0
- data/test/unit/targets.rb +132 -0
- metadata +19 -551
- data/bin/os +0 -23
- data/examples/kitchen-ansible/.kitchen/logs/default-ubuntu-1204.log +0 -0
- data/examples/kitchen-ansible/.kitchen/logs/default-ubuntu-1404.log +0 -432
- data/examples/kitchen-ansible/.kitchen/logs/kitchen.log +0 -10
- data/examples/kitchen-ansible/Gemfile.lock +0 -154
- data/examples/kitchen-chef/.kitchen/default-centos-71.yml +0 -6
- data/examples/kitchen-chef/.kitchen/default-ubuntu-1204.yml +0 -6
- data/examples/kitchen-chef/.kitchen/default-ubuntu-1404.yml +0 -6
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/id +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-centos-71/Vagrantfile +0 -9
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1204/Vagrantfile +0 -9
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/examples/kitchen-chef/.kitchen/kitchen-vagrant/kitchen-kitchen-chef-default-ubuntu-1404/Vagrantfile +0 -9
- data/examples/kitchen-chef/.kitchen/logs/default-centos-71.log +0 -4
- data/examples/kitchen-chef/.kitchen/logs/default-ubuntu-1204.log +0 -4
- data/examples/kitchen-chef/.kitchen/logs/default-ubuntu-1404.log +0 -4
- data/examples/kitchen-chef/.kitchen/logs/kitchen.log +0 -8
- data/examples/kitchen-chef/Berksfile.lock +0 -11
- data/examples/kitchen-chef/Gemfile.lock +0 -223
- data/examples/kitchen-puppet/.bundle/config +0 -2
- 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 +0 -306
- data/examples/kitchen-puppet/.kitchen/logs/kitchen.log +0 -10
- data/examples/kitchen-puppet/.librarian/puppet/config +0 -2
- data/examples/kitchen-puppet/Gemfile.lock +0 -174
- data/examples/kitchen-puppet/Puppetfile.lock +0 -2
- data/examples/profile/libraries/.DS_Store +0 -0
- data/examples/test-kitchen/.kitchen/logs/default-centos-71.log +0 -5
- data/examples/test-kitchen/.kitchen/logs/default-ubuntu-1204.log +0 -5
- data/examples/test-kitchen/.kitchen/logs/default-ubuntu-1404.log +0 -5
- data/examples/test-kitchen/.kitchen/logs/kitchen.log +0 -5
- data/examples/test-kitchen/Berksfile.lock +0 -11
- data/examples/test-kitchen/Gemfile.lock +0 -233
- data/lib/.DS_Store +0 -0
- data/lib/resources/certificate.rb +0 -0
- data/lib/resources/private_key.rb +0 -0
- data/test/chefdk/.gitignore +0 -16
- data/test/chefdk/.kitchen.yml +0 -27
- data/test/chefdk/Policyfile.rb +0 -16
- data/test/chefdk/README.md +0 -4
- data/test/chefdk/chefignore +0 -100
- data/test/chefdk/metadata.rb +0 -7
- data/test/chefdk/recipes/default.rb +0 -5
- data/test/chefdk/spec/spec_helper.rb +0 -2
- data/test/chefdk/spec/unit/recipes/default_spec.rb +0 -20
- data/test/chefdk/test/integration/default/serverspec/default_spec.rb +0 -9
- data/test/chefdk/test/integration/helpers/serverspec/spec_helper.rb +0 -8
- data/test/integration/.DS_Store +0 -0
- data/test/integration/.kitchen.local.yml +0 -68
- data/test/integration/.kitchen/default-aws-linux.yml +0 -4
- data/test/integration/.kitchen/default-centos-511.yml +0 -6
- data/test/integration/.kitchen/default-centos-67.yml +0 -6
- data/test/integration/.kitchen/default-centos-7.yml +0 -4
- data/test/integration/.kitchen/default-centos-71.yml +0 -6
- data/test/integration/.kitchen/default-debian-6010.yml +0 -6
- data/test/integration/.kitchen/default-debian-78.yml +0 -6
- data/test/integration/.kitchen/default-debian-8.yml +0 -4
- data/test/integration/.kitchen/default-debian-81.yml +0 -6
- data/test/integration/.kitchen/default-fedora-21.yml +0 -6
- data/test/integration/.kitchen/default-fedora-22.yml +0 -4
- data/test/integration/.kitchen/default-freebsd-102.yml +0 -6
- data/test/integration/.kitchen/default-freebsd-93.yml +0 -6
- data/test/integration/.kitchen/default-opensuse-132-x86-64.yml +0 -6
- data/test/integration/.kitchen/default-redhat-65.yml +0 -4
- data/test/integration/.kitchen/default-redhat-71.yml +0 -4
- data/test/integration/.kitchen/default-suse-11sp3.yml +0 -4
- data/test/integration/.kitchen/default-suse-12.yml +0 -4
- data/test/integration/.kitchen/default-ubuntu-1004.yml +0 -6
- data/test/integration/.kitchen/default-ubuntu-1204.yml +0 -4
- data/test/integration/.kitchen/default-ubuntu-1404.yml +0 -4
- data/test/integration/.kitchen/default-ubuntu-1510.yml +0 -4
- data/test/integration/.kitchen/default-windows-2012.yml +0 -5
- data/test/integration/.kitchen/default-windows-2012r2.yml +0 -6
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-511/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67-i386/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-67/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-centos-71/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-6010/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-78/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-debian-81/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-21/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-fedora-22/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-102/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-freebsd-93/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-opensuse-132-x86-64/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1004/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1204/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-default-ubuntu-1404/Vagrantfile +0 -9
- data/test/integration/.kitchen/kitchen-vagrant/kitchen-integration-new-ubuntu-1404/Vagrantfile +0 -9
- 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 +0 -23
- 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 +0 -3
- 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 +0 -3
- 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 +0 -1
- data/test/integration/Berksfile.lock +0 -11
- data/test/integration/TODO.md +0 -15
- 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 +0 -7
- data/test/integration/test/integration/default/etc_group.rb +0 -13
- data/test/serverspec/.kitchen.yml +0 -18
- data/test/serverspec/.kitchen/default-ubuntu-1404.yml +0 -6
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/id +0 -1
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/test/serverspec/.kitchen/kitchen-vagrant/kitchen-serverspec-default-ubuntu-1404/Vagrantfile +0 -9
- data/test/serverspec/.kitchen/logs/default-ubuntu-1404.log +0 -2
- data/test/serverspec/.kitchen/logs/kitchen.log +0 -3
- data/test/serverspec/Berksfile +0 -3
- data/test/serverspec/Berksfile.lock +0 -5
- data/test/serverspec/TODO.md +0 -2
- data/test/serverspec/test/integration/default/serverspec/os_spec.rb +0 -25
- data/test/serverspec/test/integration/default/serverspec/spec_helper.rb +0 -48
- data/test/serverspec/test/integration/default/serverspec/sysctl_spec.rb +0 -37
- data/test/unit/mock/cmd/lsof-np-itcp +0 -4
data/lib/inspec/version.rb
CHANGED
data/lib/matchers/matchers.rb
CHANGED
data/lib/resources/command.rb
CHANGED
@@ -39,15 +39,15 @@ class Cmd < Inspec.resource(1)
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def exist?
|
42
|
+
# silent for mock resources
|
43
|
+
return false if inspec.os[:family].to_s == 'unknown'
|
44
|
+
|
42
45
|
if inspec.os.linux?
|
43
46
|
res = inspec.backend.run_command("bash -c 'type \"#{@command}\"'")
|
44
47
|
elsif inspec.os.windows?
|
45
48
|
res = inspec.backend.run_command("where.exe \"#{@command}\"")
|
46
49
|
elsif inspec.os.unix?
|
47
50
|
res = inspec.backend.run_command("type \"#{@command}\"")
|
48
|
-
elsif inspec.os[:family].to_s == 'unknown'
|
49
|
-
# silent for mock resources
|
50
|
-
return false
|
51
51
|
else
|
52
52
|
warn "`command(#{@command}).exist?` is not suported on you OS: #{inspec.os[:family]}"
|
53
53
|
return false
|
data/lib/resources/etc_group.rb
CHANGED
@@ -45,7 +45,7 @@ class EtcGroup < Inspec.resource(1)
|
|
45
45
|
|
46
46
|
# skip resource if it is not supported on current OS
|
47
47
|
return skip_resource 'The `etc_group` resource is not supported on your OS.' \
|
48
|
-
unless %w{ubuntu debian redhat fedora centos arch darwin freebsd wrlinux}.include?(inspec.os[:family])
|
48
|
+
unless %w{ubuntu debian redhat fedora centos arch darwin freebsd wrlinux aix}.include?(inspec.os[:family])
|
49
49
|
end
|
50
50
|
|
51
51
|
def groups(filter = nil)
|
data/lib/resources/file.rb
CHANGED
@@ -92,9 +92,8 @@ module Inspec::Resources
|
|
92
92
|
def file_permission_granted?(flag, by_usergroup, by_specific_user)
|
93
93
|
fail 'Checking file permissions is not supported on your os' unless unix?
|
94
94
|
|
95
|
-
|
96
|
-
|
97
|
-
if by_specific_user.nil?
|
95
|
+
if by_specific_user.nil? || by_specific_user.empty?
|
96
|
+
usergroup = usergroup_for(by_usergroup, by_specific_user)
|
98
97
|
check_file_permission_by_mask(usergroup, flag)
|
99
98
|
else
|
100
99
|
check_file_permission_by_user(by_specific_user, flag)
|
@@ -113,6 +112,8 @@ module Inspec::Resources
|
|
113
112
|
perm_cmd = "su -s /bin/sh -c \"test -#{flag} #{path}\" #{user}"
|
114
113
|
elsif family == 'freebsd'
|
115
114
|
perm_cmd = "sudo -u #{user} test -#{flag} #{path}"
|
115
|
+
elsif family == 'aix'
|
116
|
+
perm_cmd = "su #{user} -c test -#{flag} #{path}"
|
116
117
|
else
|
117
118
|
return skip_resource 'The `file` resource does not support `by_user` on your OS.'
|
118
119
|
end
|
data/lib/resources/group.rb
CHANGED
@@ -48,15 +48,13 @@ class Group < Inspec.resource(1)
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def gid
|
51
|
-
if group_info.nil? || group_info.size == 0
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
return group_info.map { |grp| grp[:gid] }
|
59
|
-
end
|
51
|
+
return nil if group_info.nil? || group_info.size == 0
|
52
|
+
|
53
|
+
# the default case should be one group
|
54
|
+
return group_info[0][:gid] if group_info.size == 1
|
55
|
+
|
56
|
+
# return array if we got multiple gids
|
57
|
+
group_info.map { |grp| grp[:gid] }
|
60
58
|
end
|
61
59
|
|
62
60
|
# implements rspec has matcher, to be compatible with serverspec
|
@@ -65,15 +63,13 @@ class Group < Inspec.resource(1)
|
|
65
63
|
end
|
66
64
|
|
67
65
|
def local
|
68
|
-
if group_info.nil? || group_info.size == 0
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
return group_info.map { |grp| grp[:local] }
|
76
|
-
end
|
66
|
+
return nil if group_info.nil? || group_info.size == 0
|
67
|
+
|
68
|
+
# the default case should be one group
|
69
|
+
return group_info[0][:local] if group_info.size == 1
|
70
|
+
|
71
|
+
# return array if we got multiple gids
|
72
|
+
group_info.map { |grp| grp[:local] }
|
77
73
|
end
|
78
74
|
|
79
75
|
def to_s
|
data/lib/resources/iptables.rb
CHANGED
@@ -47,7 +47,7 @@ class IpTables < Inspec.resource(1)
|
|
47
47
|
retrieve_rules.each { |line|
|
48
48
|
# checks if the rule is part of the ruleset
|
49
49
|
# for now, we expect an excact match
|
50
|
-
found = true if line.
|
50
|
+
found = true if line.casecmp(rule) == 0
|
51
51
|
}
|
52
52
|
found
|
53
53
|
end
|
data/lib/resources/json.rb
CHANGED
@@ -74,11 +74,9 @@ class JsonConfig < Inspec.resource(1)
|
|
74
74
|
value = value[key.to_s].nil? ? nil : value[key.to_s]
|
75
75
|
end
|
76
76
|
|
77
|
-
#
|
78
|
-
if
|
79
|
-
|
80
|
-
|
81
|
-
return value
|
82
|
-
end
|
77
|
+
# if there are no more keys, just return the value
|
78
|
+
return value if keys.first.nil?
|
79
|
+
# if there are more keys, extract more
|
80
|
+
extract_value(keys.clone, value)
|
83
81
|
end
|
84
82
|
end
|
data/lib/resources/os.rb
CHANGED
@@ -13,7 +13,7 @@ class OS < Inspec.resource(1)
|
|
13
13
|
|
14
14
|
# reuse helper methods from backend
|
15
15
|
%w{redhat? debian? suse? bsd? solaris? linux? unix? windows?}.each do |os_family|
|
16
|
-
define_method(
|
16
|
+
define_method(os_family.to_sym) do
|
17
17
|
inspec.backend.os.send(os_family)
|
18
18
|
end
|
19
19
|
end
|
data/lib/resources/package.rb
CHANGED
@@ -36,6 +36,8 @@ class Package < Inspec.resource(1)
|
|
36
36
|
@pkgman = Brew.new(inspec)
|
37
37
|
when 'windows'
|
38
38
|
@pkgman = WindowsPkg.new(inspec)
|
39
|
+
when 'aix'
|
40
|
+
@pkgman = BffPkg.new(inspec)
|
39
41
|
else
|
40
42
|
return skip_resource 'The `package` resource is not supported on your OS yet.'
|
41
43
|
end
|
@@ -134,9 +136,9 @@ class Brew < PkgManagement
|
|
134
136
|
# parse data
|
135
137
|
pkg = JSON.parse(cmd.stdout)[0]
|
136
138
|
{
|
137
|
-
name:
|
139
|
+
name: pkg.name.to_s,
|
138
140
|
installed: true,
|
139
|
-
version:
|
141
|
+
version: pkg.installed.version.to_s,
|
140
142
|
type: 'brew',
|
141
143
|
}
|
142
144
|
end
|
@@ -186,3 +188,19 @@ class WindowsPkg < PkgManagement
|
|
186
188
|
}
|
187
189
|
end
|
188
190
|
end
|
191
|
+
|
192
|
+
# AIX
|
193
|
+
class BffPkg < PkgManagement
|
194
|
+
def info(package_name)
|
195
|
+
cmd = inspec.command("lslpp -cL #{package_name}")
|
196
|
+
return nil if cmd.exit_status.to_i != 0
|
197
|
+
|
198
|
+
bff_pkg = cmd.stdout.split("\n").last.split(':')
|
199
|
+
{
|
200
|
+
name: bff_pkg[1],
|
201
|
+
installed: true,
|
202
|
+
version: bff_pkg[2],
|
203
|
+
type: 'bff',
|
204
|
+
}
|
205
|
+
end
|
206
|
+
end
|
data/lib/resources/passwd.rb
CHANGED
data/lib/resources/port.rb
CHANGED
@@ -34,8 +34,11 @@ class Port < Inspec.resource(1)
|
|
34
34
|
case inspec.os[:family]
|
35
35
|
when 'ubuntu', 'debian', 'redhat', 'fedora', 'centos', 'arch', 'wrlinux'
|
36
36
|
@port_manager = LinuxPorts.new(inspec)
|
37
|
-
when 'darwin'
|
38
|
-
|
37
|
+
when 'darwin', 'aix'
|
38
|
+
# AIX: see http://www.ibm.com/developerworks/aix/library/au-lsof.html#resources
|
39
|
+
# and https://www-01.ibm.com/marketing/iwm/iwm/web/reg/pick.do?source=aixbp
|
40
|
+
# Darwin: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/lsof.8.html
|
41
|
+
@port_manager = LsofPorts.new(inspec)
|
39
42
|
when 'windows'
|
40
43
|
@port_manager = WindowsPorts.new(inspec)
|
41
44
|
when 'freebsd'
|
@@ -129,44 +132,110 @@ class WindowsPorts < PortsInfo
|
|
129
132
|
end
|
130
133
|
end
|
131
134
|
|
132
|
-
# extracts udp and tcp ports from
|
133
|
-
class
|
134
|
-
|
135
|
-
# collects UDP and TCP information
|
136
|
-
cmd = inspec.command('lsof -nP -iTCP -iUDP -sTCP:LISTEN')
|
137
|
-
return nil if cmd.exit_status.to_i != 0
|
135
|
+
# extracts udp and tcp ports from the lsof command
|
136
|
+
class LsofPorts < PortsInfo
|
137
|
+
attr_reader :lsof
|
138
138
|
|
139
|
+
def initialize(inspec, lsofpath = nil)
|
140
|
+
@lsof = lsofpath || 'lsof'
|
141
|
+
super(inspec)
|
142
|
+
end
|
143
|
+
|
144
|
+
def info
|
139
145
|
ports = []
|
140
|
-
# split on each newline
|
141
|
-
cmd.stdout.each_line do |line|
|
142
|
-
# parse each line
|
143
|
-
# 1 - COMMAND, 2 - PID, 3 - USER, 4 - FD, 5 - TYPE, 6 - DEVICE, 7 - SIZE/OFF, 8 - NODE, 9 - NAME
|
144
|
-
parsed = /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+).*$/.match(line)
|
145
|
-
# extract network info
|
146
|
-
net_addr = parsed[9].split(':')
|
147
|
-
# convert to number if possible
|
148
|
-
net_port = net_addr[1]
|
149
|
-
net_port = net_port.to_i if /^\d+$/.match(net_port)
|
150
|
-
protocol = parsed[8].downcase
|
151
|
-
|
152
|
-
# add version to protocol
|
153
|
-
type = parsed[5].downcase
|
154
|
-
protocol += '6' if type == 'IPv6'
|
155
|
-
|
156
|
-
# map data
|
157
|
-
port_info = {
|
158
|
-
port: net_port,
|
159
|
-
address: net_addr[0],
|
160
|
-
protocol: protocol,
|
161
|
-
process: parsed[1],
|
162
|
-
pid: parsed[2].to_i,
|
163
|
-
}
|
164
146
|
|
165
|
-
|
166
|
-
|
147
|
+
# check that lsof is available, otherwise fail
|
148
|
+
fail 'Please ensure `lsof` is available on the machine.' if !inspec.command(@lsof.to_s).exist?
|
149
|
+
|
150
|
+
# -F p=pid, c=command, P=protocol name, t=type, n=internet addresses
|
151
|
+
# see 'OUTPUT FOR OTHER PROGRAMS' in LSOF(8)
|
152
|
+
lsof_cmd = inspec.command("#{@lsof} -nP -i -FpctPn")
|
153
|
+
return nil if lsof_cmd.exit_status.to_i != 0
|
154
|
+
|
155
|
+
# map to desired return struct
|
156
|
+
lsof_parser(lsof_cmd).each do |process, port_ids|
|
157
|
+
pid, cmd = process.split(':')
|
158
|
+
port_ids.each do |port_str|
|
159
|
+
# should not break on ipv6 addresses
|
160
|
+
ipv, proto, port, host = port_str.split(':', 4)
|
161
|
+
ports.push({ port: port.to_i,
|
162
|
+
address: host,
|
163
|
+
protocol: ipv == 'ipv6' ? proto + '6' : proto,
|
164
|
+
process: cmd,
|
165
|
+
pid: pid.to_i })
|
166
|
+
end
|
167
167
|
end
|
168
|
+
|
168
169
|
ports
|
169
170
|
end
|
171
|
+
|
172
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
173
|
+
# rubocop:disable Metrics/AbcSize
|
174
|
+
def lsof_parser(lsof_cmd)
|
175
|
+
procs = {}
|
176
|
+
# build this with formatted output (-F) from lsof
|
177
|
+
# procs = {
|
178
|
+
# '123:sshd' => [
|
179
|
+
# 'ipv4:tcp:22:127.0.0.1',
|
180
|
+
# 'ipv6:tcp:22:::1',
|
181
|
+
# 'ipv4:tcp:*',
|
182
|
+
# 'ipv6:tcp:*',
|
183
|
+
# ],
|
184
|
+
# '456:ntpd' => [
|
185
|
+
# 'ipv4:udp:123:*',
|
186
|
+
# 'ipv6:udp:123:*',
|
187
|
+
# ]
|
188
|
+
# }
|
189
|
+
proc_id = port_id = nil
|
190
|
+
lsof_cmd.stdout.each_line do |line|
|
191
|
+
line.chomp!
|
192
|
+
key = line.slice!(0)
|
193
|
+
case key
|
194
|
+
when 'p'
|
195
|
+
proc_id = line
|
196
|
+
port_id = nil
|
197
|
+
when 'c'
|
198
|
+
proc_id += ':' + line
|
199
|
+
when 't'
|
200
|
+
port_id = line.downcase
|
201
|
+
when 'P'
|
202
|
+
port_id += ':' + line.downcase
|
203
|
+
when 'n'
|
204
|
+
src, dst = line.split('->')
|
205
|
+
|
206
|
+
# skip active comm streams
|
207
|
+
next if dst
|
208
|
+
|
209
|
+
host, port = /^(\S+):(\d+|\*)$/.match(src)[1, 2]
|
210
|
+
|
211
|
+
# skip channels from port 0 - what does this mean?
|
212
|
+
next if port == '*'
|
213
|
+
|
214
|
+
# create new array stub if !exist?
|
215
|
+
procs[proc_id] = [] unless procs.key?(proc_id)
|
216
|
+
|
217
|
+
# change address '*' to zero
|
218
|
+
host = (port_id =~ /^ipv6:/) ? '[::]' : '0.0.0.0' if host == '*'
|
219
|
+
# entrust URI to scrub the host and port
|
220
|
+
begin
|
221
|
+
uri = URI("addr://#{host}:#{port}")
|
222
|
+
uri.host && uri.port
|
223
|
+
rescue => e
|
224
|
+
warn "could not parse URI 'addr://#{host}:#{port}' - #{e}"
|
225
|
+
next
|
226
|
+
end
|
227
|
+
|
228
|
+
# e.g. 'ipv4:tcp:22:127.0.0.1'
|
229
|
+
# strip ipv6 squares for inspec
|
230
|
+
port_id += ':' + port + ':' + host.gsub(/^\[|\]$/, '')
|
231
|
+
|
232
|
+
# lsof will give us another port unless it's done
|
233
|
+
procs[proc_id] << port_id
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
procs
|
238
|
+
end
|
170
239
|
end
|
171
240
|
|
172
241
|
# extract port information from netstat
|
@@ -192,17 +261,18 @@ class LinuxPorts < PortsInfo
|
|
192
261
|
# prep for URI parsing, parse ip6 port
|
193
262
|
ip6 = /^(\S+):(\d+)$/.match(net_addr)
|
194
263
|
ip6addr = ip6[1]
|
195
|
-
ip6addr = '::' if
|
264
|
+
ip6addr = '::' if ip6addr =~ /^:::$/
|
196
265
|
# build uri
|
197
266
|
ip_addr = URI("addr://[#{ip6addr}]:#{ip6[2]}")
|
198
267
|
# replace []
|
199
268
|
host = ip_addr.host[1..ip_addr.host.size-2]
|
200
|
-
port = ip_addr.port
|
201
269
|
else
|
202
270
|
ip_addr = URI('addr://'+net_addr)
|
203
271
|
host = ip_addr.host
|
204
|
-
port = ip_addr.port
|
205
272
|
end
|
273
|
+
|
274
|
+
port = ip_addr.port
|
275
|
+
|
206
276
|
[host, port]
|
207
277
|
rescue URI::InvalidURIError => e
|
208
278
|
warn "Could not parse #{net_addr}, #{e}"
|
@@ -212,7 +282,7 @@ class LinuxPorts < PortsInfo
|
|
212
282
|
def parse_netstat_line(line)
|
213
283
|
# parse each line
|
214
284
|
# 1 - Proto, 2 - Recv-Q, 3 - Send-Q, 4 - Local Address, 5 - Foreign Address, 6 - State, 7 - Inode, 8 - PID/Program name
|
215
|
-
parsed = /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)
|
285
|
+
parsed = /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)?\s+(\S+)\s+(\S+)\s+(\S+)/.match(line)
|
216
286
|
|
217
287
|
return {} if parsed.nil? || line.match(/^proto/i)
|
218
288
|
|
@@ -228,7 +298,7 @@ class LinuxPorts < PortsInfo
|
|
228
298
|
# extract PID
|
229
299
|
process = parsed[9].split('/')
|
230
300
|
pid = process[0]
|
231
|
-
pid = pid.to_i if /^\d
|
301
|
+
pid = pid.to_i if pid =~ /^\d+$/
|
232
302
|
process = process[1]
|
233
303
|
|
234
304
|
# map data
|
@@ -264,14 +334,14 @@ class FreeBsdPorts < PortsInfo
|
|
264
334
|
case protocol
|
265
335
|
when 'tcp4', 'udp4'
|
266
336
|
# replace * with 0.0.0.0
|
267
|
-
net_addr = net_addr.gsub(/^\*:/, '0.0.0.0:') if /^*:(\d+)
|
337
|
+
net_addr = net_addr.gsub(/^\*:/, '0.0.0.0:') if net_addr =~ /^*:(\d+)$/
|
268
338
|
ip_addr = URI('addr://'+net_addr)
|
269
339
|
host = ip_addr.host
|
270
340
|
port = ip_addr.port
|
271
341
|
when 'tcp6', 'udp6'
|
272
342
|
return [] if net_addr == '*:*' # abort for now
|
273
343
|
# replace * with 0:0:0:0:0:0:0:0
|
274
|
-
net_addr = net_addr.gsub(/^\*:/, '0:0:0:0:0:0:0:0:') if /^*:(\d+)
|
344
|
+
net_addr = net_addr.gsub(/^\*:/, '0:0:0:0:0:0:0:0:') if net_addr =~ /^*:(\d+)$/
|
275
345
|
# extract port
|
276
346
|
ip6 = /^(\S+):(\d+)$/.match(net_addr)
|
277
347
|
ip6addr = ip6[1]
|
@@ -301,7 +371,7 @@ class FreeBsdPorts < PortsInfo
|
|
301
371
|
|
302
372
|
# extract PID
|
303
373
|
pid = parsed[3]
|
304
|
-
pid = pid.to_i if /^\d
|
374
|
+
pid = pid.to_i if pid =~ /^\d+$/
|
305
375
|
|
306
376
|
# map tcp4 and udp4
|
307
377
|
protocol = 'tcp' if protocol.eql?('tcp4')
|
@@ -21,7 +21,7 @@ class PostgresConf < Inspec.resource(1)
|
|
21
21
|
|
22
22
|
def initialize(conf_path = nil)
|
23
23
|
@conf_path = conf_path || inspec.postgres.conf_path
|
24
|
-
@conf_dir = File.expand_path(File.dirname
|
24
|
+
@conf_dir = File.expand_path(File.dirname(@conf_path))
|
25
25
|
@files_contents = {}
|
26
26
|
@content = nil
|
27
27
|
@params = nil
|