prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Update OSSEC to v3.0
  ## Description
  
  OSSEC 3.0 was released on July 17th 2018[0], containing a large amount of bug fixes (including 2 security fixes) as well as new major functionality. Of note, it supports whitelisting syscheck md5 hashes in a sqlite database, potentially reducing notification noise.
  
  ## User Research Evidence
  
  Users like up-to-date packages
  
  ## User Stories
  
  As a SecureDrop administrator, I would like to have all packages updated and would like to minimize alerts/noise.
  
  [0] https://github.com/ossec/ossec-hids/releases
  
  </issue>
  <code>
  [start of install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py]
  1 #!/usr/bin/env python
  2 DOCUMENTATION = '''
  3 ---
  4 module: ossec_urls
  5 short_description: Gather facts for OSSEC download URLs
  6 description:
  7   - Gather version, checksum, and URL info for OSSEC downloads
  8 author:
  9     - Conor Schaefer (@conorsch)
  10     - Freedom of the Press Foundation (@freedomofpress)
  11 requirements:
  12     - requests
  13 options:
  14   ossec_version:
  15     description:
  16       - version number of release to download
  17     default: "2.8.2"
  18     required: no
  19 notes:
  20   - The OSSEC version to download is hardcoded to avoid surprises.
  21     If you want a newer version than the current default, you should
  22     pass the version in via I(ossec_version).
  23 '''
  24 EXAMPLES = '''
  25 - ossec_urls:
  26     ossec_version: "2.8.2"
  27 '''
  28 
  29 import re  # noqa: E402
  30 
  31 
  32 HAS_REQUESTS = True
  33 try:
  34     import requests
  35 except ImportError:
  36     HAS_REQUESTS = False
  37 
  38 
  39 class OSSECURLs():
  40 
  41     def __init__(self, ossec_version):
  42         self.ossec_version = ossec_version
  43 
  44         checksums = self.parse_checksums()
  45 
  46         self.ansible_facts = dict(
  47             ossec_version=self.ossec_version,
  48             ossec_tarball_filename=self.ossec_tarball_filename,
  49             ossec_tarball_url=self.ossec_tarball_url,
  50             ossec_checksum_filename=self.ossec_checksum_filename,
  51             ossec_checksum_url=self.ossec_checksum_url,
  52             )
  53 
  54         self.ansible_facts.update(checksums)
  55 
  56     @property
  57     def ossec_tarball_filename(self):
  58         return "ossec-hids-{}.tar.gz".format(self.ossec_version)
  59 
  60     @property
  61     def ossec_tarball_url(self):
  62         return "https://github.com/ossec/ossec-hids/archive/{}.tar.gz".format(
  63                 self.ossec_version)
  64 
  65     @property
  66     def ossec_checksum_url(self):
  67         return "https://github.com/ossec/ossec-hids/releases/download/{}/{}".format(  # noqa: E501
  68                 self.ossec_version, self.ossec_checksum_filename)
  69 
  70     @property
  71     def ossec_checksum_filename(self):
  72         return "{}-checksum.txt".format(self.ossec_tarball_filename)
  73 
  74     def parse_checksums(self):
  75         r = requests.get(self.ossec_checksum_url)
  76         checksum_regex = re.compile(r'''
  77                                     ^MD5\(
  78                                     '''
  79                                     + re.escape(self.ossec_tarball_filename) +
  80                                     r'''\)=\s+(?P<ossec_md5_checksum>[0-9a-f]{32})\s+
  81                                     SHA1\(
  82                                     '''
  83                                     + re.escape(self.ossec_tarball_filename) +
  84                                     r'''\)=\s+(?P<ossec_sha1_checksum>[0-9a-f]{40})$
  85                                     ''', re.VERBOSE | re.MULTILINE
  86                                     )
  87         checksum_list = r.content.rstrip()
  88         results = re.match(checksum_regex, checksum_list).groupdict()
  89         return results
  90 
  91 
  92 def main():
  93     module = AnsibleModule(  # noqa: F405
  94         argument_spec=dict(
  95             ossec_version=dict(default="2.8.2"),
  96         ),
  97         supports_check_mode=False
  98     )
  99     if not HAS_REQUESTS:
  100         module.fail_json(msg='requests required for this module')
  101 
  102     ossec_version = module.params['ossec_version']
  103     try:
  104         ossec_config = OSSECURLs(ossec_version=ossec_version)
  105     except:  # noqa: E722
  106         msg = ("Failed to find checksum information for OSSEC v{}."
  107                "Ensure you have the proper release specified, "
  108                "and check the download page to confirm: "
  109                "http://www.ossec.net/?page_id=19".format(ossec_version))
  110         module.fail_json(msg=msg)
  111 
  112     results = ossec_config.ansible_facts
  113 
  114     if results:
  115         module.exit_json(changed=False, ansible_facts=results)
  116     else:
  117         msg = "Failed to fetch OSSEC URL facts."
  118         module.fail_json(msg=msg)
  119 
  120 
  121 from ansible.module_utils.basic import * # noqa E402,F403
  122 main()
  123
  [end of install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.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/install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py b/install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py
  --- a/install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py
  +++ b/install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py
  @@ -14,7 +14,7 @@
     ossec_version:
       description:
         - version number of release to download
  -    default: "2.8.2"
  +    default: "3.0.0"
       required: no
   notes:
     - The OSSEC version to download is hardcoded to avoid surprises.
  @@ -23,15 +23,15 @@
   '''
   EXAMPLES = '''
   - ossec_urls:
  -    ossec_version: "2.8.2"
  +    ossec_version: "3.0.0"
   '''
   
  -import re  # noqa: E402
  +import re  # noqa: F401
   
   
   HAS_REQUESTS = True
   try:
  -    import requests
  +    import requests  # noqa: F401
   except ImportError:
       HAS_REQUESTS = False
   
  @@ -39,60 +39,38 @@
   class OSSECURLs():
   
       def __init__(self, ossec_version):
  +        self.REPO_URL = "https://github.com/ossec/ossec-hids"
           self.ossec_version = ossec_version
  -
  -        checksums = self.parse_checksums()
  -
           self.ansible_facts = dict(
               ossec_version=self.ossec_version,
               ossec_tarball_filename=self.ossec_tarball_filename,
               ossec_tarball_url=self.ossec_tarball_url,
  -            ossec_checksum_filename=self.ossec_checksum_filename,
  -            ossec_checksum_url=self.ossec_checksum_url,
  +            ossec_signature_filename=self.ossec_signature_filename,
  +            ossec_signature_url=self.ossec_signature_url,
               )
   
  -        self.ansible_facts.update(checksums)
  -
       @property
       def ossec_tarball_filename(self):
           return "ossec-hids-{}.tar.gz".format(self.ossec_version)
   
       @property
       def ossec_tarball_url(self):
  -        return "https://github.com/ossec/ossec-hids/archive/{}.tar.gz".format(
  -                self.ossec_version)
  +        return self.REPO_URL + "/archive/{}.tar.gz".format(self.ossec_version)
   
       @property
  -    def ossec_checksum_url(self):
  -        return "https://github.com/ossec/ossec-hids/releases/download/{}/{}".format(  # noqa: E501
  -                self.ossec_version, self.ossec_checksum_filename)
  +    def ossec_signature_url(self):
  +        return self.REPO_URL + "/releases/download/{}/{}".format(
  +                self.ossec_version, self.ossec_signature_filename)
   
       @property
  -    def ossec_checksum_filename(self):
  -        return "{}-checksum.txt".format(self.ossec_tarball_filename)
  -
  -    def parse_checksums(self):
  -        r = requests.get(self.ossec_checksum_url)
  -        checksum_regex = re.compile(r'''
  -                                    ^MD5\(
  -                                    '''
  -                                    + re.escape(self.ossec_tarball_filename) +
  -                                    r'''\)=\s+(?P<ossec_md5_checksum>[0-9a-f]{32})\s+
  -                                    SHA1\(
  -                                    '''
  -                                    + re.escape(self.ossec_tarball_filename) +
  -                                    r'''\)=\s+(?P<ossec_sha1_checksum>[0-9a-f]{40})$
  -                                    ''', re.VERBOSE | re.MULTILINE
  -                                    )
  -        checksum_list = r.content.rstrip()
  -        results = re.match(checksum_regex, checksum_list).groupdict()
  -        return results
  +    def ossec_signature_filename(self):
  +        return "ossec-hids-{}.tar.gz.asc".format(self.ossec_version)
   
   
   def main():
       module = AnsibleModule(  # noqa: F405
           argument_spec=dict(
  -            ossec_version=dict(default="2.8.2"),
  +            ossec_version=dict(default="3.0.0"),
           ),
           supports_check_mode=False
       )
  
verification_info: {"golden_diff": "diff --git a/install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py b/install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py\n--- a/install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py\n+++ b/install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py\n@@ -14,7 +14,7 @@\n   ossec_version:\n     description:\n       - version number of release to download\n-    default: \"2.8.2\"\n+    default: \"3.0.0\"\n     required: no\n notes:\n   - The OSSEC version to download is hardcoded to avoid surprises.\n@@ -23,15 +23,15 @@\n '''\n EXAMPLES = '''\n - ossec_urls:\n-    ossec_version: \"2.8.2\"\n+    ossec_version: \"3.0.0\"\n '''\n \n-import re  # noqa: E402\n+import re  # noqa: F401\n \n \n HAS_REQUESTS = True\n try:\n-    import requests\n+    import requests  # noqa: F401\n except ImportError:\n     HAS_REQUESTS = False\n \n@@ -39,60 +39,38 @@\n class OSSECURLs():\n \n     def __init__(self, ossec_version):\n+        self.REPO_URL = \"https://github.com/ossec/ossec-hids\"\n         self.ossec_version = ossec_version\n-\n-        checksums = self.parse_checksums()\n-\n         self.ansible_facts = dict(\n             ossec_version=self.ossec_version,\n             ossec_tarball_filename=self.ossec_tarball_filename,\n             ossec_tarball_url=self.ossec_tarball_url,\n-            ossec_checksum_filename=self.ossec_checksum_filename,\n-            ossec_checksum_url=self.ossec_checksum_url,\n+            ossec_signature_filename=self.ossec_signature_filename,\n+            ossec_signature_url=self.ossec_signature_url,\n             )\n \n-        self.ansible_facts.update(checksums)\n-\n     @property\n     def ossec_tarball_filename(self):\n         return \"ossec-hids-{}.tar.gz\".format(self.ossec_version)\n \n     @property\n     def ossec_tarball_url(self):\n-        return \"https://github.com/ossec/ossec-hids/archive/{}.tar.gz\".format(\n-                self.ossec_version)\n+        return self.REPO_URL + \"/archive/{}.tar.gz\".format(self.ossec_version)\n \n     @property\n-    def ossec_checksum_url(self):\n-        return \"https://github.com/ossec/ossec-hids/releases/download/{}/{}\".format(  # noqa: E501\n-                self.ossec_version, self.ossec_checksum_filename)\n+    def ossec_signature_url(self):\n+        return self.REPO_URL + \"/releases/download/{}/{}\".format(\n+                self.ossec_version, self.ossec_signature_filename)\n \n     @property\n-    def ossec_checksum_filename(self):\n-        return \"{}-checksum.txt\".format(self.ossec_tarball_filename)\n-\n-    def parse_checksums(self):\n-        r = requests.get(self.ossec_checksum_url)\n-        checksum_regex = re.compile(r'''\n-                                    ^MD5\\(\n-                                    '''\n-                                    + re.escape(self.ossec_tarball_filename) +\n-                                    r'''\\)=\\s+(?P<ossec_md5_checksum>[0-9a-f]{32})\\s+\n-                                    SHA1\\(\n-                                    '''\n-                                    + re.escape(self.ossec_tarball_filename) +\n-                                    r'''\\)=\\s+(?P<ossec_sha1_checksum>[0-9a-f]{40})$\n-                                    ''', re.VERBOSE | re.MULTILINE\n-                                    )\n-        checksum_list = r.content.rstrip()\n-        results = re.match(checksum_regex, checksum_list).groupdict()\n-        return results\n+    def ossec_signature_filename(self):\n+        return \"ossec-hids-{}.tar.gz.asc\".format(self.ossec_version)\n \n \n def main():\n     module = AnsibleModule(  # noqa: F405\n         argument_spec=dict(\n-            ossec_version=dict(default=\"2.8.2\"),\n+            ossec_version=dict(default=\"3.0.0\"),\n         ),\n         supports_check_mode=False\n     )\n", "issue": "Update OSSEC to v3.0\n## Description\r\n\r\nOSSEC 3.0 was released on July 17th 2018[0], containing a large amount of bug fixes (including 2 security fixes) as well as new major functionality. Of note, it supports whitelisting syscheck md5 hashes in a sqlite database, potentially reducing notification noise.\r\n\r\n## User Research Evidence\r\n\r\nUsers like up-to-date packages\r\n\r\n## User Stories\r\n\r\nAs a SecureDrop administrator, I would like to have all packages updated and would like to minimize alerts/noise.\r\n\r\n[0] https://github.com/ossec/ossec-hids/releases\n", "before_files": [{"content": "#!/usr/bin/env python\nDOCUMENTATION = '''\n---\nmodule: ossec_urls\nshort_description: Gather facts for OSSEC download URLs\ndescription:\n  - Gather version, checksum, and URL info for OSSEC downloads\nauthor:\n    - Conor Schaefer (@conorsch)\n    - Freedom of the Press Foundation (@freedomofpress)\nrequirements:\n    - requests\noptions:\n  ossec_version:\n    description:\n      - version number of release to download\n    default: \"2.8.2\"\n    required: no\nnotes:\n  - The OSSEC version to download is hardcoded to avoid surprises.\n    If you want a newer version than the current default, you should\n    pass the version in via I(ossec_version).\n'''\nEXAMPLES = '''\n- ossec_urls:\n    ossec_version: \"2.8.2\"\n'''\n\nimport re  # noqa: E402\n\n\nHAS_REQUESTS = True\ntry:\n    import requests\nexcept ImportError:\n    HAS_REQUESTS = False\n\n\nclass OSSECURLs():\n\n    def __init__(self, ossec_version):\n        self.ossec_version = ossec_version\n\n        checksums = self.parse_checksums()\n\n        self.ansible_facts = dict(\n            ossec_version=self.ossec_version,\n            ossec_tarball_filename=self.ossec_tarball_filename,\n            ossec_tarball_url=self.ossec_tarball_url,\n            ossec_checksum_filename=self.ossec_checksum_filename,\n            ossec_checksum_url=self.ossec_checksum_url,\n            )\n\n        self.ansible_facts.update(checksums)\n\n    @property\n    def ossec_tarball_filename(self):\n        return \"ossec-hids-{}.tar.gz\".format(self.ossec_version)\n\n    @property\n    def ossec_tarball_url(self):\n        return \"https://github.com/ossec/ossec-hids/archive/{}.tar.gz\".format(\n                self.ossec_version)\n\n    @property\n    def ossec_checksum_url(self):\n        return \"https://github.com/ossec/ossec-hids/releases/download/{}/{}\".format(  # noqa: E501\n                self.ossec_version, self.ossec_checksum_filename)\n\n    @property\n    def ossec_checksum_filename(self):\n        return \"{}-checksum.txt\".format(self.ossec_tarball_filename)\n\n    def parse_checksums(self):\n        r = requests.get(self.ossec_checksum_url)\n        checksum_regex = re.compile(r'''\n                                    ^MD5\\(\n                                    '''\n                                    + re.escape(self.ossec_tarball_filename) +\n                                    r'''\\)=\\s+(?P<ossec_md5_checksum>[0-9a-f]{32})\\s+\n                                    SHA1\\(\n                                    '''\n                                    + re.escape(self.ossec_tarball_filename) +\n                                    r'''\\)=\\s+(?P<ossec_sha1_checksum>[0-9a-f]{40})$\n                                    ''', re.VERBOSE | re.MULTILINE\n                                    )\n        checksum_list = r.content.rstrip()\n        results = re.match(checksum_regex, checksum_list).groupdict()\n        return results\n\n\ndef main():\n    module = AnsibleModule(  # noqa: F405\n        argument_spec=dict(\n            ossec_version=dict(default=\"2.8.2\"),\n        ),\n        supports_check_mode=False\n    )\n    if not HAS_REQUESTS:\n        module.fail_json(msg='requests required for this module')\n\n    ossec_version = module.params['ossec_version']\n    try:\n        ossec_config = OSSECURLs(ossec_version=ossec_version)\n    except:  # noqa: E722\n        msg = (\"Failed to find checksum information for OSSEC v{}.\"\n               \"Ensure you have the proper release specified, \"\n               \"and check the download page to confirm: \"\n               \"http://www.ossec.net/?page_id=19\".format(ossec_version))\n        module.fail_json(msg=msg)\n\n    results = ossec_config.ansible_facts\n\n    if results:\n        module.exit_json(changed=False, ansible_facts=results)\n    else:\n        msg = \"Failed to fetch OSSEC URL facts.\"\n        module.fail_json(msg=msg)\n\n\nfrom ansible.module_utils.basic import * # noqa E402,F403\nmain()\n", "path": "install_files/ansible-base/roles/build-ossec-deb-pkg/library/ossec_urls.py"}]}