def all_packs(): # cursor = pack_files_coll.find({}, {'_id': 0}) cursor = pack_files_coll.find({}, { '_id': 0 }).sort([("_id", pymongo.DESCENDING)]) return CursorResult.many(cursor)
def find(file_id, func_addr): cursor = func_cache_coll.find( { 'file_id': file_id, 'func_addr': func_addr }, {'_id': 0}) return CursorResult.one(cursor)
def fetch_record(file_id, key_name): cursor = file_cache_coll.find({'file_id': file_id}, {'_id': 0}) doc = CursorResult.one(cursor) if doc is not None and doc.get(key_name) is not None: return doc.get(key_name) else: return None
def search_info_of_component_name(name): cursor = cnvd_share_coll.find( {'products.product': { '$regex': name, '$options': 'i' }}) # 操作符"i"表示“不区分大小写” 模糊查询 return CursorResult.many(cursor)
def search_all_com_files(): # cursor = fw_files_coll.find({'component': 1}, {'_id': 0}) # return CursorResult.many(cursor) cursor = fw_files_coll.aggregate([ {"$lookup": {"from": "pack_files", "localField": "pack_id", "foreignField": "pack_id", "as": "pack_docs"}}, {"$match": {"component": 1}}, # {"$unwind": "$pack_docs"}, ]) return CursorResult.many(cursor)
def search_files_of_pack(pack_id, file_type, arch, file_name): if file_name is None: cursor = make_com_files_coll.find( { 'pack_id': pack_id, 'file_type': file_type, 'arch': arch }, {'_id': 0}) else: cursor = make_com_files_coll.find( { 'pack_id': pack_id, 'file_type': file_type, 'arch': arch, 'file_name': file_name }, {'_id': 0}) return CursorResult.many(cursor)
def find(file_id): cursor = fw_files_coll.find({'file_id': file_id}, {'_id': 0}) return CursorResult.one(cursor)
def find(file_id): cursor = cfg_result_col.find({'file_id': file_id}, {'_id': 0}) return CursorResult.one(cursor)
def all_component(): cursor = tasks_coll.find({'task_type': TaskType.COMPONENT_CHECK}, {'_id': 0}) return CursorResult.many(cursor)
def list(): cursor = func_taint_col.find({}, {'_id': 0}) return CursorResult.many(cursor)
def all_packs(): cursor = pack_com_files_coll.find({}, {'_id': 0}) return CursorResult.many(cursor)
def get_files_of_pack(pack_id): cursor = fw_files_coll.find({'pack_id': pack_id}, {'_id': 0}) return CursorResult.many(cursor)
def search_files_of_pack(pack_id): cursor = source_code_files_coll.find({ 'pack_id': pack_id, }, {'_id': 0}) return CursorResult.many(cursor)
def fetch_name(name): cursor = pack_com_files_coll.find({'name': name}, {'_id': 0}) return CursorResult.one(cursor)
def search_component_name(file_name): cursor = make_com_files_coll.find({'file_name': file_name}) return CursorResult.one(cursor)
def fetch_file(file_id): cursor = make_com_files_coll.find({'file_id': file_id}, {'_id': 0}) return CursorResult.one(cursor)
def search_func_name(func_name): cursor = func_taint_col.find({'func_name': func_name}, {'_id': 0}) return CursorResult.one(cursor)
def find(fun_id): cursor = func_taint_col.find({'fun_id': fun_id}, {'_id': 0}) return CursorResult.one(cursor)
def search_files_of_pack(pack_id, file_type=None): if file_type is None: cursor = fw_files_coll.find({'pack_id': pack_id}, {'_id': 0}) else: cursor = fw_files_coll.find({'pack_id': pack_id, 'file_type': file_type}, {'_id': 0}) return CursorResult.many(cursor)
def find(task_id): cursor = tasks_coll.find({'task_id': task_id}, {'_id': 0}) return CursorResult.one(cursor)
def find(file_id): cursor = cnvd_share_coll.find({'file_id': file_id}, {'_id': 0}) return CursorResult.one(cursor)
def all_tasks(): cursor = tasks_coll.find({}, {'_id': 0}) return CursorResult.many(cursor)
def fetch_pack(pack_id): cursor = pack_com_files_coll.find({'pack_id': pack_id}, {'_id': 0}) return CursorResult.one(cursor)
def search_by_pack(pack_id): cursor = tasks_coll.find({'pack_id': pack_id}, {'_id': 0}) return CursorResult.many(cursor)
def all_packs_type(pack_type): cursor = pack_com_files_coll.find({'pack_type': pack_type}, {'_id': 0}) return CursorResult.many(cursor)
def search_by_file(file_id): cursor = tasks_coll.find({'file_id': file_id}, {'_id': 0}) return CursorResult.many(cursor)