This file is indexed.

/usr/share/pyshared/lazr/restful/debug.py is in python-lazr.restful 0.19.3-0ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright 2008 Canonical Ltd.  All rights reserved.

"""Module docstring goes here."""

__metaclass__ = type
__all__ = [
    "debug_proxy",
    "typename"
    ]


from cStringIO import StringIO
import zope.proxy

from zope.security.checker import getChecker, Checker, CheckerPublic, Proxy


def typename(obj):
    """Return the typename of an object."""
    t = type(obj)
    if t.__module__ == '__builtin__':
        return t.__name__
    else:
        return "%s.%s" % (t.__module__, t.__name__)


def default_proxy_formatter(proxy):
    """Formatter that simply returns the proxy's type name."""
    return typename(proxy)


def get_permission_mapping(checker):
    """Return a list of (permission, list of protected names) for the checker.

    Permission used to check for attribute setting have (set) appended.
    """
    permission_to_names = {}
    for name, permission in checker.get_permissions.items():
        if permission is CheckerPublic:
            permission = 'public'
        permission_to_names.setdefault(permission, []).append(name)
    for name, permission in checker.set_permissions.items():
        if permission is CheckerPublic:
            permission = 'public'
        set_permission = "%s (set)" % permission
        permission_to_names.setdefault(set_permission, []).append(name)
    return sorted((permission, sorted(names))
                   for permission, names in permission_to_names.items())


def security_proxy_formatter(proxy):
    """Return informative text about the checker used by the proxy."""
    checker = getChecker(proxy)
    output = ["%s (using %s)" % (typename(proxy), typename(checker))]
    if type(checker) is Checker:
        for permission, names in get_permission_mapping(checker):
            output.append('%s: %s' % (permission, ", ".join(sorted(names))))
    return "\n    ".join(output)


proxy_formatters = {Proxy: security_proxy_formatter}


def debug_proxy(obj):
    """Return informative text about the proxies wrapping obj.

    Usually used like print debug_proxy(obj).
    """
    if not zope.proxy.isProxy(obj):
        return "%r doesn't have any proxies." % obj
    buf = StringIO()
    for proxy in zope.proxy.ProxyIterator(obj):
        if not zope.proxy.isProxy(proxy):
            break
        printer = proxy_formatters.get(type(proxy), default_proxy_formatter)
        print >>buf, printer(proxy)
    return buf.getvalue()