Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish version 2.1.19 #783

Merged
merged 35 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ee2fcd2
start version 2.1.19
Sep 20, 2023
af1a763
different classes | improve usage of flag 'XML_PARSE_BIG_LINES' in me…
Sep 21, 2023
1678163
all type=XYZ | start supporting location=!shared
Sep 21, 2023
61a02f0
revert implementation of 'location=!shared'
Sep 21, 2023
ca2526e
class PANConf / Panoramaconfg | implement method ChildDeviceGroups() …
Sep 21, 2023
f4f680f
class UTIL - extend help for argument location=
Sep 21, 2023
bac726d
class PANConf|VirtualSystem | bugfix to support SharedGateway also fo…
Sep 22, 2023
11ce883
type=gcp | introduce argument 'namespace=XYZ' to specify and better f…
Sep 22, 2023
e8d9e13
Class VirtualSystem/SharedGatewayStore | better handling of version v…
Sep 22, 2023
23a88ed
type=device | introduce actions=virtualSystem-delete/sharedgateway-de…
Sep 22, 2023
781a6b5
type=static-route | introduction of new type= | with 'filter=(nexthop…
Sep 22, 2023
b009382
type=static-route actions=delete | introduce new action
Sep 22, 2023
f113333
Class AddressStore/ServiceStore/IPSecCryptoProfileStore - replce mdeb…
Sep 22, 2023
be13190
type=xml-issue | bugfix to display read-only DeviceGroup duplicate ad…
Sep 22, 2023
85d6da4
type=address-merger | bugfix - do not merger address objects if tag c…
Sep 25, 2023
d139f29
type=rule | introduce actions=from-/to-remove-from-file:FILE.txt
Sep 25, 2023
7088aed
Update actions-rule.php
Sep 25, 2023
fd5ce31
type=address-merger | bugfix for removing tag objects from upper leve…
Sep 25, 2023
59a7f03
type=XYZ | introduce new arguments: shadow-loadreduce - to not update…
Sep 26, 2023
d12b250
bugfix for argument 'location=shared:excludemaindg' on FW config file
Sep 26, 2023
e7195fd
Update CHANGELOG.txt
Sep 26, 2023
89ae92e
develop | introduce config_validation.php
Sep 27, 2023
e8c00af
Update config_validation.php
Sep 27, 2023
01d8fa7
Update config_validation.php
Sep 27, 2023
ed6fa25
Update config_validation.php
Sep 27, 2023
66adeaa
Update interface_getIP.php
Sep 27, 2023
6ba998a
type=appid-toolbox | improvements for further. new features - example…
Sep 28, 2023
f476a11
type=rule actions=name-replace-character | set default value for repl…
Sep 29, 2023
5df3fda
type=rule | introduce new actions=appid-stats-fastapi:-90days/service…
Sep 29, 2023
938efd9
type=rule new actions rename - start with "stats-"
Sep 29, 2023
5887d31
type=routing | introduce actions=exporttoexcel:file.html | 'filter=(p…
swaschkut Oct 3, 2023
d6c8994
type=schedule | bugfix actions=replacewithobject:OBJECTNAME
swaschkut Oct 5, 2023
3eb5b36
type=gcp | introdruce $namespace | improve handling for tenant like t…
swaschkut Oct 5, 2023
8818090
type=xpath | introduce actions=remove | introduce 'filter-text=NODETEXT'
swaschkut Oct 6, 2023
99c381e
GENERAL - APP-ID update to Device App-ID version: 8762-8327
swaschkut Oct 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions CHANGELOG.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
CHANGELOG

2.1.18
2.1.19
UTIL:

* different classes | improve usage of flag 'XML_PARSE_BIG_LINES' in method loadXML
* class PANConf / Panoramaconfg | implement method ChildDeviceGroups() for 'location=shared:excludemaindg'
* type=gcp | introduce argument 'namespace=XYZ' to specify and better filter for get pods
* type=device | introduce actions=virtualSystem-delete/sharedgateway-delete/sharedgateway-migrate-to-vsys
* type=static-route | introduction of new type= | with 'filter=(nexthop-ip is.set)' / (nexthop-vr is.set) / nexthop-interface is.set) / (destination ip4.includes-full 172.33.10.0/23)
* type=static-route actions=delete | introduce new action
* type=rule | introduce actions=from-/to-remove-from-file:FILE.txt
* type=XYZ | introduce new arguments: shadow-loadreduce - to not update TAG object related address-groups | debugloadtime - display load time for specific XML sections
* develop | introduce config_validation.php
* type=appid-toolbox | improvements for further. new features - example rule address/service report generator
* type=rule actions=name-replace-character | set default value for replace to ''
* type=rule | introduce new actions=stats-appid-fastapi:-90days/stats-service-fastapi:/stats-address-source-fastapi/stats-address-destination-fastapi/stats-address-fastapi/stats-traffic-fastapi
* type=routing | introduce actions=exporttoexcel:file.html
* type=routing | introduce 'filter=(protocol.bgp is.enabled)'
* type=gcp | introdruce $namespace | improve handling for tenant like togglesvc
* type=xpath | introduce actions=remove | introduce 'filter-text=NODETEXT'

BUGFIX:
* class PANConf|VirtualSystem | bugfix to support SharedGateway also for Tag objects correctly
* type=xml-issue | bugfix to display read-only DeviceGroup duplicate address-group fixes correctly in summary
* type=address-merger | bugfix - do not merger address objects if tag count of planned merged object exceeds PAN-OS limit of 64 tag members
* type=address-merger | bugfix for removing tag objects from upper level, if adr merged objects are using them and tag is also available at address level
* bugfix for argument 'location=shared:excludemaindg' on FW config file
* type=schedule | bugfix actions=replacewithobject:OBJECTNAME

GENERAL:
* Class VirtualSystem/SharedGatewayStore | better handling of version variable
* update actions/filter JSON file
* APP-ID update to Device App-ID version: 8762-8327


2.1.18 (20230920)
BUGFIX:
* type=address/service 'actions=move:shared,skipIfConflict' | bugfix as variable $findSubSystem was not declared for targetlocation 'shared'

GENERAL:


2.1.17 (20230920)
UTIL:
Expand Down
152 changes: 121 additions & 31 deletions appid-toolbox/lib/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,26 @@
class DeviceGroupRuleAppUsage
{
public $logs = Array();
public $logsSrcDst = Array();

public function load_from_file($filename)
public function load_from_file($filename, $SrcDst = false)
{
$xmlDoc = new DOMDocument();
$xmlDoc->Load($filename);

$recordsNode = DH::findFirstElementOrDie('records', $xmlDoc);

if( $SrcDst )
$keyword = "ips";
else
$keyword = "apps";

foreach( $recordsNode->childNodes as $entryNode )
{
if( $entryNode->nodeType != XML_ELEMENT_NODE )
continue;

$logRecord = Array( 'apps' => Array() );
$logRecord = Array( $keyword => Array() );

/** @var DOMElement $entryNode */

Expand All @@ -88,27 +94,55 @@ public function load_from_file($filename)

/** @var DOMElement $appNode */

$logRecord['apps'][$appNode->getAttribute('name')] = Array( 'name' => $appNode->getAttribute('name'), 'count' => $appNode->getAttribute('count'));
$logRecord[$keyword][$appNode->getAttribute('name')] = Array( 'name' => $appNode->getAttribute('name'), 'count' => $appNode->getAttribute('count'));
}

$this->logs[$ruleName] = &$logRecord;
if( $SrcDst )
$this->logsSrcDst[$ruleName] = &$logRecord;
else
$this->logs[$ruleName] = &$logRecord;
unset($logRecord);
}


}

public function save_to_file($filename)
public function save_to_file($filename, $SrcDst = false)
{
$xml = "<records>\n";

foreach($this->logs as $name => &$log)
if($SrcDst)
{
$logArray = $this->logsSrcDst;
$keyWord = "ips";
}
else
{
$logArray = $this->logs;
$keyWord = "apps";
}


foreach($logArray as $name => &$log)
{
$xml .= " <entry name=\"{$name}\" timestamp=\"{$log['timestamp']}\" Htimestamp=\"".timestamp_to_date($log['timestamp'])."\">\n";

foreach( $log['apps'] as &$app )
foreach( $log[$keyWord] as $key => &$app )
{
$xml .= " <app name=\"{$app['name']}\" count=\"{$app['count']}\"/>\n";
if( $keyWord == "apps")
{
$xml .= " <".$keyWord." name=\"{$app['name']}\" count=\"{$app['count']}\"/>\n";
}
else
{
#$xml .= " <".$keyWord.">\n";
foreach( $app as $ip )
{
$xml .= " <".$keyWord."-".$key." name=\"{$ip['name']}\" count=\"{$ip['count']}\"/>\n";
}

#$xml .= " </".$keyWord.">\n";
}
}

$xml .= " </entry>\n";
Expand All @@ -119,6 +153,7 @@ public function save_to_file($filename)
file_put_contents($filename, $xml);
}


public function addRuleStats($ruleName , $appName, $hitCount)
{
if( isset($this->logs[$ruleName]) )
Expand All @@ -139,33 +174,75 @@ public function addRuleStats($ruleName , $appName, $hitCount)
$record['apps'][$appName] = Array('name'=>$appName, 'count' => $hitCount);
}

public function addRuleStats_SrcDst($ruleName , $srcOrDst, $ip, $hitCount)
{
if( isset($this->logsSrcDst[$ruleName]) )
{
$record = &$this->logsSrcDst[$ruleName];
}
else
{
$SrcDstArray = array('src', 'dst');
$record = Array( 'ips' => $SrcDstArray );
$this->logsSrcDst[$ruleName] = &$record;
}

$record['timestamp'] = time();

if( isset($record['ips'][$srcOrDst][$ip]) )
$record['ips'][$srcOrDst][$ip]['count'] += $hitCount;
else
$record['ips'][$srcOrDst][$ip] = Array('name'=>$ip, 'count' => $hitCount);
}

/**
* @param string $ruleName
* @return null|int
*/
public function getRuleUpdateTimestamp($ruleName)
public function getRuleUpdateTimestamp($ruleName, $SrcDst = false)
{
if( isset($this->logs[$ruleName]) )
{
return $this->logs[$ruleName]['timestamp'];
}
if( $SrcDst )
if( isset($this->logsSrcDst[$ruleName]) )
{
return $this->logsSrcDst[$ruleName]['timestamp'];
}
else
if( isset($this->logs[$ruleName]) )
{
return $this->logs[$ruleName]['timestamp'];
}

return null;
}


public function resetRulesStats($ruleName)
public function resetRulesStats($ruleName, $SrcDst = false)
{
if( isset($this->logs[$ruleName]) )
unset($this->logs[$ruleName]);
if( $SrcDst )
if( isset($this->logsSrcDst[$ruleName]) )
unset($this->logsSrcDst[$ruleName]);
else
if( isset($this->logs[$ruleName]) )
unset($this->logs[$ruleName]);
}


public function getRuleStats($ruleName)
public function getRuleStats($ruleName, $SrcDst = false)
{
if( !isset($this->logs[$ruleName]) )
return null;
if( $SrcDst )
{
if( !isset($this->logsSrcDst[$ruleName]) )
return null;

return $this->logsSrcDst[$ruleName]['ips'];
}
else
{
if( !isset($this->logs[$ruleName]) )
return null;

return $this->logs[$ruleName]['apps'];
return $this->logs[$ruleName]['apps'];
}
}

public function isRuleUsed($ruleName, $ignoreApps = Array('incomplete', 'non-syn-tcp') )
Expand All @@ -183,21 +260,34 @@ public function isRuleUsed($ruleName, $ignoreApps = Array('incomplete', 'non-syn

}

public function createRuleStats($ruleName)
public function createRuleStats($ruleName, $SrcDst = false)
{
if( !isset($this->logs[$ruleName]) )
{
$record = Array( 'apps' => Array(), 'timestamp' => time() );
$this->logs[$ruleName] = &$record;
}
if( $SrcDst )
if( !isset($this->logsSrcDst[$ruleName]) )
{
$record = Array( 'ips' => Array(), 'timestamp' => time() );
$this->logsSrcDst[$ruleName] = &$record;
}
else
if( !isset($this->logs[$ruleName]) )
{
$record = Array( 'apps' => Array(), 'timestamp' => time() );
$this->logs[$ruleName] = &$record;
}
}

public function updateRuleUpdateTimestamp($ruleName)
public function updateRuleUpdateTimestamp($ruleName, $SrcDst = false)
{
if( isset($this->logs[$ruleName]) )
{
$this->logs[$ruleName]['timestamp'] = time();
}
if( $SrcDst )
if( isset($this->logsSrcDst[$ruleName]) )
{
$this->logsSrcDst[$ruleName]['timestamp'] = time();
}
else
if( isset($this->logs[$ruleName]) )
{
$this->logs[$ruleName]['timestamp'] = time();
}
}


Expand Down
15 changes: 10 additions & 5 deletions appid-toolbox/lib/trait/lib_1_rule_marker.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function ruleMarker_Phase1_init()
if( isset(PH::$args['help']) )
$this->display_usage_and_exit_p1();

$supportedOptions = array('phase', 'in', 'out', 'help', 'location');
$supportedOptions = array('phase', 'in', 'out', 'help', 'location', 'debugapi');
$supportedOptions = array_flip($supportedOptions);

foreach( PH::$args as $arg => $argvalue )
Expand All @@ -54,6 +54,10 @@ function ruleMarker_Phase1_init()

$debugAPI = FALSE;

if( isset(PH::$args['debugapi']) )
{
$debugAPI = TRUE;
}

$return = AppIDToolbox_common::location();
$configInput = $return['configInput'];
Expand Down Expand Up @@ -99,11 +103,12 @@ function ruleMarker_Phase1_main($subSystem, $configInput, $pan, $inputConnector,

foreach( $rules as $rule )
{
PH::print_stdout();
PH::print_stdout(" - rule '{$rule->name()}'");

if( $ridTagLibrary->ruleIsTagged($rule) )
{
PH::print_stdout(" SKIPPED : already tagged");
PH::print_stdout(" SKIPPED : already tagged");
$alreadyMarked++;
continue;
}
Expand All @@ -112,7 +117,7 @@ function ruleMarker_Phase1_main($subSystem, $configInput, $pan, $inputConnector,


$newTagName = $ridTagLibrary->findAvailableTagName('appRID#');
PH::print_stdout();

PH::print_stdout(" * creating Virtual TAG '$newTagName' ... ");

PH::print_stdout(" * applying tag to rule description... ");
Expand All @@ -129,10 +134,10 @@ function ruleMarker_Phase1_main($subSystem, $configInput, $pan, $inputConnector,
$xmlPreRules .= "<entry name=\"{$rule->name()}\"><description>" . htmlspecialchars($rule->description()) . "</description></entry>";
}

PH::print_stdout("\n\nNumber of rules marked: {$markedRules} (vs already marked: {$alreadyMarked}");
PH::print_stdout("\n\nNumber of rules marked: '{$markedRules}' (vs already marked: '{$alreadyMarked}')");

if( $markedRules < 1 )
PH::print_stdout("\n\n No change to push as not rule is set to be marked");
PH::print_stdout("\n\nNo change to push as no rule is set to be marked");
else
{
if( $configInput['type'] == 'api' )
Expand Down
Loading
Loading