Skip to content

Commit 19b14fe

Browse files
committed
Set full command as default for dangerous binaries
For commands that should not be blanket-allowed like curl or wget, set the "this command line only" as default target for rules
1 parent 728e609 commit 19b14fe

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

ui/opensnitch/dialogs/prompt/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
APPIMAGE_PREFIX = "/tmp/.mount_"
3434
SNAP_PREFIX = "/snap"
35+
FULL_COMMAND_BIN = ["python", "curl", "wget", "node", "java"]
3536

3637
# label displayed in the pop-up combo
3738
DURATION_session = QC.translate("popups", "until reboot")

ui/opensnitch/dialogs/prompt/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from slugify import slugify
22
import os
33
import ipaddress
4+
from pathlib import Path
45

56
from PyQt6.QtCore import QCoreApplication as QC
67

@@ -230,6 +231,7 @@ def set_default_duration(cfg, durationCombo):
230231
def set_default_target(combo, con, cfg, app_name, app_args):
231232
# set appimage as default target if the process path starts with
232233
# /tmp/._mount
234+
connection_path = Path(con.process_path)
233235
if con.process_path.startswith(constants.APPIMAGE_PREFIX):
234236
idx = combo.findData(constants.FIELD_APPIMAGE)
235237
if idx != -1:
@@ -240,6 +242,11 @@ def set_default_target(combo, con, cfg, app_name, app_args):
240242
if idx != -1:
241243
combo.setCurrentIndex(idx)
242244
return
245+
# entire command as default target for "dangerous" commands
246+
# (e.g. curl, wget, node)
247+
elif any(bin in connection_path.name for bin in constants.FULL_COMMAND_BIN):
248+
combo.setCurrentIndex(1)
249+
return
243250

244251
if int(con.process_id) > 0 and app_name != "" and app_args != "":
245252
combo.setCurrentIndex(int(cfg.getSettings(cfg.DEFAULT_TARGET_KEY)))

0 commit comments

Comments
 (0)