1.1 --- a/inspector.py Thu Jul 05 23:41:16 2018 +0200
1.2 +++ b/inspector.py Mon Jul 09 17:32:35 2018 +0200
1.3 @@ -21,7 +21,8 @@
1.4 """
1.5
1.6 from branching import BranchTracker
1.7 -from common import CommonModule, get_argnames, init_item, predefined_constants
1.8 +from common import CommonModule, get_argnames, init_item, \
1.9 + predefined_constants, privileged_attributes
1.10 from modules import BasicModule, CacheWritingModule, InspectionNaming
1.11 from errors import InspectError
1.12 from referencing import Reference
1.13 @@ -358,6 +359,16 @@
1.14
1.15 "Process the given attribute access node 'n'."
1.16
1.17 + path = self.get_namespace_path()
1.18 +
1.19 + # Test for access to special privileged attributes.
1.20 +
1.21 + if isinstance(n, compiler.ast.Getattr) and \
1.22 + n.attrname in privileged_attributes and not n.privileged:
1.23 +
1.24 + raise InspectError("Attribute %s is accessed by an unprivileged operation." %
1.25 + n.attrname, path, n)
1.26 +
1.27 # Obtain any completed chain and return the reference to it.
1.28
1.29 name_ref = self.process_attribute_chain(n)
1.30 @@ -372,8 +383,6 @@
1.31 # either being name-based and thus an access rooted on a name, or being
1.32 # based on some other node and thus an anonymous access of some kind.
1.33
1.34 - path = self.get_namespace_path()
1.35 -
1.36 # Start with the the full attribute chain.
1.37
1.38 remaining = self.attrs