#todo 聚合

This commit is contained in:
Autumn.home 2024-07-13 12:22:08 +08:00
parent 952d54bb8b
commit 4a7b2c6d62
3 changed files with 6 additions and 3 deletions

View File

@ -28,7 +28,7 @@ async def get_projects_data(request_data: dict, db=Depends(get_mongo_db), _: dic
query = {
"$or": [
{"name": {"$regex": search_query, "$options": "i"}},
{"target": {"$regex": search_query, "$options": "i"}}
{"root_domain": {"$regex": search_query, "$options": "i"}}
]
} if search_query else {}

View File

@ -152,7 +152,8 @@ async def get_projects_vul_data(request_data: dict, db=Depends(get_mongo_db), _:
async def fetch_asset_data(r):
tmp_result = {
"port": r['_id'],
"id": generate_random_string(5)
"id": generate_random_string(5),
"count": r['count']
}
query_copy = query.copy()
@ -236,6 +237,7 @@ async def get_projects_service_data(request_data: dict, db=Depends(get_mongo_db)
async def fetch_asset_data(r):
tmp_result = {
"service": r['_id'],
"count": r['count'],
"id": generate_random_string(5),
"domain": "",
"ip": "",

View File

@ -427,7 +427,8 @@ async def get_search_query(name, request_data):
if len(tmp_or) != 0:
query["$and"].append({"$or": tmp_or})
fuzzy_query = request_data.get("fq", {})
fuzzy_query_key = {"sub_host": 'host', "sub_value": "value", "sub_ip": "ip", "port_port": "port", "port_domain":['domain', 'host'], 'port_ip': ['ip', 'host'], 'port_protocol': ['type', 'protocol']}
fuzzy_query_key = {"sub_host": 'host', "sub_value": "value", "sub_ip": "ip", "port_port": "port", "port_domain":['domain', 'host'], 'port_ip': ['ip', 'host'], 'port_protocol': ['type', 'protocol'],
"service_service": ['type', 'webServer', 'protocol'], "service_domain": ['domain', 'host'], "service_port": "port", "service_ip": ['ip', 'host']}
if fuzzy_query:
if "$and" not in query:
query["$and"] = []