AppID Toolbox - PAN-OS-PHP
AppID Toolbox - PAN-OS-PHP
The different phases, procedures and safeguards should allow Engineers to adapt to customer’s risk
aversion level, SLAs and Change Processes and staff availability.
Migration Process
Overview
Each firewall Vsys or Panorama Device-Group shall be considered an a sub-project for which, the
same process will be followed:
It’s important to know that Phase 2 to 6 can be run several times in loop to ensure the safest and
most accurate migration.
Duration : 15 minutes.
Remember that our proposed approach doesn’t require the customer to do a Freeze on his
configuration changes. In order to track rules over several weeks/months and ensure the process will
not create troubles with customer’s changes like new rules creations, cloning or deletions then our
tools will Mark each concerned rule with a unique identifier.
The Identifier is a word that is added into the Rule description field. It is in the form of ‘appRID#XXX’
where XXX is unique (see screenshot):
For this phase, we will be using script ‘rule-marker.php’. A rule will be marked if it fulfills the following
conditions:
Duration: variable.
Now that all rules have been marked, we can start looking for applications seen in traffic logs. This
can be a lengthy process that depends on numerous factors: number of rules, number of hits, log
retention period, busyness of FW/Panorama management and database performances. A period of
1-3 days is common for 1000 rules.
Script ‘report-generator.php’ will look at all marked rules will start crunching data :
This script will store statistics in a XML file located in the current directory. Filename will be VSYS/DG
name.xml (ie: deviceGroup1.xml).
If the script happens to terminate (sometimes Panorama can stop answering for a minute or 2 or be
rebooted or Log job can fail), just start it again, it will resume where it stopped as the statistics file is
updated after each rule report is read from the device.
As you probably already understood, there are no changes made to rules at this point, only log
statistics collection.
Duration: 30 minutes
Now that application usage for each eligible rules has been calculated in previous phase, each
Legacy rule will be cloned with the following method:
Note: creating the rule in Disabled mode avoids creating a Change Request on the customer side. It’s
also very helpful for next phases as manual reviews and changes will still not impact production.
Here comes the lengthy part of the project: now that legacy rules have cloned with Applications and
remain in disable state, it’s time to review them one by one with customers. You can also decide to do
a first pass on them and request customer assistance and opinion only for a selection of them.
During this phase, you will not make any change on active rules : only on disabled AppID rules in
order to add/remove/fix application list. The purpose is to prepare the ground for Phase 5 where a
script will activate/enable AppID rules for you. Phase 5 script will activate AppID rules for which there
is not tag like ‘appid#NTBR#XXX’ where NTBR stands for Need To Be Reviewed and XXX as the
reason.
So the process is to go after each NTBR tag and fix the rule accordingly. Once done, remove the Tag
so Phase 5 can activate the rule.
Note that Phase5 can be applied several times: you can decide after a week of review to activate
rules which have been fixed so far while you keep working on the remaining ones.
• ‘appid#NTBR#tooManyApps’ : when more than 10 apps are showing in a single rule. In most
cases it means that it’s an ‘internet access’ based rule and shall deserve a different attention
(no fixed list of apps) or at least read carefully this list of apps to see if it makes sense.
● ‘appid#NTBR#unused’ : from the logs, this rule is apparently unused. It may be due to the
fact that for the moment only 28 days of logs are on Panorama or because they are really used
once per quarter or never. You may want to investigate some of these to confirm or deny they
are really unused. Whatever, you can just skip this rule, leave the tag as it is and try to refresh
log statistics later to confirm it’s really note used.
● ‘appid#NTBR#onlyInvalidApps’ : logs are showing that the rule has only special applications
like non-syn-tcp, incomplete and insufficient-data. This is a sign that the rule may not be used
at all (rule is open but services on servers are offline/decommissioned, or not in production
yet).
● ‘appid#NTBR#appNotAny’ : there can be quite some time between the day reports are
generated and the day I clone rules, in the meantime someone may have editing rules and
added applications in it. Our Toolbox has lots of safeguard and tracks this situation. You will
probably want to remove the Tag and rule unique Identifier as well to exclude this rule from
future AppID process.
Activating an AppID rule will happen if the following conditions are met:
● Script was able to find the couple of Legacy + AppID rules holding the same Unique Identifier.
● Legacy and AppID rules have no ‘appid#NTBR#XXXX’ like tags.
● Legacy rule is not disabled.
● Legacy and AppID rules are identical (outside of the Application field of course !)
● Legacy rule is placed after AppID rule.
1. Legacy rule is renamed with the following model: appRID-XX-YYYY where XX is the Unique
Identifier number and YYYY is a random number. Renaming the rule to a new that has never
been seen before will help for Phase 6 to know if that rule is still in use.
2. Legacy rule ‘log at start’ is enabled to ensure the rule generates a log in case it’s used in the
middle of a session lifetime.
3. AppID rule is renamed with the original Legacy rule name (which ensures better traceability for
the customer as the AppID Migration process doesn’t change rule names).
5. Both AppID and Legacy rule get a tag with their activation date in the form of :
appid#activated#YYYYMMDD where YYYY is year, MM month of the year, DD day of the
month. This will be used in Phase 6 to determine which legacy rules are still in use.
**** WARNING : no changes were made because you didn't use 'confirm' argument in the command line
****
Tip : you may want to run the script a few hours/day before without ‘confirm’ option to do a first pass
of possible issues like Legacy vs AppID rule mismatch etc etc.
Tip: you can run this script several times as it will only activate rules which have not been activated
yet.
After a reasonable amount of time past their cloning & activation, legacy rules which are not used
anymore can be safely deleted.
In order to know which rules are still hit or not, you need to fresh the log statistics with
report-generator.php with the ‘updatePreviousData’ flag to make sure it will refresh already existing
data. Don’t forget to change the logHistory value to match the wanted number of days to compute
statistics on if the 60days default is too short for you.
These rules were not cloned nor activated because no single logs were found during the whole
process. Customer should delete them in the end but it’s not your role to do this unless the customer
agreed he wanted you to delete them.
The cleaner script will do only 1 thing for these rules: remove rule Unique Identifier from the rule
description. The appid#unused tag will stay there to help customers investigate it later.
If the script determines that legacy rule is not used anymore then it will proceed to the following:
...
**** SUMMARY ****
**** WARNING : no changes were made because you didn't use 'confirm' argument in the command line
****
You are encouraged to run the script first in preview mode which is the default. No change will be
made to the firewall before you use the ‘confirm’ argument in the CLI. As you are fixing issues and
run the CLI again and again then they should vanish or move from a category to another.
Report-generator.php script does collect data from summary logs which should usually have
longer term retention. Anyway, if it’s not enough then you can run report-generator.php as often as
you want and use the following flags to merge statistics with previous runs: “php
report-generator.php updatePreviousData …….”