From 2d9e600411555da5fff596e4da5c9b9c5f4f004a Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sun, 26 Jun 2016 15:57:00 +0200 Subject: [PATCH] (ids) re-create database if table count doesn't match --- src/opnsense/scripts/suricata/lib/rulecache.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/opnsense/scripts/suricata/lib/rulecache.py b/src/opnsense/scripts/suricata/lib/rulecache.py index 0c42ac7af..54e32e2c7 100644 --- a/src/opnsense/scripts/suricata/lib/rulecache.py +++ b/src/opnsense/scripts/suricata/lib/rulecache.py @@ -140,9 +140,11 @@ class RuleCache(object): try: db = sqlite3.connect(self.cachefile) cur = db.cursor() + cur.execute("select count(*) from sqlite_master WHERE type='table'") + table_count = cur.fetchall()[0][0] cur.execute('SELECT max(timestamp), max(files) FROM stats') results = cur.fetchall() - if last_mtime == results[0][0] and len(all_rule_files) == results[0][1]: + if last_mtime == results[0][0] and len(all_rule_files) == results[0][1] and table_count == 3: return False except sqlite3.DatabaseError: # if some reason the cache is unreadble, continue and report changed