prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Set a default file size limit for PlasoTask hashers
  Currently, all PlasoTask instances will attempt to hash files of any size, potentially very large ones .This could lead to unusually long processing times.
  
  This is a small part of a larger effort to try to optimize how Turbinia configures Plaso tasks to better utilize inherent parallel processing capabilities.
  
  </issue>
  <code>
  [start of turbinia/workers/plaso.py]
  1 # -*- coding: utf-8 -*-
  2 # Copyright 2015 Google Inc.
  3 #
  4 # Licensed under the Apache License, Version 2.0 (the "License");
  5 # you may not use this file except in compliance with the License.
  6 # You may obtain a copy of the License at
  7 #
  8 #      http://www.apache.org/licenses/LICENSE-2.0
  9 #
  10 # Unless required by applicable law or agreed to in writing, software
  11 # distributed under the License is distributed on an "AS IS" BASIS,
  12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 # See the License for the specific language governing permissions and
  14 # limitations under the License.
  15 """Task for running Plaso."""
  16 
  17 from __future__ import unicode_literals
  18 
  19 import os
  20 import logging
  21 
  22 from turbinia import config
  23 from turbinia.evidence import EvidenceState as state
  24 from turbinia.evidence import PlasoFile
  25 from turbinia.workers import TurbiniaTask
  26 from turbinia.lib import file_helpers
  27 
  28 
  29 class PlasoTask(TurbiniaTask):
  30   """Task to run Plaso (log2timeline)."""
  31 
  32   # Plaso requires the Disk to be attached, but doesn't require it be mounted.
  33   REQUIRED_STATES = [
  34       state.ATTACHED, state.DECOMPRESSED, state.CONTAINER_MOUNTED
  35   ]
  36 
  37   TASK_CONFIG = {
  38       # 'none' as indicated in the options for status_view within
  39       # the Plaso documentation
  40       'status_view': 'none',
  41       'hashers': 'all',
  42       'partitions': 'all',
  43       'vss_stores': 'none',
  44       # artifact_filters and file_filter are mutually exclusive
  45       # parameters and Plaso will error out if both parameters are used.
  46       'artifact_filters': None,
  47       'file_filter': None,
  48       'custom_artifact_definitions': None,
  49       'parsers': None,
  50       'yara_rules': None
  51   }
  52 
  53   def build_plaso_command(self, base_command, conf):
  54     """Builds a typical plaso command, contains logic specific to log2timeline.
  55 
  56     Args:
  57       base_command (str): Command to invoke log2timeline (e.g. log2timeline.py)
  58       conf (dict): Dynamic config containing the parameters for the command.
  59 
  60     Returns:
  61       String for valid Log2timeline command.
  62     """
  63     self.result.log(
  64         'Generating Plaso command line from arguments: {0!s}'.format(conf),
  65         level=logging.DEBUG)
  66     cmd = [base_command]
  67     for k, v in conf.items():
  68       cli_args = [
  69           'status_view', 'hashers', 'partitions', 'vss_stores',
  70           'custom_artifact_definitions', 'parsers', 'artifact_filters',
  71           'file_filter', 'yara_rules'
  72       ]
  73       if (k not in cli_args or not v):
  74         continue
  75       prepend = '-'
  76       if len(k) > 1:
  77         prepend = '--'
  78       if k == 'file_filter':
  79         file_path = file_helpers.write_list_to_temp_file(
  80             v, preferred_dir=self.tmp_dir)
  81         cmd.extend(['-f', file_path])
  82       elif k == 'yara_rules':
  83         file_path = file_helpers.write_str_to_temp_file(
  84             v, preferred_dir=self.tmp_dir)
  85         cmd.extend(['--yara_rules', file_path])
  86       elif isinstance(v, list):
  87         cmd.extend([prepend + k, ','.join(v)])
  88       elif isinstance(v, bool):
  89         cmd.append(prepend + k)
  90       elif isinstance(v, str):
  91         cmd.extend([prepend + k, v])
  92     return cmd
  93 
  94   def run(self, evidence, result):
  95     """Task that process data with Plaso.
  96 
  97     Args:
  98         evidence (Evidence object):  The evidence we will process.
  99         result (TurbiniaTaskResult): The object to place task results into.
  100 
  101     Returns:
  102         TurbiniaTaskResult object.
  103     """
  104 
  105     config.LoadConfig()
  106 
  107     # Write plaso file into tmp_dir because sqlite has issues with some shared
  108     # filesystems (e.g NFS).
  109     plaso_file = os.path.join(self.tmp_dir, '{0:s}.plaso'.format(self.id))
  110     plaso_evidence = PlasoFile(source_path=plaso_file)
  111     plaso_log = os.path.join(self.output_dir, '{0:s}.log'.format(self.id))
  112 
  113     cmd = self.build_plaso_command('log2timeline.py', self.task_config)
  114 
  115     if config.DEBUG_TASKS or self.task_config.get('debug_tasks'):
  116       cmd.append('-d')
  117 
  118     if evidence.credentials:
  119       for credential_type, credential_data in evidence.credentials:
  120         cmd.extend([
  121             '--credential', '{0:s}:{1:s}'.format(
  122                 credential_type, credential_data)
  123         ])
  124 
  125     cmd.extend(['--temporary_directory', self.tmp_dir])
  126     cmd.extend(['--logfile', plaso_log])
  127     cmd.extend(['--unattended'])
  128     cmd.extend(['--storage_file', plaso_file])
  129     cmd.extend([evidence.local_path])
  130 
  131     result.log('Running plaso as [{0:s}]'.format(' '.join(cmd)))
  132     self.execute(
  133         cmd, result, log_files=[plaso_log], new_evidence=[plaso_evidence],
  134         close=True)
  135 
  136     return result
  137
  [end of turbinia/workers/plaso.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/turbinia/workers/plaso.py b/turbinia/workers/plaso.py
  --- a/turbinia/workers/plaso.py
  +++ b/turbinia/workers/plaso.py
  @@ -39,6 +39,7 @@
         # the Plaso documentation
         'status_view': 'none',
         'hashers': 'all',
  +      'hasher_file_size_limit': '1073741824',
         'partitions': 'all',
         'vss_stores': 'none',
         # artifact_filters and file_filter are mutually exclusive
  @@ -66,9 +67,9 @@
       cmd = [base_command]
       for k, v in conf.items():
         cli_args = [
  -          'status_view', 'hashers', 'partitions', 'vss_stores',
  -          'custom_artifact_definitions', 'parsers', 'artifact_filters',
  -          'file_filter', 'yara_rules'
  +          'status_view', 'hashers', 'hasher_file_size_limit', 'partitions',
  +          'vss_stores', 'custom_artifact_definitions', 'parsers',
  +          'artifact_filters', 'file_filter', 'yara_rules'
         ]
         if (k not in cli_args or not v):
           continue
  
verification_info: {"golden_diff": "diff --git a/turbinia/workers/plaso.py b/turbinia/workers/plaso.py\n--- a/turbinia/workers/plaso.py\n+++ b/turbinia/workers/plaso.py\n@@ -39,6 +39,7 @@\n       # the Plaso documentation\n       'status_view': 'none',\n       'hashers': 'all',\n+      'hasher_file_size_limit': '1073741824',\n       'partitions': 'all',\n       'vss_stores': 'none',\n       # artifact_filters and file_filter are mutually exclusive\n@@ -66,9 +67,9 @@\n     cmd = [base_command]\n     for k, v in conf.items():\n       cli_args = [\n-          'status_view', 'hashers', 'partitions', 'vss_stores',\n-          'custom_artifact_definitions', 'parsers', 'artifact_filters',\n-          'file_filter', 'yara_rules'\n+          'status_view', 'hashers', 'hasher_file_size_limit', 'partitions',\n+          'vss_stores', 'custom_artifact_definitions', 'parsers',\n+          'artifact_filters', 'file_filter', 'yara_rules'\n       ]\n       if (k not in cli_args or not v):\n         continue\n", "issue": "Set a default file size limit for PlasoTask hashers\nCurrently, all PlasoTask instances will attempt to hash files of any size, potentially very large ones .This could lead to unusually long processing times.\r\n\r\nThis is a small part of a larger effort to try to optimize how Turbinia configures Plaso tasks to better utilize inherent parallel processing capabilities.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright 2015 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Task for running Plaso.\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport os\nimport logging\n\nfrom turbinia import config\nfrom turbinia.evidence import EvidenceState as state\nfrom turbinia.evidence import PlasoFile\nfrom turbinia.workers import TurbiniaTask\nfrom turbinia.lib import file_helpers\n\n\nclass PlasoTask(TurbiniaTask):\n  \"\"\"Task to run Plaso (log2timeline).\"\"\"\n\n  # Plaso requires the Disk to be attached, but doesn't require it be mounted.\n  REQUIRED_STATES = [\n      state.ATTACHED, state.DECOMPRESSED, state.CONTAINER_MOUNTED\n  ]\n\n  TASK_CONFIG = {\n      # 'none' as indicated in the options for status_view within\n      # the Plaso documentation\n      'status_view': 'none',\n      'hashers': 'all',\n      'partitions': 'all',\n      'vss_stores': 'none',\n      # artifact_filters and file_filter are mutually exclusive\n      # parameters and Plaso will error out if both parameters are used.\n      'artifact_filters': None,\n      'file_filter': None,\n      'custom_artifact_definitions': None,\n      'parsers': None,\n      'yara_rules': None\n  }\n\n  def build_plaso_command(self, base_command, conf):\n    \"\"\"Builds a typical plaso command, contains logic specific to log2timeline.\n\n    Args:\n      base_command (str): Command to invoke log2timeline (e.g. log2timeline.py)\n      conf (dict): Dynamic config containing the parameters for the command.\n\n    Returns:\n      String for valid Log2timeline command.\n    \"\"\"\n    self.result.log(\n        'Generating Plaso command line from arguments: {0!s}'.format(conf),\n        level=logging.DEBUG)\n    cmd = [base_command]\n    for k, v in conf.items():\n      cli_args = [\n          'status_view', 'hashers', 'partitions', 'vss_stores',\n          'custom_artifact_definitions', 'parsers', 'artifact_filters',\n          'file_filter', 'yara_rules'\n      ]\n      if (k not in cli_args or not v):\n        continue\n      prepend = '-'\n      if len(k) > 1:\n        prepend = '--'\n      if k == 'file_filter':\n        file_path = file_helpers.write_list_to_temp_file(\n            v, preferred_dir=self.tmp_dir)\n        cmd.extend(['-f', file_path])\n      elif k == 'yara_rules':\n        file_path = file_helpers.write_str_to_temp_file(\n            v, preferred_dir=self.tmp_dir)\n        cmd.extend(['--yara_rules', file_path])\n      elif isinstance(v, list):\n        cmd.extend([prepend + k, ','.join(v)])\n      elif isinstance(v, bool):\n        cmd.append(prepend + k)\n      elif isinstance(v, str):\n        cmd.extend([prepend + k, v])\n    return cmd\n\n  def run(self, evidence, result):\n    \"\"\"Task that process data with Plaso.\n\n    Args:\n        evidence (Evidence object):  The evidence we will process.\n        result (TurbiniaTaskResult): The object to place task results into.\n\n    Returns:\n        TurbiniaTaskResult object.\n    \"\"\"\n\n    config.LoadConfig()\n\n    # Write plaso file into tmp_dir because sqlite has issues with some shared\n    # filesystems (e.g NFS).\n    plaso_file = os.path.join(self.tmp_dir, '{0:s}.plaso'.format(self.id))\n    plaso_evidence = PlasoFile(source_path=plaso_file)\n    plaso_log = os.path.join(self.output_dir, '{0:s}.log'.format(self.id))\n\n    cmd = self.build_plaso_command('log2timeline.py', self.task_config)\n\n    if config.DEBUG_TASKS or self.task_config.get('debug_tasks'):\n      cmd.append('-d')\n\n    if evidence.credentials:\n      for credential_type, credential_data in evidence.credentials:\n        cmd.extend([\n            '--credential', '{0:s}:{1:s}'.format(\n                credential_type, credential_data)\n        ])\n\n    cmd.extend(['--temporary_directory', self.tmp_dir])\n    cmd.extend(['--logfile', plaso_log])\n    cmd.extend(['--unattended'])\n    cmd.extend(['--storage_file', plaso_file])\n    cmd.extend([evidence.local_path])\n\n    result.log('Running plaso as [{0:s}]'.format(' '.join(cmd)))\n    self.execute(\n        cmd, result, log_files=[plaso_log], new_evidence=[plaso_evidence],\n        close=True)\n\n    return result\n", "path": "turbinia/workers/plaso.py"}]}