Skip to content

Commit

Permalink
ui: display all fields in the details of a view
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-iniguez-goya committed Dec 23, 2024
1 parent 2b3028e commit 906b225
Showing 1 changed file with 93 additions and 60 deletions.
153 changes: 93 additions & 60 deletions ui/opensnitch/dialogs/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2190,23 +2190,29 @@ def _set_nodes_query(self, data):
"count(c.process) as {2}, " \
"c.uid as {3}, " \
"c.protocol as {4}, " \
"c.dst_ip as {5}, " \
"c.dst_host as {6}, " \
"c.dst_port as {7}, " \
"c.process || ' (' || c.pid || ')' as {8}, " \
"c.process_args as {9}, " \
"c.src_port as {5}, " \
"c.src_ip as {6}, " \
"c.dst_ip as {7}, " \
"c.dst_host as {8}, " \
"c.dst_port as {9}, " \
"c.pid as {10}, " \
"c.process as {11}, " \
"c.process_args as {12}, " \
"c.process_cwd as CWD, " \
"c.rule as {10} " \
"c.rule as {13} " \
"FROM connections as c " \
"WHERE c.node = '{11}' GROUP BY {12}, c.process_args, c.uid, c.src_ip, c.dst_ip, c.dst_host, c.dst_port, c.protocol {13}".format(
"WHERE c.node = '{14}' GROUP BY {15}, c.process_args, c.uid, c.src_ip, c.dst_ip, c.dst_host, c.dst_port, c.protocol {16}".format(
self.COL_STR_TIME,
self.COL_STR_ACTION,
self.COL_STR_HITS,
self.COL_STR_UID,
self.COL_STR_PROTOCOL,
self.COL_STR_SRC_PORT,
self.COL_STR_SRC_IP,
self.COL_STR_DST_IP,
self.COL_STR_DST_HOST,
self.COL_STR_DST_PORT,
self.COL_STR_PID,
self.COL_STR_PROCESS,
self.COL_STR_PROC_CMDLINE,
self.COL_STR_RULE,
Expand Down Expand Up @@ -2338,22 +2344,28 @@ def _set_rules_query(self, rule_name="", node=""):
"count(c.process) as {2}, " \
"c.uid as {3}, " \
"c.protocol as {4}, " \
"c.dst_port as {5}, " \
"c.dst_ip as {6}, " \
"c.dst_host as {7}, " \
"c.process as {8}, " \
"c.process_args as {9}, " \
"c.src_port as {5}, " \
"c.src_ip as {6}, " \
"c.dst_ip as {7}, " \
"c.dst_host as {8}, " \
"c.dst_port as {9}, " \
"c.pid as {10}, " \
"c.process as {11}, " \
"c.process_args as {12}, " \
"c.process_cwd as CWD " \
"FROM connections as c " \
"WHERE {10} GROUP BY c.process, c.process_args, c.uid, c.dst_ip, c.dst_host, c.dst_port {11}".format(
"WHERE {13} GROUP BY c.process, c.process_args, c.uid, c.dst_ip, c.dst_host, c.dst_port {14}".format(
self.COL_STR_TIME,
self.COL_STR_NODE,
self.COL_STR_HITS,
self.COL_STR_UID,
self.COL_STR_PROTOCOL,
self.COL_STR_DST_PORT,
self.COL_STR_SRC_PORT,
self.COL_STR_SRC_IP,
self.COL_STR_DST_IP,
self.COL_STR_DST_HOST,
self.COL_STR_DST_PORT,
self.COL_STR_PID,
self.COL_STR_PROCESS,
self.COL_STR_PROC_CMDLINE,
condition,
Expand All @@ -2369,22 +2381,28 @@ def _set_hosts_query(self, data):
"c.action as {3}, " \
"c.uid as {4}, " \
"c.protocol as {5}, " \
"c.dst_port as {6}, " \
"c.dst_ip as {7}, " \
"c.process || ' (' || c.pid || ')' as {8}, " \
"c.process_args as {9}, " \
"c.src_port as {6}, " \
"c.src_ip as {7}, " \
"c.dst_ip as {9}, " \
"c.dst_port as {8}, " \
"c.pid as {10}, " \
"c.process as {11}, " \
"c.process_args as {12}, " \
"c.process_cwd as CWD, " \
"c.rule as {10} " \
"c.rule as {13} " \
"FROM connections as c " \
"WHERE c.dst_host = '{11}' GROUP BY c.pid, {12}, c.process_args, c.src_ip, c.dst_ip, c.dst_port, c.protocol, c.action, c.node {13}".format(
"WHERE c.dst_host = '{14}' GROUP BY c.pid, {15}, c.process_args, c.src_ip, c.dst_ip, c.dst_port, c.protocol, c.action, c.node {16}".format(
self.COL_STR_TIME,
self.COL_STR_NODE,
self.COL_STR_HITS,
self.COL_STR_ACTION,
self.COL_STR_UID,
self.COL_STR_PROTOCOL,
self.COL_STR_DST_PORT,
self.COL_STR_SRC_PORT,
self.COL_STR_SRC_IP,
self.COL_STR_DST_IP,
self.COL_STR_DST_PORT,
self.COL_STR_PID,
self.COL_STR_PROCESS,
self.COL_STR_PROC_CMDLINE,
self.COL_STR_RULE,
Expand All @@ -2401,24 +2419,28 @@ def _set_process_query(self, data):
"c.action as {3}, " \
"c.uid as {4}, " \
"c.protocol as {5}, " \
"c.dst_ip as {6}, " \
"c.dst_host as {7}, " \
"c.dst_port as {8}, " \
"c.src_port as {6}, " \
"c.src_ip as {7}, " \
"c.dst_ip as {8}, " \
"c.dst_host as {9}, " \
"c.dst_port as {10}, " \
"c.pid as PID, " \
"c.process_args as {9}, " \
"c.process_args as {11}, " \
"c.process_cwd as CWD, " \
"c.rule as {10} " \
"c.rule as {12} " \
"FROM connections as c " \
"WHERE c.process = '{11}' " \
"GROUP BY c.src_ip, c.dst_ip, c.dst_host, c.dst_port, c.uid, c.action, c.node, c.pid, c.process_args {12}".format(
"WHERE c.process = '{13}' " \
"GROUP BY c.src_ip, c.dst_ip, c.dst_host, c.dst_port, c.uid, c.action, c.node, c.pid, c.process_args {14}".format(
self.COL_STR_TIME,
self.COL_STR_NODE,
self.COL_STR_HITS,
self.COL_STR_ACTION,
self.COL_STR_UID,
self.COL_STR_PROTOCOL,
self.COL_STR_SRC_PORT,
self.COL_STR_SRC_IP,
self.COL_STR_DST_IP,
self.COL_STR_DESTINATION,
self.COL_STR_DST_HOST,
self.COL_STR_DST_PORT,
self.COL_STR_PROC_CMDLINE,
self.COL_STR_RULE,
Expand All @@ -2437,31 +2459,34 @@ def _set_addrs_query(self, data):
"c.action as {3}, " \
"c.uid as {4}, " \
"c.protocol as {5}, " \
"CASE c.dst_host WHEN ''" \
" THEN c.dst_ip " \
" ELSE c.dst_host " \
"END {6}, " \
"c.dst_port as {7}, " \
"c.process || ' (' || c.pid || ')' as {8}, " \
"c.process_args as {9}, " \
"c.src_port as {6}, " \
"c.src_ip as {7}, " \
"c.dst_host as {8}, " \
"c.dst_port as {9}, " \
"c.pid as {10}, " \
"c.process as {11}, " \
"c.process_args as {12}, " \
"c.process_cwd as CWD, " \
"c.rule as {10} " \
"c.rule as {13} " \
"FROM connections as c " \
"WHERE c.dst_ip = '{11}' GROUP BY c.pid, {12}, c.process_args, c.src_ip, c.dst_port, {13}, c.protocol, c.action, c.uid, c.node {14}".format(
"WHERE c.dst_ip = '{14}' GROUP BY c.pid, {15}, c.process_args, c.src_ip, c.dst_port, {16}, c.protocol, c.action, c.uid, c.node {17}".format(
self.COL_STR_TIME,
self.COL_STR_NODE,
self.COL_STR_HITS,
self.COL_STR_ACTION,
self.COL_STR_UID,
self.COL_STR_PROTOCOL,
self.COL_STR_DESTINATION,
self.COL_STR_SRC_PORT,
self.COL_STR_SRC_IP,
self.COL_STR_DST_HOST,
self.COL_STR_DST_PORT,
self.COL_STR_PID,
self.COL_STR_PROCESS,
self.COL_STR_PROC_CMDLINE,
self.COL_STR_RULE,
data,
self.COL_STR_PROCESS,
self.COL_STR_DESTINATION,
self.COL_STR_DST_HOST,
self._get_order("1") + self._get_limit()))

def _set_ports_query(self, data):
Expand All @@ -2473,31 +2498,34 @@ def _set_ports_query(self, data):
"c.action as {3}, " \
"c.uid as {4}, " \
"c.protocol as {5}, " \
"c.dst_ip as {6}, " \
"CASE c.dst_host WHEN ''" \
" THEN c.dst_ip " \
" ELSE c.dst_host " \
"END {7}, " \
"c.process || ' (' || c.pid || ')' as {8}, " \
"c.process_args as {9}, " \
"c.src_port as {6}, " \
"c.src_ip as {7}, " \
"c.dst_ip as {8}, " \
"c.dst_host as {9}, " \
"c.pid as {10}, " \
"c.process as {11}, " \
"c.process_args as {12}, " \
"c.process_cwd as CWD, " \
"c.rule as {10} " \
"c.rule as {13} " \
"FROM connections as c " \
"WHERE c.dst_port = '{11}' GROUP BY c.pid, {12}, c.process_args, {13}, c.src_ip, c.dst_ip, c.protocol, c.action, c.uid, c.node {14}".format(
"WHERE c.dst_port = '{14}' GROUP BY c.pid, {15}, c.process_args, {16}, c.src_ip, c.dst_ip, c.protocol, c.action, c.uid, c.node {17}".format(
self.COL_STR_TIME,
self.COL_STR_NODE,
self.COL_STR_HITS,
self.COL_STR_ACTION,
self.COL_STR_UID,
self.COL_STR_PROTOCOL,
self.COL_STR_SRC_PORT,
self.COL_STR_SRC_IP,
self.COL_STR_DST_IP,
self.COL_STR_DESTINATION,
self.COL_STR_DST_HOST,
self.COL_STR_PID,
self.COL_STR_PROCESS,
self.COL_STR_PROC_CMDLINE,
self.COL_STR_RULE,
data,
self.COL_STR_PROCESS,
self.COL_STR_DESTINATION,
self.COL_STR_DST_HOST,
self._get_order("1") + self._get_limit()))

def _set_users_query(self, data):
Expand All @@ -2509,28 +2537,33 @@ def _set_users_query(self, data):
model = self._get_active_table().model()
self.setQuery(model, "SELECT " \
"MAX(c.time) as {0}, " \
"c.uid, " \
"c.node as {1}, " \
"count(c.dst_ip) as {2}, " \
"c.action as {3}, " \
"c.protocol as {4}, " \
"c.dst_ip as {5}, " \
"c.dst_host as {6}, " \
"c.dst_port as {7}, " \
"c.process || ' (' || c.pid || ')' as {8}, " \
"c.process_args as {9}, " \
"c.src_port as {5}, " \
"c.src_ip as {6}, " \
"c.dst_ip as {7}, " \
"c.dst_host as {8}, " \
"c.dst_port as {9}, " \
"c.pid as {10}, " \
"c.process as {11}, " \
"c.process_args as {12}, " \
"c.process_cwd as CWD, " \
"c.rule as {10} " \
"c.rule as {13} " \
"FROM connections as c " \
"WHERE c.uid = '{11}' GROUP BY c.pid, {12}, c.process_args, c.src_ip, c.dst_ip, c.dst_host, c.dst_port, c.protocol, c.action, c.node {13}".format(
"WHERE c.uid = '{14}' GROUP BY c.pid, {15}, c.process_args, c.src_ip, c.dst_ip, c.dst_host, c.dst_port, c.protocol, c.action, c.node {16}".format(
self.COL_STR_TIME,
self.COL_STR_NODE,
self.COL_STR_HITS,
self.COL_STR_ACTION,
self.COL_STR_PROTOCOL,
self.COL_STR_SRC_PORT,
self.COL_STR_SRC_IP,
self.COL_STR_DST_IP,
self.COL_STR_DESTINATION,
self.COL_STR_DST_HOST,
self.COL_STR_DST_PORT,
self.COL_STR_PID,
self.COL_STR_PROCESS,
self.COL_STR_PROC_CMDLINE,
self.COL_STR_RULE,
Expand Down

0 comments on commit 906b225

Please sign in to comment.