Merge pull request #3 from apache/base-exception
Don't catch BaseException
diff --git a/client/blocky.py b/client/blocky.py
index c49c079..6403fbd 100644
--- a/client/blocky.py
+++ b/client/blocky.py
@@ -229,7 +229,7 @@
try:
actions = requests.get(apiurl).json()
syslog.syslog(syslog.LOG_INFO, "Fetched a total of %u firewall actions from %s" % (len(actions), apiurl))
- except:
+ except Exception: # TODO: narrow further to expected Exceptions
syslog.syslog(syslog.LOG_WARNING, "Could not retrieve blocky actions list from %s - server down??!" % apiurl)
whitelist = [] # Things we are unbanning, and thus shouldn't just ban right again
diff --git a/server/api/handler.py b/server/api/handler.py
index 77a833a..24356ad 100644
--- a/server/api/handler.py
+++ b/server/api/handler.py
@@ -50,7 +50,7 @@
try:
print("Removing BG thread pid file...")
os.unlink(pidfile)
- except:
+ except Exception: # TODO: narrow further to expected Exceptions
pass
if not os.path.exists(pidfile) or os.path.getmtime(pidfile) < (now - 60):
@@ -168,7 +168,7 @@
}, indent = 4) + "\n"
return
- except:
+ except Exception: # TODO: narrow further to expected Exceptions
err_type, err_value, tb = sys.exc_info()
traceback_output = ['API traceback:']
traceback_output += traceback.format_tb(tb)
@@ -177,7 +177,7 @@
try:
start_response('500 Internal Server Error', [
('Content-Type', 'application/json')])
- except:
+ except Exception: # TODO: narrow further to expected Exceptions
pass
yield json.dumps({
"API": "Blocky API 1.0",
@@ -216,7 +216,7 @@
session.headers.append(bucket)
try:
start_response("200 Okay", session.headers)
- except:
+ except Exception: # TODO: narrow further to expected Exceptions
pass
a += 1
# WSGI prefers byte strings, so convert if regular py3 string
diff --git a/server/api/plugins/session.py b/server/api/plugins/session.py
index 19f4c17..4555685 100644
--- a/server/api/plugins/session.py
+++ b/server/api/plugins/session.py
@@ -47,7 +47,7 @@
self.DB.ES.delete(index=self.DB.dbname, doc_type='uisession', id = self.cookie)
self.cookie = None
self.user = None
- except:
+ except Exception: # TODO: narrow further to expected Exceptions
pass
def newCookie(self):
cookie = uuid.uuid4()
diff --git a/server/api/plugins/worker.py b/server/api/plugins/worker.py
index b696bd7..9ffff9c 100644
--- a/server/api/plugins/worker.py
+++ b/server/api/plugins/worker.py
@@ -343,7 +343,7 @@
rdns = bad_ip['ip']
try:
rdns = socket.gethostbyaddr(bad_ip['ip'])[0]
- except:
+ except Exception: # Don't catch fatal exceptions
pass # don't care, at all
bad_ip['dns'] = rdns if rdns else bad_ip['ip']
print("Banning %s as %s" % (bad_ip['ip'], banid))