Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
b81596f5
Commit
b81596f5
authored
1 year ago
by
karamchandan
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup of the DAD service implementation
parent
b3c0e922
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!142
Release TeraFlowSDN 2.1
,
!141
Pre-release fixes and code cleanup in L3 cybersecurity components
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/l3_distributedattackdetector/service/l3_distributedattackdetector.py
+10
-4
10 additions, 4 deletions
...tedattackdetector/service/l3_distributedattackdetector.py
with
10 additions
and
4 deletions
src/l3_distributedattackdetector/service/l3_distributedattackdetector.py
+
10
−
4
View file @
b81596f5
...
@@ -177,6 +177,7 @@ class l3_distributedattackdetector:
...
@@ -177,6 +177,7 @@ class l3_distributedattackdetector:
stub
=
ContextServiceStub
(
channel
)
stub
=
ContextServiceStub
(
channel
)
context_id
=
ContextId
()
context_id
=
ContextId
()
context_id
.
context_uuid
.
uuid
=
context_id_str
context_id
.
context_uuid
.
uuid
=
context_id_str
return
stub
.
ListServiceIds
(
context_id
)
return
stub
.
ListServiceIds
(
context_id
)
def
get_services
(
self
,
context_id_str
):
def
get_services
(
self
,
context_id_str
):
...
@@ -184,26 +185,31 @@ class l3_distributedattackdetector:
...
@@ -184,26 +185,31 @@ class l3_distributedattackdetector:
stub
=
ContextServiceStub
(
channel
)
stub
=
ContextServiceStub
(
channel
)
context_id
=
ContextId
()
context_id
=
ContextId
()
context_id
.
context_uuid
.
uuid
=
context_id_str
context_id
.
context_uuid
.
uuid
=
context_id_str
return
stub
.
ListServices
(
context_id
)
return
stub
.
ListServices
(
context_id
)
def
get_service_id
(
self
,
context_id
):
def
get_service_id
(
self
,
context_id
):
service_list
=
self
.
get_services
(
context_id
)
service_list
=
self
.
get_services
(
context_id
)
service_id
=
None
service_id
=
None
for
s
in
service_list
.
services
:
for
s
in
service_list
.
services
:
if
s
.
service_type
==
ServiceTypeEnum
.
SERVICETYPE_L3NM
:
if
s
.
service_type
==
ServiceTypeEnum
.
SERVICETYPE_L3NM
:
service_id
=
s
.
service_id
service_id
=
s
.
service_id
break
break
else
:
else
:
pass
pass
return
service_id
return
service_id
def
get_endpoint_id
(
self
,
context_id
):
def
get_endpoint_id
(
self
,
context_id
):
service_list
=
self
.
get_services
(
context_id
)
service_list
=
self
.
get_services
(
context_id
)
endpoint_id
=
None
endpoint_id
=
None
for
s
in
service_list
.
services
:
for
s
in
service_list
.
services
:
if
s
.
service_type
==
ServiceTypeEnum
.
SERVICETYPE_L3NM
:
if
s
.
service_type
==
ServiceTypeEnum
.
SERVICETYPE_L3NM
:
endpoint_id
=
s
.
service_endpoint_ids
[
0
]
endpoint_id
=
s
.
service_endpoint_ids
[
0
]
break
break
return
endpoint_id
return
endpoint_id
def
get_features_ids
(
self
):
def
get_features_ids
(
self
):
...
@@ -275,7 +281,7 @@ class l3_distributedattackdetector:
...
@@ -275,7 +281,7 @@ class l3_distributedattackdetector:
LOGGER
.
error
(
f
"
Error sending batch:
{
e
}
"
)
LOGGER
.
error
(
f
"
Error sending batch:
{
e
}
"
)
async
def
send_data
(
self
,
metrics_list_pb
,
send_data_times
):
async
def
send_data
(
self
,
metrics_list_pb
,
send_data_times
):
# Send to CAD
# Send
data
to CAD
if
SEND_DATA_IN_BATCHES
:
if
SEND_DATA_IN_BATCHES
:
if
len
(
metrics_list_pb
)
==
BATCH_SIZE
:
if
len
(
metrics_list_pb
)
==
BATCH_SIZE
:
send_data_time_start
=
time
.
time
()
send_data_time_start
=
time
.
time
()
...
@@ -319,24 +325,24 @@ class l3_distributedattackdetector:
...
@@ -319,24 +325,24 @@ class l3_distributedattackdetector:
LOGGER
.
info
(
"
Waiting for new data...
"
)
LOGGER
.
info
(
"
Waiting for new data...
"
)
time
.
sleep
(
1
/
100
)
time
.
sleep
(
1
/
100
)
line
=
next
(
loglines
,
None
)
line
=
next
(
loglines
,
None
)
if
index
==
0
and
IGNORE_FIRST_LINE_TSTAT
:
if
index
==
0
and
IGNORE_FIRST_LINE_TSTAT
:
index
=
index
+
1
index
=
index
+
1
continue
continue
if
STOP
:
if
STOP
:
break
break
num_lines
+=
1
num_lines
+=
1
start
=
time
.
time
()
start
=
time
.
time
()
line_id
=
line
.
split
(
"
"
)
line_id
=
line
.
split
(
"
"
)
self
.
conn_id
=
(
line_id
[
0
],
line_id
[
1
],
line_id
[
14
],
line_id
[
15
])
self
.
conn_id
=
(
line_id
[
0
],
line_id
[
1
],
line_id
[
14
],
line_id
[
15
])
self
.
new_connections
[
self
.
conn_id
]
=
self
.
process_line
(
line
)
self
.
new_connections
[
self
.
conn_id
]
=
self
.
process_line
(
line
)
self
.
check_if_connection_is_attack
()
self
.
check_if_connection_is_attack
()
self
.
insert_connection
()
self
.
insert_connection
()
self
.
create_cad_features
()
self
.
create_cad_features
()
self
.
check_types
()
self
.
check_types
()
connection_metadata
=
ConnectionMetadata
(
**
self
.
cad_features
[
"
connection_metadata
"
])
connection_metadata
=
ConnectionMetadata
(
**
self
.
cad_features
[
"
connection_metadata
"
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment