swaschkut / pan-os-php

Framework and utilities to easily manage and edit Palo Alto Network PANOS devices
ISC License
18 stars 1 forks source link

exportToExcel getting Call to undefined method EDL::isGroup() on v2.1.27 #29

Open bethatasitmay opened 1 month ago

bethatasitmay commented 1 month ago

Before we get into the details, a quick question: does v2.1.27 require a newer PHP version?

I'm still running PHP v8.3.11.

Also, my installed older version was showing as 2.1.25 but I think it was a bugfix dev release that rolled into v2.1.26 if I remember correctly (could be wrong).

Describe the bug

I ran a command that worked fine the last time I used it (then-current-release or possibly dev release v2.1.25 downloaded 2 Sep 2024), but after upgrading to v2.1.27 latest release today I get the error in the title.

Expected behavior

Normal output per previous versions.

Current behavior

> php -r "require_once 'C:/tools/pan/pan-os-php/utils/pan-os-php.php';" type=rule in=api://panorama.domain.com location=any ruletype=security 'actions=exportToExcel:DevQA-Rules.xls' 'filter=(src has.recursive network1) or (src has.recursive host1) or (src has.recursive host2) or (src has.recursive host3) or (src has.recursive host4) or (dst has.recursive network1) or (dst has.recursive host1) or (dst has.recursive host2) or (dst has.recursive host3) or (dst has.recursive host4)'

***********************************************
*********** pan-os-php.php type=rule UTILITY **************

 - PAN-OS-PHP version: 2.1.27 [WIN] [8.3.11]
 - Downloading config from API...
 - Detected platform type is 'panorama'
 - No 'template' provided so using default ='any'
 - filter after sanitization : (src has.recursive network1) or (src has.recursive host1) or (src has.recursive host2) or (src has.recursive host3) or (src has.recursive host4) or (dst has.recursive network1) or (dst has.recursive host1) or (dst has.recursive host2) or (dst has.recursive host3) or (dst has.recursive host4)
 - Loading configuration through PAN-OS-PHP library...
   (0.97 seconds, 52.43 mb memory)
 - PAN-OS-PHP APP-ID version: 8902-9003

 - PAN-OS APP-ID version: 8904-9011
 - PAN-OS AV version: 4974-5492
 - PAN-OS WF version: 515890-518890
 - PAN-OS THREAT version: 8904-9011
 - PAN-OS version: 110
 - PAN-OS Device timezone: US/Pacific is used. actual time: 2024/10/17 13:09:44
   - action 'exportToExcel' has tasks to process before start.
   - action 'exportToExcel' has tasks to process before start.
   - action 'exportToExcel' has tasks to process before start.

* processing ruleset 'PanoramaConf: / RuleStore:Security' that holds 454 rules
PHP Fatal error:  Uncaught Error: Call to undefined method EDL::isGroup() in C:\tools\pan\pan-os-php\lib\container-classes\AddressRuleContainer.php:555
Stack trace:
#0 C:\tools\pan\pan-os-php\lib\misc-classes\RQuery.php(199) : eval()'d code(1): AddressRuleContainer->hasObjectRecursive()
#1 C:\tools\pan\pan-os-php\lib\misc-classes\RQuery.php(199): eval()
#2 C:\tools\pan\pan-os-php\lib\misc-classes\RQuery.php(331): RQuery->matchSingleObject()
#3 C:\tools\pan\pan-os-php\utils\lib\RULEUTIL.php(371): RQuery->matchSingleObject()
#4 C:\tools\pan\pan-os-php\utils\lib\RULEUTIL.php(37): RULEUTIL->time_to_process_objects()
#5 C:\tools\pan\pan-os-php\utils\lib\UTIL.php(215): RULEUTIL->utilStart()
#6 C:\tools\pan\pan-os-php\lib\misc-classes\PH.php(1060): UTIL->__construct()
#7 C:\tools\pan\pan-os-php\utils\pan-os-php.php(118): PH::callPANOSPHP()
#8 Command line code(1): require_once('...')
#9 {main}
  thrown in C:\tools\pan\pan-os-php\lib\container-classes\AddressRuleContainer.php on line 555

Possible solution

On v2.1.25 (again, not sure if this was the stable or dev release from my last issue report), I get this:

> php -r "require_once 'C:/tools/pan/pan-os-php/utils/pan-os-php.php';" type=rule in=api://panorama.domain.com location=any ruletype=security 'actions=exportToExcel:DevQA-Rules.xls' 'filter=(src has.recursive network1) or (src has.recursive host1) or (src has.recursive host2) or (src has.recursive host3) or (src has.recursive host4) or (dst has.recursive network1) or (dst has.recursive host1) or (dst has.recursive host2) or (dst has.recursive host3) or (dst has.recursive host4)'

***********************************************
*********** pan-os-php.php type=rule UTILITY **************

 - PAN-OS-PHP version: 2.1.25 [WIN] [8.3.11]
 - Downloading config from API...
 - Detected platform type is 'panorama'
 - No 'template' provided so using default ='any'
 - filter after sanitization : (src has.recursive network1) or (src has.recursive host1) or (src has.recursive host2) or (src has.recursive host3) or (src has.recursive host4) or (dst has.recursive network1) or (dst has.recursive host1) or (dst has.recursive host2) or (dst has.recursive host3) or (dst has.recursive host4)
 - Loading configuration through PAN-OS-PHP library...
   (1.20 seconds, 52.43 mb memory)
 - PAN-OS-PHP APP-ID version: 8867-8824

 - PAN-OS APP-ID version: 8904-9011
 - PAN-OS AV version: 4974-5492
 - PAN-OS WF version: 515890-518890
 - PAN-OS THREAT version: 8904-9011
 - PAN-OS version: 110
 - PAN-OS Device timezone: US/Pacific is used. actual time: 2024/10/17 13:14:09
   - action 'exportToExcel' has tasks to process before start.
   - action 'exportToExcel' has tasks to process before start.
   - action 'exportToExcel' has tasks to process before start.

* processing ruleset 'PanoramaConf: / RuleStore:Security' that holds 454 rules
   - object 'rule001'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'File-Sharing-01'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'File-Sharing-02'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule002'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule003'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule004'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule005'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule006'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule007'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule008'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule009'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

* objects processed in DG/Vsys '' : 11 filtered over 454 available

* processing ruleset 'PanoramaConf: / DeviceGroup:FW1 / RuleStore:Security' that holds 950 rules
   - object 'rule010'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule011'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule012'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule013'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule014'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule014a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule014b'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule015'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule016'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule017'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule018'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule018a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule019'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule019a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule020'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule021'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule021a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule022'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule023'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule024'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule025'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule025a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule026'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule027'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule028'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule029'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule030'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

* objects processed in DG/Vsys 'FW1' : 28 filtered over 950 available

* processing ruleset 'PanoramaConf: / DeviceGroup:FW2 / RuleStore:Security' that holds 1469 rules
   - object 'rule011'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule010'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule015'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule016'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule012'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule029'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule030'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule018'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule018a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule013'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule017'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule019'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule014'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule014a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule014b'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule020'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule021'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule021a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule023'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule024'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule025'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule025a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule026'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule031'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule028'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule019a'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule013-1'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule012b'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'rule013-2'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

   - object 'File-Sharing-01-T2'  passing through Action='exportToExcel' Args: filename=DevQA-Rules.xls, additionalFields=,

* objects processed in DG/Vsys 'FW2' : 30 filtered over 1469 available

   - action 'exportToExcel' has tasks to process before shutdown.

 **** PROCESSED 69 objects over 2873 available ****

************* END OF SCRIPT pan-os-php.php type=rule ************

Your Environment

swaschkut commented 1 week ago

Thanks for sharing this. Sorry I did not saw your ticket.

This bug is now fixed in latest develop container, and it will be published in the next few week to latest container.

in your case please use: https://github.com/swaschkut/pan-os-php/tree/develop_2-1-X

bethatasitmay commented 1 week ago

No worries - I just assumed you were busy or on holiday. Thanks for getting to it.

I'll check out the dev build in a few hours.

bethatasitmay commented 1 week ago

Sorry, I was doing some punishing PANOS upgrades that did not go well (nice 16 hour day). I'll check it out later today (Wednesday).

bethatasitmay commented 1 week ago

My apologies for the delay - I finally was able to test the dev build and it worked fine.

Thanks!