125 lines
5.3 KiB
Python
125 lines
5.3 KiB
Python
|
|
#!/user/bin/python
|
|||
|
|
#-*-coding:utf-8-*-
|
|||
|
|
import requests
|
|||
|
|
import random
|
|||
|
|
import json
|
|||
|
|
number = random.randint(0,100000)
|
|||
|
|
str = random.choice('abcdefghijklmnopqrstuvwxyz!@#$%^&*()')
|
|||
|
|
list = []
|
|||
|
|
# def schema():
|
|||
|
|
# url = "http://192.168.44.72:8080/v1/log/schema?logType=security_event_log"
|
|||
|
|
# headers = {"Content-Type":"application/x-www-form-urlencoded","Authorization":"555b5dc2-d69f-44a4-8a00-171e81edd739&889&"}
|
|||
|
|
# response = requests.get(url=url,headers=headers)
|
|||
|
|
# return response.json()
|
|||
|
|
|
|||
|
|
def Filter1(schema):
|
|||
|
|
print("1234")
|
|||
|
|
print(type(schema))
|
|||
|
|
json_str = json.dumps(schema)
|
|||
|
|
schema1 = json.loads(json_str)
|
|||
|
|
fields = schema1["data"]["fields"]
|
|||
|
|
#print(fields)
|
|||
|
|
|
|||
|
|
#print(type(fields))
|
|||
|
|
operator = schema1["data"]["doc"]["schema_query"]["references"]["operator"]
|
|||
|
|
#print(operator)
|
|||
|
|
for i in fields:
|
|||
|
|
print(i)
|
|||
|
|
name = i["name"]
|
|||
|
|
doc = i["doc"]
|
|||
|
|
if doc == None:
|
|||
|
|
type1 = i["type"]
|
|||
|
|
for j in operator:
|
|||
|
|
if type1 == j["type"]:
|
|||
|
|
if type1 == "int" or type1 == "long":
|
|||
|
|
value1 = number
|
|||
|
|
functions = j["functions"]
|
|||
|
|
functions1 = functions.split(",")
|
|||
|
|
for v in functions1:
|
|||
|
|
str1 = name + " "+v + " "+ f"{value1}"
|
|||
|
|
list.append(str1)
|
|||
|
|
elif type1 == "string":
|
|||
|
|
value1 = str
|
|||
|
|
functions = j["functions"]
|
|||
|
|
functions1 = functions.split(",")
|
|||
|
|
for v in functions1:
|
|||
|
|
str1 = name + " "+v + " "+ value1
|
|||
|
|
list.append(str1)
|
|||
|
|
else:
|
|||
|
|
if i["doc"]["constraints"]== None:
|
|||
|
|
type1 = i["type"]
|
|||
|
|
for j in operator:
|
|||
|
|
if type1==j["type"]:
|
|||
|
|
if type1=="int" or type1=="long":
|
|||
|
|
value1 = number
|
|||
|
|
functions = j["functions"]
|
|||
|
|
functions1 = functions.split(",")
|
|||
|
|
for v in functions1:
|
|||
|
|
str1 = name + " "+v + " "+ f"{value1}"
|
|||
|
|
list.append(str1)
|
|||
|
|
elif type1=="string":
|
|||
|
|
value1 = str
|
|||
|
|
functions = j["functions"]
|
|||
|
|
functions1 = functions.split(",")
|
|||
|
|
for v in functions1:
|
|||
|
|
str1=name + " "+v + " "+ value1
|
|||
|
|
list.append(str1)
|
|||
|
|
|
|||
|
|
else:
|
|||
|
|
if i["doc"]["constraints"]["operator_functions"]==None:
|
|||
|
|
type1 = i["type"]
|
|||
|
|
for j in operator:
|
|||
|
|
if type1 == j["type"]:
|
|||
|
|
if type1 == "int" or type1 == "long":
|
|||
|
|
value1 = number
|
|||
|
|
functions = j["functions"]
|
|||
|
|
functions1 = functions.split(",")
|
|||
|
|
for v in functions1:
|
|||
|
|
str1 = name + " "+ v + " "+ f"{value1}"
|
|||
|
|
list.append(str1)
|
|||
|
|
elif type1 == "string":
|
|||
|
|
value1 = str
|
|||
|
|
functions = j["functions"]
|
|||
|
|
functions1 = functions.split(",")
|
|||
|
|
for v in functions1:
|
|||
|
|
str1 = name + " "+ v + " "+ value1
|
|||
|
|
list.append(str1)
|
|||
|
|
else:
|
|||
|
|
type1 = i["type"]
|
|||
|
|
operator1 = i["doc"]["constraints"]["operator_functions"]
|
|||
|
|
operator2 = operator1.split(",")
|
|||
|
|
data = i["doc"]["data"]
|
|||
|
|
for d in data:
|
|||
|
|
code = d["code"]
|
|||
|
|
if type1 == "int" or type1 == "long":
|
|||
|
|
for o in operator2:
|
|||
|
|
str1 = name + " "+ o + " "+ code
|
|||
|
|
list.append(str1)
|
|||
|
|
else:
|
|||
|
|
for o in operator2:
|
|||
|
|
str1 = name + " "+ o + " "+ code
|
|||
|
|
list.append(str1)
|
|||
|
|
print(list)
|
|||
|
|
return list
|
|||
|
|
# def api():
|
|||
|
|
# filter2 = Filter1()
|
|||
|
|
# a = schema()
|
|||
|
|
# fields = a["data"]["fields"]
|
|||
|
|
# for i in filter2:
|
|||
|
|
# url = "http://192.168.32.59:8888/v1/log/list"
|
|||
|
|
# headers = {"Content-Type": "application/json",
|
|||
|
|
# "Authorization": "7dda2581-38ca-4c48-9103-98ab852a5be5&807&"}
|
|||
|
|
# data = {
|
|||
|
|
# "start_common_recv_time":'2021-03-20 16:36:41',
|
|||
|
|
# "end_common_recv_time":'2021-03-21 17:36:41',
|
|||
|
|
# "logType":"security_event_log",
|
|||
|
|
# "fields":fields,
|
|||
|
|
# "filter":i
|
|||
|
|
# }
|
|||
|
|
# print(data)
|
|||
|
|
# response1 = requests.post(url=url, data=json.dumps(data),headers=headers)
|
|||
|
|
# print(response1.json())
|
|||
|
|
# return response1.json()
|
|||
|
|
#
|
|||
|
|
# if __name__ == '__main__':
|
|||
|
|
# api()
|