class Account(db.Document): """ 用户账号:操作时间、操作ip、具体操作、是否本人操作、操作日期 """ meta = {'collection': 'account'} _id = db.StringField(default=shortuuid.uuid) operator = db.StringField(required=False) ip = db.StringField(required=False) today = db.DateTimeField(required=False) operate_time = db.DateTimeField(required=False) operate_detail = db.StringField(required=False)
class Log(db.Document): ''' 用户日志: 登录时间,登出时间,登录ip,登录日期 todo: 记录审核日志 ''' meta = {'collection': 'user_log'} _id = db.StringField(default=shortuuid.uuid) handler = db.StringField(required=True) ip = db.StringField(required=True) login_time = db.DateTimeField(required=False) logout_time = db.DateTimeField(required=False) today = db.DateTimeField(requried=False)
class Operate_Log(db.Document): meta = {'collection': 'operate_log'} realname = db.StringField() operate_time = db.DateTimeField(default=datetime.now) ip = db.StringField() path = db.StringField() operation = db.StringField()
class User(db.Document): query_class = UserQuery AUTH, ADMIN = 100, 200 name = db.StringField() email = db.StringField() password = db.StringField() photo = db.StringField(default='') following_count = db.IntField(default=0) follower_count = db.IntField(default=0) post_count = db.IntField(default=0) active = db.BoolField(default=True) role = db.EnumField(db.IntField(), AUTH, ADMIN, default=AUTH) @db.computed_field(db.DateTimeField()) def updated(self): return now @property def created_time(self): if self.has_id(): return self.mongo_id.generation_time def check_password(self, password): if self.password is None: return False return self.password == hash_str(password) class Permissions(object): def __init__(self, obj): self.obj = obj @cached_property def edit(self): return Permission(UserNeed(self.obj.pk)) & admin @cached_property def delete(self): return Permission(UserNeed(self.obj.pk)) & admin @cached_property def pk(self): return str(self.mongo_id) @cached_property def permissions(self): return self.Permissions(self) @cached_property def provides(self): needs = [RoleNeed('auth'), UserNeed(self.pk)] if self.is_admin: needs.append(RoleNeed('admin')) return needs @property def is_admin(self): return self.role >= self.ADMIN
class Rule(db.Document): ''' 规则数据库:包含规则、类型、等级、描述、建议、添加时间、命中次数 ''' meta = {'collection': 'rules'} # _id =db.StringField(primary_key=True) # id = db.StringField(required=False,primary_key=False) rule = db.StringField(required=False) type = db.StringField(required=False) leave = db.StringField(required=False) des = db.StringField(required=False) suggestion = db.StringField(required=False) create_time = db.DateTimeField(required=False, default=datetime.now) hit_count = db.IntField(default=0)
class All_Result(db.Document): ''' 一次域名扫描后的结果:扫描时间、响应code、域名、任务id、事件列表 ''' meta = {'collection': 'all_result'} time = db.DateTimeField(default=datetime.now) code = db.IntField() domain = db.StringField() jobid = db.StringField() keyword_data = db.ListField() jump_url = db.ListField() events_list = db.ListField() websousec = db.StringField() img = db.StringField() message = db.StringField()
class Event_Spider(db.Document): ''' 爬虫匹配到的事件数据库:自增长ID、自定义ID、域名、任务ID、命中的规则、来源、首次发现时间、最新发现事件、 审核详情、审核状态、快照 ''' meta = {'collection': 'sec_event'} _id = db.IntField(required=False, primary_key=True) id = db.StringField(required=False) domain = db.StringField(required=False) jobid = db.StringField(required=False) event = db.ReferenceField(Rule) _from = db.StringField(required=False) first_time = db.DateTimeField(default=datetime.now) last_time = db.ListField(required=False) audit = db.ListField(required=False) status = db.StringField(required=False) img = db.StringField(required=False)
class User(db.Document): ''' 用户登录:用户名、密码、邮箱、真实姓名、加入时间、头像地址 ''' meta = {'collection': 'user'} _id = db.StringField(default=shortuuid.uuid) username = db.StringField(required=True, max_length=50) password = db.StringField(required=True, max_length=200) email = db.EmailField(required=True, max_length=100) realname = db.StringField(required=True, max_length=10) join_time = db.DateTimeField(required=False, default=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) avatar_path = db.StringField(required=False) def avatar(self): print(sep + 'static' + sep + 'eog' + sep + 'img' + sep + 'default' + sep + random.choice( os.listdir('./static/eog/img/default/'))) return sep + 'static' + sep + 'eog' + sep + 'img' + sep + 'default' + sep + random.choice( os.listdir('./static/eog/img/default/'))
class Event_Search_Engine(db.Document): ''' 搜索引擎事件数据库:自增长ID、自定义ID、域名、任务ID、命中的规则、来源、首次发现时间、最新发现事件、 审核详情、审核状态、快照 ''' meta = {'collection': 'sec_event_test'} _id = db.IntField(required=False, default='num') id = db.StringField(required=False) domain = db.StringField(required=False) jobid = db.StringField(required=False) event = db.StringField(required=False) keyword = db.StringField(required=False) _from = db.StringField(required=False) first_time = db.DateTimeField(default=datetime.now) last_time = db.ListField(required=False) audit = db.ListField(required=False) status = db.StringField(required=False) suggestion = db.StringField(required=False) img = db.StringField(required=False)