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:
Gustavo Iñiguez Goia 2024-01-22 12:54:10 +01:00
parent 2f1a9b8c9e
commit 016f4842ff
Failed to generate hash of commit
2 changed files with 15 additions and 4 deletions

View file

@ -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))

View file

@ -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