prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  The aws-cli bundle package uses an insecure version of PyYAML
  ### awscli version:<br>
  `aws-cli/1.16.52 Python/2.7.15 Linux/4.14.77-69.57.amzn1.x86_64 exec-env/AWS_ECS_EC2 botocore/1.12.42`
  
  [NVD entry](https://nvd.nist.gov/vuln/detail/CVE-2017-18342)
  
  This issue was found when vulnerability alerts started appearing in Twistlock in response to scans of Docker images that we are using in several applications. The generic error found in these outlines is as such:<br>
  
  ```
  Impacted versions: <=3.13
  In PyYAML before 4.1, the yaml.load() API could execute arbitrary code. In other words, yaml.safe_load is not used.
  ```
  
  These images are not natively using PyYAML, so this led us to a Docker `RUN` line in a Dockerfile that executed a script that contains a line of code that executes the installation of the `aws-cli` bundle using the following URL:<br>
  
  `https://s3.amazonaws.com/aws-cli/awscli-bundle.zip`
  
  Unpacking this archive shows a list of package dependencies that includes the vulnerable version of PyYAML:<br>
  
  `awscli-bundle/packages/PyYAML-3.13.tar.gz`
  
  The latest (and actually secure) version of PyYAML appears to be 4.1 according to the developer via the [GitHub repo](https://github.com/yaml/pyyaml).
  
  ### Request
  
  Is it possible to have the patched version of PyYAML added to this bundle to avoid this vulnerability?
  
  Thank you!
  
  </issue>
  <code>
  [start of awscli/customizations/ecs/filehelpers.py]
  1 # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License"). You
  4 # may not use this file except in compliance with the License. A copy of
  5 # the License is located at
  6 #
  7 # http://aws.amazon.com/apache2.0/
  8 #
  9 # or in the "license" file accompanying this file. This file is
  10 # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  11 # ANY KIND, either express or implied. See the License for the specific
  12 # language governing permissions and limitations under the License.
  13 
  14 import json
  15 import yaml
  16 
  17 from awscli.customizations.ecs import exceptions
  18 
  19 MAX_CHAR_LENGTH = 46
  20 APP_PREFIX = 'AppECS-'
  21 DGP_PREFIX = 'DgpECS-'
  22 
  23 
  24 def find_required_key(resource_name, obj, key):
  25 
  26     if obj is None:
  27         raise exceptions.MissingPropertyError(
  28             resource=resource_name, prop_name=key)
  29 
  30     result = _get_case_insensitive_key(obj, key)
  31 
  32     if result is None:
  33         raise exceptions.MissingPropertyError(
  34             resource=resource_name, prop_name=key)
  35     else:
  36         return result
  37 
  38 
  39 def _get_case_insensitive_key(target_obj, target_key):
  40     key_to_match = target_key.lower()
  41     key_list = target_obj.keys()
  42 
  43     for key in key_list:
  44         if key.lower() == key_to_match:
  45             return key
  46 
  47 
  48 def get_app_name(service, cluster, app_value):
  49     if app_value is not None:
  50         return app_value
  51     else:
  52         suffix = _get_ecs_suffix(service, cluster)
  53         return APP_PREFIX + suffix
  54 
  55 
  56 def get_cluster_name_from_arn(arn):
  57     return arn.split('/')[1]
  58 
  59 
  60 def get_deploy_group_name(service, cluster, dg_value):
  61     if dg_value is not None:
  62         return dg_value
  63     else:
  64         suffix = _get_ecs_suffix(service, cluster)
  65         return DGP_PREFIX + suffix
  66 
  67 
  68 def _get_ecs_suffix(service, cluster):
  69     if cluster is None:
  70         cluster_name = 'default'
  71     else:
  72         cluster_name = cluster[:MAX_CHAR_LENGTH]
  73 
  74     return cluster_name + '-' + service[:MAX_CHAR_LENGTH]
  75 
  76 
  77 def parse_appspec(appspec_str):
  78     try:
  79         return json.loads(appspec_str)
  80     except ValueError:
  81         return yaml.load(appspec_str)
  82
  [end of awscli/customizations/ecs/filehelpers.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/awscli/customizations/ecs/filehelpers.py b/awscli/customizations/ecs/filehelpers.py
  --- a/awscli/customizations/ecs/filehelpers.py
  +++ b/awscli/customizations/ecs/filehelpers.py
  @@ -78,4 +78,4 @@
       try:
           return json.loads(appspec_str)
       except ValueError:
  -        return yaml.load(appspec_str)
  +        return yaml.safe_load(appspec_str)
  
verification_info: {"golden_diff": "diff --git a/awscli/customizations/ecs/filehelpers.py b/awscli/customizations/ecs/filehelpers.py\n--- a/awscli/customizations/ecs/filehelpers.py\n+++ b/awscli/customizations/ecs/filehelpers.py\n@@ -78,4 +78,4 @@\n     try:\n         return json.loads(appspec_str)\n     except ValueError:\n-        return yaml.load(appspec_str)\n+        return yaml.safe_load(appspec_str)\n", "issue": "The aws-cli bundle package uses an insecure version of PyYAML\n### awscli version:<br>\r\n`aws-cli/1.16.52 Python/2.7.15 Linux/4.14.77-69.57.amzn1.x86_64 exec-env/AWS_ECS_EC2 botocore/1.12.42`\r\n\r\n[NVD entry](https://nvd.nist.gov/vuln/detail/CVE-2017-18342)\r\n\r\nThis issue was found when vulnerability alerts started appearing in Twistlock in response to scans of Docker images that we are using in several applications. The generic error found in these outlines is as such:<br>\r\n\r\n```\r\nImpacted versions: <=3.13\r\nIn PyYAML before 4.1, the yaml.load() API could execute arbitrary code. In other words, yaml.safe_load is not used.\r\n```\r\n\r\nThese images are not natively using PyYAML, so this led us to a Docker `RUN` line in a Dockerfile that executed a script that contains a line of code that executes the installation of the `aws-cli` bundle using the following URL:<br>\r\n\r\n`https://s3.amazonaws.com/aws-cli/awscli-bundle.zip`\r\n\r\nUnpacking this archive shows a list of package dependencies that includes the vulnerable version of PyYAML:<br>\r\n\r\n`awscli-bundle/packages/PyYAML-3.13.tar.gz`\r\n\r\nThe latest (and actually secure) version of PyYAML appears to be 4.1 according to the developer via the [GitHub repo](https://github.com/yaml/pyyaml).\r\n\r\n### Request\r\n\r\nIs it possible to have the patched version of PyYAML added to this bundle to avoid this vulnerability?\r\n\r\nThank you!\n", "before_files": [{"content": "# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n# http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n\nimport json\nimport yaml\n\nfrom awscli.customizations.ecs import exceptions\n\nMAX_CHAR_LENGTH = 46\nAPP_PREFIX = 'AppECS-'\nDGP_PREFIX = 'DgpECS-'\n\n\ndef find_required_key(resource_name, obj, key):\n\n    if obj is None:\n        raise exceptions.MissingPropertyError(\n            resource=resource_name, prop_name=key)\n\n    result = _get_case_insensitive_key(obj, key)\n\n    if result is None:\n        raise exceptions.MissingPropertyError(\n            resource=resource_name, prop_name=key)\n    else:\n        return result\n\n\ndef _get_case_insensitive_key(target_obj, target_key):\n    key_to_match = target_key.lower()\n    key_list = target_obj.keys()\n\n    for key in key_list:\n        if key.lower() == key_to_match:\n            return key\n\n\ndef get_app_name(service, cluster, app_value):\n    if app_value is not None:\n        return app_value\n    else:\n        suffix = _get_ecs_suffix(service, cluster)\n        return APP_PREFIX + suffix\n\n\ndef get_cluster_name_from_arn(arn):\n    return arn.split('/')[1]\n\n\ndef get_deploy_group_name(service, cluster, dg_value):\n    if dg_value is not None:\n        return dg_value\n    else:\n        suffix = _get_ecs_suffix(service, cluster)\n        return DGP_PREFIX + suffix\n\n\ndef _get_ecs_suffix(service, cluster):\n    if cluster is None:\n        cluster_name = 'default'\n    else:\n        cluster_name = cluster[:MAX_CHAR_LENGTH]\n\n    return cluster_name + '-' + service[:MAX_CHAR_LENGTH]\n\n\ndef parse_appspec(appspec_str):\n    try:\n        return json.loads(appspec_str)\n    except ValueError:\n        return yaml.load(appspec_str)\n", "path": "awscli/customizations/ecs/filehelpers.py"}]}