From ce54d0bb3f0ee6790f616b66b56e9b5eefb81226 Mon Sep 17 00:00:00 2001 From: Nikolai Prokoschenko Date: Mon, 12 Mar 2018 17:21:19 +0100 Subject: [PATCH] Change setting default parameters to something that will actually work `kwargs.get()` will only use a default parameter if the key is not found, not if it's `None`. In this case, every parameter is being given to the function so we'd actually have to check for the return value of `kwargs.get()` and then set the default. --- openvas_to_report/libs/data/parsed_data.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openvas_to_report/libs/data/parsed_data.py b/openvas_to_report/libs/data/parsed_data.py index 6e3bf9a..d32a4cc 100644 --- a/openvas_to_report/libs/data/parsed_data.py +++ b/openvas_to_report/libs/data/parsed_data.py @@ -197,12 +197,12 @@ def __init__(self, id, name, threat, **kwargs): :raises: TypeError, ValueError """ # Get info - cves = kwargs.get("cves", []) - cvss = kwargs.get("cvss", -1.0) - description = kwargs.get("description", "") - references = kwargs.get("references", []) - level = kwargs.get("level", "low") - family = kwargs.get("family", "unknown") + cves = kwargs.get("cves") or [] + cvss = kwargs.get("cvss") or -1.0 + description = kwargs.get("description") or "" + references = kwargs.get("references") or [] + level = kwargs.get("level") or "low" + family = kwargs.get("family") or "unknown" if not isinstance(id, str): raise TypeError("Expected basestring, got '%s' instead" % type(id)) @@ -307,4 +307,4 @@ def __eq__(self, other): else: return False - return True \ No newline at end of file + return True