Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Warden Connectors
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Warden
Warden Connectors
Commits
4d0ecd01
Commit
4d0ecd01
authored
1 year ago
by
Pavel Kácha
Browse files
Options
Downloads
Patches
Plain Diff
LaBrea: More Py3 compat, remove support for IPv6 (LaBrea does not support it at all)
parent
cb54d16e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hp-labrea/labrea-idea.py
+16
-10
16 additions, 10 deletions
hp-labrea/labrea-idea.py
with
16 additions
and
10 deletions
hp-labrea/labrea-idea.py
+
16
−
10
View file @
4d0ecd01
...
@@ -7,7 +7,6 @@ import re
...
@@ -7,7 +7,6 @@ import re
import
time
import
time
import
optparse
import
optparse
import
signal
import
signal
import
contextlib
import
uuid
import
uuid
import
json
import
json
import
socket
import
socket
...
@@ -28,6 +27,17 @@ try:
...
@@ -28,6 +27,17 @@ try:
except
ImportError
:
except
ImportError
:
from
ordereddict
import
OrderedDict
from
ordereddict
import
OrderedDict
try
:
from
contextlib
import
nested
except
ImportError
:
from
contextlib
import
ExitStack
,
contextmanager
@contextmanager
def
nested
(
*
contexts
):
with
ExitStack
()
as
stack
:
for
ctx
in
contexts
:
stack
.
enter_context
(
ctx
)
yield
contexts
class
WindowContextMgr
(
object
):
class
WindowContextMgr
(
object
):
...
@@ -46,7 +56,7 @@ class WindowContextMgr(object):
...
@@ -46,7 +56,7 @@ class WindowContextMgr(object):
def
expire_queue
(
self
,
queue
,
window
):
def
expire_queue
(
self
,
queue
,
window
):
aggr_events
=
[]
aggr_events
=
[]
ctx_to_del
=
[]
ctx_to_del
=
[]
for
ctx
,
timestamp
in
queue
.
iter
items
():
for
ctx
,
timestamp
in
queue
.
items
():
if
timestamp
>=
self
.
update_timestamp
-
window
:
if
timestamp
>=
self
.
update_timestamp
-
window
:
break
break
closed
=
self
.
ctx_close
(
self
.
contexts
[
ctx
])
closed
=
self
.
ctx_close
(
self
.
contexts
[
ctx
])
...
@@ -304,7 +314,7 @@ class IdeaGen(object):
...
@@ -304,7 +314,7 @@ class IdeaGen(object):
def
gen_idea
(
self
,
src
,
src_ports
,
targets
,
detect_time
,
event_time
,
cease_time
,
count
,
template
):
def
gen_idea
(
self
,
src
,
src_ports
,
targets
,
detect_time
,
event_time
,
cease_time
,
count
,
template
):
tmpl
=
self
.
template
[
template
]
tmpl
=
self
.
template
[
template
]
isource
=
{
isource
=
{
"
IP6
"
if
"
:
"
in
src
else
"
IP4
"
:
[
src
],
"
IP4
"
:
[
src
],
"
Proto
"
:
tmpl
[
"
proto
"
]
"
Proto
"
:
tmpl
[
"
proto
"
]
}
}
if
"
source_type
"
in
tmpl
:
if
"
source_type
"
in
tmpl
:
...
@@ -318,12 +328,8 @@ class IdeaGen(object):
...
@@ -318,12 +328,8 @@ class IdeaGen(object):
itargets
=
[]
itargets
=
[]
for
ports
,
tgt
in
folded_tgt
.
items
():
for
ports
,
tgt
in
folded_tgt
.
items
():
itarget
=
{
"
Proto
"
:
tmpl
[
"
proto
"
]}
itarget
=
{
"
Proto
"
:
tmpl
[
"
proto
"
]}
tgts4
=
[
ip
for
ip
in
tgt
if
"
:
"
not
in
ip
]
if
tgt
:
tgts6
=
[
ip
for
ip
in
tgt
if
"
:
"
in
ip
]
itarget
[
"
IP4
"
]
=
tgt
if
tgts4
:
itarget
[
"
IP4
"
]
=
tgts4
if
tgts6
:
itarget
[
"
IP6
"
]
=
tgts6
if
ports
:
if
ports
:
itarget
[
"
Port
"
]
=
[
int
(
port
)
for
port
in
ports
]
itarget
[
"
Port
"
]
=
[
int
(
port
)
for
port
in
ports
]
itargets
.
append
(
itarget
)
itargets
.
append
(
itarget
)
...
@@ -661,7 +667,7 @@ def main():
...
@@ -661,7 +667,7 @@ def main():
for
context
in
[
PingContextMgr
,
ConnectContextMgr
,
InboundContextMgr
]
for
context
in
[
PingContextMgr
,
ConnectContextMgr
,
InboundContextMgr
]
]
]
with
contextlib
.
nested
(
*
files
):
with
nested
(
*
files
):
for
line_set
in
izip
(
*
files
):
for
line_set
in
izip
(
*
files
):
for
line
in
line_set
:
for
line
in
line_set
:
if
not
line
:
if
not
line
:
...
...
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