Skip to content

Commit

Permalink
Merge pull request #774 from swaschkut/main
Browse files Browse the repository at this point in the history
version 2.1.15 - bugfixes
  • Loading branch information
swaschkut committed Aug 30, 2023
2 parents 45990f4 + 12608b2 commit 11b0ac5
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 17 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
CHANGELOG

2.1.14
2.1.15
UTIL:

BUGFIX:
* type=address/service 'filter=(object is.unused/is.unused.recursive) | overwritten objects used at higher DG level are now also used
* bugfix to create correct XML file Increament for prettyXML - so that it is identical to Panorama / Firewall created config
* README.md - fix broken links

GENERAL:


2.1.14 (20230829)
UTIL:
type=rule actions=display | introduction of argument actions=display:hitcount,ApplicationSeen

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ INSTALLATION
The recommended installation of PAN-OS-PHP is via Docker.
Please install Docker Desktop if needed.

[README docker](https://github.com/PaloAltoNetworks/pan-os-php/READMEdocker.md)
[README docker](https://github.com/PaloAltoNetworks/pan-os-php/blob/main/READMEdocker.md)

[WIKI docker](https://github.com/PaloAltoNetworks/pan-os-php/wiki/docker)

Expand All @@ -33,7 +33,7 @@ Old detailed information

File tree:
* **/lib/** contains library files source code
* **/utils/** contains ready to run scripts, more information in [utils/README](https://github.com/PaloAltoNetworks/pan-os-php/utils/README.md)
* **/utils/** contains ready to run scripts, more information in [utils/README](https://github.com/PaloAltoNetworks/pan-os-php/blob/main/utils/README.md)
* **/doc/index.html** has all classes documentations
* **/example-xxx.php** are examples about using this library

Expand All @@ -49,7 +49,7 @@ Usage (create custom Scripts)

With less than 20 lines of code, you should be able to solve most of your needs. Brief overview:

[README customScripting](https://github.com/PaloAltoNetworks/pan-os-php/READMEcustomScripting.md)
[README customScripting](https://github.com/PaloAltoNetworks/pan-os-php/blob/main/READMEcustomScripting.md)


UTIL (predefined Scripts)
Expand All @@ -59,7 +59,7 @@ UTIL (predefined Scripts)

Use around 50 different predefined entry parts [e.g. address / service / tag / rule / ...] with 100 of actions and filters to easily improve your Palo Alto Networks Firewall and Panorama configuration

[README util](https://github.com/PaloAltoNetworks/pan-os-php/READMEutil.md)
[README util](https://github.com/PaloAltoNetworks/pan-os-php/blob/main/READMEutil.md)



Expand All @@ -68,6 +68,6 @@ Docker build

There are Dockerfiles available with OS: Ubuntu20/22 and CentOS 7/8

[README docker](https://github.com/PaloAltoNetworks/pan-os-php/READMEdocker.md)
[README docker](https://github.com/PaloAltoNetworks/pan-os-php/blob/main/READMEdocker.md)

[WIKI docker](https://github.com/PaloAltoNetworks/pan-os-php/wiki/docker)
2 changes: 1 addition & 1 deletion lib/device-and-system-classes/FawkesConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public function save_to_file($fileName, $printMessage = TRUE, $lineReturn = TRUE

//Todo: swaschkut check
//$indentingXmlIncreament was 2 per default for Panroama
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament);
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament + 1);

$path_parts = pathinfo($fileName);
if (!is_dir($path_parts['dirname']))
Expand Down
2 changes: 1 addition & 1 deletion lib/device-and-system-classes/PANConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ public function save_to_file($fileName, $printMessage = TRUE, $lineReturn = TRUE
if( $printMessage )
PH::print_stdout( "Now saving PANConf to file '$fileName'...");

$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament);
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament + 1);

$path_parts = pathinfo($fileName);
if (!is_dir($path_parts['dirname']))
Expand Down
2 changes: 1 addition & 1 deletion lib/device-and-system-classes/PanoramaConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ public function save_to_file($fileName, $printMessage = TRUE, $lineReturn = TRUE

//Todo: swaschkut check
//$indentingXmlIncreament was 2 per default for Panroama
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament);
$xml = &DH::dom_to_xml($this->xmlroot, $indentingXml, $lineReturn, -1, $indentingXmlIncreament + 1);

$path_parts = pathinfo($fileName);
if (!is_dir($path_parts['dirname']))
Expand Down
2 changes: 1 addition & 1 deletion lib/misc-classes/PH.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function __construct($argv, $argc)

private static $library_version_major = 2;
private static $library_version_sub = 1;
private static $library_version_bugfix = 14;
private static $library_version_bugfix = 15;

//BASIC AUTH PAN-OS 7.1
public static $softwareupdate_key = "658d787f293e631196dac9fb29490f1cc1bb3827";
Expand Down
6 changes: 4 additions & 2 deletions lib/misc-classes/filters/filters-Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
);
RQuery::$defaultFilters['address']['object']['operators']['is.unused'] = array(
'Function' => function (AddressRQueryContext $context) {
return $context->object->countReferences() == 0;
$object = $context->object;

return $object->objectIsUnused();
#return $context->object->countReferences() == 0;
},
'arg' => FALSE,
'ci' => array(
Expand All @@ -33,7 +36,6 @@
$object = $context->object;

return $object->objectIsUnusedRecursive();

},
'arg' => FALSE,
'ci' => array(
Expand Down
5 changes: 4 additions & 1 deletion lib/misc-classes/filters/filters-Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
);
RQuery::$defaultFilters['service']['object']['operators']['is.unused'] = array(
'Function' => function (ServiceRQueryContext $context) {
return $context->object->countReferences() == 0;
$object = $context->object;

return $object->objectIsUnused();
#return $context->object->countReferences() == 0;
},
'arg' => FALSE,
'ci' => array(
Expand Down
38 changes: 34 additions & 4 deletions lib/misc-classes/trait/ReferenceableObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,31 @@ public function name()
return $this->name;
}

public function objectIsUnused()
{
$className = "";

if( get_class($this) == 'Service' || get_class($this) == 'ServiceGroup' )
$className = 'ServiceGroup';
elseif( get_class($this) == 'Address' || get_class($this) == 'AddressGroup' )
$className = 'AddressGroup';
else
return null;

/** @var Address|AddressGroup|Service|ServiceGroup $this */
if( $this->countReferences() == 0 )
{
//- check if higher DG has same name and only if it is also unused return TRUE
$tmp_obj = $this->owner->find( $this->name() );
if( $tmp_obj === null || $tmp_obj->countReferences() == 0 )
return TRUE;
else
return FALSE;
}

return FALSE;
}

public function objectIsUnusedRecursive()
{
$className = "";
Expand All @@ -520,9 +545,16 @@ public function objectIsUnusedRecursive()
else
return null;

/** @var Service|ServiceGroup $ref */
/** @var Address|AddressGroup|Service|ServiceGroup $this */
if( $this->countReferences() == 0 )
return TRUE;
{
//- check if higher DG has same name and only if it is also unused return TRUE
$tmp_obj = $this->owner->find( $this->name() );
if( $tmp_obj === null || $tmp_obj->countReferences() == 0 )
return TRUE;
else
return FALSE;
}

$groups = $this->findReferencesWithClass($className);

Expand All @@ -540,7 +572,5 @@ public function objectIsUnusedRecursive()
}

return TRUE;

}

}

0 comments on commit 11b0ac5

Please sign in to comment.