Skip annotations are sometimes ignored in terraform_plan mode
Describe the bug
The handle_skipped_checks loop removes elements from a list it is iterating on. This can cause some skip annotations to be ignored, making Checkov report findings as failures even if there is a comment on the resource asking for the finding to be suppressed.
To Reproduce
Steps to reproduce the behavior:
Create a plan file from the following HCL:
text
provider "aws" {
region = "us-west-2"
}
resource "aws_s3_bucket" "bucket" {
# checkov:skip=CKV_AWS_20: skip this
acl = "public-read"
}
resource "aws_dynamodb_table" "table" {
# checkov:skip=CKV_AWS_28: and also this
name = "table"
hash_key = "UserId"
attribute {
name = "UserId"
type = "S"
}
}