PaloAltoNetworks / pan-os-php

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

type=rule action=description-append is failing #772

Closed bethatasitmay closed 1 year ago

bethatasitmay commented 1 year ago

Describe the bug

When I run a command with action=description-append it is failing.

Expected behavior

Baring too many description entries, a filter-matching rule's description should be updated. This was working prior to me upgrading from v2.0.73 to v2.1.13. I tried saved commands that previously worked and they do not work now. I've tried different filters to confirm it isn't getting stuck on a single rule.

Current behavior

PS C:\tools\pan> PS C:\tools\pan> PS C:\tools\pan>PS C:\tools\pan> php -r "require_once 'C:/tools/pan/pan-os-php/utils/pan-os-php.php';" type=rule in=api://panorama.domain.com location=firewall01 actions=description-Append:' Ticket-229 8-28-23',no 'filter=(dst has.recursive host01)'


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

Steps to reproduce

php -r "require_once 'C:/tools/pan/pan-os-php/utils/pan-os-php.php';" type=rule in=api://lv-pamgmt01.dcswins.com location=any actions=description-Append:'TEST 8-28-23',yes 'filter=(tag has Migration-06)'

I've also tried filtering on a src has.recursive/dst has.recursive and using location any. With location any, it did update a Shared rule but then still failed with the above error.

Context

For audit purposes, we are required to make a rule description update that corresponds to a commit.

Your Environment

swaschkut commented 1 year ago

PHP Fatal error: Uncaught Error: Call to undefined function mb_convert_encoding()

mb_convert_encoding() is not part of PAN-OS-PHP, there was also no change between 2.0.73 and 2.1.13 of using this;

php-mbstring is an extension to PHP is still needed, please check on your PHP version that this is still working fine.

bethatasitmay commented 1 year ago

hmmm, I haven't touched my PHP install since I had to revert from v8.2 when I upgraded to it when I shouldn't have (around January). I'll uninstall/re-install and see how it goes.

I'm assuming that php-mbstring is part of the normal install and, in particular, a part of the Chocolatey method of installing PHP.

Also, do I still need to install a PHP version <8.2?

swaschkut commented 1 year ago

you can continue with PHP 8.2 since you reached out I fixed all of this, and run myself only 8.2

bethatasitmay commented 1 year ago

Ah, I missed that in the updates (I do read them, just too fast sometimes :-) )

swaschkut commented 1 year ago

ok, so I will close this case, as this is related to PHP and PHP module installation

bethatasitmay commented 1 year ago

All good now - thanks!

TL;DR

In my last PHP 8.1.6 install, I did not enable the mbstring extension (I didn't even have it in my notes to do that which makes me think it was never enabled). I uninstalled 8.1, installed 8.2, fixed the path, enabled the mbstring extension, and re-downloaded PAN-OS-PHP from GIT just to be sure.

I didn't think to check the php.ini for the extension being enabled and testing it prior to the uninstall - I only looked at it as with a new PHP install, enable_dl needs to be turned on and I had a note to enable the openssl extension (although I think you fixed that issue a while back).

The uninstall retains the php.ini since it's not the original and I did not have the mbstring extension enabled in my previous install. Strange that it worked for so long without issue.

The action=description-append is now working.