Is it possible to enable firewall rules via the command line / cron / API?

Started by bitTwiddler, June 10, 2024, 08:51:51 PM

Previous topic - Next topic
I frequently disable a rule for testing and then forget to re-enable it.

It would be very nice to be able to have a cron job run nightly to re-enable all the rules for those times that I forget to do so.  However, I am not seeing that ability in the docs.

Am I overlooking the obvious?

Skye

Maybe a better question, is there an API endpoint which allows rules to be enabled?

I am looking at these docs and it is unclear if this works on the built-in firewall rules based upon this statement:

Although the plugin does contains a basic user interface (in Firewall ‣ Automation), it's mirely intended as a reference and testbed. There's no relation to any of the rules being managed via the core system.

 I am using an example from the docs and it returns an empty result set.  Are the API docs out of date now that the firewall endpoints are built in?

rule_description='test_rule_1'
remote_uri="http://192.168.1.1"

# search for rule
r = requests.get("%s/api/firewall/filter/searchRule?searchPhrase=%s" % (
        remote_uri, rule_description
    ),
    auth=(api_key, api_secret), verify=False
)
print("status code", r.status_code, r.text)




status code 200 {"rows":[],"rowCount":0,"total":0,"current":1}
rule test_rule_1 not found