Skip to content

Commit

Permalink
Merge pull request #1467 from p-l-/fix-diff-categories
Browse files Browse the repository at this point in the history
DB/Mongo: fix .diff_categories() addr values
  • Loading branch information
p-l- committed Jan 7, 2023
2 parents af08a65 + fa76e48 commit 72e21f3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ivre/db/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# This file is part of IVRE.
# Copyright 2011 - 2022 Pierre LALET <pierre@droids-corp.org>
# Copyright 2011 - 2023 Pierre LALET <pierre@droids-corp.org>
#
# IVRE is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -4304,8 +4304,7 @@ def _features_port_list_pipeline(self, flt, use_service, use_product, use_versio
)

def diff_categories(self, category1, category2, flt=None, include_both_open=True):
"""`category1` and `category2` must be categories (provided as str or
unicode objects)
"""`category1` and `category2` must be categories (provided as str objects)
Returns a generator of tuples:
({'addr': address, 'proto': protocol, 'port': port}, value)
Expand Down Expand Up @@ -4367,7 +4366,12 @@ def categories_to_val(categories):
return (state2 > state1) - (state2 < state1)

cursor = (
dict(x["_id"], value=categories_to_val(x["categories"])) for x in cursor
dict(
x["_id"],
addr=self.internal2ip(x["_id"]["addr"]),
value=categories_to_val(x["categories"]),
)
for x in cursor
)
if include_both_open:
return cursor
Expand Down

0 comments on commit 72e21f3

Please sign in to comment.