Skip to content

Commit 35ce27f

Browse files
olethanhnesitor
authored andcommitted
fix supervisor-filter rule recreating
1 parent 63eeaf8 commit 35ce27f

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

src/aleph/vm/network/firewall.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,19 @@ def is_entity_present(nft_ruleset: list[dict], t: EntityType, **kwargs) -> bool:
113113

114114

115115
def _is_superset(a, b):
116-
for k, v in a.items():
117-
if b.get(k) != v:
116+
if isinstance(a, dict) and isinstance(b, dict):
117+
for k, v in a.items():
118+
if k not in b:
119+
return False
120+
if not _is_superset(v, b[k]):
121+
return False
122+
return True
123+
elif isinstance(a, list) and isinstance(b, list):
124+
if len(a) != len(b):
118125
return False
119-
return True
126+
return all(_is_superset(x, y) for x, y in zip(a, b))
127+
else:
128+
return a == b
120129

121130

122131
def if_chain_exists(nft_ruleset: list[dict], family: str, table: str, name: str) -> bool:
@@ -285,7 +294,7 @@ def initialize_nftables() -> None:
285294
"match": {
286295
"op": "in",
287296
"left": {"ct": {"key": "state"}},
288-
"right": ["related", "established"],
297+
"right": ["established", "related"],
289298
}
290299
},
291300
{"accept": None},

0 commit comments

Comments
 (0)