Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env variables azure_backend.rb library issue, if credential file not present #39

Closed
gianlucaciocci opened this issue Jun 2, 2017 · 2 comments
Assignees

Comments

@gianlucaciocci
Copy link

I run into this issue passing Azure SPN credential via environment variables. I don't have any credential file into ~/.azure folder as did set up the following env variables:

export AZURE_SUBSCRIPTION_ID="<value>" 
export AZURE_CLIENT_ID="<value>" 
export AZURE_CLIENT_SECRET="<value>" 
export AZURE_TENANT_ID="<value>"

I am on Ubuntu 16.04, Inspec 1.26.0, Ruby 2.4.1p111.

Error:

Please report a bug if this causes problems.
/home/vagrant/.azure/credentials was not found or not accessible
libraries/azure_backend.rb:59:in `spn': undefined method `sections' for nil:NilClass (NoMethodError)
	from libraries/azure_backend.rb:43:in `connection'
	from libraries/azure_backend.rb:217:in `initialize'
	from libraries/azure_backend.rb:121:in `new'
	from libraries/azure_backend.rb:121:in `initialize'
	from libraries/azure_resource_group.rb:35:in `new'
	from libraries/azure_resource_group.rb:35:in `initialize'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/plugins/resource.rb:47:in `initialize'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/resource.rb:48:in `new'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/resource.rb:48:in `block (3 levels) in create_dsl'
	from startup-compliance/controls/resource_groups.rb:12:in `block in load_with_context'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/rule.rb:50:in `instance_eval'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/rule.rb:50:in `initialize'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/control_eval_context.rb:71:in `new'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/control_eval_context.rb:71:in `block (2 levels) in create'
	from startup-compliance/controls/resource_groups.rb:7:in `load_with_context'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/profile_context.rb:146:in `instance_eval'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/profile_context.rb:146:in `load_with_context'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/profile_context.rb:130:in `load_control_file'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/profile.rb:151:in `block in collect_tests'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/profile.rb:148:in `each'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/profile.rb:148:in `collect_tests'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/runner.rb:90:in `block in load'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/runner.rb:79:in `each'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/runner.rb:79:in `load'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/runner.rb:100:in `run'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/base_cli.rb:83:in `run_tests'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/lib/inspec/cli.rb:159:in `exec'
	from /home/vagrant/.gem/ruby/2.4.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
	from /home/vagrant/.gem/ruby/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
	from /home/vagrant/.gem/ruby/2.4.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
	from /home/vagrant/.gem/ruby/2.4.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
	from /usr/local/lib/ruby/gems/2.4.0/gems/inspec-1.26.0/bin/inspec:12:in `<top (required)>'
	from /home/vagrant/.gem/ruby/2.4.0/bin/inspec:22:in `load'
	from /home/vagrant/.gem/ruby/2.4.0/bin/inspec:22:in `<main>'

What am I doing wrong?

@russellseymour
Copy link
Contributor

@gianlucaciocci You are not doing anything wrong

There is a bug in the code. It is trying to access the credentials file when it does not exist even though you have set the AZURE_SUBSCRIPTION_ID environment variable. I will correct this.

@gianlucaciocci
Copy link
Author

@russellseymour Thanks for getting back to me...I've tried to fix the issue and I've opened a pull request #40. Let me know your thoughts.

russellseymour added a commit that referenced this issue Jun 12, 2017
Fixes #39

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
@russellseymour russellseymour self-assigned this Jun 12, 2017
chris-rock pushed a commit that referenced this issue Oct 9, 2017
…#42)

* Updated so that the credentials file is only interogated if it exists
Fixes #39

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>

* Made change to set credentials to nil as requested

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants