prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  gcp serverless runtime error on implicit boto dependency
  reported in gitter, gcp functions should not need to depend on boto3, looks like some of the securityhub work caused an implicit dependency on boto3.
  
  ```
  textPayload: "ModuleNotFoundError: No module named 'boto3'" - Getting this error for the cloud function to stop a instance in GCP
  instance-off
  qte7iow5dhzi
  Traceback (most recent call last): File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 346, in run_http_function result = _function_handler.invoke_user_function(flask.request) File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 217, in invoke_user_function return call_user_function(request_or_event) File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 210, in call_user_function return self._user_function(request_or_event) File "/user_code/main.py", line 21, in run from c7n_gcp.handler import run File "/user_code/c7n_gcp/handler.py", line 24, in <module> from c7n_gcp.entry import initialize_gcp File "/user_code/c7n_gcp/entry.py", line 18, in <module> import c7n_gcp.resources.bigquery File "/user_code/c7n_gcp/resources/bigquery.py", line 16, in <module> from c7n_gcp.query import QueryResourceManager, TypeInfo File "/user_code/c7n_gcp/query.py", line 23, in <module> from c7n.filters import FilterRegistry File "/user_code/c7n/filters/init.py", line 32, in <module> from .securityhub import SecurityHubFindingFilter File "/user_code/c7n/filters/securityhub.py", line 19, in <module> from c7n.resources import aws File "/user_code/c7n/resources/aws.py", line 31, in <module> import boto3 ModuleNotFoundError: No module named 'boto3
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `c7n/filters/securityhub.py`
  Content:
  ```
  1 # Copyright 2019 Capital One Services, LLC
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 # http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 from __future__ import absolute_import, division, print_function, unicode_literals
  15 
  16 from c7n.utils import local_session, type_schema
  17 from .core import Filter
  18 from c7n.manager import resources
  19 from c7n.resources import aws
  20 
  21 
  22 class SecurityHubFindingFilter(Filter):
  23     """Check if there are Security Hub Findings related to the resources
  24     """
  25     schema = type_schema(
  26         'finding',
  27         # Many folks do an aggregator region, allow them to use that
  28         # for filtering.
  29         region={'type': 'string'},
  30         query={'type': 'object'})
  31 
  32     permissions = ('securityhub:GetFindings',)
  33     annotation_key = 'c7n:finding-filter'
  34     query_shape = 'AwsSecurityFindingFilters'
  35 
  36     def validate(self):
  37         query = self.data.get('query')
  38         if query:
  39             aws.shape_validate(query, self.query_shape, 'securityhub')
  40 
  41     def process(self, resources, event=None):
  42         client = local_session(
  43             self.manager.session_factory).client(
  44                 'securityhub', region_name=self.data.get('region'))
  45         found = []
  46         params = dict(self.data.get('query', {}))
  47 
  48         for r_arn, resource in zip(self.manager.get_arns(resources), resources):
  49             params['ResourceId'] = [{"Value": r_arn, "Comparison": "EQUALS"}]
  50             findings = client.get_findings(Filters=params).get("Findings")
  51             if len(findings) > 0:
  52                 resource[self.annotation_key] = findings
  53                 found.append(resource)
  54         return found
  55 
  56     @classmethod
  57     def register_resources(klass, registry, resource_class):
  58         """ meta model subscriber on resource registration.
  59 
  60         SecurityHub Findings Filter
  61         """
  62         for rtype, resource_manager in registry.items():
  63             if not resource_manager.has_arn():
  64                 continue
  65             if 'post-finding' in resource_manager.action_registry:
  66                 continue
  67             resource_class.filter_registry.register('finding', klass)
  68 
  69 
  70 resources.subscribe(resources.EVENT_REGISTER, SecurityHubFindingFilter.register_resources)
  71
  ```
  --- 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/c7n/filters/securityhub.py b/c7n/filters/securityhub.py
  --- a/c7n/filters/securityhub.py
  +++ b/c7n/filters/securityhub.py
  @@ -16,7 +16,6 @@
   from c7n.utils import local_session, type_schema
   from .core import Filter
   from c7n.manager import resources
  -from c7n.resources import aws
   
   
   class SecurityHubFindingFilter(Filter):
  @@ -36,6 +35,7 @@
       def validate(self):
           query = self.data.get('query')
           if query:
  +            from c7n.resources import aws
               aws.shape_validate(query, self.query_shape, 'securityhub')
   
       def process(self, resources, event=None):
  
verification_info: {"golden_diff": "diff --git a/c7n/filters/securityhub.py b/c7n/filters/securityhub.py\n--- a/c7n/filters/securityhub.py\n+++ b/c7n/filters/securityhub.py\n@@ -16,7 +16,6 @@\n from c7n.utils import local_session, type_schema\n from .core import Filter\n from c7n.manager import resources\n-from c7n.resources import aws\n \n \n class SecurityHubFindingFilter(Filter):\n@@ -36,6 +35,7 @@\n     def validate(self):\n         query = self.data.get('query')\n         if query:\n+            from c7n.resources import aws\n             aws.shape_validate(query, self.query_shape, 'securityhub')\n \n     def process(self, resources, event=None):\n", "issue": "gcp serverless runtime error on implicit boto dependency\nreported in gitter, gcp functions should not need to depend on boto3, looks like some of the securityhub work caused an implicit dependency on boto3.\r\n\r\n```\r\ntextPayload: \"ModuleNotFoundError: No module named 'boto3'\" - Getting this error for the cloud function to stop a instance in GCP\r\ninstance-off\r\nqte7iow5dhzi\r\nTraceback (most recent call last): File \"/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py\", line 346, in run_http_function result = _function_handler.invoke_user_function(flask.request) File \"/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py\", line 217, in invoke_user_function return call_user_function(request_or_event) File \"/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py\", line 210, in call_user_function return self._user_function(request_or_event) File \"/user_code/main.py\", line 21, in run from c7n_gcp.handler import run File \"/user_code/c7n_gcp/handler.py\", line 24, in <module> from c7n_gcp.entry import initialize_gcp File \"/user_code/c7n_gcp/entry.py\", line 18, in <module> import c7n_gcp.resources.bigquery File \"/user_code/c7n_gcp/resources/bigquery.py\", line 16, in <module> from c7n_gcp.query import QueryResourceManager, TypeInfo File \"/user_code/c7n_gcp/query.py\", line 23, in <module> from c7n.filters import FilterRegistry File \"/user_code/c7n/filters/init.py\", line 32, in <module> from .securityhub import SecurityHubFindingFilter File \"/user_code/c7n/filters/securityhub.py\", line 19, in <module> from c7n.resources import aws File \"/user_code/c7n/resources/aws.py\", line 31, in <module> import boto3 ModuleNotFoundError: No module named 'boto3\r\n```\n", "before_files": [{"content": "# Copyright 2019 Capital One Services, LLC\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.\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom c7n.utils import local_session, type_schema\nfrom .core import Filter\nfrom c7n.manager import resources\nfrom c7n.resources import aws\n\n\nclass SecurityHubFindingFilter(Filter):\n    \"\"\"Check if there are Security Hub Findings related to the resources\n    \"\"\"\n    schema = type_schema(\n        'finding',\n        # Many folks do an aggregator region, allow them to use that\n        # for filtering.\n        region={'type': 'string'},\n        query={'type': 'object'})\n\n    permissions = ('securityhub:GetFindings',)\n    annotation_key = 'c7n:finding-filter'\n    query_shape = 'AwsSecurityFindingFilters'\n\n    def validate(self):\n        query = self.data.get('query')\n        if query:\n            aws.shape_validate(query, self.query_shape, 'securityhub')\n\n    def process(self, resources, event=None):\n        client = local_session(\n            self.manager.session_factory).client(\n                'securityhub', region_name=self.data.get('region'))\n        found = []\n        params = dict(self.data.get('query', {}))\n\n        for r_arn, resource in zip(self.manager.get_arns(resources), resources):\n            params['ResourceId'] = [{\"Value\": r_arn, \"Comparison\": \"EQUALS\"}]\n            findings = client.get_findings(Filters=params).get(\"Findings\")\n            if len(findings) > 0:\n                resource[self.annotation_key] = findings\n                found.append(resource)\n        return found\n\n    @classmethod\n    def register_resources(klass, registry, resource_class):\n        \"\"\" meta model subscriber on resource registration.\n\n        SecurityHub Findings Filter\n        \"\"\"\n        for rtype, resource_manager in registry.items():\n            if not resource_manager.has_arn():\n                continue\n            if 'post-finding' in resource_manager.action_registry:\n                continue\n            resource_class.filter_registry.register('finding', klass)\n\n\nresources.subscribe(resources.EVENT_REGISTER, SecurityHubFindingFilter.register_resources)\n", "path": "c7n/filters/securityhub.py"}], "after_files": [{"content": "# Copyright 2019 Capital One Services, LLC\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.\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom c7n.utils import local_session, type_schema\nfrom .core import Filter\nfrom c7n.manager import resources\n\n\nclass SecurityHubFindingFilter(Filter):\n    \"\"\"Check if there are Security Hub Findings related to the resources\n    \"\"\"\n    schema = type_schema(\n        'finding',\n        # Many folks do an aggregator region, allow them to use that\n        # for filtering.\n        region={'type': 'string'},\n        query={'type': 'object'})\n\n    permissions = ('securityhub:GetFindings',)\n    annotation_key = 'c7n:finding-filter'\n    query_shape = 'AwsSecurityFindingFilters'\n\n    def validate(self):\n        query = self.data.get('query')\n        if query:\n            from c7n.resources import aws\n            aws.shape_validate(query, self.query_shape, 'securityhub')\n\n    def process(self, resources, event=None):\n        client = local_session(\n            self.manager.session_factory).client(\n                'securityhub', region_name=self.data.get('region'))\n        found = []\n        params = dict(self.data.get('query', {}))\n\n        for r_arn, resource in zip(self.manager.get_arns(resources), resources):\n            params['ResourceId'] = [{\"Value\": r_arn, \"Comparison\": \"EQUALS\"}]\n            findings = client.get_findings(Filters=params).get(\"Findings\")\n            if len(findings) > 0:\n                resource[self.annotation_key] = findings\n                found.append(resource)\n        return found\n\n    @classmethod\n    def register_resources(klass, registry, resource_class):\n        \"\"\" meta model subscriber on resource registration.\n\n        SecurityHub Findings Filter\n        \"\"\"\n        for rtype, resource_manager in registry.items():\n            if not resource_manager.has_arn():\n                continue\n            if 'post-finding' in resource_manager.action_registry:\n                continue\n            resource_class.filter_registry.register('finding', klass)\n\n\nresources.subscribe(resources.EVENT_REGISTER, SecurityHubFindingFilter.register_resources)\n", "path": "c7n/filters/securityhub.py"}]}