inspec 1.43.8 → 1.44.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2547e56cb83568acdb210c14ff571d28220d7f6f
4
- data.tar.gz: 0ad635b3cb99c3728b0deb137df108f1608a9c50
3
+ metadata.gz: '0586114d59157e09b9b4aa313cf7ec2e3db9a720'
4
+ data.tar.gz: cb26ac2fb7d6d46606b4e84b9be339da1f4b5d07
5
5
  SHA512:
6
- metadata.gz: 5eb0cb325ab1c2284da9d72b01f05429c6e09716e5b6bab351949481f592221e580f69fba6b63bd27ee304f0c619e85c910e0092fb60a252b89886d84cd56fac
7
- data.tar.gz: 9b05c484bb430bbcbbf6711baddaf3e48c8ab02971b173284ee2420a43874306db503049ceac71b5a96e15a17c9ece5d19cc993072c61d88f695a9fb626b34e3
6
+ metadata.gz: b6b466fd7877af420af8fad49925b94e51b09e3ed07ea9bc21ebc9e211d67966d73e27c6461a49bd48be9afbfa3b7a7f9647d40d5b4f2ecdb323bde76ad6b990
7
+ data.tar.gz: 652504e305a7b8a145c5d17120313f107c2e3742668491431a73767b43463f8d71b29517bc71b330863929cee4f5668c498194c780b66d993c750ce08113191c
data/CHANGELOG.md CHANGED
@@ -1,22 +1,42 @@
1
1
  # Change Log
2
2
  <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
3
- <!-- latest_release 1.43.8 -->
4
- ## [v1.43.8](https://github.com/chef/inspec/tree/v1.43.8) (2017-11-02)
3
+ <!-- latest_release 1.44.8 -->
4
+ ## [v1.44.8](https://github.com/chef/inspec/tree/v1.44.8) (2017-11-09)
5
5
 
6
- #### Bug Fixes
7
- - service resource: properly search for SysV Init S files [#2274](https://github.com/chef/inspec/pull/2274) ([Wing924](https://github.com/Wing924))
6
+ #### Enhancements
7
+ - Issue warning during check if profile name contains slash [#2231](https://github.com/chef/inspec/pull/2231) ([clintoncwolfe](https://github.com/clintoncwolfe))
8
8
  <!-- latest_release -->
9
9
 
10
- <!-- release_rollup since=1.43.5 -->
11
- ### Changes since 1.43.5 release
10
+ <!-- release_rollup since=1.43.8 -->
11
+ ### Changes since 1.43.8 release
12
+
13
+ #### Enhancements
14
+ - Issue warning during check if profile name contains slash [#2231](https://github.com/chef/inspec/pull/2231) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 1.44.8 -->
15
+ - http resource: supply max-time option using read_timeout and open_timeout [#2289](https://github.com/chef/inspec/pull/2289) ([bdellegrazie](https://github.com/bdellegrazie)) <!-- 1.44.5 -->
16
+ - allow users to specify user/namespace when fetching profiles from Chef Automate [#2275](https://github.com/chef/inspec/pull/2275) ([arlimus](https://github.com/arlimus)) <!-- 1.44.1 -->
17
+ - Add non-halting exception support to resources [#2235](https://github.com/chef/inspec/pull/2235) ([jerryaldrichiii](https://github.com/jerryaldrichiii)) <!-- 1.44.0 -->
18
+
19
+ #### Merged Pull Requests
20
+ - Eliminate deprecation warnings on resource skipped messages [#2296](https://github.com/chef/inspec/pull/2296) ([adamleff](https://github.com/adamleff)) <!-- 1.44.6 -->
21
+ - Use Ruby 2.4.2 in the Omnibus InSpec packages [#2294](https://github.com/chef/inspec/pull/2294) ([adamleff](https://github.com/adamleff)) <!-- 1.44.4 -->
22
+ - Switch to tomlrb for TOML parsing [#2295](https://github.com/chef/inspec/pull/2295) ([adamleff](https://github.com/adamleff)) <!-- 1.44.2 -->
23
+ - Pin RubyGems to 2.6.14 [#2287](https://github.com/chef/inspec/pull/2287) ([adamleff](https://github.com/adamleff)) <!-- 1.43.10 -->
12
24
 
13
25
  #### Bug Fixes
14
- - service resource: properly search for SysV Init S files [#2274](https://github.com/chef/inspec/pull/2274) ([Wing924](https://github.com/Wing924)) <!-- 1.43.8 -->
15
- - mount resource: fix for Device-/Sharenames and Mountpoints including … [#2257](https://github.com/chef/inspec/pull/2257) ([mgrobelin](https://github.com/mgrobelin)) <!-- 1.43.7 -->
16
- - inspec compliance login: Ensure supplied server has a proper URI scheme [#2268](https://github.com/chef/inspec/pull/2268) ([jerryaldrichiii](https://github.com/jerryaldrichiii)) <!-- 1.43.6 -->
26
+ - Properly compare profile version strings as SemVer [#2280](https://github.com/chef/inspec/pull/2280) ([adamleff](https://github.com/adamleff)) <!-- 1.44.7 -->
27
+ - nginx resource: support quoted identifiers [#2292](https://github.com/chef/inspec/pull/2292) ([adamleff](https://github.com/adamleff)) <!-- 1.44.3 -->
28
+ - http resource: use proper syntax in `curl` header option [#2285](https://github.com/chef/inspec/pull/2285) ([schisamo](https://github.com/schisamo)) <!-- 1.43.9 -->
17
29
  <!-- release_rollup -->
18
30
 
19
31
  <!-- latest_stable_release -->
32
+ ## [v1.43.8](https://github.com/chef/inspec/tree/v1.43.8) (2017-11-02)
33
+
34
+ #### Bug Fixes
35
+ - inspec compliance login: Ensure supplied server has a proper URI scheme [#2268](https://github.com/chef/inspec/pull/2268) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
36
+ - mount resource: fix for Device-/Sharenames and Mountpoints including … [#2257](https://github.com/chef/inspec/pull/2257) ([mgrobelin](https://github.com/mgrobelin))
37
+ - service resource: properly search for SysV Init S files [#2274](https://github.com/chef/inspec/pull/2274) ([Wing924](https://github.com/Wing924))
38
+ <!-- latest_stable_release -->
39
+
20
40
  ## [v1.43.5](https://github.com/chef/inspec/tree/v1.43.5) (2017-10-26)
21
41
 
22
42
  #### New Resources
@@ -30,7 +50,6 @@
30
50
 
31
51
  #### Bug Fixes
32
52
  - Fix regression when uploading compliance profiles [#2264](https://github.com/chef/inspec/pull/2264) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
33
- <!-- latest_stable_release -->
34
53
 
35
54
  ## [v1.42.3](https://github.com/chef/inspec/tree/v1.42.3) (2017-10-19)
36
55
 
data/docs/ruby_usage.md CHANGED
@@ -114,7 +114,6 @@ methods available, etc. For the above example:
114
114
  [3] pry> ls perl_out
115
115
  Inspec::Plugins::Resource#methods: inspect
116
116
  Inspec::Resources::Cmd#methods: command exist? exit_status result stderr stdout to_s
117
- Inspec::Plugins::ResourceCommon#methods: resource_skipped skip_resource
118
117
  Inspec::Resource::Registry::Command#methods: inspec
119
118
  instance variables: @__backend_runner__ @__resource_name__ @command @result
120
119
  [4] pry> perl_out.stdout.partition('@INC:').last.strip.split("\n")
data/inspec.gemspec CHANGED
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.add_dependency 'sslshake', '~> 1.2'
41
41
  spec.add_dependency 'parallel', '~> 1.9'
42
42
  spec.add_dependency 'faraday', '>=0.9.0'
43
- spec.add_dependency 'toml', '~> 0.1'
43
+ spec.add_dependency 'tomlrb', '~> 1.2'
44
44
  spec.add_dependency 'addressable', '~> 2.4'
45
45
  spec.add_dependency 'parslet', '~> 1.5'
46
46
  spec.add_dependency 'semverse'
@@ -16,13 +16,17 @@ module Compliance
16
16
  extend Compliance::API::Login
17
17
 
18
18
  # return all compliance profiles available for the user
19
+ # the user is either specified in the options hash or by default
20
+ # the username of the account is used that is logged in
19
21
  def self.profiles(config)
22
+ owner = config['owner'] || config['user']
23
+
20
24
  # Chef Compliance
21
25
  if is_compliance_server?(config)
22
26
  url = "#{config['server']}/user/compliance"
23
27
  # Chef Automate
24
28
  elsif is_automate_server?(config)
25
- url = "#{config['server']}/profiles/#{config['user']}"
29
+ url = "#{config['server']}/profiles/#{owner}"
26
30
  else
27
31
  raise ServerConfigurationMissing
28
32
  end
@@ -45,9 +49,8 @@ module Compliance
45
49
  elsif is_automate_server_pre_080?(config)
46
50
  mapped_profiles = profiles.values.flatten
47
51
  else
48
- owner_id = config['user']
49
52
  mapped_profiles = profiles.map { |e|
50
- e['owner_id'] = owner_id
53
+ e['owner_id'] = owner
51
54
  e
52
55
  }
53
56
  end
@@ -85,8 +88,13 @@ module Compliance
85
88
 
86
89
  # verifies that a profile
87
90
  def self.exist?(config, profile)
88
- _msg, profiles = Compliance::API.profiles(config)
89
91
  owner, id, ver = profile_split(profile)
92
+
93
+ # ensure that we do not manipulate the configuration object
94
+ user_config = config.dup
95
+ user_config['owner'] = owner
96
+ _msg, profiles = Compliance::API.profiles(user_config)
97
+
90
98
  if !profiles.empty?
91
99
  profiles.any? do |p|
92
100
  p['owner_id'] == owner &&
@@ -104,10 +112,10 @@ module Compliance
104
112
  url = "#{config['server']}/owners/#{owner}/compliance/#{profile_name}/tar"
105
113
  # Chef Automate pre 0.8.0
106
114
  elsif is_automate_server_pre_080?(config)
107
- url = "#{config['server']}/#{config['user']}"
115
+ url = "#{config['server']}/#{owner}"
108
116
  # Chef Automate
109
117
  else
110
- url = "#{config['server']}/profiles/#{config['user']}"
118
+ url = "#{config['server']}/profiles/#{owner}"
111
119
  end
112
120
 
113
121
  headers = get_headers(config)
@@ -79,11 +79,15 @@ module Compliance
79
79
  end
80
80
 
81
81
  desc 'profiles', 'list all available profiles in Chef Compliance'
82
-
82
+ option :owner, type: :string, required: false,
83
+ desc: 'owner whose profiles to list'
83
84
  def profiles
84
85
  config = Compliance::Configuration.new
85
86
  return if !loggedin(config)
86
87
 
88
+ # set owner to config
89
+ config['owner'] = options['owner'] || config['user']
90
+
87
91
  msg, profiles = Compliance::API.profiles(config)
88
92
  profiles.sort_by! { |hsh| hsh['title'] }
89
93
  if !profiles.empty?
@@ -145,11 +149,16 @@ module Compliance
145
149
 
146
150
  desc 'upload PATH', 'uploads a local profile to Chef Compliance'
147
151
  option :overwrite, type: :boolean, default: false,
148
- desc: 'Overwrite existing profile on Chef Compliance.'
152
+ desc: 'Overwrite existing profile on Server.'
153
+ option :owner, type: :string, required: false,
154
+ desc: 'Owner that should own the profile'
149
155
  def upload(path) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, PerceivedComplexity, Metrics/CyclomaticComplexity
150
156
  config = Compliance::Configuration.new
151
157
  return if !loggedin(config)
152
158
 
159
+ # set owner to config
160
+ config['owner'] = options['owner'] || config['user']
161
+
153
162
  unless File.exist?(path)
154
163
  puts "Directory #{path} does not exist."
155
164
  exit 1
@@ -181,14 +190,12 @@ module Compliance
181
190
  error.call('Please login via `inspec compliance login`')
182
191
  end
183
192
 
184
- # owner
185
- owner = config['user']
186
193
  # read profile name from inspec.yml
187
194
  profile_name = profile.params[:name]
188
195
 
189
196
  # check that the profile is not uploaded already,
190
197
  # confirm upload to the user (overwrite with --force)
191
- if Compliance::API.exist?(config, "#{owner}/#{profile_name}") && !options['overwrite']
198
+ if Compliance::API.exist?(config, "#{config['owner']}/#{profile_name}") && !options['overwrite']
192
199
  error.call('Profile exists on the server, use --overwrite')
193
200
  end
194
201
 
@@ -207,12 +214,12 @@ module Compliance
207
214
  archive_path = path
208
215
  end
209
216
 
210
- puts "Start upload to #{owner}/#{profile_name}"
217
+ puts "Start upload to #{config['owner']}/#{profile_name}"
211
218
  pname = ERB::Util.url_encode(profile_name)
212
219
 
213
220
  Compliance::API.is_automate_server?(config) ? upload_msg = 'Uploading to Chef Automate' : upload_msg = 'Uploading to Chef Compliance'
214
221
  puts upload_msg
215
- success, msg = Compliance::API.upload(config, owner, pname, archive_path)
222
+ success, msg = Compliance::API.upload(config, config['owner'], pname, archive_path)
216
223
 
217
224
  if success
218
225
  puts 'Successfully uploaded profile'
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'inspec/profile_vendor'
5
5
  require 'mixlib/shellout'
6
- require 'toml'
6
+ require 'tomlrb'
7
7
 
8
8
  module Habitat
9
9
  class Profile # rubocop:disable Metrics/ClassLength
@@ -298,7 +298,7 @@ module Habitat
298
298
  config_file = File.join(ENV['HOME'], '.hab', 'etc', 'cli.toml')
299
299
  return {} unless File.exist?(config_file)
300
300
 
301
- @cli_config = TOML.load_file(config_file)
301
+ @cli_config = Tomlrb.load_file(config_file)
302
302
  end
303
303
 
304
304
  def output_dir
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'inspec/cached_fetcher'
3
3
  require 'inspec/dependencies/dependency_set'
4
+ require 'semverse'
4
5
 
5
6
  module Inspec
6
7
  #
@@ -39,10 +40,10 @@ module Inspec
39
40
  req
40
41
  end
41
42
 
42
- attr_reader :cwd, :opts, :required_version
43
+ attr_reader :cwd, :opts, :version_constraints
43
44
  def initialize(name, version_constraints, cache, cwd, opts)
44
45
  @name = name
45
- @required_version = Gem::Requirement.new(Array(version_constraints))
46
+ @version_constraints = Array(version_constraints)
46
47
  @cache = cache
47
48
  @backend = opts[:backend]
48
49
  @opts = opts
@@ -62,11 +63,13 @@ module Inspec
62
63
  end
63
64
 
64
65
  def source_satisfies_spec?
65
- gem_dep.match?(profile.name, profile.version)
66
- end
66
+ return true if version_constraints.empty?
67
67
 
68
- def gem_dep
69
- @gem_dep ||= Gem::Dependency.new(profile.name, required_version, :runtime)
68
+ # Semverse::Constraint.satisfy_all returns a list of versions that match all of the
69
+ # supplied constraints. Since we're only matching against a single version, the return
70
+ # of satisfy_all will be non-empty if the profile version we have satisfies the constraints.
71
+ constraints = @version_constraints.map { |x| Semverse::Constraint.new(x) }
72
+ !Semverse::Constraint.satisfy_all(constraints, Semverse::Version.new(profile.version)).empty?
70
73
  end
71
74
 
72
75
  def resolved_source
@@ -77,7 +80,7 @@ module Inspec
77
80
  h = {
78
81
  'name' => name,
79
82
  'resolved_source' => resolved_source,
80
- 'version_constraints' => required_version.to_s,
83
+ 'version_constraints' => version_constraints.to_s,
81
84
  }
82
85
 
83
86
  if !dependencies.empty?
@@ -71,7 +71,7 @@ module Inspec
71
71
  end
72
72
 
73
73
  if !dep.source_satisfies_spec?
74
- raise Inspec::UnsatisfiedVersionSpecification, "The profile #{dep.name} from #{dep.resolved_source} has a version #{dep.source_version} which doesn't match #{dep.required_version}"
74
+ raise Inspec::UnsatisfiedVersionSpecification, "The profile #{dep.name} from #{dep.resolved_source} has a version #{dep.source_version} which doesn't match #{dep.version_constraints}"
75
75
  end
76
76
 
77
77
  Inspec::Log.debug("Adding dependency #{dep.name} (#{dep.resolved_source})")
@@ -5,6 +5,8 @@ module Inspec
5
5
  module Exceptions
6
6
  class AttributesFileDoesNotExist < ArgumentError; end
7
7
  class AttributesFileNotReadable < ArgumentError; end
8
+ class ResourceFailed < StandardError; end
9
+ class ResourceSkipped < StandardError; end
8
10
  class SecretsBackendNotFound < ArgumentError; end
9
11
  end
10
12
  end
@@ -11,6 +11,9 @@ require 'utils/spdx'
11
11
 
12
12
  module Inspec
13
13
  # Extract metadata.rb information
14
+ # A Metadata object may be created and finalized with invalid data.
15
+ # This allows the check CLI command to analyse the issues.
16
+ # Use valid? to determine if the metadata is coherent.
14
17
  class Metadata # rubocop:disable Metrics/ClassLength
15
18
  attr_reader :ref
16
19
  attr_accessor :params, :content
@@ -112,6 +115,12 @@ module Inspec
112
115
  errors.push("Missing profile #{field} in #{ref}")
113
116
  end
114
117
 
118
+ if params[:name] =~ %r{[\/\\]}
119
+ warnings.push("Your profile name (#{params[:name]}) contains a slash " \
120
+ 'which will not be permitted in InSpec 2.0. Please change your profile ' \
121
+ 'name in the `inspec.yml` file.')
122
+ end
123
+
115
124
  # if version is set, ensure it is correct
116
125
  if !params[:version].nil? && !valid_version?(params[:version])
117
126
  errors.push('Version needs to be in SemVer format')
@@ -212,7 +221,12 @@ module Inspec
212
221
  return unless metadata.params[:title].nil?
213
222
 
214
223
  # create a new name based on the original target if it exists
215
- metadata.params[:name] = "tests from #{original_target}" unless original_target.to_s.empty?
224
+ # Crudely slug the target to not contain slashes, to avoid breaking
225
+ # unit tests that look for warning sequences
226
+ unless original_target.to_s.empty?
227
+ metadata.params[:title] = "tests from #{original_target}"
228
+ metadata.params[:name] = metadata.params[:title].gsub(%r{[\\\/]}, '.')
229
+ end
216
230
  end
217
231
 
218
232
  def self.finalize(metadata, profile_id, options, logger = nil)
@@ -37,14 +37,26 @@ module Inspec
37
37
  Inspec::Resource.registry
38
38
  end
39
39
 
40
- def __register(name, obj)
40
+ def __register(name, obj) # rubocop:disable Metrics/MethodLength
41
41
  cl = Class.new(obj) do
42
+ attr_reader :resource_exception_message
43
+
42
44
  def initialize(backend, name, *args)
45
+ @resource_skipped = false
46
+ @resource_failed = false
47
+
43
48
  # attach the backend to this instance
44
49
  @__backend_runner__ = backend
45
50
  @__resource_name__ = name
51
+
46
52
  # call the resource initializer
47
- super(*args)
53
+ begin
54
+ super(*args)
55
+ rescue Inspec::Exceptions::ResourceSkipped => e
56
+ skip_resource(e.message)
57
+ rescue Inspec::Exceptions::ResourceFailed => e
58
+ fail_resource(e.message)
59
+ end
48
60
  end
49
61
 
50
62
  def self.desc(description = nil)
@@ -57,12 +69,29 @@ module Inspec
57
69
  @example = example
58
70
  end
59
71
 
72
+ def skip_resource(message)
73
+ @resource_skipped = true
74
+ @resource_exception_message = message
75
+ end
76
+
77
+ def resource_skipped?
78
+ @resource_skipped
79
+ end
80
+
60
81
  def resource_skipped
61
- @resource_skipped if defined?(@resource_skipped)
82
+ warn('[DEPRECATION] Use `resource_exception_message` for the resource skipped message. This method will be removed in InSpec 2.0.')
83
+ # Returning `nil` here to match previous behavior
84
+ return nil if @resource_skipped == false
85
+ @resource_exception_message
62
86
  end
63
87
 
64
- def skip_resource(message)
65
- @resource_skipped = message
88
+ def fail_resource(message)
89
+ @resource_failed = true
90
+ @resource_exception_message = message
91
+ end
92
+
93
+ def resource_failed?
94
+ @resource_failed
66
95
  end
67
96
 
68
97
  def inspec
data/lib/inspec/runner.rb CHANGED
@@ -231,35 +231,18 @@ module Inspec
231
231
  def get_check_example(method_name, arg, block)
232
232
  opts = block_source_info(block)
233
233
 
234
- if !arg.empty? &&
235
- arg[0].respond_to?(:resource_skipped) &&
236
- !arg[0].resource_skipped.nil?
237
- return @test_collector.example_group(*arg, opts) do
238
- it arg[0].resource_skipped
239
- end
240
- else
241
- # add the resource
242
- case method_name
243
- when 'describe'
244
- return @test_collector.example_group(*arg, opts, &block)
245
- when 'expect'
246
- return block.example_group
247
- when 'describe.one'
248
- tests = arg.map do |x|
249
- @test_collector.example_group(x[1][0], block_source_info(x[2]), &x[2])
250
- end
251
- return nil if tests.empty?
252
- ok_tests = tests.find_all(&:run)
253
- # return all tests if none succeeds; we will just report full failure
254
- return tests if ok_tests.empty?
255
- # otherwise return all working tests
256
- return ok_tests
257
- else
258
- raise "A rule was registered with #{method_name.inspect}, "\
259
- "which isn't understood and cannot be processed."
260
- end
234
+ return nil if arg.empty?
235
+
236
+ if arg[0].respond_to?(:resource_skipped?) && arg[0].resource_skipped?
237
+ return rspec_skipped_block(arg, opts, arg[0].resource_exception_message)
238
+ end
239
+
240
+ if arg[0].respond_to?(:resource_failed?) && arg[0].resource_failed?
241
+ return rspec_failed_block(arg, opts, arg[0].resource_exception_message)
261
242
  end
262
- nil
243
+
244
+ # If neither skipped nor failed then add the resource
245
+ add_resource(method_name, arg, opts, block)
263
246
  end
264
247
 
265
248
  def register_rule(rule)
@@ -288,5 +271,46 @@ module Inspec
288
271
 
289
272
  true
290
273
  end
274
+
275
+ def rspec_skipped_block(arg, opts, message)
276
+ @test_collector.example_group(*arg, opts) do
277
+ # Send custom `it` block to RSpec
278
+ it message
279
+ end
280
+ end
281
+
282
+ def rspec_failed_block(arg, opts, message)
283
+ @test_collector.example_group(*arg, opts) do
284
+ # Send custom `it` block to RSpec
285
+ it '' do
286
+ # Raising here to fail the test and get proper formatting
287
+ raise Inspec::Exceptions::ResourceFailed, message
288
+ end
289
+ end
290
+ end
291
+
292
+ def add_resource(method_name, arg, opts, block)
293
+ case method_name
294
+ when 'describe'
295
+ @test_collector.example_group(*arg, opts, &block)
296
+ when 'expect'
297
+ block.example_group
298
+ when 'describe.one'
299
+ tests = arg.map do |x|
300
+ @test_collector.example_group(x[1][0], block_source_info(x[2]), &x[2])
301
+ end
302
+ return nil if tests.empty?
303
+
304
+ successful_tests = tests.find_all(&:run)
305
+
306
+ # Return all tests if none succeeds; we will just report full failure
307
+ return tests if successful_tests.empty?
308
+
309
+ successful_tests
310
+ else
311
+ raise "A rule was registered with #{method_name.inspect}," \
312
+ "which isn't understood and cannot be processed."
313
+ end
314
+ end
291
315
  end
292
316
  end
@@ -4,5 +4,5 @@
4
4
  # author: Christoph Hartmann
5
5
 
6
6
  module Inspec
7
- VERSION = '1.43.8'.freeze
7
+ VERSION = '1.44.8'.freeze
8
8
  end
@@ -205,12 +205,13 @@ module Inspec::Resources
205
205
  def curl_command
206
206
  cmd = ["curl -i -X #{http_method}"]
207
207
  cmd << "--connect-timeout #{open_timeout}"
208
+ cmd << "--max-time #{open_timeout+read_timeout}"
208
209
  cmd << "--user \'#{username}:#{password}\'" unless username.nil? || password.nil?
209
210
  cmd << '--insecure' unless ssl_verify?
210
211
  cmd << "--data #{Shellwords.shellescape(request_body)}" unless request_body.nil?
211
212
 
212
213
  request_headers.each do |k, v|
213
- cmd << "-H '#{k}=#{v}'"
214
+ cmd << "-H '#{k}: #{v}'"
214
215
  end
215
216
 
216
217
  cmd << "'#{url}'"
@@ -63,7 +63,7 @@ module Inspec::Resources
63
63
  end
64
64
 
65
65
  def filtered_packages
66
- warn "The packages resource is not yet supported on OS #{inspec.os.name}" if resource_skipped
66
+ warn "The packages resource is not yet supported on OS #{inspec.os.name}" if resource_skipped?
67
67
  @list
68
68
  end
69
69
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # author: Nolan Davidson
3
3
 
4
- require 'toml'
4
+ require 'tomlrb'
5
5
 
6
6
  module Inspec::Resources
7
7
  class TomlConfig < JsonConfig
@@ -16,7 +16,7 @@ module Inspec::Resources
16
16
  "
17
17
 
18
18
  def parse(content)
19
- TOML::Parser.new(content).parsed
19
+ Tomlrb.parse(content)
20
20
  end
21
21
 
22
22
  def to_s
@@ -21,15 +21,24 @@ class NginxParser < Parslet::Parser
21
21
  (identifier >> values.maybe.as(:args)).as(:assignment) >> str(';') >> filler?
22
22
  }
23
23
 
24
- rule(:identifier) {
24
+ rule(:standard_identifier) {
25
25
  (match('[a-zA-Z]') >> match('\S').repeat).as(:identifier) >> space >> space.repeat
26
26
  }
27
27
 
28
+ rule(:quoted_identifier) {
29
+ str('"') >> (str('"').absent? >> any).repeat.as(:identifier) >> str('"') >> space.repeat
30
+ }
31
+
32
+ rule(:identifier) {
33
+ standard_identifier | quoted_identifier
34
+ }
35
+
28
36
  rule(:value) {
29
37
  ((match('[#;{]').absent? >> any) >> (
30
38
  str('\\') >> any | match('[#;{]|\s').absent? >> any
31
39
  ).repeat).as(:value) >> space.repeat
32
40
  }
41
+
33
42
  rule(:values) {
34
43
  value.repeat >> space.maybe
35
44
  }
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: 1.43.8
4
+ version: 1.44.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-02 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train
@@ -213,19 +213,19 @@ dependencies:
213
213
  - !ruby/object:Gem::Version
214
214
  version: 0.9.0
215
215
  - !ruby/object:Gem::Dependency
216
- name: toml
216
+ name: tomlrb
217
217
  requirement: !ruby/object:Gem::Requirement
218
218
  requirements:
219
219
  - - "~>"
220
220
  - !ruby/object:Gem::Version
221
- version: '0.1'
221
+ version: '1.2'
222
222
  type: :runtime
223
223
  prerelease: false
224
224
  version_requirements: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - "~>"
227
227
  - !ruby/object:Gem::Version
228
- version: '0.1'
228
+ version: '1.2'
229
229
  - !ruby/object:Gem::Dependency
230
230
  name: addressable
231
231
  requirement: !ruby/object:Gem::Requirement
@@ -698,7 +698,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
698
698
  version: '0'
699
699
  requirements: []
700
700
  rubyforge_project:
701
- rubygems_version: 2.6.13
701
+ rubygems_version: 2.6.14
702
702
  signing_key:
703
703
  specification_version: 4
704
704
  summary: Infrastructure and compliance testing.