Ignore any UnsupportedOperationExceptions thrown during scan · Issue #1644 · snyk/driftctl · GitHub
Skip to content

Ignore any UnsupportedOperationExceptions thrown during scan #1644

Open

Description

@drem-darios

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: aws-sdk-go@1.38.68

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.

Activity

  1. drem-darios commented on Mar 18, 2023

    @drem-darios
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions