def build_quick_xpcom(method, interface, traverser, wrapper=False):
    """A shortcut to quickly build XPCOM objects on the fly."""
    extra = ()
    if isinstance(interface, (list, tuple)):
        interface, extra = interface[0], interface[1:]

    def interface_obj(iface):
        return traverser._build_global(
            name=method,
            entity={
                'xpcom_map':
                lambda: INTERFACES.get(iface, INTERFACES['nsISupports'])
            })

    constructor = xpcom_const(method, pretraversed=True)
    obj = constructor(None, [interface_obj(interface)], traverser)

    for iface in extra:
        # `xpcom_constructor` really needs to be cleaned up so we can avoid
        # this duplication.
        iface = interface_obj(iface)
        iface = traverser._build_global('QueryInterface',
                                        iface.value['xpcom_map']())

        obj.value = obj.value.copy()

        value = obj.value['value'].copy()
        value.update(iface.value['value'])

        obj.value.update(iface.value)
        obj.value['value'] = value

    if isinstance(obj, JSWrapper) and not wrapper:
        obj = obj.value
    return obj
def build_quick_xpcom(method, interface, traverser, wrapper=False):
    """A shortcut to quickly build XPCOM objects on the fly."""
    extra = ()
    if isinstance(interface, (list, tuple)):
        interface, extra = interface[0], interface[1:]

    def interface_obj(iface):
        return traverser._build_global(
            name=method,
            entity={'xpcom_map':
                lambda: INTERFACES.get(iface, INTERFACES['nsISupports'])})

    constructor = xpcom_const(method, pretraversed=True)
    obj = constructor(None, [interface_obj(interface)], traverser)

    for iface in extra:
        # `xpcom_constructor` really needs to be cleaned up so we can avoid
        # this duplication.
        iface = interface_obj(iface)
        iface = traverser._build_global('QueryInterface',
                                        iface.value['xpcom_map']())

        obj.value = obj.value.copy()

        value = obj.value['value'].copy()
        value.update(iface.value['value'])

        obj.value.update(iface.value)
        obj.value['value'] = value

    if isinstance(obj, JSWrapper) and not wrapper:
        obj = obj.value
    return obj
Пример #3
0
def build_quick_xpcom(method, interface, traverser):
    """A shortcut to quickly build XPCOM objects on the fly."""
    constructor = xpcom_const(method, pretraversed=True)
    interface_obj = traverser._build_global(name=method, entity={"xpcom_map": lambda: INTERFACES[interface]})
    obj = constructor(None, [interface_obj], traverser)
    if isinstance(obj, JSWrapper):
        obj = obj.value
    return obj
Пример #4
0
def build_quick_xpcom(method, interface, traverser, wrapper=False):
    """A shortcut to quickly build XPCOM objects on the fly."""
    constructor = xpcom_const(method, pretraversed=True)
    interface_obj = traverser._build_global(
        name=method, entity={"xpcom_map": lambda: INTERFACES[interface]})
    obj = constructor(None, [interface_obj], traverser)
    if isinstance(obj, JSWrapper) and not wrapper:
        obj = obj.value
    return obj
Пример #5
0
         u"sin": {"return": python_wrap(math.sin, [("num", 0)])},
         u"sqrt": {"return": python_wrap(math.sqrt, [("num", 1)])},
         u"tan": {"return": python_wrap(math.tan, [("num", 0)])},
     }
 },
 u"netscape": {
     "value": {u"security": {"value": {u"PrivilegeManager": {"value": {u"enablePrivilege": {"dangerous": True}}}}}}
 },
 u"navigator": {"value": {u"wifi": {"dangerous": True}, u"geolocation": {"dangerous": True}}},
 u"Components": {
     "dangerous_on_read": lambda t, e: bool(e.metadata.get("is_jetpack")),
     "value": {
         u"classes": {
             "xpcom_wildcard": True,
             "value": {
                 u"createInstance": {"return": xpcom_const("createInstance")},
                 u"getService": {"return": xpcom_const("getService")},
             },
         },
         "utils": {
             "value": {
                 u"evalInSandbox": {"dangerous": True},
                 u"import": {"dangerous": lambda a, t, e: a and "ctypes.jsm" in _get_as_str(t(a[0]))},
             }
         },
         u"interfaces": {"value": INTERFACE_ENTITIES},
     },
 },
 u"extensions": {"dangerous": True},
 u"xpcnativewrappers": {"dangerous": True},
 u"AddonManagerPrivate": {"value": {u"registerProvider": {"return": call_definitions.amp_rp_bug660359}}},
         u'wifi': {
             'dangerous': True
         },
         u'geolocation': {
             'dangerous': True
         }
     }
 },
 u'Components': {
     'dangerous_on_read': lambda t, e: bool(e.metadata.get('is_jetpack')),
     'value': {
         u'classes': {
             'xpcom_wildcard': True,
             'value': {
                 u'createInstance': {
                     'return': xpcom_const('createInstance')
                 },
                 u'getService': {
                     'return': xpcom_const('getService')
                 }
             }
         },
         'utils': {
             'value': {
                 u'evalInSandbox': {
                     'dangerous': {
                         'editors_only': 'true',
                         'signing_help': DANGEROUS_EVAL['signing_help'],
                         'signing_severity': 'low'
                     }
                 },
                                            'unnecessary. It should not be '
                                            'used under any circumstances.'),
                                      }}}}}}}},
    u'navigator':
        {'value': {u'wifi': {'dangerous': True},
                   u'geolocation': {'dangerous': True}}},

    u'Components':
        {'dangerous_on_read':
             lambda t, e: bool(e.metadata.get('is_jetpack')),
         'value':
             {u'classes':
                  {'xpcom_wildcard': True,
                   'value':
                       {u'createInstance':
                           {'return': xpcom_const('createInstance')},
                        u'getService':
                           {'return': xpcom_const('getService')}}},
              'utils':
                  {'value': {u'evalInSandbox':
                                 {'dangerous': {
                                     'editors_only': 'true',
                                     'signing_help':
                                     DANGEROUS_EVAL['signing_help'],
                                     'signing_severity': 'low'}},
                             u'cloneInto':
                                 {'dangerous': {
                                     'editors_only': True,
                                     'signing_help': FUNCTION_EXPORT_HELP,
                                     'signing_severity': 'low',
                                     'description': (
Пример #8
0
         u"wifi": {
             "dangerous": True
         },
         u"geolocation": {
             "dangerous": True
         }
     }
 },
 u"Components": {
     "dangerous_on_read": lambda t, e: bool(e.metadata.get("is_jetpack")),
     "value": {
         u"classes": {
             "xpcom_wildcard": True,
             "value": {
                 u"createInstance": {
                     "return": xpcom_const("createInstance")
                 },
                 u"getService": {
                     "return": xpcom_const("getService")
                 }
             }
         },
         "utils": {
             "value": {
                 u"evalInSandbox": {
                     "dangerous": True
                 },
                 u"import": {
                     "dangerous":
                     lambda a, t, e: a and "ctypes.jsm" in _get_as_str(
                         t(a[0]))