Commit 67103062 by lyh3024

Merge branch 'develop' into 'master'

fix

See merge request lyh3024/knowledge_graph!3
parents 9e5e087f cab982f5
...@@ -4,29 +4,29 @@ from datetime import datetime ...@@ -4,29 +4,29 @@ from datetime import datetime
from neomodel import db from neomodel import db
from block.models import Account, Transaction, Contract, Miner, Block from block.models import Account, Transaction, Contract, Miner, Block
db.set_connection('bolt://neo4j:neo4j@localhost:7687/neo4j') db.set_connection('bolt://neo4j:lyh0214@localhost:7687/')
def test(): def test(i):
time1 = datetime(year=2022, month=1, day=1) time1 = datetime(year=2022, month=1, day=i)
hash1 = '0xdf4af22891e6831a621c8641b3bb01d880117a7e01aab04a8b262385220c1b06' hash1 = '0xdf4af22891e6831a621c8641b3bb01d880117a7e01aab04a8b262385220c1b06' + str(i)
hash2 = '0x8c46fe20c6d8d56f02e126f5d13231577ee6d56b5ec6a108fd6f222291de3263' hash2 = '0x8c46fe20c6d8d56f02e126f5d13231577ee6d56b5ec6a108fd6f222291de3263' + str(i)
hash3 = '0xed77bac6775469ab6ef272bc918f0c9f7c019659f67fc3727cd97ea4de99954b' hash3 = '0xed77bac6775469ab6ef272bc918f0c9f7c019659f67fc3727cd97ea4de99954b' + str(i)
hash4 = '0x12f5421f4e68c47d27068089ffe2bd02af0a4c9d34438153b1f872482f289292' hash4 = '0x12f5421f4e68c47d27068089ffe2bd02af0a4c9d34438153b1f872482f289292' + str(i)
hash5 = '0xaea2c08b5f2b66e8460e332e364a6d478d9e7f5acc04db3b9f4a047f6a08fc01' hash5 = '0xaea2c08b5f2b66e8460e332e364a6d478d9e7f5acc04db3b9f4a047f6a08fc01' + str(i)
hash6 = '0xabe02f108f350877493fa49fb3017788333970ea2e78962b7f2b79707cda7b77' hash6 = '0xabe02f108f350877493fa49fb3017788333970ea2e78962b7f2b79707cda7b77' + str(i)
b1 = Block(hash=hash1) b1 = Block(hash=hash1)
b2 = Block(hash=hash2) b2 = Block(hash=hash2)
b3 = Block(hash=hash3) b3 = Block(hash=hash3)
b4 = Block(hash=hash4) b4 = Block(hash=hash4)
t1 = Transaction(hash=hash5, amount=10000.0) t1 = Transaction(hash=hash5, amount=10000.0 + i * 100)
t2 = Transaction(hash=hash6, amount=20000.0) t2 = Transaction(hash=hash6, amount=20000.0 + i * 100)
address1 = '0x65f716f794026d4ff4723141100f0e3c3080e97d' address1 = '0x65f716f794026d4ff4723141100f0e3c3080e97d' + str(i)
address2 = '0x687b6e85b9b08a33991b6ceeeb1d12df278a9a5b' address2 = '0x687b6e85b9b08a33991b6ceeeb1d12df278a9a5b' + str(i)
address3 = '0x17a84ba96a7374de9586a770b4529f57c6b991d6' address3 = '0x17a84ba96a7374de9586a770b4529f57c6b991d6' + str(i)
address4 = '0x422bc251a0582aba25e2dd3b27e80435bc13d402' address4 = '0x422bc251a0582aba25e2dd3b27e80435bc13d402' + str(i)
address5 = '0x2daa35962a6d43eb54c48367b33d0b379c930e5e' address5 = '0x2daa35962a6d43eb54c48367b33d0b379c930e5e' + str(i)
address6 = '0x829bd824b016326a401d083b33d092293333a830' address6 = '0x829bd824b016326a401d083b33d092293333a830' + str(i)
a1 = Account(address=address1) a1 = Account(address=address1)
a2 = Account(address=address2) a2 = Account(address=address2)
c1 = Contract(address=address3) c1 = Contract(address=address3)
...@@ -53,4 +53,5 @@ def test(): ...@@ -53,4 +53,5 @@ def test():
if __name__ == '__main__': if __name__ == '__main__':
test() for i in range(1, 20):
test(i)
...@@ -4,25 +4,25 @@ from datetime import datetime ...@@ -4,25 +4,25 @@ from datetime import datetime
from neomodel import db from neomodel import db
from domain.models import Label, RequestIp, DnsIp, DomainName from domain.models import Label, RequestIp, DnsIp, DomainName
db.set_connection('bolt://neo4j:neo4j@localhost:7687/neo4j') db.set_connection('bolt://neo4j:lyh0214@localhost:7687/')
def test(): def test(i):
t1 = datetime(year=2022, month=1, day=1) t1 = datetime(year=2022, month=1, day=i)
l1 = Label(label_name="恶意域名") l1 = Label(label_name="恶意域名" + str(i))
l2 = Label(label_name="境外域名") l2 = Label(label_name="境外域名" + str(i))
l1.save() l1.save()
l2.save() l2.save()
req1 = RequestIp(request_ip='127.0.0.1', province='四川', isp='电信') req1 = RequestIp(request_ip='127.0.0.1' + str(i), province='四川', isp='电信')
req2 = RequestIp(request_ip='127.0.0.2', province='四川', isp='电信') req2 = RequestIp(request_ip='127.0.0.2' + str(i), province='四川', isp='电信')
req1.save() req1.save()
req2.save() req2.save()
d1 = DnsIp(dns_ip='127.0.0.3') d1 = DnsIp(dns_ip='127.0.0.3' + str(i))
d2 = DnsIp(dns_ip='127.0.0.4') d2 = DnsIp(dns_ip='127.0.0.4' + str(i))
d1.save() d1.save()
d2.save() d2.save()
do1 = DomainName(domain_name='www.baidu.com') do1 = DomainName(domain_name='www.baidu.com' + str(i))
do2 = DomainName(domain_name='google.cn') do2 = DomainName(domain_name='google.cn' + str(i))
do1.save() do1.save()
do2.save() do2.save()
r1 = req1.request_domain.connect(do1, {"index": "123", "date": t1}) r1 = req1.request_domain.connect(do1, {"index": "123", "date": t1})
...@@ -35,10 +35,10 @@ def test(): ...@@ -35,10 +35,10 @@ def test():
r.save() r.save()
def test1(): def test1(i):
t1 = datetime(year=2022, month=1, day=1).timestamp() t1 = datetime(year=2022, month=1, day=i).timestamp()
t2 = datetime(year=2022, month=1, day=2).timestamp() t2 = datetime(year=2022, month=1, day=i).timestamp()
param = {"ips": ['127.0.0.1', '127.0.0.2']} param = {"ips": ['127.0.0.1' + str(i), '127.0.0.2' + str(i)]}
query = 'match (r:RequestIp)-[req:REQUEST]->(d:DomainName)-[lab:LABEL]->(l:Label), (dns:DnsIp)-[par:PARSE]->(d)' \ query = 'match (r:RequestIp)-[req:REQUEST]->(d:DomainName)-[lab:LABEL]->(l:Label), (dns:DnsIp)-[par:PARSE]->(d)' \
'where r.request_ip in $ips return r, d, l, dns, req, lab, par' 'where r.request_ip in $ips return r, d, l, dns, req, lab, par'
items = db.cypher_query(query, param)[0] items = db.cypher_query(query, param)[0]
...@@ -59,15 +59,15 @@ def test1(): ...@@ -59,15 +59,15 @@ def test1():
print(r.nodes[0].id) print(r.nodes[0].id)
def test2(): def test2(i):
t1 = datetime(year=2022, month=1, day=2) t1 = datetime(year=2022, month=1, day=i)
req1 = RequestIp(request_ip='127.0.0.10', province='北京', isp='联通') req1 = RequestIp(request_ip='127.0.0.10' + str(i), province='北京', isp='联通')
req1.save() req1.save()
d1 = DnsIp(dns_ip='127.0.0.11') d1 = DnsIp(dns_ip='127.0.0.11' + str(i))
d1.save() d1.save()
do1 = DomainName(domain_name='tencent.com') do1 = DomainName(domain_name='tencent.com' + str(i))
do1.save() do1.save()
l1 = Label.nodes.filter(label_name='恶意域名').first() l1 = Label.nodes.filter(label_name='恶意域名' + str(i)).first()
r1 = req1.request_domain.connect(do1, {"index": "221", "date": t1}) r1 = req1.request_domain.connect(do1, {"index": "221", "date": t1})
r2 = d1.parse_domain.connect(do1, {"index": "299", "date": t1}) r2 = d1.parse_domain.connect(do1, {"index": "299", "date": t1})
r3 = do1.label.connect(l1, {"index": "199", "date": t1}) r3 = do1.label.connect(l1, {"index": "199", "date": t1})
...@@ -76,12 +76,12 @@ def test2(): ...@@ -76,12 +76,12 @@ def test2():
r3.save() r3.save()
def test3(): def test3(i):
t1 = datetime(year=2022, month=1, day=2) t1 = datetime(year=2022, month=1, day=i)
req1 = RequestIp(request_ip='127.0.0.12', province='北京', isp='联通') req1 = RequestIp(request_ip=('127.0.0.12' + str(i)), province='北京', isp='联通')
d1 = DnsIp.nodes.filter(dns_ip='127.0.0.11').first() d1 = DnsIp.nodes.filter(dns_ip=('127.0.0.11' + str(i))).first()
req1.save() req1.save()
do1 = DomainName.nodes.filter(domain_name='tencent.com').first() do1 = DomainName.nodes.filter(domain_name='tencent.com' + str(i)).first()
r1 = req1.request_domain.connect(do1, {"index": "222", "date": t1}) r1 = req1.request_domain.connect(do1, {"index": "222", "date": t1})
r2 = d1.parse_domain.connect(do1, {"index": "999", "date": t1}) r2 = d1.parse_domain.connect(do1, {"index": "999", "date": t1})
r1.save() r1.save()
...@@ -99,7 +99,8 @@ def test4(): ...@@ -99,7 +99,8 @@ def test4():
if __name__ == '__main__': if __name__ == '__main__':
test() for i in range(1, 20):
test2() test(i)
test3() test2(i)
test3(i)
# test4() # test4()
...@@ -90,7 +90,7 @@ DATABASES = { ...@@ -90,7 +90,7 @@ DATABASES = {
} }
} }
config.DATABASE_URL = 'bolt://neo4j:neo4j@localhost:7687/neo4j' config.DATABASE_URL = 'bolt://neo4j:lyh0214@localhost:7687'
# Password validation # Password validation
......
...@@ -2,14 +2,17 @@ from neomodel import db ...@@ -2,14 +2,17 @@ from neomodel import db
from datetime import datetime from datetime import datetime
from route.models import RouteIp, FirstIp, EndIp from route.models import RouteIp, FirstIp, EndIp
db.set_connection('bolt://neo4j:neo4j@localhost:7687/neo4j') db.set_connection('bolt://neo4j:lyh0214@localhost:7687')
def test(): def test(i):
t1 = datetime(year=2022, month=1, day=1) t1 = datetime(year=2022, month=1, day=1)
n1 = FirstIp(ip='127.0.0.1', country='中国', province='四川', city='成都', isp='电信', start_ip='127.0.0.1', root_ip='127.0.0.3') ip1 = '127.0.0' + str(i)
n2 = RouteIp(ip='127.0.0.2', country='中国', province='四川', city='成都', isp='电信', start_ip='127.0.0.1', root_ip='127.0.0.3') ip2 = '0.0.0' + str(i)
n3 = EndIp(ip='127.0.0.3', country='中国', province='四川', city='成都', isp='电信', start_ip='127.0.0.1', root_ip='127.0.0.3') ip3 = '255.255.255' + str(i)
n1 = FirstIp(ip=ip1, country='中国', province='四川', city='成都', isp='电信', start_ip=ip1, root_ip=ip3)
n2 = RouteIp(ip=ip2, country='中国', province='四川', city='成都', isp='电信', start_ip=ip1, root_ip=ip3)
n3 = EndIp(ip=ip3, country='中国', province='四川', city='成都', isp='电信', start_ip=ip1, root_ip=ip3)
n1.save() n1.save()
n2.save() n2.save()
n3.save() n3.save()
...@@ -24,4 +27,5 @@ def test(): ...@@ -24,4 +27,5 @@ def test():
if __name__ == "__main__": if __name__ == "__main__":
test() for i in range(20):
test(i)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment