mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
ui:use appimages pattern as default target if found
If the path of a process starts with /tmp/.mount_*, which is the common path for appimages, use it as the default target on the popups. Previously it was only added to the list of targets, but preselecting it will help users to create rules for appimages.
This commit is contained in:
parent
2f1a9b8c9e
commit
016f4842ff
2 changed files with 15 additions and 4 deletions
|
@ -419,10 +419,7 @@ class PromptDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self._default_action = self._cfg.getInt(self._cfg.DEFAULT_ACTION_KEY)
|
||||
_utils.set_default_duration(self._cfg, self.durationCombo)
|
||||
|
||||
if int(con.process_id) > 0 and app_name != "" and app_args != "":
|
||||
self.whatCombo.setCurrentIndex(int(self._cfg.getSettings(self._cfg.DEFAULT_TARGET_KEY)))
|
||||
else:
|
||||
self.whatCombo.setCurrentIndex(2)
|
||||
_utils.set_default_target(self.whatCombo, con, self._cfg, app_name, app_args)
|
||||
|
||||
self.checkDstIP.setChecked(self._cfg.getBool(self._cfg.DEFAULT_POPUP_ADVANCED_DSTIP))
|
||||
self.checkDstPort.setChecked(self._cfg.getBool(self._cfg.DEFAULT_POPUP_ADVANCED_DSTPORT))
|
||||
|
|
|
@ -119,6 +119,20 @@ def set_default_duration(cfg, durationCombo):
|
|||
else:
|
||||
durationCombo.setCurrentIndex(Config.DEFAULT_DURATION_IDX)
|
||||
|
||||
def set_default_target(combo, con, cfg, app_name, app_args):
|
||||
# set appimage as default target if the process path starts with
|
||||
# /tmp/._mount
|
||||
if con.process_path.startswith(_constants.APPIMAGE_PREFIX):
|
||||
idx = combo.findData(_constants.FIELD_APPIMAGE)
|
||||
if idx != -1:
|
||||
combo.setCurrentIndex(idx)
|
||||
return
|
||||
|
||||
if int(con.process_id) > 0 and app_name != "" and app_args != "":
|
||||
combo.setCurrentIndex(int(cfg.getSettings(cfg.DEFAULT_TARGET_KEY)))
|
||||
else:
|
||||
combo.setCurrentIndex(2)
|
||||
|
||||
def get_combo_operator(data, comboText, con):
|
||||
if data == _constants.FIELD_PROC_PATH:
|
||||
return Config.RULE_TYPE_SIMPLE, Config.OPERAND_PROCESS_PATH, con.process_path
|
||||
|
|
Loading…
Add table
Reference in a new issue