def analyse(self, query): context = self.get_context(query) word_id = Indexing.insert_dictionary_word(query['word'], query['type']) pdbh = DB.DBO() sql = DB.expand("select inode.inode_id as `inode_id` "\ "%s where (%s) and (%s)", (context.get('tables',''), context.get('inode_sql','1'), context.get('where','1'))) Indexing.schedule_inode_index_sql(query['case'], sql, word_id, query['cookie'], unique=True) ## Now wait here until everyone is finished: while 1: pdbh.execute("select count(*) as c from jobs where cookie=%r", query['cookie']) row = pdbh.fetch() self.rows_left = row['c'] if row['c'] == 0: break time.sleep(1) return 1
def ensure_carver_signatures_in_dictionary(carver): carver.ids = [] for word in carver.regexs: id = Indexing.insert_dictionary_word(word, word_type='regex', classification='_Carver', binary=True) ## Make sure the carver knows about it carver.ids.append(id)
def display(self, query, result): ## The dictionary is site wide and lives in the FlagDB dbh = DB.DBO() ## class_override the class variable: try: if len(query['class_override']) > 3: del query['class'] query['class'] = query['class_override'] del query['class_override'] except KeyError: pass status = '' ## Do we need to add a new entry: try: if len(query['word']) < 3: raise DB.DBError( "Word is too short to index, minimum of 3 letter words") if query['action'] == 'insert': try: if len(query['class']) < 3: raise DB.DBError( "Class name is too short, minimum of 3 letter words are used as class names" ) except KeyError: status = "Classification missing or too short" raise Indexing.insert_dictionary_word(query['word'], query['type'], query['class']) status = "Added word %s to dictionary" % query['word'] elif query['action'] == 'delete': dbh.delete("dictionary", where=DB.expand("word=%b and type=%r", (query['word'], query['type']))) status = "Deleted word %s from dictionary" % query['word'] except KeyError, e: pass
def display(self,query,result): ## The dictionary is site wide and lives in the FlagDB dbh=DB.DBO() ## class_override the class variable: try: if len(query['class_override'])>3: del query['class'] query['class']=query['class_override'] del query['class_override'] except KeyError: pass status = '' ## Do we need to add a new entry: try: if len(query['word'])<3: raise DB.DBError("Word is too short to index, minimum of 3 letter words") if query['action']=='insert': try: if len(query['class'])<3: raise DB.DBError("Class name is too short, minimum of 3 letter words are used as class names") except KeyError: status = "Classification missing or too short" raise Indexing.insert_dictionary_word(query['word'], query['type'], query['class']) status = "Added word %s to dictionary" % query['word'] elif query['action']=='delete': dbh.delete("dictionary", where=DB.expand("word=%b and type=%r", (query['word'],query['type']))) status = "Deleted word %s from dictionary" % query['word'] except KeyError,e: pass
def analyse(self, query): context = self.get_context(query) word_id = Indexing.insert_dictionary_word(query['word'], query['type']) pdbh = DB.DBO() sql = DB.expand("select inode.inode_id as `inode_id` "\ "%s where (%s) and (%s)", (context.get('tables',''), context.get('inode_sql','1'), context.get('where','1'))) Indexing.schedule_inode_index_sql(query['case'], sql, word_id, query['cookie'], unique=True) ## Now wait here until everyone is finished: while 1: pdbh.execute("select count(*) as c from jobs where cookie=%r", query['cookie']) row = pdbh.fetch() self.rows_left = row['c'] if row['c']==0: break time.sleep(1) return 1