diff --git a/ui/opensnitch/customwidgets/generictableview.py b/ui/opensnitch/customwidgets/generictableview.py index 335e1fc9ef..fd7826554e 100644 --- a/ui/opensnitch/customwidgets/generictableview.py +++ b/ui/opensnitch/customwidgets/generictableview.py @@ -739,6 +739,7 @@ def onKeyDown(self): self._rows_selection.clear() self._rows_selection.add(curIdx.data()) + viewport_row = self.getViewportRowPos(curRow) newValue = self.vScrollBar.value() offset = self.model().queryOffset diff --git a/ui/opensnitch/customwidgets/main.py b/ui/opensnitch/customwidgets/main.py index f26434d170..5e811b330f 100644 --- a/ui/opensnitch/customwidgets/main.py +++ b/ui/opensnitch/customwidgets/main.py @@ -236,6 +236,7 @@ def refreshViewport(self, value, maxRowsInViewport): #sequential number of topmost/bottommost rows in viewport (numbering starts from the bottom with 1 not with 0) botRowNo = max(1, self.totalRowCount - (value + maxRowsInViewport-1)) topRowNo = min(botRowNo + maxRowsInViewport-1, self.totalRowCount) + offsetInRange = 0 if not self.isQueryFilter: part1, part2 = self.origQueryStr.split('ORDER') diff --git a/ui/opensnitch/database/__init__.py b/ui/opensnitch/database/__init__.py index e0edcaf80e..735dc10891 100644 --- a/ui/opensnitch/database/__init__.py +++ b/ui/opensnitch/database/__init__.py @@ -450,8 +450,8 @@ def remove(self, qstr, args=None): def _insert(self, query_str, columns): with self._lock: + q = None try: - q = QSqlQuery(self.db) q.prepare(query_str) for idx, v in enumerate(columns): @@ -465,7 +465,8 @@ def _insert(self, query_str, columns): except Exception as e: self.logger.warning("_insert exception: %s", repr(e)) finally: - q.finish() + if q is not None: + q.finish() return False @@ -497,6 +498,7 @@ def update(self, table, fields, values, condition=None, action_on_conflict="OR I qstr = "UPDATE " + action_on_conflict + " " + table + " SET " + fields if condition is not None: qstr += " WHERE " + condition + q = None try: with self._lock: q = QSqlQuery(qstr, self.db) @@ -510,11 +512,13 @@ def update(self, table, fields, values, condition=None, action_on_conflict="OR I except Exception as e: self.logger.warning("update() exception: %s", repr(e)) finally: - q.finish() + if q is not None: + q.finish() def _insert_batch(self, query_str, fields, values): result=True with self._lock: + q = None try: q = QSqlQuery(self.db) q.prepare(query_str) @@ -530,7 +534,8 @@ def _insert_batch(self, query_str, fields, values): except Exception as e: self.logger.warning("_insert_batch() exception: %s", repr(e)) finally: - q.finish() + if q is not None: + q.finish() return result diff --git a/ui/opensnitch/desktop_parser.py b/ui/opensnitch/desktop_parser.py index 2d10cb81c0..5d50bc81b8 100644 --- a/ui/opensnitch/desktop_parser.py +++ b/ui/opensnitch/desktop_parser.py @@ -6,11 +6,10 @@ import re import locale -is_pyinotify_available = True try: import pyinotify except Exception as e: - is_pyinotify_available = False + pyinotify = None print("Error importing pyinotify:", e) DESKTOP_PATHS = tuple([ @@ -47,7 +46,7 @@ def __init__(self): for desktop_file in glob.glob(os.path.join(desktop_path, '*.desktop')): self._parse_desktop_file(desktop_file) - if is_pyinotify_available: + if pyinotify is not None: self.start() def get_locale(self): @@ -179,6 +178,8 @@ def get_info_by_binname(self, name, default_icon): return self.apps.get(def_name, (def_name, default_icon, None)) def run(self): + if pyinotify is None: + return self.running = True wm = pyinotify.WatchManager() notifier = pyinotify.Notifier(wm) diff --git a/ui/opensnitch/dialogs/events/menus.py b/ui/opensnitch/dialogs/events/menus.py index 8aa725ba16..abc6c1ef1d 100644 --- a/ui/opensnitch/dialogs/events/menus.py +++ b/ui/opensnitch/dialogs/events/menus.py @@ -155,6 +155,7 @@ def configure_fwrules_contextual_menu(self, pos): rule_action = model.index(selection[0].row(), FirewallTableModel.COL_ACTION).data() rule_action = rule_action.lower() + _action_accept = _action_drop = _action_reject = _action_return = None nodes_menu = [] if self.nodes_count() > 1: nodes_menu.append( diff --git a/ui/opensnitch/dialogs/events/queries.py b/ui/opensnitch/dialogs/events/queries.py index 9df50468e3..bbf02ed7b0 100644 --- a/ui/opensnitch/dialogs/events/queries.py +++ b/ui/opensnitch/dialogs/events/queries.py @@ -244,6 +244,8 @@ def get_filter_line(self, idx, text, adv_search=None): def get_indetail_filter(self, indetail_view, lastQuery, text, advanced_filter): """builds the query when a tab is in the detail view.""" + base_query = [] + qstr = "" try: cur_idx = self.win.get_current_view_idx() base_query = lastQuery.split("GROUP BY") diff --git a/ui/opensnitch/dialogs/events/views.py b/ui/opensnitch/dialogs/events/views.py index 5a29492e53..f04c499ba2 100644 --- a/ui/opensnitch/dialogs/events/views.py +++ b/ui/opensnitch/dialogs/events/views.py @@ -526,8 +526,8 @@ def on_menu_import_clicked(self, triggered): QtWidgets.QMessageBox.Icon.Warning) def on_cmd_back_clicked(self, idx): + cur_idx = self.get_current_view_idx() try: - cur_idx = self.get_current_view_idx() self.set_in_detail_view(cur_idx, False) self.set_active_widgets(cur_idx, False) diff --git a/ui/opensnitch/dialogs/prompt/dialog.py b/ui/opensnitch/dialogs/prompt/dialog.py index 5197beda16..e0bdd47310 100644 --- a/ui/opensnitch/dialogs/prompt/dialog.py +++ b/ui/opensnitch/dialogs/prompt/dialog.py @@ -441,6 +441,7 @@ def _display_checksums_warning(self, peer, con): self.set_message_style('') self.labelChecksumStatus.setText('') is_valid = True + expected = "" checksums = con.process_checksums expected_list = [] diff --git a/ui/opensnitch/firewall/chains.py b/ui/opensnitch/firewall/chains.py index 759888b96c..a40386d13e 100644 --- a/ui/opensnitch/firewall/chains.py +++ b/ui/opensnitch/firewall/chains.py @@ -14,22 +14,6 @@ def get(self): chains[node] = self.get_node_chains(node) return chains - def get_node_chains(self, addr): - node = self._nodes.get_node(addr) - if node == None: - return rules - if not 'firewall' in node: - return rules - - chains = [] - for c in node['firewall'].SystemRules: - # Chains node does not exist on <= v1.5.x - try: - chains.append(c.Chains) - except Exception: - pass - return chains - def get_node_chains(self, addr): node = self._nodes.get_node(addr) if node is None: @@ -65,10 +49,7 @@ def set_policy(self, node_addr, hook=Hooks.INPUT.value, _type=ChainType.FILTER.v # specify ipv4 OR/AND ipv6? some systems have ipv6 disabled if c.Hook.lower() == hook and c.Type.lower() == _type and c.Family.lower() == family: fwcfg.SystemRules[sdx].Chains[cdx].Policy = policy - - if wantedHook == Fw.Hooks.INPUT.value and wantedPolicy == Fw.Policy.DROP.value: - fwcfg.SystemRules[sdx].Chains[cdx].Rules.extend([rule.Rules[0]]) - self._nodes.add_fw_config(node_addr, fwcfg) + self._nodes.add_fw_config(node_addr, fwcfg) return True return False diff --git a/ui/opensnitch/plugins/__init__.py b/ui/opensnitch/plugins/__init__.py index 8cfdc7f896..6bf946db69 100644 --- a/ui/opensnitch/plugins/__init__.py +++ b/ui/opensnitch/plugins/__init__.py @@ -30,10 +30,6 @@ def connect(self, callback): def disconnect(self, callback): self.signal.disconnect(callback) - #@QtCore.pyqtSlot(dict) - def cb_signal(self, args): - self.signal.disconnect(callback) - class PluginsList(): """plugins store. Whenever a plugin is instantiated, it's added to the plugin list automatically diff --git a/ui/opensnitch/plugins/downloader/downloader.py b/ui/opensnitch/plugins/downloader/downloader.py index 166ae8f44a..b2cf577c1f 100644 --- a/ui/opensnitch/plugins/downloader/downloader.py +++ b/ui/opensnitch/plugins/downloader/downloader.py @@ -100,6 +100,7 @@ def compile(self): interval = ((float(config['interval']) * 60) * 60) * 60 else: logger.warning("compile() unknown time format '{0}'".format(config['units'])) + continue self.scheduled_tasks[config['name']] = self.new_timer(interval, config) except Exception as e: diff --git a/ui/opensnitch/plugins/virustotal/virustotal.py b/ui/opensnitch/plugins/virustotal/virustotal.py index b2618f7ddb..5ddae6585c 100644 --- a/ui/opensnitch/plugins/virustotal/virustotal.py +++ b/ui/opensnitch/plugins/virustotal/virustotal.py @@ -366,6 +366,7 @@ def update_popup(self, what, response, parent, config, conn, errmsg=None): error = (errmsg is not None) malicious = False + verdict = None labelStyle = "color: {0}".format(config['benign-label-style']) try: if error: diff --git a/ui/opensnitch/rules.py b/ui/opensnitch/rules.py index a97229ae31..9ebe64d348 100644 --- a/ui/opensnitch/rules.py +++ b/ui/opensnitch/rules.py @@ -238,6 +238,7 @@ def export_rule(self, node, rule_name, outdir): """Gets the rule from the DB and writes it out to a directory. A new directory per node will be created. """ + rulesdir = outdir try: records = self._db.get_rule(rule_name, node) if records.next() == False: diff --git a/ui/opensnitch/service.py b/ui/opensnitch/service.py index 13a84d98b7..0f65e55323 100644 --- a/ui/opensnitch/service.py +++ b/ui/opensnitch/service.py @@ -481,8 +481,8 @@ def callback_open_clicked(notifObject, action): self._stats_dialog.activateWindow() has_ntfs, ntf_type = self._has_desktop_notifications() + timeout = self._cfg.getInt(Config.DEFAULT_TIMEOUT_KEY, 15) if has_ntfs: - timeout = self._cfg.getInt(Config.DEFAULT_TIMEOUT_KEY, 15) try: self.show_systray_msg( title, @@ -636,6 +636,8 @@ def _is_local_request(self, proto, addr): return False def _build_missed_rule_msg(self, conn, rule, node, hostname): + _title = "" + tmpl = "" try: _title = conn.process_path if _title == "": diff --git a/ui/opensnitch/utils/__init__.py b/ui/opensnitch/utils/__init__.py index 11006c12ca..97f9043560 100644 --- a/ui/opensnitch/utils/__init__.py +++ b/ui/opensnitch/utils/__init__.py @@ -443,6 +443,7 @@ def new(widget, icon_name): def get_by_appname(app_icon): """return the pixmap of an application. """ + pixmap = None try: icon = QtGui.QIcon().fromTheme(app_icon) pixmap = icon.pixmap(icon.actualSize(QtCore.QSize(48, 48)))