test without handle
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 8s
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 8s
This commit is contained in:
@@ -324,6 +324,18 @@ def parse_ruleset_text(nft_text: str) -> Dict[Tuple[str, str, str], List[Dict[st
|
||||
return result
|
||||
|
||||
|
||||
def clean_rule_line(line: str) -> str:
|
||||
"""
|
||||
Remove trailing ' # handle <num>' from a textual rule line.
|
||||
This strips the handle comment part while preserving the rest of the line.
|
||||
"""
|
||||
if not line:
|
||||
return line
|
||||
# remove ' # handle 123' optionally preceded by spaces and possibly at end-of-line
|
||||
cleaned = re.sub(r"\s+#\s*handle\s*\d+\b\s*$", "", line)
|
||||
return cleaned
|
||||
|
||||
|
||||
def populate_text_from_ruleset_text(custom: Dict[str, Any], nft_text: str) -> None:
|
||||
"""
|
||||
Enrich JSON-derived 'custom' structure in-place by setting only rule['text']
|
||||
@@ -380,11 +392,12 @@ def populate_text_from_ruleset_text(custom: Dict[str, Any], nft_text: str) -> No
|
||||
break
|
||||
|
||||
if mapped is not None:
|
||||
# ensure we only write a str into 'text'
|
||||
# clean the handle fragment from the textual line before storing
|
||||
try:
|
||||
rule["text"] = str(mapped)
|
||||
cleaned = clean_rule_line(str(mapped))
|
||||
rule["text"] = cleaned
|
||||
except Exception:
|
||||
rule["text"] = mapped # should be str already
|
||||
rule["text"] = mapped # fallback (should be str)
|
||||
|
||||
|
||||
# ---------- Normalization helper (lightweight and safe) ----------
|
||||
|
||||
Reference in New Issue
Block a user