mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 16:44:46 +01:00
Merge branch 'ui2.0' into main
This commit is contained in:
commit
8a2fe51abe
6 changed files with 80 additions and 38 deletions
|
@ -62,6 +62,7 @@ class Database:
|
|||
"pid text, " \
|
||||
"process text, " \
|
||||
"process_args text, " \
|
||||
"process_cwd text, " \
|
||||
"rule text, " \
|
||||
"UNIQUE(node, action, protocol, src_ip, src_port, dst_ip, dst_port, uid, pid, process, process_args))",
|
||||
self.db)
|
||||
|
|
|
@ -183,6 +183,12 @@ class PromptDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
|
||||
def _render_connection(self, con):
|
||||
app_name, app_icon, _ = self._apps_parser.get_info_by_path(con.process_path, "terminal")
|
||||
if app_name != con.process_path and con.process_path not in con.process_args:
|
||||
self.appPathLabel.setFixedHeight(20)
|
||||
self.appPathLabel.setText("(%s)" % con.process_path)
|
||||
else:
|
||||
self.appPathLabel.setFixedHeight(1)
|
||||
self.appPathLabel.setText("")
|
||||
|
||||
if app_name == "":
|
||||
app_name = "Unknown process"
|
||||
|
|
|
@ -122,6 +122,7 @@ class RulesEditorDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
return False
|
||||
|
||||
def _reset_state(self):
|
||||
self.ruleNameEdit.setText("")
|
||||
self.statusLabel.setText("")
|
||||
|
||||
self.actionDenyRadio.setChecked(True)
|
||||
|
|
|
@ -729,7 +729,8 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
"c.dst_host as DstHost, " \
|
||||
"c.dst_port as DstPort, " \
|
||||
"c.process || ' (' || c.pid || ')' as Process, " \
|
||||
"c.process_args as Args " \
|
||||
"c.process_args as Args, " \
|
||||
"c.process_cwd as CWD " \
|
||||
"FROM nodes as n, connections as c " \
|
||||
"WHERE n.addr = '%s' %s GROUP BY Process, Args, UserID, DstIP, DstHost, DstPort, Protocol, Status %s" % (data, s, self._get_order()))
|
||||
|
||||
|
@ -752,7 +753,8 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
"c.dst_port as DstPort, " \
|
||||
"c.dst_host as DstIP, " \
|
||||
"c.process as Process, " \
|
||||
"c.process_args as Args " \
|
||||
"c.process_args as Args, " \
|
||||
"c.process_cwd as CWD " \
|
||||
"FROM rules as r, connections as c " \
|
||||
"WHERE %s r.name = '%s' AND r.name = c.rule AND r.node = c.node GROUP BY Process, Args, UserID, DstIP, DstPort %s" % (node, data, self._get_order()))
|
||||
|
||||
|
@ -769,6 +771,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
"c.dst_ip as DstIP, " \
|
||||
"c.process || ' (' || c.pid || ')' as Process, " \
|
||||
"c.process_args as Args, " \
|
||||
"c.process_cwd as CWD, " \
|
||||
"c.rule as Rule " \
|
||||
"FROM hosts as h, connections as c " \
|
||||
"WHERE h.what = '%s' AND c.dst_host = h.what GROUP BY c.pid, Process, Args, DstIP, DstPort, Protocol, Action, Node %s" % (data, self._get_order()))
|
||||
|
@ -784,6 +787,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
"c.dst_host || ' -> ' || c.dst_port as Destination, " \
|
||||
"c.pid as PID, " \
|
||||
"c.process_args as Args, " \
|
||||
"c.process_cwd as CWD, " \
|
||||
"c.rule as Rule " \
|
||||
"FROM procs as p, connections as c " \
|
||||
"WHERE p.what = '%s' AND p.what = c.process GROUP BY c.dst_ip, c.dst_host, c.dst_port, UserID, Action, Node %s" % (data, self._get_order()))
|
||||
|
@ -801,6 +805,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
"c.dst_port as DstPort, " \
|
||||
"c.process || ' (' || c.pid || ')' as Process, " \
|
||||
"c.process_args as Args, " \
|
||||
"c.process_cwd as CWD, " \
|
||||
"c.rule as Rule " \
|
||||
"FROM addrs as a, connections as c " \
|
||||
"WHERE a.what = '%s' AND c.dst_ip = a.what GROUP BY c.pid, Process, Args, DstPort, DstHost, Protocol, Action, UserID, Node %s" % (data, self._get_order()))
|
||||
|
@ -818,6 +823,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
"c.dst_host as DstHost, " \
|
||||
"c.process || ' (' || c.pid || ')' as Process, " \
|
||||
"c.process_args as Args, " \
|
||||
"c.process_cwd as CWD, " \
|
||||
"c.rule as Rule " \
|
||||
"FROM ports as p, connections as c " \
|
||||
"WHERE p.what = '%s' AND c.dst_port = p.what GROUP BY c.pid, Process, Args, DstHost, DstIP, Protocol, Action, UserID, Node %s" % (data, self._get_order()))
|
||||
|
@ -835,6 +841,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
"c.dst_port as DstPort, " \
|
||||
"c.process || ' (' || c.pid || ')' as Process, " \
|
||||
"c.process_args as Args, " \
|
||||
"c.process_cwd as CWD, " \
|
||||
"c.rule as Rule " \
|
||||
"FROM users as u, connections as c " \
|
||||
"WHERE u.what = '%s' AND u.what LIKE '%%(' || c.uid || ')' GROUP BY c.pid, Process, Args, DstIP, DstHost, DstPort, Protocol, Action, Node %s" % (data, self._get_order()))
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>540</width>
|
||||
<width>536</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -83,7 +83,7 @@
|
|||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -520,7 +520,7 @@
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="emblem-important">
|
||||
<normaloff>../../../../../../../../../../../../../../.designer/backup</normaloff>../../../../../../../../../../../../../../.designer/backup</iconset>
|
||||
<normaloff>../../../../../../../../../../../../../../../../../../../../.designer/backup</normaloff>../../../../../../../../../../../../../../../../../../../../.designer/backup</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -549,7 +549,7 @@
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="emblem-default">
|
||||
<normaloff>../../../../../../../../../../../../../../.designer/backup</normaloff>../../../../../../../../../../../../../../.designer/backup</iconset>
|
||||
<normaloff>../../../../../../../../../../../../../../../../../../../../.designer/backup</normaloff>../../../../../../../../../../../../../../../../../../../../.designer/backup</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -649,36 +649,6 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="argsLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>/opt/google/chrome/bin/chrome --something abc --more-long def --for-word-wrapping</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="appNameLabel">
|
||||
<property name="sizePolicy">
|
||||
|
@ -708,6 +678,55 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="argsLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>/opt/google/chrome/bin/chrome --something abc --more-long def --for-word-wrapping</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="appPathLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>(/path/to/bin/chromium)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -123,6 +123,7 @@ class UIService(ui_pb2_grpc.UIServicer, QtWidgets.QGraphicsObject):
|
|||
|
||||
self._tray = QtWidgets.QSystemTrayIcon(self.off_icon)
|
||||
self._tray.setContextMenu(self._menu)
|
||||
self._tray.activated.connect(self._on_tray_icon_activated)
|
||||
|
||||
self._menu.addAction("Help").triggered.connect(
|
||||
lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(Config.HELP_URL))
|
||||
|
@ -135,6 +136,13 @@ class UIService(ui_pb2_grpc.UIServicer, QtWidgets.QGraphicsObject):
|
|||
if not self._tray.isSystemTrayAvailable():
|
||||
self._stats_dialog.show()
|
||||
|
||||
def _on_tray_icon_activated(self, reason):
|
||||
if reason == QtWidgets.QSystemTrayIcon.Trigger or reason == QtWidgets.QSystemTrayIcon.MiddleClick:
|
||||
if self._stats_dialog.isVisible():
|
||||
self._stats_dialog.hide()
|
||||
else:
|
||||
self._stats_dialog.show()
|
||||
|
||||
def _on_close(self):
|
||||
self._exit = True
|
||||
self._on_exit()
|
||||
|
@ -285,13 +293,13 @@ class UIService(ui_pb2_grpc.UIServicer, QtWidgets.QGraphicsObject):
|
|||
need_refresh=True
|
||||
# FIXME Since every node may have different time, and the daemon doesn't send the unix timestamp, use the time we insert it in the db
|
||||
db.insert("connections",
|
||||
"(time, node, action, protocol, src_ip, src_port, dst_ip, dst_host, dst_port, uid, pid, process, process_args, rule)",
|
||||
"(time, node, action, protocol, src_ip, src_port, dst_ip, dst_host, dst_port, uid, pid, process, process_args, process_cwd, rule)",
|
||||
(str(datetime.now()), "%s:%s" % (proto, addr), event.rule.action,
|
||||
event.connection.protocol, event.connection.src_ip, str(event.connection.src_port),
|
||||
event.connection.dst_ip, event.connection.dst_host, str(event.connection.dst_port),
|
||||
str(event.connection.user_id), str(event.connection.process_id),
|
||||
event.connection.process_path, " ".join(event.connection.process_args),
|
||||
event.rule.name),
|
||||
event.connection.process_cwd, event.rule.name),
|
||||
action_on_conflict="IGNORE"
|
||||
)
|
||||
# TODO: move to nodes.add_node()
|
||||
|
|
Loading…
Add table
Reference in a new issue