prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN 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"
            }
          ]
        }
      }
    }
  }
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py`
  Content:
  ```
  1 """
  2 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3 SPDX-License-Identifier: MIT-0
  4 """
  5 import hashlib
  6 import json
  7 
  8 from cfnlint.helpers import RESOURCE_SPECS
  9 from cfnlint.rules import CloudFormationLintRule, RuleMatch
  10 
  11 
  12 class ListDuplicatesAllowed(CloudFormationLintRule):
  13     """Check if duplicates exist in a List"""
  14 
  15     id = "I3037"
  16     shortdesc = "Check if a list that allows duplicates has any duplicates"
  17     description = (
  18         "Certain lists support duplicate items."
  19         "Provide an alert when list of strings or numbers have repeats."
  20     )
  21     source_url = "https://github.com/aws-cloudformation/cfn-python-lint/blob/main/docs/rules.md#rules-1"
  22     tags = ["resources", "property", "list"]
  23 
  24     def initialize(self, cfn):
  25         """Initialize the rule"""
  26         for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get(
  27             "ResourceTypes"
  28         ):
  29             self.resource_property_types.append(resource_type_spec)
  30         for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get(
  31             "PropertyTypes"
  32         ):
  33             self.resource_sub_property_types.append(property_type_spec)
  34 
  35     def _check_duplicates(self, values, path, scenario=None):
  36         """Check for Duplicates"""
  37         matches = []
  38 
  39         list_items = []
  40         if isinstance(values, list):
  41             for index, value in enumerate(values):
  42                 value_hash = hashlib.sha1(
  43                     json.dumps(value, sort_keys=True).encode("utf-8")
  44                 ).hexdigest()
  45                 if value_hash in list_items:
  46                     if not scenario:
  47                         message = "List has a duplicate value at {0}"
  48                         matches.append(
  49                             RuleMatch(
  50                                 path + [index],
  51                                 message.format("/".join(map(str, path + [index]))),
  52                             )
  53                         )
  54                     else:
  55                         scenario_text = " and ".join(
  56                             [f'condition "{k}" is {v}' for (k, v) in scenario.items()]
  57                         )
  58                         message = "List has a duplicate value at {0} when {1}"
  59                         matches.append(
  60                             RuleMatch(
  61                                 path,
  62                                 message.format("/".join(map(str, path)), scenario_text),
  63                             )
  64                         )
  65 
  66                 list_items.append(value_hash)
  67 
  68         return matches
  69 
  70     def check_duplicates(self, values, path, cfn):
  71         """Check for duplicates"""
  72         matches = []
  73 
  74         if isinstance(values, list):
  75             matches.extend(self._check_duplicates(values, path))
  76         elif isinstance(values, dict):
  77             props = cfn.get_object_without_conditions(values)
  78             for prop in props:
  79                 matches.extend(
  80                     self._check_duplicates(
  81                         prop.get("Object"), path, prop.get("Scenario")
  82                     )
  83                 )
  84 
  85         return matches
  86 
  87     def check(self, cfn, properties, value_specs, path):
  88         """Check itself"""
  89         matches = []
  90         for p_value, p_path in properties.items_safe(path[:]):
  91             for prop in p_value:
  92                 if prop in value_specs:
  93                     property_type = value_specs.get(prop).get("Type")
  94                     primitive_type = value_specs.get(prop).get("PrimitiveItemType")
  95                     duplicates_allowed = value_specs.get(prop).get(
  96                         "DuplicatesAllowed", False
  97                     )
  98                     if (
  99                         property_type == "List"
  100                         and duplicates_allowed
  101                         and primitive_type in ["String", "Integer"]
  102                     ):
  103                         matches.extend(
  104                             self.check_duplicates(p_value[prop], p_path + [prop], cfn)
  105                         )
  106 
  107         return matches
  108 
  109     def match_resource_sub_properties(self, properties, property_type, path, cfn):
  110         """Match for sub properties"""
  111         matches = []
  112 
  113         specs = (
  114             RESOURCE_SPECS.get(cfn.regions[0])
  115             .get("PropertyTypes")
  116             .get(property_type, {})
  117             .get("Properties", {})
  118         )
  119         matches.extend(self.check(cfn, properties, specs, path))
  120 
  121         return matches
  122 
  123     def match_resource_properties(self, properties, resource_type, path, cfn):
  124         """Check CloudFormation Properties"""
  125         matches = []
  126 
  127         specs = (
  128             RESOURCE_SPECS.get(cfn.regions[0])
  129             .get("ResourceTypes")
  130             .get(resource_type, {})
  131             .get("Properties", {})
  132         )
  133         matches.extend(self.check(cfn, properties, specs, path))
  134 
  135         return matches
  136
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: 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 @@
       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 @@
           """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")
  
verification_info: {"golden_diff": "diff --git a/src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py b/src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py\n--- a/src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py\n+++ b/src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py\n@@ -21,6 +21,10 @@\n     source_url = \"https://github.com/aws-cloudformation/cfn-python-lint/blob/main/docs/rules.md#rules-1\"\n     tags = [\"resources\", \"property\", \"list\"]\n \n+    def __init__(self):\n+        super().__init__()\n+        self.exceptions = [\"Command\"]\n+\n     def initialize(self, cfn):\n         \"\"\"Initialize the rule\"\"\"\n         for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get(\n@@ -71,11 +75,15 @@\n         \"\"\"Check for duplicates\"\"\"\n         matches = []\n \n+        if path[-1] in self.exceptions:\n+            return matches\n         if isinstance(values, list):\n             matches.extend(self._check_duplicates(values, path))\n         elif isinstance(values, dict):\n             props = cfn.get_object_without_conditions(values)\n             for prop in props:\n+                if prop in self.exceptions:\n+                    continue\n                 matches.extend(\n                     self._check_duplicates(\n                         prop.get(\"Object\"), path, prop.get(\"Scenario\")\n", "issue": "`I3037` false positives in `AWS::ECS::TaskDefinition.ContainerDefinitions.Command`\n### CloudFormation Lint Version\n\n0.83.0\n\n### What operating system are you using?\n\nMac\n\n### Describe the bug\n\n`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.\n\n### Expected behavior\n\nNo issue is detected.\n\n### Reproduction template\n\n```json\r\n{\r\n  \"AWSTemplateFormatVersion\": \"2010-09-09\",\r\n  \"Description\": \"This template deploys an ECS task definition.\",\r\n  \"Resources\": {\r\n    \"MyECSTaskDefinition\": {\r\n      \"Type\": \"AWS::ECS::TaskDefinition\",\r\n      \"Properties\": {\r\n        \"ContainerDefinitions\": [\r\n          {\r\n            \"Command\": [\r\n              \"do_something\",\r\n              \"--foo\",\r\n              \"1\",\r\n              \"--bar\",\r\n              \"1\"\r\n            ],\r\n            \"Image\": \"my-image\",\r\n            \"Name\": \"my-task\"\r\n          }\r\n        ]\r\n      }\r\n    }\r\n  }\r\n}\r\n```\n", "before_files": [{"content": "\"\"\"\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0\n\"\"\"\nimport hashlib\nimport json\n\nfrom cfnlint.helpers import RESOURCE_SPECS\nfrom cfnlint.rules import CloudFormationLintRule, RuleMatch\n\n\nclass ListDuplicatesAllowed(CloudFormationLintRule):\n    \"\"\"Check if duplicates exist in a List\"\"\"\n\n    id = \"I3037\"\n    shortdesc = \"Check if a list that allows duplicates has any duplicates\"\n    description = (\n        \"Certain lists support duplicate items.\"\n        \"Provide an alert when list of strings or numbers have repeats.\"\n    )\n    source_url = \"https://github.com/aws-cloudformation/cfn-python-lint/blob/main/docs/rules.md#rules-1\"\n    tags = [\"resources\", \"property\", \"list\"]\n\n    def initialize(self, cfn):\n        \"\"\"Initialize the rule\"\"\"\n        for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get(\n            \"ResourceTypes\"\n        ):\n            self.resource_property_types.append(resource_type_spec)\n        for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get(\n            \"PropertyTypes\"\n        ):\n            self.resource_sub_property_types.append(property_type_spec)\n\n    def _check_duplicates(self, values, path, scenario=None):\n        \"\"\"Check for Duplicates\"\"\"\n        matches = []\n\n        list_items = []\n        if isinstance(values, list):\n            for index, value in enumerate(values):\n                value_hash = hashlib.sha1(\n                    json.dumps(value, sort_keys=True).encode(\"utf-8\")\n                ).hexdigest()\n                if value_hash in list_items:\n                    if not scenario:\n                        message = \"List has a duplicate value at {0}\"\n                        matches.append(\n                            RuleMatch(\n                                path + [index],\n                                message.format(\"/\".join(map(str, path + [index]))),\n                            )\n                        )\n                    else:\n                        scenario_text = \" and \".join(\n                            [f'condition \"{k}\" is {v}' for (k, v) in scenario.items()]\n                        )\n                        message = \"List has a duplicate value at {0} when {1}\"\n                        matches.append(\n                            RuleMatch(\n                                path,\n                                message.format(\"/\".join(map(str, path)), scenario_text),\n                            )\n                        )\n\n                list_items.append(value_hash)\n\n        return matches\n\n    def check_duplicates(self, values, path, cfn):\n        \"\"\"Check for duplicates\"\"\"\n        matches = []\n\n        if isinstance(values, list):\n            matches.extend(self._check_duplicates(values, path))\n        elif isinstance(values, dict):\n            props = cfn.get_object_without_conditions(values)\n            for prop in props:\n                matches.extend(\n                    self._check_duplicates(\n                        prop.get(\"Object\"), path, prop.get(\"Scenario\")\n                    )\n                )\n\n        return matches\n\n    def check(self, cfn, properties, value_specs, path):\n        \"\"\"Check itself\"\"\"\n        matches = []\n        for p_value, p_path in properties.items_safe(path[:]):\n            for prop in p_value:\n                if prop in value_specs:\n                    property_type = value_specs.get(prop).get(\"Type\")\n                    primitive_type = value_specs.get(prop).get(\"PrimitiveItemType\")\n                    duplicates_allowed = value_specs.get(prop).get(\n                        \"DuplicatesAllowed\", False\n                    )\n                    if (\n                        property_type == \"List\"\n                        and duplicates_allowed\n                        and primitive_type in [\"String\", \"Integer\"]\n                    ):\n                        matches.extend(\n                            self.check_duplicates(p_value[prop], p_path + [prop], cfn)\n                        )\n\n        return matches\n\n    def match_resource_sub_properties(self, properties, property_type, path, cfn):\n        \"\"\"Match for sub properties\"\"\"\n        matches = []\n\n        specs = (\n            RESOURCE_SPECS.get(cfn.regions[0])\n            .get(\"PropertyTypes\")\n            .get(property_type, {})\n            .get(\"Properties\", {})\n        )\n        matches.extend(self.check(cfn, properties, specs, path))\n\n        return matches\n\n    def match_resource_properties(self, properties, resource_type, path, cfn):\n        \"\"\"Check CloudFormation Properties\"\"\"\n        matches = []\n\n        specs = (\n            RESOURCE_SPECS.get(cfn.regions[0])\n            .get(\"ResourceTypes\")\n            .get(resource_type, {})\n            .get(\"Properties\", {})\n        )\n        matches.extend(self.check(cfn, properties, specs, path))\n\n        return matches\n", "path": "src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py"}], "after_files": [{"content": "\"\"\"\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0\n\"\"\"\nimport hashlib\nimport json\n\nfrom cfnlint.helpers import RESOURCE_SPECS\nfrom cfnlint.rules import CloudFormationLintRule, RuleMatch\n\n\nclass ListDuplicatesAllowed(CloudFormationLintRule):\n    \"\"\"Check if duplicates exist in a List\"\"\"\n\n    id = \"I3037\"\n    shortdesc = \"Check if a list that allows duplicates has any duplicates\"\n    description = (\n        \"Certain lists support duplicate items.\"\n        \"Provide an alert when list of strings or numbers have repeats.\"\n    )\n    source_url = \"https://github.com/aws-cloudformation/cfn-python-lint/blob/main/docs/rules.md#rules-1\"\n    tags = [\"resources\", \"property\", \"list\"]\n\n    def __init__(self):\n        super().__init__()\n        self.exceptions = [\"Command\"]\n\n    def initialize(self, cfn):\n        \"\"\"Initialize the rule\"\"\"\n        for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get(\n            \"ResourceTypes\"\n        ):\n            self.resource_property_types.append(resource_type_spec)\n        for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get(\n            \"PropertyTypes\"\n        ):\n            self.resource_sub_property_types.append(property_type_spec)\n\n    def _check_duplicates(self, values, path, scenario=None):\n        \"\"\"Check for Duplicates\"\"\"\n        matches = []\n\n        list_items = []\n        if isinstance(values, list):\n            for index, value in enumerate(values):\n                value_hash = hashlib.sha1(\n                    json.dumps(value, sort_keys=True).encode(\"utf-8\")\n                ).hexdigest()\n                if value_hash in list_items:\n                    if not scenario:\n                        message = \"List has a duplicate value at {0}\"\n                        matches.append(\n                            RuleMatch(\n                                path + [index],\n                                message.format(\"/\".join(map(str, path + [index]))),\n                            )\n                        )\n                    else:\n                        scenario_text = \" and \".join(\n                            [f'condition \"{k}\" is {v}' for (k, v) in scenario.items()]\n                        )\n                        message = \"List has a duplicate value at {0} when {1}\"\n                        matches.append(\n                            RuleMatch(\n                                path,\n                                message.format(\"/\".join(map(str, path)), scenario_text),\n                            )\n                        )\n\n                list_items.append(value_hash)\n\n        return matches\n\n    def check_duplicates(self, values, path, cfn):\n        \"\"\"Check for duplicates\"\"\"\n        matches = []\n\n        if path[-1] in self.exceptions:\n            return matches\n        if isinstance(values, list):\n            matches.extend(self._check_duplicates(values, path))\n        elif isinstance(values, dict):\n            props = cfn.get_object_without_conditions(values)\n            for prop in props:\n                if prop in self.exceptions:\n                    continue\n                matches.extend(\n                    self._check_duplicates(\n                        prop.get(\"Object\"), path, prop.get(\"Scenario\")\n                    )\n                )\n\n        return matches\n\n    def check(self, cfn, properties, value_specs, path):\n        \"\"\"Check itself\"\"\"\n        matches = []\n        for p_value, p_path in properties.items_safe(path[:]):\n            for prop in p_value:\n                if prop in value_specs:\n                    property_type = value_specs.get(prop).get(\"Type\")\n                    primitive_type = value_specs.get(prop).get(\"PrimitiveItemType\")\n                    duplicates_allowed = value_specs.get(prop).get(\n                        \"DuplicatesAllowed\", False\n                    )\n                    if (\n                        property_type == \"List\"\n                        and duplicates_allowed\n                        and primitive_type in [\"String\", \"Integer\"]\n                    ):\n                        matches.extend(\n                            self.check_duplicates(p_value[prop], p_path + [prop], cfn)\n                        )\n\n        return matches\n\n    def match_resource_sub_properties(self, properties, property_type, path, cfn):\n        \"\"\"Match for sub properties\"\"\"\n        matches = []\n\n        specs = (\n            RESOURCE_SPECS.get(cfn.regions[0])\n            .get(\"PropertyTypes\")\n            .get(property_type, {})\n            .get(\"Properties\", {})\n        )\n        matches.extend(self.check(cfn, properties, specs, path))\n\n        return matches\n\n    def match_resource_properties(self, properties, resource_type, path, cfn):\n        \"\"\"Check CloudFormation Properties\"\"\"\n        matches = []\n\n        specs = (\n            RESOURCE_SPECS.get(cfn.regions[0])\n            .get(\"ResourceTypes\")\n            .get(resource_type, {})\n            .get(\"Properties\", {})\n        )\n        matches.extend(self.check(cfn, properties, specs, path))\n\n        return matches\n", "path": "src/cfnlint/rules/resources/properties/ListDuplicatesAllowed.py"}]}