inspec 0.28.1 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +46 -2
 - data/README.md +3 -3
 - data/inspec.gemspec +1 -1
 - data/lib/inspec/rspec_json_formatter.rb +107 -34
 - data/lib/inspec/runner.rb +1 -1
 - data/lib/inspec/version.rb +1 -1
 - data/lib/resources/apache.rb +1 -2
 - data/lib/resources/auditd_rules.rb +1 -1
 - data/lib/resources/command.rb +2 -2
 - data/lib/resources/grub_conf.rb +29 -17
 - data/lib/resources/kernel_module.rb +1 -1
 - data/lib/resources/mysql.rb +1 -1
 - data/lib/resources/oneget.rb +1 -1
 - data/lib/resources/os_env.rb +1 -1
 - data/lib/resources/package.rb +1 -1
 - data/lib/resources/parse_config.rb +22 -13
 - data/lib/resources/pip.rb +1 -3
 - data/lib/resources/port.rb +27 -21
 - data/lib/resources/postgres.rb +9 -15
 - data/lib/resources/service.rb +27 -26
 - data/lib/resources/windows_feature.rb +1 -1
 - data/test/cookbooks/os_prepare/recipes/apt.rb +2 -2
 - data/test/cookbooks/os_prepare/recipes/default.rb +2 -0
 - data/test/cookbooks/os_prepare/recipes/package.rb +1 -2
 - data/test/cookbooks/os_prepare/recipes/postgres.rb +2 -0
 - data/test/cookbooks/os_prepare/recipes/prep_container.rb +15 -0
 - data/test/cookbooks/os_prepare/recipes/service.rb +3 -3
 - data/test/docker_test.rb +8 -0
 - data/test/functional/inspec_exec_test.rb +4 -3
 - data/test/helper.rb +20 -19
 - data/test/integration/default/_debug_spec.rb +8 -1
 - data/test/integration/default/apache_conf_spec.rb +8 -3
 - data/test/integration/default/apt_spec.rb +1 -6
 - data/test/integration/default/etc_group_spec.rb +4 -2
 - data/test/integration/default/file_spec.rb +4 -3
 - data/test/integration/default/iptables_spec.rb +4 -3
 - data/test/integration/default/kernel_module_spec.rb +8 -3
 - data/test/integration/default/kernel_parameter_spec.rb +4 -3
 - data/test/integration/default/mount_spec.rb +8 -3
 - data/test/integration/default/package_spec.rb +0 -3
 - data/test/integration/default/port_spec.rb +4 -3
 - data/test/integration/default/postgres_session_spec.rb +4 -3
 - data/test/integration/default/service_spec.rb +4 -3
 - data/test/unit/mock/files/sysctl.conf +7 -0
 - data/test/unit/profile_context_test.rb +6 -6
 - data/test/unit/resources/os_test.rb +5 -5
 - data/test/unit/resources/parse_config_test.rb +26 -0
 - data/test/unit/resources/port_test.rb +9 -0
 - metadata +10 -4
 
| 
         @@ -60,11 +60,12 @@ Target:  local:// 
     | 
|
| 
       60 
60 
     | 
    
         | 
| 
       61 
61 
     | 
    
         
             
            \e[32m  ✔  working should eq \"working\"\e[0m
         
     | 
| 
       62 
62 
     | 
    
         
             
            \e[37m  ○  skippy This will be skipped intentionally.\e[0m
         
     | 
| 
       63 
     | 
    
         
            -
            \e[31m  ✖  failing should eq \"as intended\"
         
     | 
| 
      
 63 
     | 
    
         
            +
            \e[31m  ✖  failing should eq \"as intended\" (
         
     | 
| 
       64 
64 
     | 
    
         
             
                 expected: \"as intended\"
         
     | 
| 
       65 
65 
     | 
    
         
             
                      got: \"failing\"
         
     | 
| 
       66 
     | 
    
         
            -
                  
     | 
| 
       67 
     | 
    
         
            -
                  
     | 
| 
      
 66 
     | 
    
         
            +
                 
         
     | 
| 
      
 67 
     | 
    
         
            +
                 (compared using ==)
         
     | 
| 
      
 68 
     | 
    
         
            +
                 )\e[0m
         
     | 
| 
       68 
69 
     | 
    
         | 
| 
       69 
70 
     | 
    
         
             
            Summary: \e[32m1 successful\e[0m, \e[31m1 failures\e[0m, \e[37m1 skipped\e[0m
         
     | 
| 
       70 
71 
     | 
    
         
             
            "
         
     | 
    
        data/test/helper.rb
    CHANGED
    
    | 
         @@ -38,25 +38,25 @@ TMP_CACHE = {} 
     | 
|
| 
       38 
38 
     | 
    
         
             
            class MockLoader
         
     | 
| 
       39 
39 
     | 
    
         
             
              # collects emulation operating systems
         
     | 
| 
       40 
40 
     | 
    
         
             
              OPERATING_SYSTEMS = {
         
     | 
| 
       41 
     | 
    
         
            -
                arch:       { family: 'arch', release: nil, arch: nil },
         
     | 
| 
       42 
     | 
    
         
            -
                centos5:    { family: 'redhat', release: '5.11', arch: 'x86_64' },
         
     | 
| 
       43 
     | 
    
         
            -
                centos6:    { family: 'redhat', release: '6.6', arch: 'x86_64' },
         
     | 
| 
       44 
     | 
    
         
            -
                centos7:    { family: 'redhat', release: '7.1.1503', arch: 'x86_64' },
         
     | 
| 
       45 
     | 
    
         
            -
                debian6:    { family: 'debian', release: '6', arch: 'x86_64' },
         
     | 
| 
       46 
     | 
    
         
            -
                debian7:    { family: 'debian', release: '7', arch: 'x86_64' },
         
     | 
| 
       47 
     | 
    
         
            -
                debian8:    { family: 'debian', release: '8', arch: 'x86_64' },
         
     | 
| 
       48 
     | 
    
         
            -
                freebsd9:   { family: 'freebsd', release: '9', arch: 'amd64' },
         
     | 
| 
       49 
     | 
    
         
            -
                freebsd10:  { family: 'freebsd', release: '10', arch: 'amd64' },
         
     | 
| 
       50 
     | 
    
         
            -
                osx104:     { family: 'darwin', release: '10.10.4', arch: nil 
     | 
| 
       51 
     | 
    
         
            -
                ubuntu1204: {  
     | 
| 
       52 
     | 
    
         
            -
                ubuntu1404: {  
     | 
| 
       53 
     | 
    
         
            -
                ubuntu1504: {  
     | 
| 
       54 
     | 
    
         
            -
                windows:    { family: 'windows', release: '6.2.9200', arch: 'x86_64' },
         
     | 
| 
       55 
     | 
    
         
            -
                wrlinux:    {  
     | 
| 
       56 
     | 
    
         
            -
                solaris11:  {  
     | 
| 
       57 
     | 
    
         
            -
                solaris10:  {  
     | 
| 
       58 
     | 
    
         
            -
                hpux:       {family: 'hpux', release: 'B.11.31', arch: 'ia64'},
         
     | 
| 
       59 
     | 
    
         
            -
                undefined:  { family: nil, release: nil, arch: nil },
         
     | 
| 
      
 41 
     | 
    
         
            +
                arch:       { name: 'arch', family: 'arch', release: nil, arch: nil },
         
     | 
| 
      
 42 
     | 
    
         
            +
                centos5:    { name: 'centos', family: 'redhat', release: '5.11', arch: 'x86_64' },
         
     | 
| 
      
 43 
     | 
    
         
            +
                centos6:    { name: 'centos', family: 'redhat', release: '6.6', arch: 'x86_64' },
         
     | 
| 
      
 44 
     | 
    
         
            +
                centos7:    { name: 'centos', family: 'redhat', release: '7.1.1503', arch: 'x86_64' },
         
     | 
| 
      
 45 
     | 
    
         
            +
                debian6:    { name: 'debian', family: 'debian', release: '6', arch: 'x86_64' },
         
     | 
| 
      
 46 
     | 
    
         
            +
                debian7:    { name: 'debian', family: 'debian', release: '7', arch: 'x86_64' },
         
     | 
| 
      
 47 
     | 
    
         
            +
                debian8:    { name: 'debian', family: 'debian', release: '8', arch: 'x86_64' },
         
     | 
| 
      
 48 
     | 
    
         
            +
                freebsd9:   { name: 'freebsd', family: 'freebsd', release: '9', arch: 'amd64' },
         
     | 
| 
      
 49 
     | 
    
         
            +
                freebsd10:  { name: 'freebsd', family: 'freebsd', release: '10', arch: 'amd64' },
         
     | 
| 
      
 50 
     | 
    
         
            +
                osx104:     { name: 'mac_os_x',family: 'darwin', release: '10.10.4', arch: nil },
         
     | 
| 
      
 51 
     | 
    
         
            +
                ubuntu1204: { name: 'ubuntu', family: 'debian', release: '12.04', arch: 'x86_64' },
         
     | 
| 
      
 52 
     | 
    
         
            +
                ubuntu1404: { name: 'ubuntu', family: 'debian', release: '14.04', arch: 'x86_64' },
         
     | 
| 
      
 53 
     | 
    
         
            +
                ubuntu1504: { name: 'ubuntu', family: 'debian', release: '15.04', arch: 'x86_64' },
         
     | 
| 
      
 54 
     | 
    
         
            +
                windows:    { name: 'windows', family: 'windows', release: '6.2.9200', arch: 'x86_64' },
         
     | 
| 
      
 55 
     | 
    
         
            +
                wrlinux:    { name: 'wrlinux', family: 'redhat', release: '7.0(3)I2(2)', arch: 'x86_64' },
         
     | 
| 
      
 56 
     | 
    
         
            +
                solaris11:  { name: "solaris", family: 'solaris', release: '11', arch: 'i386'},
         
     | 
| 
      
 57 
     | 
    
         
            +
                solaris10:  { name: "solaris", family: 'solaris', release: '10', arch: 'i386'},
         
     | 
| 
      
 58 
     | 
    
         
            +
                hpux:       { name: 'hpux', family: 'hpux', release: 'B.11.31', arch: 'ia64'},
         
     | 
| 
      
 59 
     | 
    
         
            +
                undefined:  { name: nil, family: nil, release: nil, arch: nil },
         
     | 
| 
       60 
60 
     | 
    
         
             
              }
         
     | 
| 
       61 
61 
     | 
    
         | 
| 
       62 
62 
     | 
    
         
             
              # pass the os identifier to emulate a specific operating system
         
     | 
| 
         @@ -123,6 +123,7 @@ class MockLoader 
     | 
|
| 
       123 
123 
     | 
    
         
             
                  '/etc/xinetd.d' => mockfile.call('xinetd.d'),
         
     | 
| 
       124 
124 
     | 
    
         
             
                  '/etc/xinetd.d/chargen-stream' => mockfile.call('xinetd.d_chargen-stream'),
         
     | 
| 
       125 
125 
     | 
    
         
             
                  '/etc/xinetd.d/chargen-dgram' => mockfile.call('xinetd.d_chargen-dgram'),
         
     | 
| 
      
 126 
     | 
    
         
            +
                  '/etc/sysctl.conf' => mockfile.call('sysctl.conf'),
         
     | 
| 
       126 
127 
     | 
    
         
             
                }
         
     | 
| 
       127 
128 
     | 
    
         | 
| 
       128 
129 
     | 
    
         
             
                # create all mock commands
         
     | 
| 
         @@ -1 +1,8 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            puts "-----------------------------------"
         
     | 
| 
      
 2 
     | 
    
         
            +
            puts "        TEST ENVIRONMENT           "
         
     | 
| 
      
 3 
     | 
    
         
            +
            puts "-----------------------------------"
         
     | 
| 
      
 4 
     | 
    
         
            +
            puts "    Docker: #{!ENV['DOCKER'].nil?}"
         
     | 
| 
      
 5 
     | 
    
         
            +
            puts "   OS name: #{os[:name] || 'unknown' }"
         
     | 
| 
      
 6 
     | 
    
         
            +
            puts "OS release: #{os[:release] || 'unknown'}"
         
     | 
| 
      
 7 
     | 
    
         
            +
            puts " OS family: #{os[:family] || 'unknown'}"
         
     | 
| 
      
 8 
     | 
    
         
            +
            puts "-----------------------------------"
         
     | 
| 
         @@ -1,8 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 3 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 4 
     | 
    
         
            +
              return
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
       2 
6 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            return 
     | 
| 
      
 7 
     | 
    
         
            +
            if !os.linux?
         
     | 
| 
      
 8 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__} because we are not on linux.\033[0m"
         
     | 
| 
      
 9 
     | 
    
         
            +
              return
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
       6 
11 
     | 
    
         | 
| 
       7 
12 
     | 
    
         
             
            # direct access to params of apache conf
         
     | 
| 
       8 
13 
     | 
    
         
             
            describe apache_conf do
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            if os[: 
     | 
| 
      
 3 
     | 
    
         
            +
            if os[:name] == 'ubuntu'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              describe apt('ppa:nginx/stable') do
         
     | 
| 
       6 
6 
     | 
    
         
             
                it { should exist }
         
     | 
| 
         @@ -29,11 +29,6 @@ elsif os[:family] == 'debian' 
     | 
|
| 
       29 
29 
     | 
    
         
             
                it { should be_enabled }
         
     | 
| 
       30 
30 
     | 
    
         
             
              end
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
              describe apt('http://nginx.org/packages/debian') do
         
     | 
| 
       33 
     | 
    
         
            -
                it { should exist }
         
     | 
| 
       34 
     | 
    
         
            -
                it { should be_enabled }
         
     | 
| 
       35 
     | 
    
         
            -
              end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
32 
     | 
    
         
             
              describe apt('https://deb.nodesource.com/node_4.x/dists/precise/') do
         
     | 
| 
       38 
33 
     | 
    
         
             
                it { should_not exist }
         
     | 
| 
       39 
34 
     | 
    
         
             
                it { should_not be_enabled }
         
     | 
| 
         @@ -1,7 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 4 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 5 
     | 
    
         
            +
              return
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
       5 
7 
     | 
    
         | 
| 
       6 
8 
     | 
    
         
             
            # lets define our own group
         
     | 
| 
       7 
9 
     | 
    
         
             
            root_group = 'root'
         
     | 
| 
         @@ -1,7 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            return 
     | 
| 
      
 2 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 3 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 4 
     | 
    
         
            +
              return
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            if os[:family] == 'freebsd'
         
     | 
| 
       7 
8 
     | 
    
         
             
              filedata = {
         
     | 
| 
         @@ -1,7 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            return 
     | 
| 
      
 2 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 3 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 4 
     | 
    
         
            +
              return
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            case os[:family]
         
     | 
| 
       7 
8 
     | 
    
         
             
            when 'ubuntu', 'fedora'
         
     | 
| 
         @@ -1,8 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 3 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 4 
     | 
    
         
            +
              return
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
       2 
6 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            return 
     | 
| 
      
 7 
     | 
    
         
            +
            if !os.linux?
         
     | 
| 
      
 8 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__} because we are not on linux.\033[0m"
         
     | 
| 
      
 9 
     | 
    
         
            +
              return
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
       6 
11 
     | 
    
         | 
| 
       7 
12 
     | 
    
         
             
            # Test kernel modules on all linux systems
         
     | 
| 
       8 
13 
     | 
    
         
             
            describe kernel_module('video') do
         
     | 
| 
         @@ -1,7 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            return 
     | 
| 
      
 2 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 3 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 4 
     | 
    
         
            +
              return
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            # prepare values
         
     | 
| 
       7 
8 
     | 
    
         
             
            if ['ubuntu', 'centos', 'fedora', 'opensuse', 'debian'].include?(os[:family])
         
     | 
| 
         @@ -1,8 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 3 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 4 
     | 
    
         
            +
              return
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
       2 
6 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            return 
     | 
| 
      
 7 
     | 
    
         
            +
            if !os.linux?
         
     | 
| 
      
 8 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__} because we are not on linux.\033[0m"
         
     | 
| 
      
 9 
     | 
    
         
            +
              return
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
       6 
11 
     | 
    
         | 
| 
       7 
12 
     | 
    
         
             
            # instead of `.with` or `.only_with` we recommend to use the `mount` resource
         
     | 
| 
       8 
13 
     | 
    
         
             
            describe mount '/mnt/iso-disk' do
         
     | 
| 
         @@ -11,7 +11,6 @@ when 'aix' 
     | 
|
| 
       11 
11 
     | 
    
         
             
                its('version') { should match /^(6|7)[.|\d]+\d$/ }
         
     | 
| 
       12 
12 
     | 
    
         
             
              end
         
     | 
| 
       13 
13 
     | 
    
         
             
            when 'solaris'
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
14 
     | 
    
         
             
              if os[:release] == '11'
         
     | 
| 
       16 
15 
     | 
    
         
             
                pkg = 'system/file-system/zfs'
         
     | 
| 
       17 
16 
     | 
    
         
             
                ver = /^0\.5.+$/
         
     | 
| 
         @@ -24,8 +23,6 @@ when 'solaris' 
     | 
|
| 
       24 
23 
     | 
    
         
             
                it { should be_installed }
         
     | 
| 
       25 
24 
     | 
    
         
             
                its('version') { should match ver }
         
     | 
| 
       26 
25 
     | 
    
         
             
              end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
26 
     | 
    
         
             
            end
         
     | 
| 
       30 
27 
     | 
    
         | 
| 
       31 
28 
     | 
    
         
             
            describe package('nginx') do
         
     | 
| 
         @@ -1,7 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            return 
     | 
| 
      
 2 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 3 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 4 
     | 
    
         
            +
              return
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            # check that ssh runs
         
     | 
| 
       7 
8 
     | 
    
         
             
            if os.unix?
         
     | 
| 
         @@ -1,7 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            return 
     | 
| 
      
 2 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 3 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 4 
     | 
    
         
            +
              return
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            # postgres-server is installed on these platforms
         
     | 
| 
       7 
8 
     | 
    
         
             
            if ['ubuntu', 'centos'].include? os['family']
         
     | 
| 
         @@ -1,7 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            return 
     | 
| 
      
 2 
     | 
    
         
            +
            if ENV['DOCKER']
         
     | 
| 
      
 3 
     | 
    
         
            +
              STDERR.puts "\033[1;33mTODO: Not running #{__FILE__.split("/").last} because we are running in docker\033[0m"
         
     | 
| 
      
 4 
     | 
    
         
            +
              return
         
     | 
| 
      
 5 
     | 
    
         
            +
            end
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            # based on operating system we select the available service
         
     | 
| 
       7 
8 
     | 
    
         
             
            if ['centos', 'fedora', 'freebsd', 'opensuse'].include?(os[:family])
         
     | 
| 
         @@ -77,7 +77,7 @@ describe Inspec::ProfileContext do 
     | 
|
| 
       77 
77 
     | 
    
         
             
                include DescribeOneTest
         
     | 
| 
       78 
78 
     | 
    
         | 
| 
       79 
79 
     | 
    
         
             
                it 'must provide os resource' do
         
     | 
| 
       80 
     | 
    
         
            -
                  load('print os[:family]').must_output ' 
     | 
| 
      
 80 
     | 
    
         
            +
                  load('print os[:family]').must_output 'debian'
         
     | 
| 
       81 
81 
     | 
    
         
             
                end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
83 
     | 
    
         
             
                it 'must provide file resource' do
         
     | 
| 
         @@ -215,7 +215,7 @@ describe Inspec::ProfileContext do 
     | 
|
| 
       215 
215 
     | 
    
         
             
                describe 'adds a check via describe' do
         
     | 
| 
       216 
216 
     | 
    
         
             
                  let(:check) {
         
     | 
| 
       217 
217 
     | 
    
         
             
                    profile.load(format(context_format,
         
     | 
| 
       218 
     | 
    
         
            -
                      "describe os[:family] { it { must_equal ' 
     | 
| 
      
 218 
     | 
    
         
            +
                      "describe os[:family] { it { must_equal 'debian' } }"
         
     | 
| 
       219 
219 
     | 
    
         
             
                      ))
         
     | 
| 
       220 
220 
     | 
    
         
             
                    get_checks[0]
         
     | 
| 
       221 
221 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -225,7 +225,7 @@ describe Inspec::ProfileContext do 
     | 
|
| 
       225 
225 
     | 
    
         
             
                  end
         
     | 
| 
       226 
226 
     | 
    
         | 
| 
       227 
227 
     | 
    
         
             
                  it 'registers the check with the describe argument' do
         
     | 
| 
       228 
     | 
    
         
            -
                    check[1].must_equal %w{ 
     | 
| 
      
 228 
     | 
    
         
            +
                    check[1].must_equal %w{debian}
         
     | 
| 
       229 
229 
     | 
    
         
             
                  end
         
     | 
| 
       230 
230 
     | 
    
         | 
| 
       231 
231 
     | 
    
         
             
                  it 'registers the check with the provided proc' do
         
     | 
| 
         @@ -236,7 +236,7 @@ describe Inspec::ProfileContext do 
     | 
|
| 
       236 
236 
     | 
    
         
             
                describe 'adds a check via expect' do
         
     | 
| 
       237 
237 
     | 
    
         
             
                  let(:check) {
         
     | 
| 
       238 
238 
     | 
    
         
             
                    profile.load(format(context_format,
         
     | 
| 
       239 
     | 
    
         
            -
                      "expect(os[:family]).to eq(' 
     | 
| 
      
 239 
     | 
    
         
            +
                      "expect(os[:family]).to eq('debian')"
         
     | 
| 
       240 
240 
     | 
    
         
             
                      ))
         
     | 
| 
       241 
241 
     | 
    
         
             
                    get_checks[0]
         
     | 
| 
       242 
242 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -246,7 +246,7 @@ describe Inspec::ProfileContext do 
     | 
|
| 
       246 
246 
     | 
    
         
             
                  end
         
     | 
| 
       247 
247 
     | 
    
         | 
| 
       248 
248 
     | 
    
         
             
                  it 'registers the check with the describe argument' do
         
     | 
| 
       249 
     | 
    
         
            -
                    check[1].must_equal %w{ 
     | 
| 
      
 249 
     | 
    
         
            +
                    check[1].must_equal %w{debian}
         
     | 
| 
       250 
250 
     | 
    
         
             
                  end
         
     | 
| 
       251 
251 
     | 
    
         | 
| 
       252 
252 
     | 
    
         
             
                  it 'registers the check with the provided proc' do
         
     | 
| 
         @@ -258,7 +258,7 @@ describe Inspec::ProfileContext do 
     | 
|
| 
       258 
258 
     | 
    
         
             
                  let(:check) {
         
     | 
| 
       259 
259 
     | 
    
         
             
                    profile.load(format(context_format,
         
     | 
| 
       260 
260 
     | 
    
         
             
                      "describe 'the actual test' do
         
     | 
| 
       261 
     | 
    
         
            -
                        expect(os[:family]).to eq(' 
     | 
| 
      
 261 
     | 
    
         
            +
                        expect(os[:family]).to eq('debian')
         
     | 
| 
       262 
262 
     | 
    
         
             
                      end"
         
     | 
| 
       263 
263 
     | 
    
         
             
                      ))
         
     | 
| 
       264 
264 
     | 
    
         
             
                    get_checks[0]
         
     | 
| 
         @@ -8,7 +8,7 @@ require 'inspec/resource' 
     | 
|
| 
       8 
8 
     | 
    
         
             
            describe 'Inspec::Resources::Os' do
         
     | 
| 
       9 
9 
     | 
    
         
             
              it 'verify os parsing on CentOS' do
         
     | 
| 
       10 
10 
     | 
    
         
             
                resource = MockLoader.new(:centos7).load_resource('os')
         
     | 
| 
       11 
     | 
    
         
            -
                _(resource.name).must_equal  
     | 
| 
      
 11 
     | 
    
         
            +
                _(resource.name).must_equal 'centos'
         
     | 
| 
       12 
12 
     | 
    
         
             
                _(resource.family).must_equal 'redhat'
         
     | 
| 
       13 
13 
     | 
    
         
             
                _(resource.release).must_equal '7.1.1503'
         
     | 
| 
       14 
14 
     | 
    
         
             
                _(resource.arch).must_equal 'x86_64'
         
     | 
| 
         @@ -16,7 +16,7 @@ describe 'Inspec::Resources::Os' do 
     | 
|
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
              it 'read env variable on Windows' do
         
     | 
| 
       18 
18 
     | 
    
         
             
                resource = MockLoader.new(:windows).load_resource('os')
         
     | 
| 
       19 
     | 
    
         
            -
                _(resource.name).must_equal  
     | 
| 
      
 19 
     | 
    
         
            +
                _(resource.name).must_equal 'windows'
         
     | 
| 
       20 
20 
     | 
    
         
             
                _(resource.family).must_equal 'windows'
         
     | 
| 
       21 
21 
     | 
    
         
             
                _(resource.release).must_equal '6.2.9200'
         
     | 
| 
       22 
22 
     | 
    
         
             
                _(resource.arch).must_equal 'x86_64'
         
     | 
| 
         @@ -24,7 +24,7 @@ describe 'Inspec::Resources::Os' do 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
              it 'verify os parsing on Debian' do
         
     | 
| 
       26 
26 
     | 
    
         
             
                resource = MockLoader.new(:debian8).load_resource('os')
         
     | 
| 
       27 
     | 
    
         
            -
                _(resource.name).must_equal  
     | 
| 
      
 27 
     | 
    
         
            +
                _(resource.name).must_equal 'debian'
         
     | 
| 
       28 
28 
     | 
    
         
             
                _(resource.family).must_equal 'debian'
         
     | 
| 
       29 
29 
     | 
    
         
             
                _(resource.release).must_equal '8'
         
     | 
| 
       30 
30 
     | 
    
         
             
                _(resource.arch).must_equal 'x86_64'
         
     | 
| 
         @@ -32,8 +32,8 @@ describe 'Inspec::Resources::Os' do 
     | 
|
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
              it 'verify os parsing on Ubuntu' do
         
     | 
| 
       34 
34 
     | 
    
         
             
                resource = MockLoader.new(:ubuntu1504).load_resource('os')
         
     | 
| 
       35 
     | 
    
         
            -
                _(resource.name).must_equal  
     | 
| 
       36 
     | 
    
         
            -
                _(resource.family).must_equal ' 
     | 
| 
      
 35 
     | 
    
         
            +
                _(resource.name).must_equal 'ubuntu'
         
     | 
| 
      
 36 
     | 
    
         
            +
                _(resource.family).must_equal 'debian'
         
     | 
| 
       37 
37 
     | 
    
         
             
                _(resource.release).must_equal '15.04'
         
     | 
| 
       38 
38 
     | 
    
         
             
                _(resource.arch).must_equal 'x86_64'
         
     | 
| 
       39 
39 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'inspec/resource'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            describe 'Inspec::Resources::ParseConfig' do
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              it 'verify parse_config resource' do
         
     | 
| 
      
 7 
     | 
    
         
            +
                options = {
         
     | 
| 
      
 8 
     | 
    
         
            +
                  assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
         
     | 
| 
      
 9 
     | 
    
         
            +
                }
         
     | 
| 
      
 10 
     | 
    
         
            +
                resource = MockLoader.new(:centos6).load_resource('parse_config', 'kernel.domainname = example.com', options)
         
     | 
| 
      
 11 
     | 
    
         
            +
                result = {"kernel.domainname"=>"example.com"}
         
     | 
| 
      
 12 
     | 
    
         
            +
                _(resource.params).must_equal result
         
     | 
| 
      
 13 
     | 
    
         
            +
                _(resource.content).must_equal 'kernel.domainname = example.com'
         
     | 
| 
      
 14 
     | 
    
         
            +
                _(resource.send('kernel.domainname')).must_equal 'example.com'
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              it 'verify parse_config_file resource' do
         
     | 
| 
      
 18 
     | 
    
         
            +
                options = {
         
     | 
| 
      
 19 
     | 
    
         
            +
                  assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
         
     | 
| 
      
 20 
     | 
    
         
            +
                }
         
     | 
| 
      
 21 
     | 
    
         
            +
                resource = MockLoader.new(:centos6).load_resource('parse_config_file', '/etc/sysctl.conf', options)
         
     | 
| 
      
 22 
     | 
    
         
            +
                result = {"kernel.domainname"=>"example.com"}
         
     | 
| 
      
 23 
     | 
    
         
            +
                _(resource.params).must_equal result
         
     | 
| 
      
 24 
     | 
    
         
            +
                _(resource.send('kernel.domainname')).must_equal 'example.com'
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -44,6 +44,15 @@ describe 'Inspec::Resources::Port' do 
     | 
|
| 
       44 
44 
     | 
    
         
             
                _(resource.addresses).must_equal ["0.0.0.0"]
         
     | 
| 
       45 
45 
     | 
    
         
             
              end
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
      
 47 
     | 
    
         
            +
              it 'accepts the port as a string' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                resource = MockLoader.new(:ubuntu1404).load_resource('port', '111')
         
     | 
| 
      
 49 
     | 
    
         
            +
                _(resource.listening?).must_equal true
         
     | 
| 
      
 50 
     | 
    
         
            +
                _(resource.protocols).must_equal %w{ udp }
         
     | 
| 
      
 51 
     | 
    
         
            +
                _(resource.pids).must_equal [545]
         
     | 
| 
      
 52 
     | 
    
         
            +
                _(resource.processes).must_equal ['rpcbind']
         
     | 
| 
      
 53 
     | 
    
         
            +
                _(resource.addresses).must_equal ["0.0.0.0"]
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
       47 
56 
     | 
    
         
             
              it 'verify port on MacOs x' do
         
     | 
| 
       48 
57 
     | 
    
         
             
                resource = MockLoader.new(:osx104).load_resource('port', 2022)
         
     | 
| 
       49 
58 
     | 
    
         
             
                _(resource.listening?).must_equal true
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: inspec
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.29.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Dominik Richter
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-08- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-08-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: train
         
     | 
| 
         @@ -16,7 +16,7 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - ">="
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 0.16.0
         
     | 
| 
       20 
20 
     | 
    
         
             
                - - "<"
         
     | 
| 
       21 
21 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       22 
22 
     | 
    
         
             
                    version: '1.0'
         
     | 
| 
         @@ -26,7 +26,7 @@ dependencies: 
     | 
|
| 
       26 
26 
     | 
    
         
             
                requirements:
         
     | 
| 
       27 
27 
     | 
    
         
             
                - - ">="
         
     | 
| 
       28 
28 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       29 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 29 
     | 
    
         
            +
                    version: 0.16.0
         
     | 
| 
       30 
30 
     | 
    
         
             
                - - "<"
         
     | 
| 
       31 
31 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       32 
32 
     | 
    
         
             
                    version: '1.0'
         
     | 
| 
         @@ -403,6 +403,7 @@ files: 
     | 
|
| 
       403 
403 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/mount.rb
         
     | 
| 
       404 
404 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/package.rb
         
     | 
| 
       405 
405 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/postgres.rb
         
     | 
| 
      
 406 
     | 
    
         
            +
            - test/cookbooks/os_prepare/recipes/prep_container.rb
         
     | 
| 
       406 
407 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/registry_key.rb
         
     | 
| 
       407 
408 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/service.rb
         
     | 
| 
       408 
409 
     | 
    
         
             
            - test/cookbooks/os_prepare/templates/default/sv-default-svlog-run.erb
         
     | 
| 
         @@ -556,6 +557,7 @@ files: 
     | 
|
| 
       556 
557 
     | 
    
         
             
            - test/unit/mock/files/shadow
         
     | 
| 
       557 
558 
     | 
    
         
             
            - test/unit/mock/files/ssh_config
         
     | 
| 
       558 
559 
     | 
    
         
             
            - test/unit/mock/files/sshd_config
         
     | 
| 
      
 560 
     | 
    
         
            +
            - test/unit/mock/files/sysctl.conf
         
     | 
| 
       559 
561 
     | 
    
         
             
            - test/unit/mock/files/xinetd.conf
         
     | 
| 
       560 
562 
     | 
    
         
             
            - test/unit/mock/files/xinetd.d/.gitkeep
         
     | 
| 
       561 
563 
     | 
    
         
             
            - test/unit/mock/files/xinetd.d_chargen-dgram
         
     | 
| 
         @@ -618,6 +620,7 @@ files: 
     | 
|
| 
       618 
620 
     | 
    
         
             
            - test/unit/resources/os_env_test.rb
         
     | 
| 
       619 
621 
     | 
    
         
             
            - test/unit/resources/os_test.rb
         
     | 
| 
       620 
622 
     | 
    
         
             
            - test/unit/resources/package_test.rb
         
     | 
| 
      
 623 
     | 
    
         
            +
            - test/unit/resources/parse_config_test.rb
         
     | 
| 
       621 
624 
     | 
    
         
             
            - test/unit/resources/passwd_test.rb
         
     | 
| 
       622 
625 
     | 
    
         
             
            - test/unit/resources/pip_test.rb
         
     | 
| 
       623 
626 
     | 
    
         
             
            - test/unit/resources/port_test.rb
         
     | 
| 
         @@ -688,6 +691,7 @@ test_files: 
     | 
|
| 
       688 
691 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/mount.rb
         
     | 
| 
       689 
692 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/package.rb
         
     | 
| 
       690 
693 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/postgres.rb
         
     | 
| 
      
 694 
     | 
    
         
            +
            - test/cookbooks/os_prepare/recipes/prep_container.rb
         
     | 
| 
       691 
695 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/registry_key.rb
         
     | 
| 
       692 
696 
     | 
    
         
             
            - test/cookbooks/os_prepare/recipes/service.rb
         
     | 
| 
       693 
697 
     | 
    
         
             
            - test/cookbooks/os_prepare/templates/default/sv-default-svlog-run.erb
         
     | 
| 
         @@ -841,6 +845,7 @@ test_files: 
     | 
|
| 
       841 
845 
     | 
    
         
             
            - test/unit/mock/files/shadow
         
     | 
| 
       842 
846 
     | 
    
         
             
            - test/unit/mock/files/ssh_config
         
     | 
| 
       843 
847 
     | 
    
         
             
            - test/unit/mock/files/sshd_config
         
     | 
| 
      
 848 
     | 
    
         
            +
            - test/unit/mock/files/sysctl.conf
         
     | 
| 
       844 
849 
     | 
    
         
             
            - test/unit/mock/files/xinetd.conf
         
     | 
| 
       845 
850 
     | 
    
         
             
            - test/unit/mock/files/xinetd.d/.gitkeep
         
     | 
| 
       846 
851 
     | 
    
         
             
            - test/unit/mock/files/xinetd.d_chargen-dgram
         
     | 
| 
         @@ -903,6 +908,7 @@ test_files: 
     | 
|
| 
       903 
908 
     | 
    
         
             
            - test/unit/resources/os_env_test.rb
         
     | 
| 
       904 
909 
     | 
    
         
             
            - test/unit/resources/os_test.rb
         
     | 
| 
       905 
910 
     | 
    
         
             
            - test/unit/resources/package_test.rb
         
     | 
| 
      
 911 
     | 
    
         
            +
            - test/unit/resources/parse_config_test.rb
         
     | 
| 
       906 
912 
     | 
    
         
             
            - test/unit/resources/passwd_test.rb
         
     | 
| 
       907 
913 
     | 
    
         
             
            - test/unit/resources/pip_test.rb
         
     | 
| 
       908 
914 
     | 
    
         
             
            - test/unit/resources/port_test.rb
         
     |