def _find_sites_for_user(email):
    """Find all sites that the user has access to"""
    sitez = set()
    for g in groups.find({"users": email}):
        for s in g['sites']:
            sitez.add(s)
    return list(sitez)
示例#2
0
def _find_sites_for_user(email):
    """Find all sites that the user has access to"""
    sitez = set()
    for g in groups.find({"users":email}):
        for s in g['sites']:
            sitez.add(s)
    return list(sitez)
def _check_plan_by_email(email, plan_name):
    plan = plans.find_one({'name': plan_name})
    if not plan:
        return False
    sitez = sites.find({'plans': plan_name})
    if sitez.count():
        matches = 0
        for site in sitez:
            groupz = groups.find({'users': email, 'sites': site['url']})
            if groupz.count():
                matches += 1
        return matches
示例#4
0
 def has_permission(*args, **kwargs):
     email = request.args.get('email')
     if email:
         user = users.find_one({'email': email})
         if not user:
             return jsonify(success=False, reason='user-does-not-exist')
         scan = scans.find_one({"id": kwargs['scan_id']})
         if user['role'] == 'user':
             groupz = groups.find({'users': email, 'sites': scan['configuration']['target']})
             if not groupz.count():
                 return jsonify(success=False, reason='not-found')
     return view(*args, **kwargs) # if groupz.count is not zero, or user is admin
示例#5
0
def _check_plan_by_email(email, plan_name):
    plan = plans.find_one({'name': plan_name})
    if not plan:
        return False
    sitez = sites.find({'plans': plan_name})
    if sitez.count():
        matches = 0
        for site in sitez:
            groupz = groups.find({'users': email, 'sites': site['url']})
            if groupz.count():
                matches += 1
        return matches
示例#6
0
    def has_permission(*args, **kwargs):
        email = request.args.get("email")

        # If the task is scheduled by crontab, proceed with the task
        if email == "cron":
            return view(*args, **kwargs)

        if email:
            user = users.find_one({"email": email})
            if not user:
                return jsonify(success=False, reason="user-does-not-exist")
            scan = scans.find_one({"id": kwargs["scan_id"]})
            if user["role"] == "user":
                groupz = groups.find({"users": email, "sites": scan["configuration"]["target"]})
                if not groupz.count():
                    return jsonify(success=False, reason="not-found")
        return view(*args, **kwargs)  # if groupz.count is not zero, or user is admin
    def has_permission(*args, **kwargs):
        email = request.args.get('email')

        # If the task is scheduled by crontab, proceed with the task
        if email == 'cron':
            return view(*args, **kwargs)

        if email:
            user = users.find_one({'email': email})
            if not user:
                return jsonify(success=False, reason='user-does-not-exist')
            scan = scans.find_one({"id": kwargs['scan_id']})
            if user['role'] == 'user':
                groupz = groups.find({
                    'users': email,
                    'sites': scan['configuration']['target']
                })
                if not groupz.count():
                    return jsonify(success=False, reason='not-found')
        return view(*args,
                    **kwargs)  # if groupz.count is not zero, or user is admin
示例#8
0
def _find_groups_for_site(site):
    """Find all the groups the site is part of"""
    return [g['name'] for g in groups.find({"sites":site})]
示例#9
0
def list_groups():
    return jsonify(success=True, groups=[sanitize_group(group) for group in groups.find()])
示例#10
0
def _find_groups_for_user(email):
    """Find all the groups the user is in"""
    return [g['name'] for g in groups.find({"users":email})]
def _find_groups_for_site(site):
    """Find all the groups the site is part of"""
    return [g['name'] for g in groups.find({"sites": site})]
def _find_groups_for_user(email):
    """Find all the groups the user is in. """
    return [g['name'] for g in groups.find({"users": email})]
示例#13
0
def list_groups():
    return jsonify(success=True,
                   groups=[sanitize_group(group) for group in groups.find()])