inspec 0.9.3 → 0.9.4
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 +22 -2
- data/README.md +21 -7
- data/lib/inspec/resource.rb +1 -0
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/ini.rb +23 -0
- data/lib/resources/json.rb +39 -20
- data/lib/resources/registry_key.rb +32 -11
- data/lib/resources/user.rb +12 -2
- data/test/helper.rb +5 -0
- data/test/integration/cookbooks/os_prepare/files/example.csv +7 -0
- data/test/integration/cookbooks/os_prepare/files/example.ini +6 -0
- data/test/integration/cookbooks/os_prepare/files/example.json +12 -0
- data/test/integration/cookbooks/os_prepare/files/example.yml +7 -0
- data/test/integration/cookbooks/os_prepare/recipes/default.rb +1 -0
- data/test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb +19 -0
- data/test/integration/cookbooks/os_prepare/recipes/registry_key.rb +5 -0
- data/test/integration/test/integration/default/csv_spec.rb +5 -0
- data/test/integration/test/integration/default/ini_spec.rb +5 -0
- data/test/integration/test/integration/default/json_spec.rb +5 -0
- data/test/integration/test/integration/default/registry_key_spec.rb +14 -0
- data/test/integration/test/integration/default/yaml_spec.rb +5 -0
- data/test/unit/mock/cmd/getent-passwd-jfolmer +1 -0
- data/test/unit/mock/cmd/id-jfolmer +1 -0
- data/test/unit/mock/files/rootwrap.conf +7 -0
- data/test/unit/resources/ini_test.rb +16 -0
- data/test/unit/resources/user_test.rb +13 -0
- metadata +29 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 75b5b2cf05d5f27de71c74ba5ee3bf4d8e5ea281
         | 
| 4 | 
            +
              data.tar.gz: b1934841d5088956ebc3021d31190d21aa8d3a9f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 66fe3886fed541edc87ceb0ed0f421fc8d66b4fff67f8b9564627d5f10e4b8b762a0c0be04c8dad76718b9b51d5f70abc6daa5effc95f29403cfa0c01eae207a
         | 
| 7 | 
            +
              data.tar.gz: 7da21c7c93b062a6ef3529438ad585dabf7a3ded7aa8fcb67a12aa71aa8b5c4f57631bd4d6385eb6d8a016969329dab984d8509774c9afd5c6963c3508574070
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,7 +1,26 @@ | |
| 1 1 | 
             
            # Change Log
         | 
| 2 2 |  | 
| 3 | 
            -
            ## [0.9. | 
| 4 | 
            -
            [Full Changelog](https://github.com/chef/inspec/compare/v0.9. | 
| 3 | 
            +
            ## [0.9.4](https://github.com/chef/inspec/tree/0.9.4) (2015-11-24)
         | 
| 4 | 
            +
            [Full Changelog](https://github.com/chef/inspec/compare/v0.9.3...0.9.4)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            **Fixed bugs:**
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            - registry\_key needs to be case insensitive [\#254](https://github.com/chef/inspec/issues/254)
         | 
| 9 | 
            +
            - User resource doesn't handle group names with spaces [\#238](https://github.com/chef/inspec/issues/238)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            **Closed issues:**
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            - inspec does not extract section name from test file header [\#182](https://github.com/chef/inspec/issues/182)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            **Merged pull requests:**
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            - bugfix: user resources support for group with whitespace [\#258](https://github.com/chef/inspec/pull/258) ([chris-rock](https://github.com/chris-rock))
         | 
| 18 | 
            +
            - Improve conf file resources \(csv, json, yaml, ini\) [\#257](https://github.com/chef/inspec/pull/257) ([chris-rock](https://github.com/chris-rock))
         | 
| 19 | 
            +
            - Bugfix: make registry\_key resource case-insensitive [\#255](https://github.com/chef/inspec/pull/255) ([alexpop](https://github.com/alexpop))
         | 
| 20 | 
            +
            - improvement: update install instructions and add notes for windows builds [\#253](https://github.com/chef/inspec/pull/253) ([chris-rock](https://github.com/chris-rock))
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            ## [v0.9.3](https://github.com/chef/inspec/tree/v0.9.3) (2015-11-20)
         | 
| 23 | 
            +
            [Full Changelog](https://github.com/chef/inspec/compare/v0.9.2...v0.9.3)
         | 
| 5 24 |  | 
| 6 25 | 
             
            **Implemented enhancements:**
         | 
| 7 26 |  | 
| @@ -19,6 +38,7 @@ | |
| 19 38 |  | 
| 20 39 | 
             
            **Merged pull requests:**
         | 
| 21 40 |  | 
| 41 | 
            +
            - 0.9.3 [\#251](https://github.com/chef/inspec/pull/251) ([arlimus](https://github.com/arlimus))
         | 
| 22 42 | 
             
            - Introduce automated changelog generation [\#250](https://github.com/chef/inspec/pull/250) ([arlimus](https://github.com/arlimus))
         | 
| 23 43 | 
             
            - ensure all test directories are on the runner $LOAD\_PATH [\#249](https://github.com/chef/inspec/pull/249) ([schisamo](https://github.com/schisamo))
         | 
| 24 44 | 
             
            - bugfix: support multiple computed calls to describe [\#247](https://github.com/chef/inspec/pull/247) ([arlimus](https://github.com/arlimus))
         | 
    
        data/README.md
    CHANGED
    
    | @@ -39,9 +39,17 @@ inspec exec test.rb -t docker://container_id | |
| 39 39 |  | 
| 40 40 | 
             
            ## Installation
         | 
| 41 41 |  | 
| 42 | 
            -
             | 
| 42 | 
            +
            InSpec requires Ruby ( >1.9 ).
         | 
| 43 43 |  | 
| 44 | 
            -
             | 
| 44 | 
            +
            ### Install it via rubygems.org
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            ```bash
         | 
| 47 | 
            +
            gem install inspec
         | 
| 48 | 
            +
            ```
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            ### Install it from source
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            That requires [bundler](http://bundler.io/):
         | 
| 45 53 |  | 
| 46 54 | 
             
            ```bash
         | 
| 47 55 | 
             
            bundle install
         | 
| @@ -55,16 +63,22 @@ gem build inspec.gemspec | |
| 55 63 | 
             
            gem install inspec-*.gem
         | 
| 56 64 | 
             
            ```
         | 
| 57 65 |  | 
| 58 | 
            -
             | 
| 66 | 
            +
            On Windows, you need to install [Ruby](http://rubyinstaller.org/downloads/) with [Ruby Development Kit](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit) to build dependencies with its native extensions.
         | 
| 59 67 |  | 
| 60 | 
            -
             | 
| 61 | 
            -
            gem install inspec
         | 
| 62 | 
            -
            ```
         | 
| 68 | 
            +
            ### Run InSpec
         | 
| 63 69 |  | 
| 64 70 | 
             
            You should now be able to run:
         | 
| 65 71 |  | 
| 66 72 | 
             
            ```bash
         | 
| 67 | 
            -
            inspec --help
         | 
| 73 | 
            +
            $ inspec --help
         | 
| 74 | 
            +
            Commands:
         | 
| 75 | 
            +
              inspec check PATH      # verify test structure in PATH
         | 
| 76 | 
            +
              inspec detect          # detect the target OS
         | 
| 77 | 
            +
              inspec exec PATHS      # run all test files
         | 
| 78 | 
            +
              inspec help [COMMAND]  # Describe available commands or one specific command
         | 
| 79 | 
            +
              inspec json PATH       # read all tests in PATH and generate a JSON profile
         | 
| 80 | 
            +
              inspec shell           # open an interactive debugging shell
         | 
| 81 | 
            +
              inspec version         # prints the version of this tool
         | 
| 68 82 | 
             
            ```
         | 
| 69 83 |  | 
| 70 84 | 
             
            # Examples
         | 
    
        data/lib/inspec/resource.rb
    CHANGED
    
    
    
        data/lib/inspec/version.rb
    CHANGED
    
    
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
            # author: Christoph Hartmann
         | 
| 3 | 
            +
            # author: Dominik Richter
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'utils/simpleconfig'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Parses a ini file
         | 
| 8 | 
            +
            # Usage:
         | 
| 9 | 
            +
            # descibe ini do
         | 
| 10 | 
            +
            #   its("auth_protocol") { should eq "https" }
         | 
| 11 | 
            +
            # end
         | 
| 12 | 
            +
            class IniConfig < JsonConfig
         | 
| 13 | 
            +
              name 'ini'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              # override file load and parse hash with simple config
         | 
| 16 | 
            +
              def parse(content)
         | 
| 17 | 
            +
                SimpleConfig.new(content).params
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def to_s
         | 
| 21 | 
            +
                "INI #{@path}"
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
    
        data/lib/resources/json.rb
    CHANGED
    
    | @@ -15,7 +15,21 @@ class JsonConfig < Inspec.resource(1) | |
| 15 15 |  | 
| 16 16 | 
             
              def initialize(path)
         | 
| 17 17 | 
             
                @path = path
         | 
| 18 | 
            -
                @ | 
| 18 | 
            +
                @file = inspec.file(@path)
         | 
| 19 | 
            +
                @file_content = @file.content
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                # check if file is available
         | 
| 22 | 
            +
                if !@file.file?
         | 
| 23 | 
            +
                  skip_resource "Can't find file \"#{@conf_path}\""
         | 
| 24 | 
            +
                  return @params = {}
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                # check if file is readable
         | 
| 28 | 
            +
                if @file_content.empty? && @file.size > 0
         | 
| 29 | 
            +
                  skip_resource "Can't read file \"#{@conf_path}\""
         | 
| 30 | 
            +
                  return @params = {}
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 19 33 | 
             
                @params = parse(@file_content)
         | 
| 20 34 | 
             
              end
         | 
| 21 35 |  | 
| @@ -24,21 +38,39 @@ class JsonConfig < Inspec.resource(1) | |
| 24 38 | 
             
                JSON.parse(content)
         | 
| 25 39 | 
             
              end
         | 
| 26 40 |  | 
| 41 | 
            +
              def value(key)
         | 
| 42 | 
            +
                extract_value(key, @params)
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              # Shorthand to retrieve a parameter name via `#its`.
         | 
| 46 | 
            +
              # Example: describe json('file') { its('paramX') { should eq 'Y' } }
         | 
| 47 | 
            +
              #
         | 
| 48 | 
            +
              # @param [String] name name of the field to retrieve
         | 
| 49 | 
            +
              # @return [Object] the value stored at this position
         | 
| 50 | 
            +
              def method_missing(*keys)
         | 
| 51 | 
            +
                # catch bahavior of rspec its implementation
         | 
| 52 | 
            +
                # @see https://github.com/rspec/rspec-its/blob/master/lib/rspec/its.rb#L110
         | 
| 53 | 
            +
                keys.shift if keys.is_a?(Array) && keys[0] == :[]
         | 
| 54 | 
            +
                value(keys)
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              def to_s
         | 
| 58 | 
            +
                "Json #{@path}"
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              private
         | 
| 62 | 
            +
             | 
| 27 63 | 
             
              def extract_value(keys, value)
         | 
| 28 64 | 
             
                key = keys.shift
         | 
| 29 65 | 
             
                return nil if key.nil?
         | 
| 30 66 |  | 
| 31 | 
            -
                # check if key is a num, try to extract from array
         | 
| 32 | 
            -
                if key.to_i.to_s == key
         | 
| 33 | 
            -
                  value = value[key.to_i]
         | 
| 34 67 | 
             
                # if value is an array, iterate over each child
         | 
| 35 | 
            -
                 | 
| 68 | 
            +
                if value.is_a?(Array)
         | 
| 36 69 | 
             
                  value = value.map { |i|
         | 
| 37 70 | 
             
                    extract_value([key], i)
         | 
| 38 71 | 
             
                  }
         | 
| 39 | 
            -
                # normal value extraction
         | 
| 40 72 | 
             
                else
         | 
| 41 | 
            -
                  value = value[key].nil? ? nil : value[key]
         | 
| 73 | 
            +
                  value = value[key.to_s].nil? ? nil : value[key.to_s]
         | 
| 42 74 | 
             
                end
         | 
| 43 75 |  | 
| 44 76 | 
             
                # check if further keys exist
         | 
| @@ -48,17 +80,4 @@ class JsonConfig < Inspec.resource(1) | |
| 48 80 | 
             
                  return value
         | 
| 49 81 | 
             
                end
         | 
| 50 82 | 
             
              end
         | 
| 51 | 
            -
             | 
| 52 | 
            -
              # Shorthand to retrieve a parameter name via `#its`.
         | 
| 53 | 
            -
              # Example: describe json('file') { its('paramX') { should eq 'Y' } }
         | 
| 54 | 
            -
              #
         | 
| 55 | 
            -
              # @param [String] name name of the field to retrieve
         | 
| 56 | 
            -
              # @return [Object] the value stored at this position
         | 
| 57 | 
            -
              def method_missing(name)
         | 
| 58 | 
            -
                @params[name.to_s]
         | 
| 59 | 
            -
              end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
              def to_s
         | 
| 62 | 
            -
                "Json #{@path}"
         | 
| 63 | 
            -
              end
         | 
| 64 83 | 
             
            end
         | 
| @@ -23,37 +23,36 @@ class RegistryKey < Inspec.resource(1) | |
| 23 23 | 
             
              end
         | 
| 24 24 |  | 
| 25 25 | 
             
              def exists?
         | 
| 26 | 
            -
                ! | 
| 26 | 
            +
                !registry_key(@reg_key).nil?
         | 
| 27 27 | 
             
              end
         | 
| 28 28 |  | 
| 29 29 | 
             
              def has_value?(value)
         | 
| 30 | 
            -
                val =  | 
| 31 | 
            -
                !val.nil? && val | 
| 30 | 
            +
                val = registry_key(@reg_key)
         | 
| 31 | 
            +
                !val.nil? && registry_property_value(val, '(default)') == value ? true : false
         | 
| 32 32 | 
             
              end
         | 
| 33 33 |  | 
| 34 34 | 
             
              def has_property?(property_name, property_type = nil)
         | 
| 35 | 
            -
                val =  | 
| 36 | 
            -
                !val.nil? &&  | 
| 35 | 
            +
                val = registry_key(@reg_key)
         | 
| 36 | 
            +
                !val.nil? && registry_property_exists(val, property_name) && (property_type.nil? || registry_property_type(val, property_name) == map2type(property_type)) ? true : false
         | 
| 37 37 | 
             
              end
         | 
| 38 38 |  | 
| 39 39 | 
             
              # deactivate rubocop, because we need to stay compatible with Serverspe
         | 
| 40 40 | 
             
              # rubocop:disable Style/OptionalArguments
         | 
| 41 41 | 
             
              def has_property_value?(property_name, property_type = nil, value)
         | 
| 42 42 | 
             
                # rubocop:enable Style/OptionalArguments
         | 
| 43 | 
            -
                val =  | 
| 43 | 
            +
                val = registry_key(@reg_key)
         | 
| 44 44 |  | 
| 45 45 | 
             
                # convert value to binary if required
         | 
| 46 46 | 
             
                value = value.bytes if !property_type.nil? && map2type(property_type) == 3 && !value.is_a?(Array)
         | 
| 47 47 |  | 
| 48 | 
            -
                !val.nil? && val | 
| 48 | 
            +
                !val.nil? && registry_property_value(val, property_name) == value && (property_type.nil? || registry_property_type(val, property_name) == map2type(property_type)) ? true : false
         | 
| 49 49 | 
             
              end
         | 
| 50 50 |  | 
| 51 51 | 
             
              # returns nil, if not existant or value
         | 
| 52 52 | 
             
              def method_missing(meth)
         | 
| 53 53 | 
             
                # get data
         | 
| 54 | 
            -
                val =  | 
| 55 | 
            -
                 | 
| 56 | 
            -
                val[meth.to_s]['value']
         | 
| 54 | 
            +
                val = registry_key(@reg_key)
         | 
| 55 | 
            +
                registry_property_value(val, meth)
         | 
| 57 56 | 
             
              end
         | 
| 58 57 |  | 
| 59 58 | 
             
              def to_s
         | 
| @@ -62,7 +61,25 @@ class RegistryKey < Inspec.resource(1) | |
| 62 61 |  | 
| 63 62 | 
             
              private
         | 
| 64 63 |  | 
| 65 | 
            -
              def  | 
| 64 | 
            +
              def registry_property_exists(regkey, property)
         | 
| 65 | 
            +
                return false if regkey.nil? || property.nil?
         | 
| 66 | 
            +
                # always ensure the key is lower case
         | 
| 67 | 
            +
                !regkey[property.to_s.downcase].nil?
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              def registry_property_value(regkey, property)
         | 
| 71 | 
            +
                return nil if regkey.nil? || property.nil?
         | 
| 72 | 
            +
                # always ensure the key is lower case
         | 
| 73 | 
            +
                regkey[property.to_s.downcase]['value']
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
              def registry_property_type(regkey, property)
         | 
| 77 | 
            +
                return nil if regkey.nil? || property.nil?
         | 
| 78 | 
            +
                # always ensure the key is lower case
         | 
| 79 | 
            +
                regkey[property.to_s.downcase]['type']
         | 
| 80 | 
            +
              end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
              def registry_key(path)
         | 
| 66 83 | 
             
                return @registy_cache if defined?(@registy_cache)
         | 
| 67 84 |  | 
| 68 85 | 
             
                # load registry key and all properties
         | 
| @@ -87,6 +104,10 @@ class RegistryKey < Inspec.resource(1) | |
| 87 104 | 
             
                # return nil if cmd.exit_status != 0, try to parse json
         | 
| 88 105 | 
             
                begin
         | 
| 89 106 | 
             
                  @registy_cache = JSON.parse(cmd.stdout)
         | 
| 107 | 
            +
                  # convert keys to lower case
         | 
| 108 | 
            +
                  @registy_cache = Hash[@registy_cache.map do |key, value|
         | 
| 109 | 
            +
                    [key.downcase, value]
         | 
| 110 | 
            +
                  end]
         | 
| 90 111 | 
             
                rescue JSON::ParserError => _e
         | 
| 91 112 | 
             
                  @registy_cache = nil
         | 
| 92 113 | 
             
                end
         | 
    
        data/lib/resources/user.rb
    CHANGED
    
    | @@ -195,8 +195,7 @@ class UnixUser < UserInfo | |
| 195 195 |  | 
| 196 196 | 
             
                # parse words
         | 
| 197 197 | 
             
                params = SimpleConfig.new(
         | 
| 198 | 
            -
                  cmd.stdout.chomp,
         | 
| 199 | 
            -
                  line_separator: ' ',
         | 
| 198 | 
            +
                  parse_id_entries(cmd.stdout.chomp),
         | 
| 200 199 | 
             
                  assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/,
         | 
| 201 200 | 
             
                  group_re: nil,
         | 
| 202 201 | 
             
                  multiple_values: false,
         | 
| @@ -210,6 +209,17 @@ class UnixUser < UserInfo | |
| 210 209 | 
             
                  groups: parse_value(params['groups']).values,
         | 
| 211 210 | 
             
                }
         | 
| 212 211 | 
             
              end
         | 
| 212 | 
            +
             | 
| 213 | 
            +
              # splits the results of id into seperate lines
         | 
| 214 | 
            +
              def parse_id_entries(raw)
         | 
| 215 | 
            +
                data = []
         | 
| 216 | 
            +
                until (index = raw.index(/\)\s{1}/)).nil?
         | 
| 217 | 
            +
                  data.push(raw[0, index+1]) # inclue closing )
         | 
| 218 | 
            +
                  raw = raw[index+2, raw.length-index-2]
         | 
| 219 | 
            +
                end
         | 
| 220 | 
            +
                data.push(raw) if !raw.nil?
         | 
| 221 | 
            +
                data.join("\n")
         | 
| 222 | 
            +
              end
         | 
| 213 223 | 
             
            end
         | 
| 214 224 |  | 
| 215 225 | 
             
            class LinuxUser < UnixUser
         | 
    
        data/test/helper.rb
    CHANGED
    
    | @@ -91,6 +91,7 @@ class MockLoader | |
| 91 91 | 
             
                  'example.csv' => mockfile.call('example.csv'),
         | 
| 92 92 | 
             
                  'policyfile.lock.json' => mockfile.call('policyfile.lock.json'),
         | 
| 93 93 | 
             
                  '/sys/class/net/br0/bridge' => mockdir.call(true),
         | 
| 94 | 
            +
                  'rootwrap.conf' => mockfile.call('rootwrap.conf'),
         | 
| 94 95 | 
             
                }
         | 
| 95 96 |  | 
| 96 97 | 
             
                # create all mock commands
         | 
| @@ -156,6 +157,10 @@ class MockLoader | |
| 156 157 | 
             
                  'id root' => cmd.call('id-root'),
         | 
| 157 158 | 
             
                  'getent passwd root' => cmd.call('getent-passwd-root'),
         | 
| 158 159 | 
             
                  'chage -l root' => cmd.call('chage-l-root'),
         | 
| 160 | 
            +
                  # user information for ldap test
         | 
| 161 | 
            +
                  'id jfolmer' => cmd.call('id-jfolmer'),
         | 
| 162 | 
            +
                  'getent passwd jfolmer' => cmd.call('getent-passwd-jfolmer'),
         | 
| 163 | 
            +
                  'chage -l jfolmer' => cmd.call('chage-l-root'),
         | 
| 159 164 | 
             
                  # user info for mac
         | 
| 160 165 | 
             
                  'id chartmann' => cmd.call('id-chartmann'),
         | 
| 161 166 | 
             
                  'dscl -q . -read /Users/chartmann NFSHomeDirectory PrimaryGroupID RecordName UniqueID UserShell' => cmd.call('dscl'),
         | 
| @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            name,version,license,title,description
         | 
| 2 | 
            +
            addressable,2.3.6,Apache 2.0,URI Implementation,"Addressable is a replacement for the URI implementation that is part of
         | 
| 3 | 
            +
            Ruby's standard library. It more closely conforms to the relevant RFCs and
         | 
| 4 | 
            +
            adds support for IRIs and URI templates."
         | 
| 5 | 
            +
            ast,2.0.0,MIT,A library for working with Abstract Syntax Trees.,A library for working with Abstract Syntax Trees.
         | 
| 6 | 
            +
            astrolabe,1.3.0,MIT,An object-oriented AST extension for Parser,An object-oriented AST extension for Parser
         | 
| 7 | 
            +
            berkshelf,3.2.3,Apache 2.0,"Manages a Cookbook's, or an Application's, Cookbook dependencies","Manages a Cookbook's, or an Application's, Cookbook dependencies"
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
            # author: Christoph Hartmann
         | 
| 3 | 
            +
            # author: Dominik Richter
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            # adds a yaml file
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            gid = 'root'
         | 
| 8 | 
            +
            gid = 'wheel' if node['platform_family'] == 'freebsd'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            ['yml', 'json', 'csv', 'ini'].each { |filetype|
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              cookbook_file "/tmp/example.#{filetype}" do
         | 
| 13 | 
            +
                source "example.#{filetype}"
         | 
| 14 | 
            +
                owner 'root'
         | 
| 15 | 
            +
                group gid
         | 
| 16 | 
            +
                mode '0755'
         | 
| 17 | 
            +
                action :create
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            }
         | 
| @@ -66,4 +66,9 @@ if node['platform_family'] == 'windows' | |
| 66 66 | 
             
                action :create
         | 
| 67 67 | 
             
              end
         | 
| 68 68 |  | 
| 69 | 
            +
              registry_key 'HKLM\System\CurrentControlSet\Control\Lsa\MSV1_0' do
         | 
| 70 | 
            +
                values [{ name: 'NTLMMinServerSec', type: :dword, data: 537_395_200 }]
         | 
| 71 | 
            +
                recursive true
         | 
| 72 | 
            +
                action :create
         | 
| 73 | 
            +
              end
         | 
| 69 74 | 
             
            end
         | 
| @@ -6,11 +6,16 @@ if os.windows? | |
| 6 6 | 
             
                it { should exist }
         | 
| 7 7 | 
             
                it { should have_value('test') }
         | 
| 8 8 | 
             
                it { should have_property('binary value', :binary) }
         | 
| 9 | 
            +
                it { should have_property('Binary value', :binary) }
         | 
| 9 10 | 
             
                it { should have_property('string value') }
         | 
| 11 | 
            +
                it { should have_property('String value') }
         | 
| 10 12 | 
             
                it { should have_property('dword value', :dword) }
         | 
| 11 13 | 
             
                it { should have_property_value('multistring value', :multi_string, ['test', 'multi','string','data']) }
         | 
| 14 | 
            +
                it { should have_property_value('Multistring Value', :multi_string, ['test', 'multi','string','data']) }
         | 
| 12 15 | 
             
                it { should have_property_value('qword value', :qword, 0) }
         | 
| 16 | 
            +
                it { should have_property_value('Qword value', :qword, 0) }
         | 
| 13 17 | 
             
                it { should have_property_value('binary value', :binary, 'dfa0f066') }
         | 
| 18 | 
            +
                it { should have_property_value('Binary value', :binary, 'dfa0f066') }
         | 
| 14 19 | 
             
              end
         | 
| 15 20 |  | 
| 16 21 | 
             
              # serverspec compatability
         | 
| @@ -33,6 +38,8 @@ if os.windows? | |
| 33 38 | 
             
              describe registry_key('HKLM\System\CurrentControlSet\Control\Session Manager') do
         | 
| 34 39 | 
             
                it { should exist }
         | 
| 35 40 | 
             
                it { should_not have_property_value('SafeDllSearchMode', :type_dword, 0) }
         | 
| 41 | 
            +
                # case-insensitive test
         | 
| 42 | 
            +
                it { should_not have_property_value('safedllsearchmode', :type_dword, 0) }
         | 
| 36 43 | 
             
              end
         | 
| 37 44 |  | 
| 38 45 | 
             
              describe registry_key('HKLM\System\CurrentControlSet\Services\LanManServer\Parameters') do
         | 
| @@ -43,6 +50,8 @@ if os.windows? | |
| 43 50 | 
             
              describe registry_key('HKLM\Software\Policies\Microsoft\Internet Explorer\Main') do
         | 
| 44 51 | 
             
                it { should exist }
         | 
| 45 52 | 
             
                its('Isolation64Bit') { should eq 1 }
         | 
| 53 | 
            +
                # check that its is case-insensitive
         | 
| 54 | 
            +
                its('isolation64bit') { should eq 1 }
         | 
| 46 55 | 
             
              end
         | 
| 47 56 |  | 
| 48 57 | 
             
              describe registry_key('HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services') do
         | 
| @@ -50,4 +59,9 @@ if os.windows? | |
| 50 59 | 
             
                its('MinEncryptionLevel') { should eq 3 }
         | 
| 51 60 | 
             
              end
         | 
| 52 61 |  | 
| 62 | 
            +
              describe registry_key('HKLM\System\CurrentControlSet\Control\Lsa\MSV1_0') do
         | 
| 63 | 
            +
                it { should exist }
         | 
| 64 | 
            +
                its('NTLMMinServerSec') { should eq 537_395_200 }
         | 
| 65 | 
            +
                its('NtlmMinServerSec') { should eq 537_395_200 }
         | 
| 66 | 
            +
              end
         | 
| 53 67 | 
             
            end
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            jfolmer:x:0:0:jfolmer:/jfolmer:/bin/bash
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            uid=201105(jfolmer) gid=200513(domain users) groups=200513(domain users),200512(domain admins),200572(denied rodc password replication group)
         | 
| @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            # Test the ini file format
         | 
| 2 | 
            +
            # Configuration for cinder-rootwrap
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            [DEFAULT]
         | 
| 5 | 
            +
            # List of directories to load filter definitions from (separated by ',').
         | 
| 6 | 
            +
            filters_path=/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap
         | 
| 7 | 
            +
            exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
            # author: Christoph Hartmann
         | 
| 3 | 
            +
            # author: Dominik Richter
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'helper'
         | 
| 6 | 
            +
            require 'inspec/resource'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            describe 'Inspec::Resources::Ini' do
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it 'check ini parsing on ubuntu' do
         | 
| 11 | 
            +
                resource = MockLoader.new(:ubuntu1404).load_resource('ini', 'rootwrap.conf')
         | 
| 12 | 
            +
                result = {"DEFAULT"=>{"filters_path"=>"/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap", "exec_dirs"=>"/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin"}}
         | 
| 13 | 
            +
                _(resource.params).must_equal result
         | 
| 14 | 
            +
                _(resource.value(['DEFAULT','exec_dirs'])).must_equal '/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin'
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -20,6 +20,19 @@ describe 'Inspec::Resources::User' do | |
| 20 20 | 
             
                _(resource.warndays).must_equal 7
         | 
| 21 21 | 
             
              end
         | 
| 22 22 |  | 
| 23 | 
            +
              # ubuntu 14.04 test with ldap user
         | 
| 24 | 
            +
              it 'read user on ubuntu' do
         | 
| 25 | 
            +
                resource = MockLoader.new(:ubuntu1404).load_resource('user', 'jfolmer')
         | 
| 26 | 
            +
                _(resource.exists?).must_equal true
         | 
| 27 | 
            +
                _(resource.group).must_equal 'domain users'
         | 
| 28 | 
            +
                _(resource.groups).must_equal ['domain users', 'domain admins', 'denied rodc password replication group']
         | 
| 29 | 
            +
                _(resource.home).must_equal '/jfolmer'
         | 
| 30 | 
            +
                _(resource.shell).must_equal '/bin/bash'
         | 
| 31 | 
            +
                _(resource.mindays).must_equal 0
         | 
| 32 | 
            +
                _(resource.maxdays).must_equal 99999
         | 
| 33 | 
            +
                _(resource.warndays).must_equal 7
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 23 36 | 
             
              # serverspec compatibility tests (do not test matcher)
         | 
| 24 37 | 
             
              it 'verify serverspec compatibility' do
         | 
| 25 38 | 
             
                resource = MockLoader.new(:ubuntu1404).load_resource('user', 'root')
         | 
    
        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.9. | 
| 4 | 
            +
              version: 0.9.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Dominik Richter
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-11- | 
| 11 | 
            +
            date: 2015-11-24 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: r-train
         | 
| @@ -211,6 +211,7 @@ files: | |
| 211 211 | 
             
            - lib/resources/group.rb
         | 
| 212 212 | 
             
            - lib/resources/host.rb
         | 
| 213 213 | 
             
            - lib/resources/inetd_conf.rb
         | 
| 214 | 
            +
            - lib/resources/ini.rb
         | 
| 214 215 | 
             
            - lib/resources/interface.rb
         | 
| 215 216 | 
             
            - lib/resources/iptables.rb
         | 
| 216 217 | 
             
            - lib/resources/json.rb
         | 
| @@ -257,17 +258,25 @@ files: | |
| 257 258 | 
             
            - test/helper.rb
         | 
| 258 259 | 
             
            - test/integration/.kitchen.yml
         | 
| 259 260 | 
             
            - test/integration/Berksfile
         | 
| 261 | 
            +
            - test/integration/cookbooks/os_prepare/files/example.csv
         | 
| 262 | 
            +
            - test/integration/cookbooks/os_prepare/files/example.ini
         | 
| 263 | 
            +
            - test/integration/cookbooks/os_prepare/files/example.json
         | 
| 264 | 
            +
            - test/integration/cookbooks/os_prepare/files/example.yml
         | 
| 260 265 | 
             
            - test/integration/cookbooks/os_prepare/metadata.rb
         | 
| 261 266 | 
             
            - test/integration/cookbooks/os_prepare/recipes/apt.rb
         | 
| 262 267 | 
             
            - test/integration/cookbooks/os_prepare/recipes/default.rb
         | 
| 263 268 | 
             
            - test/integration/cookbooks/os_prepare/recipes/file.rb
         | 
| 269 | 
            +
            - test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb
         | 
| 264 270 | 
             
            - test/integration/cookbooks/os_prepare/recipes/package.rb
         | 
| 265 271 | 
             
            - test/integration/cookbooks/os_prepare/recipes/registry_key.rb
         | 
| 266 272 | 
             
            - test/integration/cookbooks/os_prepare/recipes/service.rb
         | 
| 267 273 | 
             
            - test/integration/test/integration/default/_debug_spec.rb
         | 
| 268 274 | 
             
            - test/integration/test/integration/default/apt_spec.rb
         | 
| 275 | 
            +
            - test/integration/test/integration/default/csv_spec.rb
         | 
| 269 276 | 
             
            - test/integration/test/integration/default/file_spec.rb
         | 
| 270 277 | 
             
            - test/integration/test/integration/default/group_spec.rb
         | 
| 278 | 
            +
            - test/integration/test/integration/default/ini_spec.rb
         | 
| 279 | 
            +
            - test/integration/test/integration/default/json_spec.rb
         | 
| 271 280 | 
             
            - test/integration/test/integration/default/kernel_module_spec.rb
         | 
| 272 281 | 
             
            - test/integration/test/integration/default/kernel_parameter_spec.rb
         | 
| 273 282 | 
             
            - test/integration/test/integration/default/package_spec.rb
         | 
| @@ -275,6 +284,7 @@ files: | |
| 275 284 | 
             
            - test/integration/test/integration/default/registry_key_spec.rb
         | 
| 276 285 | 
             
            - test/integration/test/integration/default/service_spec.rb
         | 
| 277 286 | 
             
            - test/integration/test/integration/default/user_spec.rb
         | 
| 287 | 
            +
            - test/integration/test/integration/default/yaml_spec.rb
         | 
| 278 288 | 
             
            - test/resource/command_test.rb
         | 
| 279 289 | 
             
            - test/resource/dsl_test.rb
         | 
| 280 290 | 
             
            - test/resource/file_test.rb
         | 
| @@ -306,8 +316,10 @@ files: | |
| 306 316 | 
             
            - test/unit/mock/cmd/get-service-dhcp
         | 
| 307 317 | 
             
            - test/unit/mock/cmd/get-windows-feature
         | 
| 308 318 | 
             
            - test/unit/mock/cmd/getent-hosts-example.com
         | 
| 319 | 
            +
            - test/unit/mock/cmd/getent-passwd-jfolmer
         | 
| 309 320 | 
             
            - test/unit/mock/cmd/getent-passwd-root
         | 
| 310 321 | 
             
            - test/unit/mock/cmd/id-chartmann
         | 
| 322 | 
            +
            - test/unit/mock/cmd/id-jfolmer
         | 
| 311 323 | 
             
            - test/unit/mock/cmd/id-root
         | 
| 312 324 | 
             
            - test/unit/mock/cmd/initctl-show-config-ssh
         | 
| 313 325 | 
             
            - test/unit/mock/cmd/initctl-status-ssh
         | 
| @@ -349,6 +361,7 @@ files: | |
| 349 361 | 
             
            - test/unit/mock/files/ntp.conf
         | 
| 350 362 | 
             
            - test/unit/mock/files/passwd
         | 
| 351 363 | 
             
            - test/unit/mock/files/policyfile.lock.json
         | 
| 364 | 
            +
            - test/unit/mock/files/rootwrap.conf
         | 
| 352 365 | 
             
            - test/unit/mock/files/ssh_config
         | 
| 353 366 | 
             
            - test/unit/mock/files/sshd_config
         | 
| 354 367 | 
             
            - test/unit/mock/profiles/empty/metadata.rb
         | 
| @@ -369,6 +382,7 @@ files: | |
| 369 382 | 
             
            - test/unit/resources/group_test.rb
         | 
| 370 383 | 
             
            - test/unit/resources/host_test.rb
         | 
| 371 384 | 
             
            - test/unit/resources/inetd_conf_test.rb
         | 
| 385 | 
            +
            - test/unit/resources/ini_test.rb
         | 
| 372 386 | 
             
            - test/unit/resources/interface_test.rb
         | 
| 373 387 | 
             
            - test/unit/resources/iptables_test.rb
         | 
| 374 388 | 
             
            - test/unit/resources/json_test.rb
         | 
| @@ -427,17 +441,25 @@ test_files: | |
| 427 441 | 
             
            - test/helper.rb
         | 
| 428 442 | 
             
            - test/integration/.kitchen.yml
         | 
| 429 443 | 
             
            - test/integration/Berksfile
         | 
| 444 | 
            +
            - test/integration/cookbooks/os_prepare/files/example.csv
         | 
| 445 | 
            +
            - test/integration/cookbooks/os_prepare/files/example.ini
         | 
| 446 | 
            +
            - test/integration/cookbooks/os_prepare/files/example.json
         | 
| 447 | 
            +
            - test/integration/cookbooks/os_prepare/files/example.yml
         | 
| 430 448 | 
             
            - test/integration/cookbooks/os_prepare/metadata.rb
         | 
| 431 449 | 
             
            - test/integration/cookbooks/os_prepare/recipes/apt.rb
         | 
| 432 450 | 
             
            - test/integration/cookbooks/os_prepare/recipes/default.rb
         | 
| 433 451 | 
             
            - test/integration/cookbooks/os_prepare/recipes/file.rb
         | 
| 452 | 
            +
            - test/integration/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb
         | 
| 434 453 | 
             
            - test/integration/cookbooks/os_prepare/recipes/package.rb
         | 
| 435 454 | 
             
            - test/integration/cookbooks/os_prepare/recipes/registry_key.rb
         | 
| 436 455 | 
             
            - test/integration/cookbooks/os_prepare/recipes/service.rb
         | 
| 437 456 | 
             
            - test/integration/test/integration/default/_debug_spec.rb
         | 
| 438 457 | 
             
            - test/integration/test/integration/default/apt_spec.rb
         | 
| 458 | 
            +
            - test/integration/test/integration/default/csv_spec.rb
         | 
| 439 459 | 
             
            - test/integration/test/integration/default/file_spec.rb
         | 
| 440 460 | 
             
            - test/integration/test/integration/default/group_spec.rb
         | 
| 461 | 
            +
            - test/integration/test/integration/default/ini_spec.rb
         | 
| 462 | 
            +
            - test/integration/test/integration/default/json_spec.rb
         | 
| 441 463 | 
             
            - test/integration/test/integration/default/kernel_module_spec.rb
         | 
| 442 464 | 
             
            - test/integration/test/integration/default/kernel_parameter_spec.rb
         | 
| 443 465 | 
             
            - test/integration/test/integration/default/package_spec.rb
         | 
| @@ -445,6 +467,7 @@ test_files: | |
| 445 467 | 
             
            - test/integration/test/integration/default/registry_key_spec.rb
         | 
| 446 468 | 
             
            - test/integration/test/integration/default/service_spec.rb
         | 
| 447 469 | 
             
            - test/integration/test/integration/default/user_spec.rb
         | 
| 470 | 
            +
            - test/integration/test/integration/default/yaml_spec.rb
         | 
| 448 471 | 
             
            - test/resource/command_test.rb
         | 
| 449 472 | 
             
            - test/resource/dsl_test.rb
         | 
| 450 473 | 
             
            - test/resource/file_test.rb
         | 
| @@ -476,8 +499,10 @@ test_files: | |
| 476 499 | 
             
            - test/unit/mock/cmd/get-service-dhcp
         | 
| 477 500 | 
             
            - test/unit/mock/cmd/get-windows-feature
         | 
| 478 501 | 
             
            - test/unit/mock/cmd/getent-hosts-example.com
         | 
| 502 | 
            +
            - test/unit/mock/cmd/getent-passwd-jfolmer
         | 
| 479 503 | 
             
            - test/unit/mock/cmd/getent-passwd-root
         | 
| 480 504 | 
             
            - test/unit/mock/cmd/id-chartmann
         | 
| 505 | 
            +
            - test/unit/mock/cmd/id-jfolmer
         | 
| 481 506 | 
             
            - test/unit/mock/cmd/id-root
         | 
| 482 507 | 
             
            - test/unit/mock/cmd/initctl-show-config-ssh
         | 
| 483 508 | 
             
            - test/unit/mock/cmd/initctl-status-ssh
         | 
| @@ -519,6 +544,7 @@ test_files: | |
| 519 544 | 
             
            - test/unit/mock/files/ntp.conf
         | 
| 520 545 | 
             
            - test/unit/mock/files/passwd
         | 
| 521 546 | 
             
            - test/unit/mock/files/policyfile.lock.json
         | 
| 547 | 
            +
            - test/unit/mock/files/rootwrap.conf
         | 
| 522 548 | 
             
            - test/unit/mock/files/ssh_config
         | 
| 523 549 | 
             
            - test/unit/mock/files/sshd_config
         | 
| 524 550 | 
             
            - test/unit/mock/profiles/empty/metadata.rb
         | 
| @@ -539,6 +565,7 @@ test_files: | |
| 539 565 | 
             
            - test/unit/resources/group_test.rb
         | 
| 540 566 | 
             
            - test/unit/resources/host_test.rb
         | 
| 541 567 | 
             
            - test/unit/resources/inetd_conf_test.rb
         | 
| 568 | 
            +
            - test/unit/resources/ini_test.rb
         | 
| 542 569 | 
             
            - test/unit/resources/interface_test.rb
         | 
| 543 570 | 
             
            - test/unit/resources/iptables_test.rb
         | 
| 544 571 | 
             
            - test/unit/resources/json_test.rb
         |