prewikka/master: Allow looking up alert/heartbeat with NULL analyzerid

[email protected] Wed, 10 Jun 2009 12:54:04 +0200 (CEST)
Newsgroups gmane.comp.security.ids.prelude.cvs
Message-ID <[email protected]>
commit a2f87109b9a27e7f6ff28e811ea210c38d2d485a
Author: Yoann Vandoorselaere <[email protected]>
Date:   Tue Jun 9 12:35:10 2009 +0200

    Allow looking up alert/heartbeat with NULL analyzerid


========================================

 prewikka/IDMEFDatabase.py |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

========================================

diff --git a/prewikka/IDMEFDatabase.py b/prewikka/IDMEFDatabase.py
index 388f1cb..3b7a562 100644
--- a/prewikka/IDMEFDatabase.py
+++ b/prewikka/IDMEFDatabase.py
@@ -406,17 +406,20 @@ class IDMEFDatabase:
 
     def _getLastMessageIdent(self, type, get_message_idents, analyzerid):
         criteria = None
-        if analyzerid != None:
-            criteria = "%s.analyzer(-1).analyzerid == '%s'" % (type, str(analyzerid))
+        if analyzerid is not False:
+            if analyzerid is None:
+                criteria = "! %s.analyzer(-1).analyzerid" % (type)
+            else:
+                criteria = "%s.analyzer(-1).analyzerid == '%s'" % (type, str(analyzerid))
 
         idents = get_message_idents(criteria, limit=1)
 
         return idents[0]
 
-    def getLastAlertIdent(self, analyzer=None):
+    def getLastAlertIdent(self, analyzer=False):
         return self._getLastMessageIdent("alert", self.getAlertIdents, analyzer)
 
-    def getLastHeartbeatIdent(self, analyzer=None):
+    def getLastHeartbeatIdent(self, analyzer=False):
         return self._getLastMessageIdent("heartbeat", self.getHeartbeatIdents, analyzer)
 
     def getAlert(self, ident, htmlsafe=False):
_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog