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

(dynamodb): Rule suppression for DYNAMODB_PITR_ENABLED not working #251

Open
plinioh opened this issue Nov 14, 2023 · 1 comment
Open

(dynamodb): Rule suppression for DYNAMODB_PITR_ENABLED not working #251

plinioh opened this issue Nov 14, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@plinioh
Copy link

plinioh commented Nov 14, 2023

What is the problem?

The suppression rule for DYNAMODB_PITR_ENABLED is not working as expected.

Reproduction Steps

template.yaml

Resources:
  Table:
    DeletionPolicy: Delete
    UpdateReplacePolicy: Delete
    Type: AWS::DynamoDB::Table
    Metadata:
      guard:
        SuppressedRules:
          - DYNAMODB_PITR_ENABLED
    Properties:
      AttributeDefinitions:
        - { AttributeName: "partition_key", AttributeType: "S" }
      KeySchema:
        - { AttributeName: "partition_key", KeyType: "HASH" }

Rule Set:
Currently using wa-Reliability-Pillar.guard from Release v1.0.2

Command:

 cfn-guard validate -r ~/Downloads/output/wa-Reliability-Pillar.guard -d template.yaml

Result:

cfn-guard validate -r ~/Downloads/output/wa-Reliability-Pillar.guard -d template.yaml          
template.yaml Status = FAIL
FAILED rules
wa-Reliability-Pillar.guard/DYNAMODB_PITR_ENABLED                          FAIL
---
Evaluating data template.yaml against rules wa-Reliability-Pillar.guard
Number of non-compliant resources 1
Resource = Table {
  Type      = AWS::DynamoDB::Table
  Rule = DYNAMODB_PITR_ENABLED {
    ALL {
      Check =  %aws_dynamodb_table_resources[*].Properties.PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled EQUALS  true {
        Message {
          Guard Rule Set: wa-Reliability-Pillar
          Controls: REL-9
          Violation: All DynamoDB Tables must have Point-In-Time-Recovery enabled.
          Fix: Set the dynamodb table property PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled to true.
        }
        RequiredPropertyError {
          PropertyPath = /Resources/Table/Properties[L:10,C:6]
          MissingProperty = PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled
          Reason = Could not find key PointInTimeRecoverySpecification inside struct at path /Resources/Table/Properties[L:10,C:6]
          Code:
                8.        SuppressedRules:
                9.          - DYNAMODB_PITR_ENABLED
               10.    Properties:
               11.      AttributeDefinitions:
               12.        - { AttributeName: "partition_key", AttributeType: "S" }
               13.      KeySchema:
        }
      }
    }
  }
}

What did you expect to happen?

I expected the that cfn-guard validate exited cleanly since the rule for DYNAMODB_PITR_ENABLED is Supressed.

What actually happened?

cfn-guard validate evaluated the template as non-compliant

CloudFormation Guard Version

cfn-guard 3.0.1

OS

MacOS

OS Version

Sonoma 14.1.1

Other information

N/A

@plinioh plinioh added the bug Something isn't working label Nov 14, 2023
@cm-kazup0n
Copy link

cm-kazup0n commented Feb 27, 2024

@plinioh I also encountered the same issue. I believe the problem has been resolved since the conditions have been fixed in the main branch.

Conditions for SupressedRules are added in main as follows

let dynamodb_pitr_enabled = Resources.*[ Type == "AWS::DynamoDB::Table" 
  Metadata.guard.SuppressedRules not exists or
  Metadata.guard.SuppressedRules.* != "DYNAMODB_PITR_ENABLED"
]

https://github.com/aws-cloudformation/aws-guard-rules-registry/blob/main/rules/aws/dynamodb/dynamodb_pitr_enabled.guard#L31-L34

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

No branches or pull requests

2 participants