コード例 #1
0
ファイル: __init__.py プロジェクト: xaelek/RootTheBox
def cache_actions():
    ''' Loads all of the actions from the database into memory for the scoreboard pages'''
    action_list = dbsession.query(models.Action).all()
    ws_manager = WebSocketManager.Instance()
    for action in action_list:
        team = dbsession.query(models.User).filter_by(id=action.user_id).first()
        score_update = ScoreUpdate(action.created.strftime("%d%H%M%S"), action.value, team.team_name)
        ws_manager.currentUpdates.append(score_update)
コード例 #2
0
ファイル: Box.py プロジェクト: brutalhonesty/RootTheBox
 def by_ip_address(cls, ip_addr):
     '''
     Returns a box object based on an ip address, supports both ipv4
     and ipv6
     '''
     db_ip = dbsession.query(IpAddress).filter(
         or_(IpAddress.v4 == ip_addr, IpAddress.v6 == ip_addr)
     ).first()
     if db_ip is not None:
         return dbsession.query(cls).filter_by(id=db_ip.box_id).first()
     else:
         return None
コード例 #3
0
ファイル: User.py プロジェクト: xaelek/RootTheBox
 def team_name(self):
     """ Return a list with all groups names the user is a member of """
     if self.team_id == None:
         return None
     else:
         team = dbsession.query(Team).filter_by(id=self.team_id).first() #@UndefinedVariable
         return team.team_name
コード例 #4
0
ファイル: Category.py プロジェクト: moloch--/RootTheBox
 def list(cls):
     ''' Returns a list of all categories in the database '''
     categories = dbsession.query(cls).all()
     catlist = []
     for cat in categories:
         catlist.append(cat.category)
     return json.dumps(catlist)
コード例 #5
0
 def delivered(cls, user_id, uuid):
     notify = dbsession.query(cls).filter(
         and_(cls.event_uuid == uuid, cls.user_id == user_id)
     ).first()
     notify.viewed = True
     dbsession.add(notify)
     dbsession.flush()
コード例 #6
0
 def by_datetime(cls, input_datetime):
     ''' Returns all events for the day depicted by input_datetime '''
     day = input_datetime.date()
     next_day = day + datetime.timedelta(days=1)
     return dbsession.query(cls).filter(
         and_(cls.start_time >= day, cls.start_time < next_day)
     ).all()
コード例 #7
0
ファイル: Box.py プロジェクト: AdaFormacion/RootTheBox
 def by_ip_address(cls, ip_addr):
     '''
     Returns a box object based on an ip address, supports both ipv4
     and ipv6
     '''
     ip = dbsession.query(IpAddress).by_address(ip_addr).first()
     return ip.box if ip is not None else None
コード例 #8
0
 def delivered(cls, user_id, uuid):
     notify = dbsession.query(cls).filter(
         and_(cls.event_uuid == uuid, cls.user_id == user_id)
     ).first()
     if notify is not None:
         notify.viewed = True
         dbsession.add(notify)
         dbsession.commit()
コード例 #9
0
ファイル: User.py プロジェクト: xaelek/RootTheBox
 def score(self):
     ''' Returns user's current score from cache, or re-calculates if expired '''
     if self.dirty:
         actions = dbsession.query(Action).filter_by(user_id=self.id).all() #@UndefinedVariable
         self.score_cache = sum(actions)
         self.dirty = False
         dbsession.add(self)
         dbsession.flush()
     return self.score_cache
コード例 #10
0
ファイル: Monster.py プロジェクト: hathcox/Arthur
 def get_monster(cls, user):
     ''' Based on the users quest and level this will choose an appropriate monster '''
     quest = Quest.by_id(user.quest_level)
     #If we are still on quests
     if quest != None:
         #Get all valid monsters
         all = dbsession.query(cls).filter(cls.level<=quest.max_monster_level).filter(cls.level>=quest.min_monster_level).all()
         return choice(all)
     return choice(cls.get_all())
コード例 #11
0
ファイル: controller.py プロジェクト: shinriyo/teaspoon3
def get_current_user(self):
    """
    Return the request's user object.
    can be called using BaseHandler self.get_current_user() or
    by get_current_user(request_handler_instance)    
    """
    # loads the cookie and query the database to compare passwords.
    # if password was changed/deleted (in the server side) then treats as unauthed
    auth = loads(self.get_secure_cookie('auth') or '""')
    if auth:
        user = dbsession.query(User).get(auth['id'])
        if user and user.password[0:8] == auth['password']: return user
コード例 #12
0
 def by_uuid(cls, _uuid):
     ''' Return and object based on a _uuid '''
     return dbsession.query(cls).filter_by(uuid=_uuid).first()
コード例 #13
0
 def by_ip_address(cls, weapon_ip_address):
     ''' Return the WeaponSystem object whose ip_address is 'weapon_ip_address' '''
     return dbsession.query(cls).filter_by(
         ip_address=unicode(weapon_ip_address)).first()
コード例 #14
0
 def by_event_uuid(cls, uuid):
     ''' Always returns anonymous notification '''
     return dbsession.query(cls).filter_by(event_uuid=uuid).filter_by(
         user_id=None).first()
コード例 #15
0
ファイル: SnapshotTeam.py プロジェクト: lavalamp-/RootTheBox
 def name(self):
     return dbsession.query(
         Team._name).filter_by(id=self.team_id).first()[0]
コード例 #16
0
 def by_hexdigest(cls, hexvalue, jid):
     ''' Return the digest based on valud and job_id '''
     return dbsession.query(cls).filter(
         and_(cls.hexdigest == hexvalue, cls.job_id == jid)
     ).first()
コード例 #17
0
 def by_team_id(cls, team_id):
     ''' Return all paste objects for a given team '''
     return dbsession.query(cls).filter_by(team_id=team_id).order_by(desc(cls.created)).all()
コード例 #18
0
 def by_uuid(cls, _uuid):
     """ Return and object based on a uuid """
     return dbsession.query(cls).filter_by(uuid=str(_uuid)).first()
コード例 #19
0
 def by_name(cls, name):
     """ Return the box object whose name is "name" """
     return dbsession.query(cls).filter_by(_name=str(name)).first()
コード例 #20
0
ファイル: Team.py プロジェクト: lavalamp-/RootTheBox
 def ranks(cls):
     ''' Returns a list of all objects in the database '''
     return sorted(dbsession.query(cls).all())
コード例 #21
0
ファイル: Team.py プロジェクト: lavalamp-/RootTheBox
 def by_uuid(cls, uuid):
     ''' Return and object based on a uuid '''
     return dbsession.query(cls).filter_by(uuid=unicode(uuid)).first()
コード例 #22
0
ファイル: Team.py プロジェクト: lavalamp-/RootTheBox
 def by_name(cls, team_name):
     ''' Return the team object based on "team_name" '''
     return dbsession.query(cls).filter_by(name=unicode(team_name)).first()
コード例 #23
0
 def last_level(cls, number):
     ''' Returns the prior level '''
     return dbsession.query(cls).filter_by(
         next_level_id=int(number)).first()
コード例 #24
0
 def by_number(cls, number):
     ''' Returns a the object with number of number '''
     return dbsession.query(cls).filter_by(_number=abs(int(number))).first()
コード例 #25
0
ファイル: Team.py プロジェクト: bb111189/RootTheBox
 def by_id(cls, _id):
     ''' Returns a the object with id of _id '''
     return dbsession.query(cls).filter_by(id=_id).first()
コード例 #26
0
 def by_category(cls, _cat_id):
     """ Return the box object whose category is "_cat_id" """
     return dbsession.query(cls).filter_by(category_id=int(_cat_id)).all()
コード例 #27
0
ファイル: Team.py プロジェクト: bb111189/RootTheBox
 def by_name(cls, name):
     ''' Return the team object based on "team_name" '''
     return dbsession.query(cls).filter_by(_name=unicode(name)).first()
コード例 #28
0
 def all(cls):
     ''' Returns a list of all objects in the database '''
     return dbsession.query(cls).order_by(asc(cls._number)).all()
コード例 #29
0
ファイル: Snapshot.py プロジェクト: brutalhonesty/RootTheBox
 def all(cls):
     ''' Returns a list of all objects in the database '''
     return dbsession.query(cls).all()
コード例 #30
0
ファイル: User.py プロジェクト: Darkpaw95/Yoshimi-Botnet
 def get_all(cls):
     """ Return all non-admin user objects """
     return dbsession.query(cls).filter(cls.user_name != 'admin').all() 
コード例 #31
0
 def new_messages(cls, user_id):
     ''' Return all notification which have not been viewed '''
     return dbsession.query(cls).filter(
         and_(cls.user_id == user_id, cls.viewed == False)).all()
コード例 #32
0
 def by_id(cls, user_id):
     """ Return the user object whose user id is user_id """
     return dbsession.query(cls).filter_by(id=user_id).first()
コード例 #33
0
 def delivered(cls, user_id, uuid):
     notify = dbsession.query(cls).filter(
         and_(cls.event_uuid == uuid, cls.user_id == user_id)).first()
     notify.viewed = True
     dbsession.add(notify)
     dbsession.commit()
コード例 #34
0
 def get_unapproved(cls):
     """ Return all unapproved user objects """
     return dbsession.query(cls).filter_by(approved=False).all()
コード例 #35
0
 def by_uuid(cls, paste_uuid):
     ''' Get a paste object by uuid '''
     return dbsession.query(cls).filter_by(uuid=paste_uuid).first()
コード例 #36
0
 def all(cls):
     """ Return all non-admin user objects """
     return dbsession.query(cls).all()
コード例 #37
0
 def by_name(cls, weapon_name):
     ''' Return the WeaponSystem object whose name is 'weapon_name' '''
     return dbsession.query(cls).filter_by(
         name=unicode(weapon_name)).first()
コード例 #38
0
ファイル: Team.py プロジェクト: bb111189/RootTheBox
 def ranks(cls):
     ''' Returns a list of all objects in the database '''
     return sorted(dbsession.query(cls).all())
コード例 #39
0
 def by_garbage(cls, _garbage):
     return dbsession.query(cls).filter_by(garbage=_garbage).first()
コード例 #40
0
 def count(cls):
     return dbsession.query(cls).count()
コード例 #41
0
 def name(self):
     return dbsession.query(Team._name).filter_by(
         id=self.team_id
     ).first()[0]
コード例 #42
0
 def all(cls):
     """ Returns a list of all objects in the database """
     return dbsession.query(cls).all()
コード例 #43
0
 def permissions(self):
     """ Return a list with all permissions granted to the user """
     return dbsession.query(Permission).filter_by(user_id=self.id)
コード例 #44
0
 def by_uuid(cls, _uuid):
     """ Get a paste object by uuid """
     return dbsession.query(cls).filter_by(uuid=_uuid).first()
コード例 #45
0
 def by_uuid(cls, user_uuid):
     """ Return the user object whose user uuid is user_uuid """
     return dbsession.query(cls).filter_by(uuid=unicode(user_uuid)).first()
コード例 #46
0
ファイル: BotManager.py プロジェクト: gregtampa/RootTheBox
 def team(self):
     ''' Pull box object from persistant db '''
     return dbsession.query(Box).by_uuid(self.box_uuid)
コード例 #47
0
 def get_approved(cls):
     """ Return all approved user objects """
     return dbsession.query(cls).filter_by(approved=True).all()
コード例 #48
0
ファイル: SourceCode.py プロジェクト: lavalamp-/RootTheBox
 def by_uuid(cls, uuid):
     ''' Returns a the object with a given uuid '''
     return dbsession.query(cls).filter_by(uuid=unicode(uuid)).first()
コード例 #49
0
 def by_username(cls, user_name):
     """ Return the user object whose user name is 'user_name' """
     return dbsession.query(cls).filter_by(username=unicode(user_name)).first()
コード例 #50
0
ファイル: SourceCode.py プロジェクト: lavalamp-/RootTheBox
 def by_box_id(cls, bid):
     return dbsession.query(cls).filter_by(box_id=bid).first()
コード例 #51
0
ファイル: Team.py プロジェクト: bb111189/RootTheBox
 def count(cls):
     return dbsession.query(cls).count()
コード例 #52
0
 def all(cls):
     ''' Returns a list of all objects in the database '''
     return dbsession.query(cls).all()
コード例 #53
0
ファイル: Team.py プロジェクト: bb111189/RootTheBox
 def by_uuid(cls, _uuid):
     ''' Return and object based on a uuid '''
     return dbsession.query(cls).filter_by(uuid=_uuid).first()
コード例 #54
0
 def by_id(cls, ident):
     ''' Returns a the object with id of ident '''
     return dbsession.query(cls).filter_by(id=ident).first()
コード例 #55
0
 def by_id(cls, hash_id):
     ''' Return the PasswordHash object whose user id is 'hash_id' '''
     return dbsession.query(cls).filter_by(id=hash_id).first()
コード例 #56
0
 def all(cls):
     ''' Returns a list of all objects in the database '''
     return dbsession.query(cls).filter_by(user_id=None).all()
コード例 #57
0
 def by_algorithm(cls, algo):
     ''' Return all passwords objects of a given algorithm id '''
     if isinstance(algo, int):
         return dbsession.query(cls).filter_by(algorithm_id=algo).all()
     else:
         return dbsession.query(cls).filter_by(algorithm_id=algo.id).all()
コード例 #58
0
 def by_id(cls, _id):
     ''' Returns a the object with id of _id '''
     return dbsession.query(cls).filter_by(id=_id).first()
コード例 #59
0
ファイル: Snapshot.py プロジェクト: brutalhonesty/RootTheBox
 def by_id(cls, identifier):
     ''' Returns a the object with id of identifier '''
     return dbsession.query(cls).filter_by(id=identifier).first()
コード例 #60
0
 def by_user_id(cls, _id):
     ''' Return notifications for a single user '''
     return dbsession.query(cls).filter_by(user_id=_id).order_by(
         desc(cls.created)).all()