示例#1
0
    def __ne__(self, other):
        """Compare NessusReportItem with != operator
           :return: Return true if NessusReportItem has changed
           :rtype: Boolean
           :raises: TypeError
        """
        try:
            self.iscomparable(other)
        except TypeError as etyperr:
            raise etyperr

        diff = DictDiffer(self.get_vuln_info, other.get_vuln_info)
        return (len(diff.unchanged()) != len(self.get_vuln_info))
示例#2
0
 def __eq__(self, other):
     """Compare NessusReportItem with == operator
        :return: Return true if NessusReportItem has not changed
        :rtype: Boolean
        :raises: TypeError
     """
     try:
         self.iscomparable(other)
     except TypeError as etyperr:
         raise etyperr
     diff = DictDiffer(self.get_vuln_info, other.get_vuln_info)
     return (len(diff.added()) == 0 and len(diff.removed()) == 0
             and len(diff.changed()) == 0)
示例#3
0
 def diff(self, other):
     '''
     Description: diff object and provide the differences
     :param other: obj to compare to
     :type other: NessusReport
     :return: a dict of all the differences
     :rtype: dict
     '''
     diff = DictDiffer(self.__get_dict(), other.__get_dict())
     rdict = {}
     rdict["removed"] = diff.removed()
     rdict["changed"] = diff.changed()
     rdict["added"] = diff.added()
     rdict["unchanged"] = diff.unchanged()
     return rdict
示例#4
0
 def diff(self, other):
     '''
     Description: compute a diff dict obj
     :param other: the object to compare
     :type other: NessusReportHost
     :return:
     :rtype: dict
     '''
     diff = DictDiffer(self.__get_dict(), other.__get_dict())
     rdict = {}
     rdict["removed"] = diff.removed()
     rdict["changed"] = diff.changed()
     rdict["added"] = diff.added()
     rdict["unchanged"] = diff.unchanged()
     return rdict
示例#5
0
 def diff(self, other):
     """
     Description: Compare two NessusReportItem
     :param other: NessusReportItem
     :type other: NessusReportItem
     :return: a dict of set containing 4 keys unchanged, added,
     removed, changed. these set are the list of the keys in the
     get_vuln_info property that have changed
     :rtype: dict
     :raises: TypeError
     """
     try:
         self.iscomparable(other)
     except TypeError as etyperr:
         raise etyperr
     diff = DictDiffer(self.get_vuln_info, other.get_vuln_info)
     rdict = {}
     rdict["removed"] = diff.removed()
     rdict["changed"] = diff.changed()
     rdict["added"] = diff.added()
     rdict["unchanged"] = diff.unchanged()
     return rdict
 def setUp(self):
     a = {'a': 1, 'b': 1, 'c': 0}
     b = {'a': 1, 'b': 2, 'd': 0}
     self.d = DictDiffer(b, a)