snyk / driftctl

Detect, track and alert on infrastructure drift
Apache License 2.0
2.45k stars 152 forks source link

Ignore any UnsupportedOperationExceptions thrown during scan #1644

Open drem-darios opened 1 year ago

drem-darios commented 1 year ago

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

How to reproduce

Possible Solution

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

drem-darios commented 1 year ago

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
        }
    }