{"record":{"id":"89404846466457e0","repo":"jdx/mise","slug":"firewall-rule-uses-action-limit-which-re","errorCode":null,"errorMessage":"firewall rule '{}' uses action = \"limit\", which requires direction = \"incoming\" and protocol = \"tcp\"","messagePattern":"firewall rule '(.+?)' uses action = \"limit\", which requires direction = \"incoming\" and protocol = \"tcp\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/firewall.rs","lineNumber":1046,"sourceCode":"                        command_output(\n                            \"firewall-cmd\",\n                            &[\"--permanent\", &format!(\"--info-policy={policy}\")],\n                        )\n                        .is_ok_and(|output| output.status.success())\n                    })\n        }\n        FirewallBackend::Ufw => backend_active(backend),\n        FirewallBackend::Auto => false,\n    }\n}\n\nfn validate_backend_request(request: &FirewallRequest, backend: FirewallBackend) -> Result<()> {\n    for rule in &request.rules {\n        if rule.action == FirewallAction::Limit {\n            if rule.direction != FirewallDirection::Incoming\n                || rule.protocol != Some(FirewallProtocol::Tcp)\n            {\n                bail!(\n                    \"firewall rule '{}' uses action = \\\"limit\\\", which requires direction = \\\"incoming\\\" and protocol = \\\"tcp\\\"\",\n                    rule.name\n                );\n            }\n            if backend == FirewallBackend::Firewalld {\n                bail!(\n                    \"firewall rule '{}' uses per-source connection limiting, which firewalld policies cannot express safely; select backend = \\\"nftables\\\" or \\\"ufw\\\"\",\n                    rule.name\n                );\n            }\n        }\n        if backend == FirewallBackend::Firewalld && rule.interface.is_some() {\n            bail!(\n                \"firewall rule '{}' uses interface matching, which firewalld policies cannot express safely; select backend = \\\"nftables\\\" or \\\"ufw\\\"\",\n                rule.name\n            );\n        }\n        if backend == FirewallBackend::Ufw","sourceCodeStart":1028,"sourceCodeEnd":1064,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/firewall.rs#L1028-L1064","documentation":"Connection limiting (action = \"limit\") is only meaningful for inbound TCP traffic, so validation rejects any limit rule whose direction is not \"incoming\" or whose protocol is not \"tcp\". The library enforces this invariant before generating any backend-specific commands so invalid rules never reach nftables/ufw/firewalld.","triggerScenarios":"Defining a FirewallRule with action = FirewallAction::Limit while direction is Outgoing (or not Incoming) or protocol is None/Some(Udp)/Some(Sctp)/Some(Dccp), then submitting the FirewallRequest to apply/validate_backend_request.","commonSituations":"Copy-pasting a rate-limit rule template and forgetting to set protocol = \"tcp\"; intending an outbound rate limit; leaving protocol unset because the developer assumed a default.","solutions":["Set direction = \"incoming\" and protocol = \"tcp\" on the limit rule.","Change the action to \"allow\" or \"deny\" if per-connection limiting is not actually needed.","Split the rule: keep the broad rule without limit and add a separate incoming/tcp limit rule.","Wrap rule construction in a helper that asserts these invariants before building the request."],"exampleFix":"// before\nFirewallRule { name: \"ssh-limit\", action: FirewallAction::Limit, direction: FirewallDirection::Outgoing, protocol: None, .. }\n// after\nFirewallRule { name: \"ssh-limit\", action: FirewallAction::Limit, direction: FirewallDirection::Incoming, protocol: Some(FirewallProtocol::Tcp), .. }","handlingStrategy":"validation","validationCode":"fn is_valid_limit_rule(rule: &FirewallRule) -> bool {\n    rule.action != FirewallAction::Limit\n        || (rule.direction == FirewallDirection::Incoming\n            && rule.protocol == Some(FirewallProtocol::Tcp))\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = apply(&request, false, true) {\n    if e.to_string().contains(\"action = \\\"limit\\\"\") {\n        eprintln!(\"fix rule direction/protocol to incoming/tcp: {e}\");\n    }\n}","preventionTips":["Define limit rules only through a constructor that sets incoming/tcp defaults","Lint rule sets for limit invariants before submit","Never leave protocol unset on limit rules","Review copy-pasted rule templates for direction/protocol"],"tags":["firewall","validation","rules"],"backgroundTag":"invalid-config-value","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}