Repository: aws-cloudformation/cfn-lint

Issue:
`I3037` false positives in `AWS::ECS::TaskDefinition.ContainerDefinitions.Command`
### CloudFormation Lint Version

0.83.0

### What operating system are you using?

Mac

### Describe the bug

`I3037` issues (*List has a duplicate value*) are reported if the command specified in `AWS::ECS::TaskDefinition.ContainerDefinitions.Command` has repeating entries, e.g. the values of several command arguments are the same.

### Expected behavior

No issue is detected.

### Reproduction template

```json
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "This template deploys an ECS task definition.",
  "Resources": {
    "MyECSTaskDefinition": {
      "Type": "AWS::ECS::TaskDefinition",
      "Properties": {
        "ContainerDefinitions": [
          {
            "Command": [
              "do_something",
              "--foo",
              "1",
              "--bar",
              "1"
            ],
            "Image": "my-image",
            "Name": "my-task"
          }
        ]
      }
    }
  }
}
```


Discussion:

Resolving patch:
diff --git a/src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py b/src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py
--- a/src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py
+++ b/src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py
@@ -21,6 +21,10 @@ class ListDuplicatesAllowed(CloudFormationLintRule):
     source_url = "https://github.com/aws-cloudformation/cfn-python-lint/blob/main/docs/rules.md#rules-1"
     tags = ["resources", "property", "list"]
 
+    def __init__(self):
+        super().__init__()
+        self.exceptions = ["Command"]
+
     def initialize(self, cfn):
         """Initialize the rule"""
         for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get(
@@ -71,11 +75,15 @@ def check_duplicates(self, values, path, cfn):
         """Check for duplicates"""
         matches = []
 
+        if path[-1] in self.exceptions:
+            return matches
         if isinstance(values, list):
             matches.extend(self._check_duplicates(values, path))
         elif isinstance(values, dict):
             props = cfn.get_object_without_conditions(values)
             for prop in props:
+                if prop in self.exceptions:
+                    continue
                 matches.extend(
                     self._check_duplicates(
                         prop.get("Object"), path, prop.get("Scenario")


Test patch:
diff --git a/test/fixtures/templates/good/resources/properties/list_duplicates_allowed.yaml b/test/fixtures/templates/good/resources/properties/list_duplicates_allowed.yaml
--- a/test/fixtures/templates/good/resources/properties/list_duplicates_allowed.yaml
+++ b/test/fixtures/templates/good/resources/properties/list_duplicates_allowed.yaml
@@ -4,7 +4,7 @@ Metadata:
   cfn-lint:
     config:
       include_checks:
-      - I
+        - I
 Parameters:
   PrimaryRegion:
     Type: String
@@ -13,7 +13,7 @@ Parameters:
   PrivateSubnetTwo:
     Type: String
 Conditions:
-  isPrimaryRegion: !Equals [!Ref PrimaryRegion, 'us-east-1']
+  isPrimaryRegion: !Equals [!Ref PrimaryRegion, "us-east-1"]
 Resources:
   MyASG:
     Type: AWS::AutoScaling::AutoScalingGroup
@@ -32,11 +32,11 @@ Resources:
       MinSize: "1"
       VPCZoneIdentifier:
         Fn::If:
-        - isPrimaryRegion
-        - - !Ref PrivateSubnetOne
-          - !Ref PrivateSubnetTwo
-        - - !Ref PrivateSubnetOne
-          - !Ref PrivateSubnetTwo
+          - isPrimaryRegion
+          - - !Ref PrivateSubnetOne
+            - !Ref PrivateSubnetTwo
+          - - !Ref PrivateSubnetOne
+            - !Ref PrivateSubnetTwo
   MyASG3:
     Type: AWS::AutoScaling::AutoScalingGroup
     Properties:
@@ -44,5 +44,17 @@ Resources:
       MaxSize: "1"
       MinSize: "1"
       VPCZoneIdentifier:
-        - !If ['isPrimaryRegion', !Ref PrivateSubnetTwo, !Ref PrivateSubnetOne]
+        - !If ["isPrimaryRegion", !Ref PrivateSubnetTwo, !Ref PrivateSubnetOne]
         - "subnet-123456"
+  MyECSTaskDefinition:
+    Type: AWS::ECS::TaskDefinition
+    Properties:
+      ContainerDefinitions:
+        - Command:
+            - do_something
+            - --foo
+            - "1"
+            - --bar
+            - "1"
+          Image: my-image
+          Name: my-task