0

I'm having some troubles trying to fetch fw rules. I read the dock and looked at the examples at the page https://docs.opnsense.org/development/api/plugins/firewall.html but i still have problems. I'm trying to use the searchRule API via python, and i can't get anything back with a simple call without any attributes, here's my code

import json, requests


KEY = "my_key"
SECRET = "my_secret"

url = "https://192.168.2.1/api/firewall/filter/searchRule"
r = requests.get(url, verify=False, auth=(KEY, SECRET))
print(r.text)

result is always

{"rows":[],"rowCount":0,"total":0,"current":1}

Well, i've tryed to add some attributes to the call, but nothing changes, notice that i setted "icmp_dummies_rule" as the rule description cause i thought taht searchPhrase matches that field (also there's no unique name filed available, as far as i can see) I tryed:

url = 'https://192.168.2.1/api/firewall/filter/searchRule?searchPhrase="icmp_dummies_rule"'
url = 'https://192.168.2.1/api/firewall/filter/searchRule?searchPhrase=icmp_dummies_rule'
url = 'https://192.168.2.1/api/firewall/filter/searchRule?current=1&searchPhrase="icmp_dummies_rule"'
url = 'https://192.168.2.1/api/firewall/filter/searchRule?current=1&searchPhrase=icmp_dummies_rule'

Also i can't pass any UUID cause i don't know the rule UUID (but i prefere to retrive all the rules for flexibility reason and cleaner code).

Any idea here?
Thanks.

Hele
  • 189
  • 1
  • 12

1 Answers1

0

Solved,

notice that this behavoir IS NOT REPORTED in api doc.
Adding firewall-plugin module will add an Automation voice under Firewall section

enter image description here

now under Filter voice you can create, manage and delete rules, those rules will be availables via API queryes.

Notice that rules added under RULE voice (as default) aren't availables via API interface

Hele
  • 189
  • 1
  • 12