<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Tag Unused Rules in General Topics</title>
    <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194824#M58258</link>
    <description>&lt;P&gt;thanks for everyone feedback! I'll defintiely look into Firemon and also some scripts some of you have shared.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2018 16:21:49 GMT</pubDate>
    <dc:creator>nicford</dc:creator>
    <dc:date>2018-01-11T16:21:49Z</dc:date>
    <item>
      <title>Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193674#M58033</link>
      <description>&lt;P&gt;How to tag all unused security policies. I'm faimilar with the "highlight unused" and&amp;nbsp;&amp;gt; show running rule-use rule-base security type unused vsys vsys1 command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can then easily tag all my rules used say older than 90 days?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 19:26:26 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193674#M58033</guid>
      <dc:creator>nicford</dc:creator>
      <dc:date>2018-01-03T19:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193683#M58035</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;The 'Highlight Unused Rules' are rules that have not been hit since the last reboot. There is really not an easy way from the GUI to select multiple rules and add the tags you want. Unless you have a lot of them, I just do them one by one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One way would be to create the tag and then export the config xml, modifyi it to add your tags then upload it back into the PAN. I'm sure there are other ways, so other can comment with other ideas.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 19:34:33 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193683#M58035</guid>
      <dc:creator>OtakarKlier</dc:creator>
      <dc:date>2018-01-03T19:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193687#M58039</link>
      <description>&lt;P&gt;Unfortunately we have over 100 firewalls and probably 100s if not over 1000 unused rules. So something automated would be extremely helpful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 19:42:12 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193687#M58039</guid>
      <dc:creator>nicford</dc:creator>
      <dc:date>2018-01-03T19:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193693#M58043</link>
      <description>&lt;P&gt;Ah, in this case something like Ansible or Device Framework might help? I havent used either but they look promising. I would also reach out to your SE and see what their thoughts are.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://live.paloaltonetworks.com/t5/Automation-API/ct-p/automation" target="_blank"&gt;https://live.paloaltonetworks.com/t5/Automation-API/ct-p/automation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just some thoughts! Let us know how it goes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 20:01:55 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193693#M58043</guid>
      <dc:creator>OtakarKlier</dc:creator>
      <dc:date>2018-01-03T20:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193740#M58053</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/59672"&gt;@nicford&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;While automation is nice I think you are past the point of it really working the best for you to be honest. I would look at something like FireMon that can do this through a centralized basis and does it very well. Regardless this is going to take a while to clean up effectively on that many devices.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 22:12:50 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/193740#M58053</guid>
      <dc:creator>BPry</dc:creator>
      <dc:date>2018-01-03T22:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194023#M58097</link>
      <description>&lt;PRE&gt;from netmiko import ConnectHandler
import re
import time

with open('C:\\Users\\xxxxxxx\\Desktop\\test.txt') as f:
    x = []
    for line in f:
        x.append(line.strip())

def escape_ansi(line):
    ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]')
    return ansi_escape.sub('', line)

devicelist=""
for i in x:
    try:
       firewall = ConnectHandler(device_type='paloalto_panos_ssh', ip=i, username='xxxxxxx', password='xxxxxxx')
       print('\n&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Unused Policies of' + ' ' + i + ' &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;')
       time.sleep(10)
       hostname = firewall.send_command_timing(" show system info | match hostname", delay_factor=2)
       print (hostname)
       output= firewall.send_command(" show running rule-use rule-base security type unused vsys vsys1 ")
       time.sleep(20)
       output= escape_ansi(output)
       print (output.strip())
       firewall.disconnect()
       print('\n&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Logged out of Device' + ' ' + i + ' &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;')
    except:
       print ('\nUnable to login to PAN'+' '+i)
       devicelist=devicelist+ i +"\n"
print ('\nFirewalls which needs to be checked  \n' +'' +devicelist)



&lt;/PRE&gt;&lt;P&gt;Here is python script to get all the unused rules, I have implemented this today in my 50 firewall setup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please reach out if any queries.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 15:49:56 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194023#M58097</guid>
      <dc:creator>sandeep.paul</dc:creator>
      <dc:date>2018-01-05T15:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194119#M58109</link>
      <description>&lt;P&gt;thanks for the script! but reviewing it (forgive me if I'm wrong), this just prints all the unused rules. My main goals would be to print the rules, then tag them. My next step would be locate this tag, disable rules. Finally, delete all disabled rules.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 23:36:05 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194119#M58109</guid>
      <dc:creator>nicford</dc:creator>
      <dc:date>2018-01-05T23:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194122#M58112</link>
      <description>&lt;P&gt;I believe you could do this with pan-configurator:&lt;/P&gt;&lt;P&gt;&amp;nbsp;- &lt;A href="https://live.paloaltonetworks.com/t5/API-Articles/PAN-Configurator-scripting-library-and-utilities/ta-p/52163/jump-to/first-unread-message" target="_self"&gt;https://live.paloaltonetworks.com/t5/API-Articles/PAN-Configurator-scripting-library-and-utilities/ta-p/52163/jump-to/first-unread-message&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;- &lt;A href="https://github.com/cpainchaud/pan-configurator" target="_self"&gt;https://github.com/cpainchaud/pan-configurator&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clean unused rules even when you don't have logs over X months/years ( gets the list from cli 'show rulebase security type unused'):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run once : php rules-edit.php in=api://xxx actions=tag-add:Unused 'filter=(rule is.unused.fast)'&lt;/P&gt;&lt;P&gt;run every month: php rules-edit.php in=api://xxx actions=tag-remove:Unused 'filter=!(rule is.unused.fast) and (tag has Unused)' then after a few months, delete unused rules: php rules-edit.php in=api://xxxx actions=delete 'filter=(tag has Unused)'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'd just be adding an intermediary step of disabling rules with the tag first, and then delete later.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://live.paloaltonetworks.com/t5/API-Articles/rules-edit-php-to-manage-edit-export-rules-from-CLI/ta-p/53321" target="_self"&gt;https://live.paloaltonetworks.com/t5/API-Articles/rules-edit-php-to-manage-edit-export-rules-from-CLI/ta-p/53321&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jan 2018 00:16:28 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194122#M58112</guid>
      <dc:creator>jvalentine</dc:creator>
      <dc:date>2018-01-06T00:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194125#M58115</link>
      <description>Hey, yes I am working on the script to tag the sec policies, the script was basically to know the policies which needs attention on all firewalls ( in less than 15 mins).</description>
      <pubDate>Sat, 06 Jan 2018 01:54:23 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194125#M58115</guid>
      <dc:creator>sandeep.paul</dc:creator>
      <dc:date>2018-01-06T01:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194309#M58154</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/43480"&gt;@BPry&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/59672"&gt;@nicford&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;While automation is nice I think you are past the point of it really working the best for you to be honest. I would look at something like FireMon that can do this through a centralized basis and does it very well. Regardless this is going to take a while to clean up effectively on that many devices.&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without a doubt I'll second this.&amp;nbsp; If you've got "100s" of firewalls FireMon should be a "cost of doing business." It's beyond easy to use and will make your life so much easier as a firewall admin&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2018 18:35:24 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194309#M58154</guid>
      <dc:creator>Brandon_Wertz</dc:creator>
      <dc:date>2018-01-08T18:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Tag Unused Rules</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194824#M58258</link>
      <description>&lt;P&gt;thanks for everyone feedback! I'll defintiely look into Firemon and also some scripts some of you have shared.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 16:21:49 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/tag-unused-rules/m-p/194824#M58258</guid>
      <dc:creator>nicford</dc:creator>
      <dc:date>2018-01-11T16:21:49Z</dc:date>
    </item>
  </channel>
</rss>

