Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
knowledge_graph
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sun Long
knowledge_graph
Commits
cab982f5
Commit
cab982f5
authored
Apr 25, 2022
by
lyh3024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
Change-Id: I579b440acc7a609e233614f68e12e697e5b6d14b
parent
29e25d64
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
54 deletions
+60
-54
tests.py
block/tests.py
+19
-18
tests.py
domain/tests.py
+30
-29
settings.py
knowledge_graph/settings.py
+1
-1
tests.py
route/tests.py
+10
-6
No files found.
block/tests.py
View file @
cab982f5
...
...
@@ -4,29 +4,29 @@ from datetime import datetime
from
neomodel
import
db
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
():
time1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
1
)
hash1
=
'0xdf4af22891e6831a621c8641b3bb01d880117a7e01aab04a8b262385220c1b06'
hash2
=
'0x8c46fe20c6d8d56f02e126f5d13231577ee6d56b5ec6a108fd6f222291de3263'
hash3
=
'0xed77bac6775469ab6ef272bc918f0c9f7c019659f67fc3727cd97ea4de99954b'
hash4
=
'0x12f5421f4e68c47d27068089ffe2bd02af0a4c9d34438153b1f872482f289292'
hash5
=
'0xaea2c08b5f2b66e8460e332e364a6d478d9e7f5acc04db3b9f4a047f6a08fc01'
hash6
=
'0xabe02f108f350877493fa49fb3017788333970ea2e78962b7f2b79707cda7b77'
def
test
(
i
):
time1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
i
)
hash1
=
'0xdf4af22891e6831a621c8641b3bb01d880117a7e01aab04a8b262385220c1b06'
+
str
(
i
)
hash2
=
'0x8c46fe20c6d8d56f02e126f5d13231577ee6d56b5ec6a108fd6f222291de3263'
+
str
(
i
)
hash3
=
'0xed77bac6775469ab6ef272bc918f0c9f7c019659f67fc3727cd97ea4de99954b'
+
str
(
i
)
hash4
=
'0x12f5421f4e68c47d27068089ffe2bd02af0a4c9d34438153b1f872482f289292'
+
str
(
i
)
hash5
=
'0xaea2c08b5f2b66e8460e332e364a6d478d9e7f5acc04db3b9f4a047f6a08fc01'
+
str
(
i
)
hash6
=
'0xabe02f108f350877493fa49fb3017788333970ea2e78962b7f2b79707cda7b77'
+
str
(
i
)
b1
=
Block
(
hash
=
hash1
)
b2
=
Block
(
hash
=
hash2
)
b3
=
Block
(
hash
=
hash3
)
b4
=
Block
(
hash
=
hash4
)
t1
=
Transaction
(
hash
=
hash5
,
amount
=
10000.0
)
t2
=
Transaction
(
hash
=
hash6
,
amount
=
20000.0
)
address1
=
'0x65f716f794026d4ff4723141100f0e3c3080e97d'
address2
=
'0x687b6e85b9b08a33991b6ceeeb1d12df278a9a5b'
address3
=
'0x17a84ba96a7374de9586a770b4529f57c6b991d6'
address4
=
'0x422bc251a0582aba25e2dd3b27e80435bc13d402'
address5
=
'0x2daa35962a6d43eb54c48367b33d0b379c930e5e'
address6
=
'0x829bd824b016326a401d083b33d092293333a830'
t1
=
Transaction
(
hash
=
hash5
,
amount
=
10000.0
+
i
*
100
)
t2
=
Transaction
(
hash
=
hash6
,
amount
=
20000.0
+
i
*
100
)
address1
=
'0x65f716f794026d4ff4723141100f0e3c3080e97d'
+
str
(
i
)
address2
=
'0x687b6e85b9b08a33991b6ceeeb1d12df278a9a5b'
+
str
(
i
)
address3
=
'0x17a84ba96a7374de9586a770b4529f57c6b991d6'
+
str
(
i
)
address4
=
'0x422bc251a0582aba25e2dd3b27e80435bc13d402'
+
str
(
i
)
address5
=
'0x2daa35962a6d43eb54c48367b33d0b379c930e5e'
+
str
(
i
)
address6
=
'0x829bd824b016326a401d083b33d092293333a830'
+
str
(
i
)
a1
=
Account
(
address
=
address1
)
a2
=
Account
(
address
=
address2
)
c1
=
Contract
(
address
=
address3
)
...
...
@@ -53,4 +53,5 @@ def test():
if
__name__
==
'__main__'
:
test
()
for
i
in
range
(
1
,
20
):
test
(
i
)
domain/tests.py
View file @
cab982f5
...
...
@@ -4,25 +4,25 @@ from datetime import datetime
from
neomodel
import
db
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
():
t1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
1
)
l1
=
Label
(
label_name
=
"恶意域名"
)
l2
=
Label
(
label_name
=
"境外域名"
)
def
test
(
i
):
t1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
i
)
l1
=
Label
(
label_name
=
"恶意域名"
+
str
(
i
)
)
l2
=
Label
(
label_name
=
"境外域名"
+
str
(
i
)
)
l1
.
save
()
l2
.
save
()
req1
=
RequestIp
(
request_ip
=
'127.0.0.1'
,
province
=
'四川'
,
isp
=
'电信'
)
req2
=
RequestIp
(
request_ip
=
'127.0.0.2'
,
province
=
'四川'
,
isp
=
'电信'
)
req1
=
RequestIp
(
request_ip
=
'127.0.0.1'
+
str
(
i
)
,
province
=
'四川'
,
isp
=
'电信'
)
req2
=
RequestIp
(
request_ip
=
'127.0.0.2'
+
str
(
i
)
,
province
=
'四川'
,
isp
=
'电信'
)
req1
.
save
()
req2
.
save
()
d1
=
DnsIp
(
dns_ip
=
'127.0.0.3'
)
d2
=
DnsIp
(
dns_ip
=
'127.0.0.4'
)
d1
=
DnsIp
(
dns_ip
=
'127.0.0.3'
+
str
(
i
)
)
d2
=
DnsIp
(
dns_ip
=
'127.0.0.4'
+
str
(
i
)
)
d1
.
save
()
d2
.
save
()
do1
=
DomainName
(
domain_name
=
'www.baidu.com'
)
do2
=
DomainName
(
domain_name
=
'google.cn'
)
do1
=
DomainName
(
domain_name
=
'www.baidu.com'
+
str
(
i
)
)
do2
=
DomainName
(
domain_name
=
'google.cn'
+
str
(
i
)
)
do1
.
save
()
do2
.
save
()
r1
=
req1
.
request_domain
.
connect
(
do1
,
{
"index"
:
"123"
,
"date"
:
t1
})
...
...
@@ -35,10 +35,10 @@ def test():
r
.
save
()
def
test1
():
t1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
1
)
.
timestamp
()
t2
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
2
)
.
timestamp
()
param
=
{
"ips"
:
[
'127.0.0.1'
,
'127.0.0.2'
]}
def
test1
(
i
):
t1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
i
)
.
timestamp
()
t2
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
i
)
.
timestamp
()
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)'
\
'where r.request_ip in $ips return r, d, l, dns, req, lab, par'
items
=
db
.
cypher_query
(
query
,
param
)[
0
]
...
...
@@ -59,15 +59,15 @@ def test1():
print
(
r
.
nodes
[
0
]
.
id
)
def
test2
():
t1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
2
)
req1
=
RequestIp
(
request_ip
=
'127.0.0.10'
,
province
=
'北京'
,
isp
=
'联通'
)
def
test2
(
i
):
t1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
i
)
req1
=
RequestIp
(
request_ip
=
'127.0.0.10'
+
str
(
i
)
,
province
=
'北京'
,
isp
=
'联通'
)
req1
.
save
()
d1
=
DnsIp
(
dns_ip
=
'127.0.0.11'
)
d1
=
DnsIp
(
dns_ip
=
'127.0.0.11'
+
str
(
i
)
)
d1
.
save
()
do1
=
DomainName
(
domain_name
=
'tencent.com'
)
do1
=
DomainName
(
domain_name
=
'tencent.com'
+
str
(
i
)
)
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
})
r2
=
d1
.
parse_domain
.
connect
(
do1
,
{
"index"
:
"299"
,
"date"
:
t1
})
r3
=
do1
.
label
.
connect
(
l1
,
{
"index"
:
"199"
,
"date"
:
t1
})
...
...
@@ -76,12 +76,12 @@ def test2():
r3
.
save
()
def
test3
():
t1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
2
)
req1
=
RequestIp
(
request_ip
=
'127.0.0.12'
,
province
=
'北京'
,
isp
=
'联通'
)
d1
=
DnsIp
.
nodes
.
filter
(
dns_ip
=
'127.0.0.11'
)
.
first
()
def
test3
(
i
):
t1
=
datetime
(
year
=
2022
,
month
=
1
,
day
=
i
)
req1
=
RequestIp
(
request_ip
=
(
'127.0.0.12'
+
str
(
i
))
,
province
=
'北京'
,
isp
=
'联通'
)
d1
=
DnsIp
.
nodes
.
filter
(
dns_ip
=
(
'127.0.0.11'
+
str
(
i
))
)
.
first
()
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
})
r2
=
d1
.
parse_domain
.
connect
(
do1
,
{
"index"
:
"999"
,
"date"
:
t1
})
r1
.
save
()
...
...
@@ -99,7 +99,8 @@ def test4():
if
__name__
==
'__main__'
:
test
()
test2
()
test3
()
for
i
in
range
(
1
,
20
):
test
(
i
)
test2
(
i
)
test3
(
i
)
# test4()
knowledge_graph/settings.py
View file @
cab982f5
...
...
@@ -90,7 +90,7 @@ DATABASES = {
}
}
config
.
DATABASE_URL
=
'bolt://neo4j:
neo4j@localhost:7687/neo4j
'
config
.
DATABASE_URL
=
'bolt://neo4j:
lyh0214@localhost:7687
'
# Password validation
...
...
route/tests.py
View file @
cab982f5
...
...
@@ -2,14 +2,17 @@ from neomodel import db
from
datetime
import
datetime
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
)
n1
=
FirstIp
(
ip
=
'127.0.0.1'
,
country
=
'中国'
,
province
=
'四川'
,
city
=
'成都'
,
isp
=
'电信'
,
start_ip
=
'127.0.0.1'
,
root_ip
=
'127.0.0.3'
)
n2
=
RouteIp
(
ip
=
'127.0.0.2'
,
country
=
'中国'
,
province
=
'四川'
,
city
=
'成都'
,
isp
=
'电信'
,
start_ip
=
'127.0.0.1'
,
root_ip
=
'127.0.0.3'
)
n3
=
EndIp
(
ip
=
'127.0.0.3'
,
country
=
'中国'
,
province
=
'四川'
,
city
=
'成都'
,
isp
=
'电信'
,
start_ip
=
'127.0.0.1'
,
root_ip
=
'127.0.0.3'
)
ip1
=
'127.0.0'
+
str
(
i
)
ip2
=
'0.0.0'
+
str
(
i
)
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
()
n2
.
save
()
n3
.
save
()
...
...
@@ -24,4 +27,5 @@ def test():
if
__name__
==
"__main__"
:
test
()
for
i
in
range
(
20
):
test
(
i
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment