Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mentat Test 3
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
Mentat
Mentat Test 3
Commits
299799e1
Commit
299799e1
authored
2 years ago
by
Rajmund Hruška
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Consider the source of a network when updating networks. (Redmine issue:
#7618
)
parent
fad546b6
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
lib/mentat/module/netmngr.py
+7
-4
7 additions, 4 deletions
lib/mentat/module/netmngr.py
with
7 additions
and
4 deletions
lib/mentat/module/netmngr.py
+
7
−
4
View file @
299799e1
...
@@ -382,7 +382,7 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript):
...
@@ -382,7 +382,7 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript):
self
.
_check_emails
(
abuse_group_dict
,
wi_file_data
)
self
.
_check_emails
(
abuse_group_dict
,
wi_file_data
)
self
.
_groups_create_missing
(
abuse_group_dict
,
wi_file_data
,
wi_file_type
,
result
,
status_only
)
self
.
_groups_create_missing
(
abuse_group_dict
,
wi_file_data
,
wi_file_type
,
result
,
status_only
)
self
.
_groups_remove_extra
(
abuse_group_dict
,
wi_file_data
,
wi_file_type
,
result
,
status_only
)
self
.
_groups_remove_extra
(
abuse_group_dict
,
wi_file_data
,
wi_file_type
,
result
,
status_only
)
self
.
_groups_update_existing
(
abuse_group_dict
,
wi_file_data
,
result
,
status_only
)
self
.
_groups_update_existing
(
abuse_group_dict
,
wi_file_data
,
wi_file_type
,
result
,
status_only
)
return
result
return
result
...
@@ -558,13 +558,14 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript):
...
@@ -558,13 +558,14 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript):
result
[
'
delete
'
][
gkey
].
append
(
nkey
)
result
[
'
delete
'
][
gkey
].
append
(
nkey
)
self
.
logger
.
warning
(
"'
%s
'
Network
'
%s
'
was not found in loaded whois file, consider deletion.
"
,
gkey
,
nkey
)
self
.
logger
.
warning
(
"'
%s
'
Network
'
%s
'
was not found in loaded whois file, consider deletion.
"
,
gkey
,
nkey
)
def
_groups_update_existing
(
self
,
abuse_group_dict
,
wi_file_data
,
result
,
status_only
):
def
_groups_update_existing
(
self
,
abuse_group_dict
,
wi_file_data
,
wi_file_type
,
result
,
status_only
):
"""
"""
Update existing abuse groups and their appropriate whois records within
Update existing abuse groups and their appropriate whois records within
the database.
the database.
:param dict abuse_group_dict: Abuse groups and network records loaded from database.
:param dict abuse_group_dict: Abuse groups and network records loaded from database.
:param dict wi_file_data: Abuse groups and network records loaded from reference whois file.
:param dict wi_file_data: Abuse groups and network records loaded from reference whois file.
:param str wi_file_type: Value of ``__whois_type__`` meta attribute from reference whois file.
:param dict result: Structure containing processing log, will be appended to script runlog.
:param dict result: Structure containing processing log, will be appended to script runlog.
:param bool status_only: Do not actually perform any database operations, just report status.
:param bool status_only: Do not actually perform any database operations, just report status.
"""
"""
...
@@ -576,16 +577,18 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript):
...
@@ -576,16 +577,18 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript):
self
.
_group_update_networks
(
self
.
_group_update_networks
(
abuse_group_dict
[
group_name
],
abuse_group_dict
[
group_name
],
[
network
for
networks
in
wi_file_data
[
name
].
values
()
for
network
in
networks
],
[
network
for
networks
in
wi_file_data
[
name
].
values
()
for
network
in
networks
],
wi_file_type
,
result
,
result
,
status_only
)
status_only
)
self
.
sqlservice
.
session
.
commit
()
self
.
sqlservice
.
session
.
commit
()
def
_group_update_networks
(
self
,
group
,
networks
,
result
,
status_only
):
def
_group_update_networks
(
self
,
group
,
networks
,
wi_file_type
,
result
,
status_only
):
"""
"""
Update abuse group network list coming from given source.
Update abuse group network list coming from given source.
:param mentat.datatype.sqldb.GroupModel group: Abuse group to be processed.
:param mentat.datatype.sqldb.GroupModel group: Abuse group to be processed.
:param list networks: List of network records loaded from reference whois file.
:param list networks: List of network records loaded from reference whois file.
:param str wi_file_type: Value of ``__whois_type__`` meta attribute from reference whois file.
:param dict result: Structure containing processing log, will be appended to script runlog.
:param dict result: Structure containing processing log, will be appended to script runlog.
:param bool status_only: Do not actually perform any database operations, just report status.
:param bool status_only: Do not actually perform any database operations, just report status.
"""
"""
...
@@ -627,7 +630,7 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript):
...
@@ -627,7 +630,7 @@ class MentatNetmngrScript(mentat.script.fetcher.FetcherScript):
group
.
networks
[
index
].
is_base
=
net
[
'
is_base
'
]
group
.
networks
[
index
].
is_base
=
net
[
'
is_base
'
]
for
net
in
group
.
networks
:
for
net
in
group
.
networks
:
if
not
self
.
_is_network_in
(
net
,
networks
):
if
not
self
.
_is_network_in
(
net
,
networks
)
and
wi_file_type
in
net
.
source
:
nkey
=
'
{}::{}
'
.
format
(
net
.
network
,
net
.
source
)
nkey
=
'
{}::{}
'
.
format
(
net
.
network
,
net
.
source
)
result
[
'
delete
'
].
setdefault
(
gkey
,
[]).
append
(
nkey
)
result
[
'
delete
'
].
setdefault
(
gkey
,
[]).
append
(
nkey
)
if
status_only
:
if
status_only
:
...
...
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