feat: readable firewall rule expressions - #5
Merged
Conversation
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Firewall page showed each rule's body as raw nftables JSON, which is unreadable. This renders it in nft-like syntax instead.
services/nftexpr.pyrender_expr()— converts the JSON statement list to text (e.g.tcp dport 22 accept,ip saddr @allowlist accept,ct state in { established, related } accept). Defensive: unknown shapes fall back to compact JSON, never raises.title).Test plan
python -m pytest -q→ 137 passed. New:tests/test_nftexpr.py(12 cases incl. UFW/zapret-style rules).Follow-up
Will validate against a real
nft -j list rulesetdump and add a fixture if any rule renders oddly.Summary by cubic
Render firewall rules in readable nft syntax instead of raw JSON to make the Firewall page easier to scan. Handles implicit set membership and meta-key formatting with safe fallbacks.
services/nftexpr.pywithrender_expr()to convert nftables JSON to nft-like text; supports implicit set membership and correct meta-key prefixes; unknown shapes fall back to compact JSON; names iptables-nftxtmatches.titletooltip; updated headers andcode.rule-exprstyling/hover.nft_expras a template global; added tests for UFW/iptables-nft rules, meta keys, set membership, and fallback cases.Written for commit eaf3d5a. Summary will update on new commits.