04-12-2018 09:45 AM
Anybody knows a trick how to filter for rules with no log forwarding profile configured?
(log-setting eq 'Profile-Name') => all rules with Profile-Name
!(log-setting eq 'Profile-Name') => does not work, shows all rules
(log-setting neq 'Profile-Name') => does not work, shows no rules
(log-setting eq none) => does not work, shows no rules
04-12-2018 11:42 AM - edited 04-12-2018 11:45 AM
(log-setting eq 'Panorama') = Gives me panorama
(log-setting eq '') = Gives me empty values
'' is also useful in user-id searches as it gives you "empty" user-id log matches
04-13-2018 02:28 AM
this may be useful : Tips & Tricks: Filtering the security policy
log filters look for a positive match in the config file (or a negate of a positive match). values that have not been set can't be searched (in essence, any policy that does not have log forwarding set will not have the attribute in the XML of the config file)
one exception is when a policy used to have it set, and later was removed, the attribute will remain
unfortunately this makes it a little more difficult if you need to look for 'something thats NOT there'
04-13-2018 04:11 AM
Hello, thanks for all your replies.
Unfortunately (log-setting eq '') does not work for me either. It finds nothing, but there are definitely rules with Log Forwarding = None. Probably due to the behavior reaper mentioned.
04-15-2018 12:55 PM
Hi @Anon1
Depending on the amount of rules you have it might be worth to spend some time with learning - learning about the XML API and XPATH. If you're alrrady familiar with these topics: Great, then this should be easy for you.
Some basics you can find here: https://live.paloaltonetworks.com/t5/Community-Blog/Export-the-security-rulebase-using-XML-API/ba-p/...
The most important API request in this case for you is:
https://{FIREWALL-IP}/api/?type=config&action=show&key={APIKEY}&xpath={XPATH}
With XPATH you should be able to get only the rules without a log forwarding profile configured.
This XPATH will show you all the existing rules:
/config/devices/entry/vsys/entry/rulebase/security
If you now add a NOT statement to this XPATH to exclude all the rule with a log forwarding profile:
[not(rules/entry/log-setting)]
Combined this will give you this API request:
https://{FIREWALL-IP}/api/?type=config&action=show&key={APIKEY}&xpath=/config/devices/entry/vsys/entry/rulebase/security[not(rules/entry/log-setting)]
With this final request, I am actually not 100% sure if this really works but you can test this easily (copy&paste - done). @reaper: Do you know if the XML API has FULL support for XPATH queries?
If this does not work, you need to do it in two steps with the help of a scripting language, where you first do the rulebase query and then to the additional XPATH query to reduce the output to the rules without log-forwarding profile. (If it does not work and you're interested in this solution I can post a short example with powershell).
Regards,
Remo
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!