Skip to content

Commit

Permalink
Merge pull request #759 from p-l-/elastic-change-indexname
Browse files Browse the repository at this point in the history
DB/Elastic/View: change default indexname to "views"
  • Loading branch information
p-l- committed Aug 26, 2019
2 parents 9695efb + b7a73df commit f76c448
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 6 additions & 0 deletions ivre/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class DB(object):
"""
globaldb = None
ipaddr_fields = []

def __init__(self):
self.argparser = utils.ArgparserParent()
Expand Down Expand Up @@ -592,6 +593,9 @@ def cmp_schema_version(*_):


class DBActive(DB):

ipaddr_fields = ["addr", "traces.hops.ipaddr", "ports.state_reason_ip"]

def __init__(self):
super(DBActive, self).__init__()
self._schema_migrations = {
Expand Down Expand Up @@ -1847,6 +1851,8 @@ def update(self, timestamp):

class DBPassive(DB):

ipaddr_fields = ["addr"]

def __init__(self):
super(DBPassive, self).__init__()
self.argparser.add_argument('--sensor')
Expand Down
6 changes: 2 additions & 4 deletions ivre/db/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ def searchhosts(cls, hosts, neg=False):
class ElasticDBActive(ElasticDB, DBActive):

mappings = [
{
"addr": {"type": "ip"},
},
dict((field, {"type": "ip"}) for field in DBActive.ipaddr_fields),
]
index_hosts = 0

Expand Down Expand Up @@ -190,7 +188,7 @@ class ElasticDBView(ElasticDBActive, DBView):
def __init__(self, url):
super(ElasticDBView, self).__init__(url)
self.indexes = ['%s%s' % (self.index_prefix,
self.params.pop('indexname_hosts', 'hosts'))]
self.params.pop('indexname_hosts', 'views'))]

def store_or_merge_host(self, host):
if not self.merge_host(host):
Expand Down
3 changes: 0 additions & 3 deletions ivre/db/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class MongoDB(DB):
schema_latest_versions = []
hint_indexes = []
needunwind = []
ipaddr_fields = []
no_limit = 0

def __init__(self, url):
Expand Down Expand Up @@ -786,7 +785,6 @@ def searchcmp(key, val, cmpop):

class MongoDBActive(MongoDB, DBActive):

ipaddr_fields = ["addr", "traces.hops.ipaddr", "state_reason_ip"]
needunwind = [
"categories",
"cpes",
Expand Down Expand Up @@ -3605,7 +3603,6 @@ def store_or_merge_host(self, host):
class MongoDBPassive(MongoDB, DBPassive):

needunwind = ["infos.san"]
ipaddr_fields = ["addr"]
column_passive = 0
_features_column = 0
indexes = [
Expand Down

0 comments on commit f76c448

Please sign in to comment.