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

Ignore any UnsupportedOperationExceptions thrown during scan #1644

Open
drem-darios opened this issue Mar 18, 2023 · 1 comment
Open

Ignore any UnsupportedOperationExceptions thrown during scan #1644

drem-darios opened this issue Mar 18, 2023 · 1 comment
Labels
kind/bug Something isn't working

Comments

@drem-darios
Copy link

Description
When doing a deep scan on KMS keys in AWS, if a key's origin is external (imported key material), the scan fails and the AWS API throws an UnsupportedOperationException with the error message "origin is EXTERNAL which is not valid for this operation." This failure should be ignored and the scan should continue without regarding this failed key.

Environment

  • OS: MacOS and Linux
  • driftctl version: v0.38.2
  • terraform version: v1.3.2
  • terraform providers versions: [email protected]

How to reproduce

  • Create a key with an origin that is external
  • Scan KMS keys
  • An UnsupportedOperationException is thrown

Possible Solution

  • Check for UnsupportedOperationException in the error message in enumeration/remote/terraform/provider.go
  • Log a warning message but do not return the error. This results in the resource being nil
  • Continue scanning as normal

Additional context
I've only ran into this with AWS KMS keys but it might be possible on other resources.

@drem-darios drem-darios added the kind/bug Something isn't working label Mar 18, 2023
@drem-darios
Copy link
Author

I was able to get past this issue by modifying the code in provider.go with the following code block on line 211:

if err != nil {
		if strings.Contains(err.Error(), "UnsupportedOperationException") {
			logrus.Warn("Operation is not supported")
		} else {
			return nil, err
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant