Skip to content

Commit f1db396

Browse files
authored
Merge branch 'evilsocket:master' into daemon-go-rule-lists-operators-caching
2 parents 347acea + 0328a25 commit f1db396

65 files changed

Lines changed: 13855 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
.vscode/
66
.idea/
7-
.DS_Store
7+
.DS_Store

ui/opensnitch/dialogs/preferences/dialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def __init__(self, parent=None, appicon=None):
147147
self.helpButton.setIcon(helpIcon)
148148
self.dbFileButton.setIcon(openIcon)
149149

150-
self.comboUIAction.setItemIcon(Config.ACTION_DENY_IDX, denyIcon)
150+
self.comboUIAction.setItemIcon(Config.ACTION_DROP_IDX, denyIcon)
151151
self.comboUIAction.setItemIcon(Config.ACTION_ALLOW_IDX, allowIcon)
152152
self.comboUIAction.setItemIcon(Config.ACTION_REJECT_IDX, rejectIcon)
153153

ui/opensnitch/dialogs/ruleseditor/dialog.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,5 +894,13 @@ def save_rule(self):
894894

895895
if self.ruleNameEdit.text() == "":
896896
self.rule.name = slugify("%s %s %s" % (self.rule.action, self.rule.operator.type, self.rule.operator.data))
897+
elif self._old_rule_name is not None:
898+
# If the rule name was auto-generated (starts with an action prefix),
899+
# and the action has changed, update the prefix to match the new action.
900+
for old_action in (Config.ACTION_ALLOW, Config.ACTION_DENY, Config.ACTION_REJECT):
901+
if self._old_rule_name.startswith(old_action + "-") and old_action != self.rule.action:
902+
self.rule.name = self.rule.action + self._old_rule_name[len(old_action):]
903+
self.ruleNameEdit.setText(self.rule.name)
904+
break
897905

898906
return True, ""
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file is part of OpenSnitch.
2+
#
3+
# OpenSnitch is free software: you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation, either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# OpenSnitch is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with OpenSnitch. If not, see <http://www.gnu.org/licenses/>.
15+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from typing import TYPE_CHECKING, Any, Protocol
2+
3+
if TYPE_CHECKING:
4+
from PyQt6 import QtCore, QtGui, QtWidgets
5+
6+
7+
class RuleOperatorLike(Protocol):
8+
operand: str
9+
data: str | None
10+
list: list["RuleOperatorLike"]
11+
12+
13+
class RuleLike(Protocol):
14+
name: str | None
15+
enabled: bool
16+
operator: RuleOperatorLike
17+
18+
19+
class StatsDialogProto(Protocol):
20+
"""Typed subset of StatsDialog used by the plugin.
21+
22+
actionsButton is injected by uic from stats.ui and otherwise appears
23+
as unknown to static analyzers.
24+
"""
25+
26+
actionsButton: "QtWidgets.QPushButton"
27+
28+
def windowIcon(self) -> "QtGui.QIcon": ...
29+
30+
31+
class RulesEditorDialogProto(Protocol):
32+
"""Typed subset of RulesEditorDialog used by the plugin controllers."""
33+
34+
_old_rule_name: str
35+
buttonBox: "QtWidgets.QDialogButtonBox"
36+
ruleNameEdit: "QtWidgets.QLineEdit"
37+
ruleDescEdit: "QtWidgets.QPlainTextEdit"
38+
nodesCombo: "QtWidgets.QComboBox"
39+
nodeApplyAllCheck: "QtWidgets.QCheckBox"
40+
uidCombo: "QtWidgets.QComboBox"
41+
uidCheck: "QtWidgets.QCheckBox"
42+
enableCheck: "QtWidgets.QCheckBox"
43+
durationCombo: "QtWidgets.QComboBox"
44+
dstListsCheck: "QtWidgets.QCheckBox"
45+
dstListsLine: "QtWidgets.QLineEdit"
46+
47+
def installEventFilter(self, filterObj: "QtCore.QObject") -> None: ...
48+
49+
def hide(self) -> None: ...
50+
51+
def raise_(self) -> None: ...
52+
53+
def activateWindow(self) -> None: ...
54+
55+
def new_rule(self) -> None: ...
56+
57+
def edit_rule(self, records: Any, _addr: str | None = None) -> None: ...
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Runtime compatibility shim for StatsDialog across OpenSnitch versions."""
2+
3+
4+
# Runtime class kept for isinstance checks.
5+
try:
6+
from opensnitch.dialogs.events import StatsDialog
7+
except ImportError:
8+
from opensnitch.dialogs.stats import StatsDialog # type: ignore[assignment]
9+
10+
__all__ = ["StatsDialog"]

0 commit comments

Comments
 (0)