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

Azure/Aws resources should not hard fail on API exceptions #2613

Closed
jquick opened this issue Feb 12, 2018 · 5 comments
Closed

Azure/Aws resources should not hard fail on API exceptions #2613

jquick opened this issue Feb 12, 2018 · 5 comments
Labels
Platform: AWS Amazon Web Services-related issues Platform: Azure Microsoft Azure Cloud Type: Enhancement Improves an existing feature

Comments

@jquick
Copy link
Contributor

jquick commented Feb 12, 2018

A profile needs to be executable, but a control may fail. We currently throw exceptions for resources that stop full profile execution, resulting in no report. This will lead to issues if we expect json output e.g in Chef Automate. The controls needs to fail (ie, have a failure outcome but absorb any exceptions) if the resource cannot be executed, but we need to generate a report.

We should hook into the fail_resource if the resource connection is bad saying such.

@jquick jquick added enhancement Platform: AWS Amazon Web Services-related issues Platform: Azure Microsoft Azure Cloud labels Feb 12, 2018
@clintoncwolfe
Copy link
Contributor

The example @chris-rock gave - in which a run hard-failed with "The specified log group does not exist" - is not a connection error. It's an uncaught AWS API exception.

@clintoncwolfe
Copy link
Contributor

For AWS resources, we may be able to wrap the call to fetch_from_api - which gets called in the constructor for both AwsSingularResourceMixin and AwsPluralResourceMixin "mixees".

@clintoncwolfe clintoncwolfe changed the title Azure/Aws should not hard fail on connection issues Azure/Aws resources should not hard fail on API exceptions Feb 12, 2018
@clintoncwolfe clintoncwolfe self-assigned this Feb 12, 2018
@clintoncwolfe
Copy link
Contributor

@chris-rock , @jquick, @arlimus - Here is an example of intercepting a missing credentials exception, failing the controls individually, and issuing a log error message (the default AWS error message here is "unable to sign request without credentials set")

[cwolfe@lodi inspec]$ be bin/inspec exec test/aws/default/verify/controls/aws_cloudwatch_alarm.rb -t aws://us-east-2
[2018-02-12T15:28:33-05:00] ERROR: It appears that you have not set your AWS credentials.  You may set them using environment variables, or using the 'aws://region/aws_credentials_profile' target.  See https://www.inspec.io/docs/reference/platforms for details.
[2018-02-12T15:28:33-05:00] ERROR: It appears that you have not set your AWS credentials.  You may set them using environment variables, or using the 'aws://region/aws_credentials_profile' target.  See https://www.inspec.io/docs/reference/platforms for details.

Profile: tests from test/aws/default/verify/controls/aws_cloudwatch_alarm.rb (tests from test.aws.default.verify.controls.aws_cloudwatch_alarm.rb)
Version: (not specified)
Target:  aws://us-east-2

  ∅  aws_cloudwatch_alarm recall: aws_cloudwatch_alarm (2 failed)
     ∅  aws_cloudwatch_alarm
     No AWS credentials available
     ∅  aws_cloudwatch_alarm
     No AWS credentials available


Profile Summary: 0 successful controls, 1 control failure, 0 controls skipped
Test Summary: 0 successful, 2 failures, 0 skipped

So, I'm issuing a long-form message via Inspec::Log.error, and a short message via fail_resource.

@clintoncwolfe
Copy link
Contributor

In progress on branch cw/catch-cloud-exceptions

@clintoncwolfe
Copy link
Contributor

Fixed by #2636

@clintoncwolfe clintoncwolfe added Type: Enhancement Improves an existing feature and removed enhancement labels Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: AWS Amazon Web Services-related issues Platform: Azure Microsoft Azure Cloud Type: Enhancement Improves an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants