Repository: aws-cloudformation/cfn-lint

Issue:
Custom Rule not working for boolean values
*cfn-lint version: (`cfn-lint --version`)* 0.54.4

*Description of issue.* Attempting to create a custom rule to detect KMS keys that do not have auto rotate enabled. I discovered https://github.com/aws-cloudformation/cfn-lint/issues/2185 which covers the inability to react to absence of a value, but I'm just having issues with booleans. I'm able to trip the rules, so I know custom rules are registering, but I'm unable to get it to trip only against KMS Key resources who's EnableKeyRotation is false

Please provide as much information as possible:
* Template linting issues:
  * Please provide a CloudFormation sample that generated the issue.
  * If present, please add links to the (official) documentation for clarification.
  * Validate if the issue still exists with the latest version of `cfn-lint` and/or the latest Spec files
* Feature request:
  * Please provide argumentation about the missing feature. Context is key!
Example cfn
```
---
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  TestKey:
    Properties:
      EnableKeyRotation: false
      KeyPolicy:
        Statement:
        - Action: kms:*
          Effect: Allow
          Principal:
            AWS:
              Fn::Sub: arn:${AWS::Partition}:iam::${AWS::AccountId}:root
          Resource: "*"
          Sid: Enable key management, including IAM user permissions
        Version: '2012-10-17'
    Type: AWS::KMS::Key
```

rules file (showing different casings/quotings in case it's relevant)-
```
AWS::KMS::Key EnableKeyRotation == True ERROR "KMS keys should be configured to auto rotate"
AWS::KMS::Key EnableKeyRotation == true ERROR "KMS keys should be configured to auto rotate"
AWS::KMS::Key EnableKeyRotation == TRUE ERROR "KMS keys should be configured to auto rotate"
AWS::KMS::Key EnableKeyRotation == "True" ERROR "KMS keys should be configured to auto rotate"
AWS::KMS::Key EnableKeyRotation == "true" ERROR "KMS keys should be configured to auto rotate"
AWS::KMS::Key EnableKeyRotation == "TRUE" ERROR "KMS keys should be configured to auto rotate"
```

if I flip the rules to
```
AWS::KMS::Key EnableKeyRotation == false ERROR "KMS keys should be configured to auto rotate"
```
No change. But if I then flip the cfn template's EnableKeyRotation to `true` it is then flagged in violation

Cfn-lint uses the [CloudFormation Resource Specifications](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification.html) as the base to do validation. These files are included as part of the application version. Please update to the latest version of `cfn-lint` or update the spec files manually (`cfn-lint -u`)



Discussion:

Resolving patch:
diff --git a/src/cfnlint/rules/custom/Operators.py b/src/cfnlint/rules/custom/Operators.py
--- a/src/cfnlint/rules/custom/Operators.py
+++ b/src/cfnlint/rules/custom/Operators.py
@@ -49,7 +49,7 @@ def _check_value(self, value, path, property_chain, cfn):
                         cfn=cfn,
                     ))
                 return matches
-            if value:
+            if value is not None:
                 matches.extend(self.rule_func(value, self.property_value, path))
             return matches
 


Test patch:
diff --git a/test/fixtures/custom_rules/bad/custom_rule_invalid_boolean.txt b/test/fixtures/custom_rules/bad/custom_rule_invalid_boolean.txt
new file mode 100644
--- /dev/null
+++ b/test/fixtures/custom_rules/bad/custom_rule_invalid_boolean.txt
@@ -0,0 +1 @@
+AWS::EC2::Instance BlockDeviceMappings.Ebs.DeleteOnTermination == True ERROR
diff --git a/test/fixtures/custom_rules/good/custom_rule_boolean.txt b/test/fixtures/custom_rules/good/custom_rule_boolean.txt
new file mode 100644
--- /dev/null
+++ b/test/fixtures/custom_rules/good/custom_rule_boolean.txt
@@ -0,0 +1 @@
+AWS::EC2::Instance BlockDeviceMappings.Ebs.DeleteOnTermination == False ERROR
diff --git a/test/unit/module/custom_rules/test_custom_rules.py b/test/unit/module/custom_rules/test_custom_rules.py
--- a/test/unit/module/custom_rules/test_custom_rules.py
+++ b/test/unit/module/custom_rules/test_custom_rules.py
@@ -28,6 +28,8 @@ def setUp(self):
         }
 
         self.perfect_rule = 'test/fixtures/custom_rules/good/custom_rule_perfect.txt'
+        self.valid_boolean = 'test/fixtures/custom_rules/good/custom_rule_boolean.txt'
+        self.invalid_boolean = 'test/fixtures/custom_rules/bad/custom_rule_invalid_boolean.txt'
         self.invalid_op = 'test/fixtures/custom_rules/bad/custom_rule_invalid_op.txt'
         self.invalid_prop = 'test/fixtures/custom_rules/bad/custom_rule_invalid_prop.txt'
         self.invalid_propkey = 'test/fixtures/custom_rules/bad/custom_rule_invalid_propkey.txt'
@@ -71,6 +73,14 @@ def test_invalid_less_than(self):
         """Test Successful Custom_Rule Parsing"""
         assert (self.run_tests(self.invalid_less_than)[0].message.find('Lesser than check') > -1)
 
+    def test_valid_boolean_value(self):
+        """Test Boolean values"""
+        assert (self.run_tests(self.valid_boolean) == [])
+
+    def test_invalid_boolean_value(self):
+        """Test Boolean values"""
+        assert (self.run_tests(self.invalid_boolean)[0].message.find('Must equal check failed') > -1)
+
     def test_invalid_prop(self):
         """Test Successful Custom_Rule Parsing"""
         assert (self.run_tests(self.invalid_prop) == [])
@@ -92,4 +102,3 @@ def run_tests(self, rulename):
             rules.create_from_custom_rules_file(rulename)
             runner = cfnlint.runner.Runner(rules, filename, template, None, None)
             return runner.run()
-