def poc_search(request): offset = req_get_param_int(request, 'offset') count = req_get_param_int(request, 'count') value = req_get_param(request, 'value') # 查找利用信息 result_cursor = firmware_db.search(value) item_list = list(result_cursor) # 获取信息总数,并判断指定偏移量是否越界 total = len(item_list) if total == 0 or offset >= total: return app_err_p(Error.NO_MORE_DATA, {'total': total, 'count': 0}) # 读取指定位置和数量的利用信息 if count > total - offset: count = total - offset item_list = item_list[offset:offset + count] # 查询poc信息,添加到漏洞信息中 # poc_list = [] for item in item_list: poc = firmware_pocs.fetch_no_content(item['firmware_id']) item['poc'] = poc # poc_list.append(poc) #SysLog.success('搜索POC', '成功搜索POC文件,总数={}'.format(len(item_list))) return sys_app_ok_p({ 'total': total, 'count': len(item_list), 'items': item_list })
def search(request): offset = req_get_param_int(request, 'offset') count = req_get_param_int(request, 'count') value = req_get_param(request, 'value') # 查找利用信息 result_cursor = firmware_db.search(value) item_list = list(result_cursor) # 获取信息总数,并判断指定偏移量是否越界 total = len(item_list) if total == 0 or offset >= total: return app_err_p(Error.NO_MORE_DATA, {'total': total, 'count': 0}) # 读取指定位置和数量的利用信息 if count > total - offset: count = total - offset item_list = item_list[offset:offset + count] # 为性能测试中降低CPU使用率,小段延时 time.sleep(1.0) #SysLog.success('搜索漏洞', '成功搜索漏洞信息,查询到漏洞信息总数={}'.format(len(item_list))) return app_ok_p({ 'total': total, 'count': len(item_list), 'items': item_list })
def filter(request): offset = req_get_param_int(request, 'offset') count = req_get_param_int(request, 'count') field = req_get_param(request, 'field') value = req_get_param(request, 'value') # 查找利用信息 result_cursor = firmware_db.filter(field, value) if result_cursor is None: return app_err(Error.INVALID_REQ_PARAM) item_list = list(result_cursor) # 获取信息总数,并判断指定偏移量是否越界 total = len(item_list) if total == 0 or offset >= total: return app_err_p(Error.NO_MORE_DATA, {'total': total, 'count': 0}) # 读取指定位置和数量的利用信息 if count > total - offset: count = total - offset item_list = item_list[offset:offset + count] #SysLog.success('查询漏洞', '成功查询漏洞信息,查询到漏洞信息总数={}'.format(len(item_list))) return app_ok_p({ 'total': total, 'count': len(item_list), 'items': item_list })
def poc_query(request): offset = req_get_param_int(request, 'offset') count = req_get_param_int(request, 'count') # 获取信息总数 total = firmware_pocs.count() # 指定偏移量越界,则报错 if offset >= total: return app_err_p(Error.NO_MORE_DATA, {'total': total, 'count': 0}) # 读取利用方法数据 docs = firmware_pocs.query(offset, count) #SysLog.success('查询POC', '成功查询漏洞的POC,总数={}'.format(len(docs))) return app_ok_p({'total': total, 'count': len(docs), 'items': docs})