def _disable_unwanted_imports():
    """
    Override the built-in __import__ and open function to block
    potentially dangerous modules and file access.
    """
    original_import = builtins.__import__

    def restricted_import(name, globals=None, locals=None, fromlist=(), level=0):
        if name in EXECUTOR_DISALLOWED_MODULES.get():
            error_msg = IMPORT_DISALLOWED_MESSAGE_TEMPLATE.format(
                module_name=name, import_disallowed_message=IMPORT_DISALLOWED_MESSAGE
            )
            raise ImportError(error_msg)
        return original_import(name, globals, locals, fromlist, level)

    builtins.__import__ = restricted_import

    def disabled_open(*args, **kwargs):
        raise ImportError(OPEN_DISALLOWED_MESSAGE)

    builtins.open = disabled_open

    Override the built-in __import__ and open function to block
    potentially dangerous modules and file access.
    
ai/core/src/unitycatalog/ai/core/executor/local.py