class BanList(Collection): """A list of banned ids and their reason""" _fields = {'id': Field([NotNull()]), 'ban_reason': Field([NotNull()])} _validation = { 'on_save': True, } _properties = { 'keyOptions': { 'allowUserKeys': True, } } def add_user(self, _id: int, reason: str) -> Optional[Document]: """Add a Chat to the DB or return an existing one. Args: _id: The id of the User reason: The ban reason Returns: The chat Document """ data = {'_key': _id, 'id': _id, 'reason': reason} try: doc = self.createDocument(data) doc.save() return doc except CreationError: return None
class questions(Collection): _fields = { "question": Field(), "answer": Field(), "wrong_answers": Field() }
class Classes(Collection): _fields = { "course": Field(), "name": Field(), "credits": Field(), "code": Field(), "semester": Field() }
class Leis(COL.Collection): _validation = { 'on_save': True, 'on_set': True, 'allow_foreign_fields': True } _fields = { 'texto': Field(validators=[VAL.NotNull()]), 'identificador': Field() }
class NetworkConnection(Edges): _fields = { "_name": Field(), "UtcTime": Field(), "EventRecordID": Field(), "User": Field(), "DestinationPort": Field(), "DestinationIp": Field(), "SourceIp": Field(), "SourcePort": Field(), "Protocol": Field(), "Computer": Field() # For shardening }
class Chats(Collection): """A Collection containing Telegram Chats""" _fields = { 'id': Field([NotNull(), Int()]), 'tags': Field([NotNull()]), 'named_tags': Field([NotNull()]) } _validation = {'on_save': True, 'allow_foreign_fields': True} _properties = {"keyOptions": {"allowUserKeys": True}} def add_chat(self, chat_id: int) -> Optional[Document]: """Add a Chat to the DB or return an existing one. Args: chat_id: The id of the chat Returns: The chat Document """ data = { '_key': str(chat_id), 'id': chat_id, 'tags': [], 'named_tags': {} } try: doc = self.createDocument(data) doc.save() return doc except CreationError: return None def get_chat(self, chat_id: int) -> Document: """Return a Chat document Args: chat_id: The id of the chat Returns: The chat Document """ try: return self[chat_id] except DocumentNotFoundError: return self.add_chat(chat_id)
class CreateNewProcess(Edges): _fields = { "_name": Field(), "UtcTime": Field(), "EventRecordID": Field(), "CurrentDirectory": Field(), "User": Field(), "CommandLine": Field(), "Hashes": Field(), "Computer": Field() # For shardening }
class SysmonProcess(Collection): _fields = { "_name": Field(), "Image": Field(), "ProcessId": Field(), "ProcessGuid": Field(), "User": Field(), "ProcessName": Field(), "LogonGuid": Field(), "Computer": Field() # For shardening }
class ProcessAccessed(Edges): _fields = { "_name": Field(), "UtcTime": Field(), "EventRecordID": Field(), "User": Field(), "CallTrace": Field(), "TargetImage": Field(), "Computer": Field() # For shardening }
class RegistryEvent(Edges): _fields = { "_name": Field(), "UtcTime": Field(), "EventRecordID": Field(), "User": Field(), "EventType": Field(), "Computer": Field() # For shardening }
class AutobahnBlacklist(Collection): """Base class for all types of Blacklists.""" _fields = { 'string': Field([NotNull()]), } _validation = { 'on_save': True, } _properties = { 'keyOptions': { 'allowUserKeys': False, 'type': 'autoincrement', 'offset': '1' } } def add_string(self, string: str) -> Optional[Document]: """Add a Chat to the DB or return an existing one. Args: string: The id of the chat Returns: The chat Document """ data = {'string': string} try: doc = self.createDocument(data) doc.save() return doc except CreationError: return None def get_all(self) -> Dict[str, str]: """Get all strings in the Blacklist.""" return {doc['string']: doc['_key'] for doc in self.fetchAll()}
class RegistryObject(Collection): _fields = { "_name": Field(), "Path": Field(), "Computer": Field() # For shardening }
class Users(Collection): _fields = {'uname': Field(), 'status': Field(), 'likes': Field()}
class Members(Edges): _fields = { 'joinDate': Field(validators=[VAL.NotNull(), validation.String_val()]), 'position': Field(validators=[VAL.NotNull()]) }
class NetworkObject(Collection): _fields = { "_name": Field(), "Ip": Field(), "Computer": Field() # For shardening }
class Match(Edges): _fields = {'strength': Field()}
class Response(Collection): _fields = {'code': Field()}
class Users(Collection): _fields = {"username": Field()}
class Friends(Edges): _fields = { 'friend': Field(validators=[VAL.NotNull(), validation.Boolean_val()]) }
class contains(Edges): _fields = { "correct_answer_count":Field(), "wrong_answer_count":Field() }
class HasSeen(Edges): _fields = {"date": Field()}
class Question(Collection): _fields = {'code': Field()}
class Seasons(Collection): _fields = { "number": Field(), "description": Field(), }
class Series(Collection): _fields = {"title": Field(), "genre": Field()}
class Relacao(Edges): _fields = {"tipo": Field()}
class Requirements(Edges): _fields = {"label": Field()}
class Episodes(Collection): _fields = { "number": Field(), "description": Field(), }
class Users(Collection): _fields = {'uname': Field()}
class revisions(Collection): _fields = { "date": Field() }
class Follows(Edges): _fields = {"start_date": Field()}