martezr / inspec-gcp

This project is DEPRECATED and the official InSpec GCP (https://github.com/inspec/inspec-gcp) should be used.
Apache License 2.0
3 stars 3 forks source link

Error no catched when credentials are missing #5

Open tpoindessous opened 6 years ago

tpoindessous commented 6 years ago

Hi

during my tests, I forgot to export my credentials and I got this error which was not catched :

libraries/gcp_instance.rb:25:in `rescue in initialize': undefined method `body' for #<Signet::AuthorizationError:0x007f874abc1be0> (NoMethodError)
    from libraries/gcp_instance.rb:22:in `initialize'
    from /Users/thomas/.rvm/gems/ruby-2.3.0/gems/inspec-2.0.17/lib/inspec/plugins/resource.rb:71:in `initialize'
    from /Users/thomas/.rvm/gems/ruby-2.3.0/gems/inspec-2.0.17/lib/inspec/resource.rb:51:in `new'
    from /Users/thomas/.rvm/gems/ruby-2.3.0/gems/inspec-2.0.17/lib/inspec/resource.rb:51:in `block (3 levels) in create_dsl'
    from ./controls/instance.rb:5:in `block in load_with_context'

Thanks !

martezr commented 6 years ago

@tpoindessous Thanks for the feedback.

I receive the following error messages when the credentials aren't set as well as when the file specified doesn't actually exist.

Environment Variable not set

inspec exec gcp-compliance/ Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information

Non existant file specified

export GOOGLE_APPLICATION_CREDENTIALS=/creds1.json

inspec exec gcp-compliance/ Unable to read the credential file specified by GOOGLE_APPLICATION_CREDENTIALS: file /creds1.json does not exist