Skip to content

Commit 2264456

Browse files
authored
Merge branch 'dev' into patch-1
2 parents 1d99906 + f3ec8a9 commit 2264456

File tree

19 files changed

+176
-144
lines changed

19 files changed

+176
-144
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ What are the supported Python versions?
1515
|----------------------------------|------------|------------|------------|------------|-------------|
1616
| Azure Functions 2.0 (deprecated) ||| - | - | - |
1717
| Azure Functions 3.0 ||||| - |
18-
| Azure Functions 4.0 | - |||| preview |
18+
| Azure Functions 4.0 | - |||| coming soon |
1919

2020
For information about Azure Functions Runtime, please refer to [Azure Functions runtime versions overview](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions) page.
2121

SECURITY.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->
2+
3+
## Security
4+
5+
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6+
7+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
8+
9+
## Reporting Security Issues
10+
11+
**Please do not report security vulnerabilities through public GitHub issues.**
12+
13+
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
14+
15+
If you prefer to submit without logging in, send email to [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
16+
17+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
18+
19+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20+
21+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22+
* Full paths of source file(s) related to the manifestation of the issue
23+
* The location of the affected source code (tag/branch/commit or direct URL)
24+
* Any special configuration required to reproduce the issue
25+
* Step-by-step instructions to reproduce the issue
26+
* Proof-of-concept or exploit code (if possible)
27+
* Impact of the issue, including how an attacker might exploit the issue
28+
29+
This information will help us triage your report more quickly.
30+
31+
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
32+
33+
## Preferred Languages
34+
35+
We prefer all communications to be in English.
36+
37+
## Policy
38+
39+
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
40+
41+
<!-- END MICROSOFT SECURITY.MD BLOCK -->

azure_functions_worker/constants.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
PYTHON_THREADPOOL_THREAD_COUNT_MAX = sys.maxsize
4444
PYTHON_THREADPOOL_THREAD_COUNT_MAX_37 = 32
4545

46-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT = False
47-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 = False
46+
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT = True
4847
PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT = False
4948
PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT_39 = True
5049

azure_functions_worker/dispatcher.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from .logging import disable_console_logging, enable_console_logging
3030
from .logging import enable_debug_logging_recommendation
3131
from .logging import (logger, error_logger, is_system_log_category,
32-
CONSOLE_LOG_PREFIX)
32+
CONSOLE_LOG_PREFIX, format_exception)
3333
from .utils.common import get_app_setting, is_envvar_true
3434
from .utils.dependency import DependencyManager
3535
from .utils.tracing import marshall_exception_trace
@@ -745,7 +745,9 @@ def gen(resp_queue):
745745
if ex is grpc_req_stream:
746746
# Yes, this is how grpc_req_stream iterator exits.
747747
return
748-
error_logger.exception('unhandled error in gRPC thread')
748+
error_logger.exception(
749+
'unhandled error in gRPC thread. Exception: {0}'.format(
750+
format_exception(ex)))
749751
raise
750752

751753

azure_functions_worker/functions.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import pathlib
66
import typing
77

8-
from azure.functions import DataType, Function
9-
108
from . import bindings as bindings_utils
119
from . import protos
1210
from ._thirdparty import typing_inspect
@@ -216,8 +214,7 @@ def validate_function_params(params: dict, bound_params: dict,
216214
param_bind_type, param_py_type)
217215

218216
if not checks_out:
219-
if binding.data_type is not DataType(
220-
protos.BindingInfo.undefined):
217+
if binding.data_type is not protos.BindingInfo.undefined:
221218
raise FunctionLoadError(
222219
func_name,
223220
f'{param.name!r} binding type "{binding.type}" '
@@ -357,7 +354,7 @@ def add_function(self, function_id: str,
357354
output_types, return_type)
358355

359356
def add_indexed_function(self, function_id: str,
360-
function: Function):
357+
function):
361358
func = function.get_user_function()
362359
func_name = function.get_function_name()
363360
return_binding_name: typing.Optional[str] = None

azure_functions_worker/loader.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
import sys
1111
import uuid
1212
from os import PathLike, fspath
13-
from typing import List, Optional, Dict
14-
15-
from azure.functions import Function, FunctionApp
13+
from typing import Optional, Dict
1614

1715
from . import protos, functions
1816
from .constants import MODULE_NOT_FOUND_TS_URL, SCRIPT_FILE_NAME, \
@@ -47,7 +45,7 @@ def uninstall() -> None:
4745
pass
4846

4947

50-
def build_binding_protos(indexed_function: Function) -> Dict:
48+
def build_binding_protos(indexed_function) -> Dict:
5149
binding_protos = {}
5250
for binding in indexed_function.get_bindings():
5351
binding_protos[binding.name] = protos.BindingInfo(
@@ -59,7 +57,7 @@ def build_binding_protos(indexed_function: Function) -> Dict:
5957

6058

6159
def process_indexed_function(functions_registry: functions.Registry,
62-
indexed_functions: List[Function]):
60+
indexed_functions):
6361
fx_metadata_results = []
6462
for indexed_function in indexed_functions:
6563
function_id = str(uuid.uuid4())
@@ -141,10 +139,11 @@ def load_function(name: str, directory: str, script_file: str,
141139
expt_type=ImportError,
142140
message=f'Troubleshooting Guide: {MODULE_NOT_FOUND_TS_URL}'
143141
)
144-
def index_function_app(function_path: str) -> List[Function]:
142+
def index_function_app(function_path: str):
145143
module_name = pathlib.Path(function_path).stem
146144
imported_module = importlib.import_module(module_name)
147145

146+
from azure.functions import FunctionApp
148147
app: Optional[FunctionApp] = None
149148
for i in imported_module.__dir__():
150149
if isinstance(getattr(imported_module, i, None), FunctionApp):

azure_functions_worker/logging.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import logging.handlers
66
import sys
7+
import traceback
78
from typing import Optional
89

910
# Logging Prefixes
@@ -20,6 +21,13 @@
2021
error_handler: Optional[logging.Handler] = None
2122

2223

24+
def format_exception(exception):
25+
msg = str(exception) + "\n"
26+
msg += ''.join(traceback.format_exception(
27+
etype=type(exception), value=exception, tb=exception.__traceback__))
28+
return msg
29+
30+
2331
def setup(log_level, log_destination):
2432
# Since handler and error_handler are moved to the global scope,
2533
# before assigning to these handlers, we should define 'global' keyword

azure_functions_worker/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def main():
3636

3737
from . import logging
3838
from ._thirdparty import aio_compat
39-
from .logging import error_logger, logger
39+
from .logging import error_logger, logger, format_exception
4040

4141
args = parse_args()
4242
logging.setup(log_level=args.log_level, log_destination=args.log_to)
@@ -48,8 +48,10 @@ def main():
4848
try:
4949
return aio_compat.run(start_async(
5050
args.host, args.port, args.worker_id, args.request_id))
51-
except Exception:
52-
error_logger.exception('unhandled error in functions worker')
51+
except Exception as ex:
52+
error_logger.exception(
53+
'unhandled error in functions worker: {0}'.format(
54+
format_exception(ex)))
5355
raise
5456

5557

azure_functions_worker/testutils_lc.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,6 @@ def _find_latest_mesh_image(cls,
139139
cls._mesh_images[host_major] = image_tag
140140
return image_tag
141141

142-
def _delete_init_file_from_azure_dir(self):
143-
init_file_path = f"/azure-functions-host/workers/python/" \
144-
f"{self._py_version}/LINUX/X64/azure/__init__.py"
145-
run_rm_cmd = [self._docker_cmd, "exec", self._uuid]
146-
run_rm_cmd.extend(["rm", init_file_path])
147-
148-
subprocess.run(args=run_rm_cmd,
149-
stdout=subprocess.PIPE,
150-
stderr=subprocess.PIPE)
151-
152142
@staticmethod
153143
def _download_azure_functions() -> str:
154144
with urlopen(_FUNC_GITHUB_ZIP) as zipresp:
@@ -201,9 +191,6 @@ def spawn_container(self,
201191
f' {image} with uuid {self._uuid}.'
202192
f' stderr: {run_process.stderr}')
203193

204-
# Remove once worker version 4.0.0 is released
205-
self._delete_init_file_from_azure_dir()
206-
207194
# Wait for three seconds for the port to expose
208195
time.sleep(3)
209196

azure_functions_worker/utils/dependency.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
from azure_functions_worker.utils.common import is_true_like
2-
from typing import List, Optional
3-
from types import ModuleType
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
43
import importlib
54
import inspect
65
import os
76
import re
87
import sys
8+
from types import ModuleType
9+
from typing import List, Optional
910

10-
from ..logging import logger
11+
from azure_functions_worker.utils.common import is_true_like
1112
from ..constants import (
1213
AZURE_WEBJOBS_SCRIPT_ROOT,
1314
CONTAINER_NAME,
1415
PYTHON_ISOLATE_WORKER_DEPENDENCIES,
15-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT,
16-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310
16+
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
1717
)
18-
from ..utils.common import is_python_version
18+
from ..logging import logger
1919
from ..utils.wrappers import enable_feature_by
2020

2121

@@ -75,12 +75,7 @@ def is_in_linux_consumption(cls):
7575
@classmethod
7676
@enable_feature_by(
7777
flag=PYTHON_ISOLATE_WORKER_DEPENDENCIES,
78-
flag_default=(
79-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
80-
is_python_version('3.10') else
81-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
82-
)
83-
)
78+
flag_default=PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT)
8479
def use_worker_dependencies(cls):
8580
"""Switch the sys.path and ensure the worker imports are loaded from
8681
Worker's dependenciess.
@@ -106,12 +101,7 @@ def use_worker_dependencies(cls):
106101
@classmethod
107102
@enable_feature_by(
108103
flag=PYTHON_ISOLATE_WORKER_DEPENDENCIES,
109-
flag_default=(
110-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
111-
is_python_version('3.10') else
112-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
113-
)
114-
)
104+
flag_default=PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT)
115105
def prioritize_customer_dependencies(cls, cx_working_dir=None):
116106
"""Switch the sys.path and ensure the customer's code import are loaded
117107
from CX's deppendencies.
@@ -180,11 +170,7 @@ def reload_customer_libraries(cls, cx_working_dir: str):
180170
"""
181171
use_new_env = os.getenv(PYTHON_ISOLATE_WORKER_DEPENDENCIES)
182172
if use_new_env is None:
183-
use_new = (
184-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
185-
is_python_version('3.10') else
186-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
187-
)
173+
use_new = PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
188174
else:
189175
use_new = is_true_like(use_new_env)
190176

0 commit comments

Comments
 (0)