Skip to content

Instantly share code, notes, and snippets.

@nellshamrell
Created April 18, 2019 21:09
Show Gist options
  • Save nellshamrell/0cf88bd3489129d128bd3e39cf5a4f03 to your computer and use it in GitHub Desktop.
Save nellshamrell/0cf88bd3489129d128bd3e39cf5a4f03 to your computer and use it in GitHub Desktop.

Troubleshooting using the http resource on an Azure load balancer

https://github.com/inspec/inspec/issues/3689 (includes replication steps)

Backtrace

inspec/lib/resources/http.rb

def body
  @worker.body
end

When running the http resource locally, @worker is set properly. When running the http resource on an Azure load balancer, @worker is set to nil.

@nellshamrell
Copy link
Author

nellshamrell commented Apr 18, 2019

This is where that error is being generated - in the instance_eval method
inspec/lib/inspec/rule.rb

     begin
        instance_eval(&block)
      rescue StandardError => e
        # We've encountered an exception while trying to eval the code inside the
        # control block. We need to prevent the exception from bubbling up, and
        # fail the control. Controls are failed by having a failed resource within
        # them; but since our control block is unsafe (and opaque) to us, let's
        # make a dummy and fail that.
        location = block.source_location.compact.join(':')
        describe 'Control Source Code Error' do
          # Rubocop thinks we are raising an exception - we're actually calling RSpec's fail()
          its(location) { fail e.message } # rubocop: disable Style/SignalException
      end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment