Changeset - ea02c8b2b529
[Not reviewed]
default
0 1 0
Søren Løvborg - 10 years ago 2016-04-19 17:58:21
sorenl@unity3d.com
auth: prevent misuse of PermFunction in bool context

Evaluating a PermFunction as a boolean, rather than calling it, is
almost certainly an error. If not, "pf is not None" can be used.
1 file changed with 7 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/auth.py
Show inline comments
 
@@ -1002,6 +1002,13 @@ class PermsFunction(object):
 
        self.repo_name = None
 
        self.group_name = None
 

	
 
    def __nonzero__(self):
 
        """ Defend against accidentally forgetting to call the object
 
            and instead evaluating it directly in a boolean context,
 
            which could have security implications.
 
        """
 
        raise AssertionError(self.__class__.__name__ + ' is not a bool and must be called!')
 

	
 
    def __call__(self, check_location='', user=None):
 
        if not user:
 
            #TODO: remove this someday,put as user as attribute here
0 comments (0 inline, 0 general)