From dfce547f9264dae98755c337b5bcc71c281b6fc7 Mon Sep 17 00:00:00 2001 From: Sven Waschkut Date: Fri, 21 Jul 2023 14:10:06 +0200 Subject: [PATCH 1/4] start working on version 2.1.12 --- CHANGELOG.txt | 10 +++++++++- lib/misc-classes/PH.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 98f75d73..39ef9588 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,14 @@ CHANGELOG -2.1.11 +2.1.12 +UTIL: + +BUGFIX: + +GENERAL: + + +2.1.11 (20230721) UTIL: * type=rule | introduce new 'filter=(timestamp-rule-creation <>=! -30 days)' | timestamp-rule-modification * type=address | introduce 'filter=(value ip4.included-in RFC1918)' diff --git a/lib/misc-classes/PH.php b/lib/misc-classes/PH.php index c3e5078c..8544b613 100644 --- a/lib/misc-classes/PH.php +++ b/lib/misc-classes/PH.php @@ -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 = 11; + private static $library_version_bugfix = 12; //BASIC AUTH PAN-OS 7.1 public static $softwareupdate_key = "658d787f293e631196dac9fb29490f1cc1bb3827"; From b41707529fce47f57f92162f23e9c2a1d695b226 Mon Sep 17 00:00:00 2001 From: Sven Waschkut Date: Fri, 21 Jul 2023 14:54:53 +0200 Subject: [PATCH 2/4] type=bpa-generator | extend response output if not valid JSON --- CHANGELOG.txt | 1 + utils/lib/BPAGENERATOR.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 39ef9588..92cb450b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,6 +2,7 @@ CHANGELOG 2.1.12 UTIL: +* type=bpa-generator | extend response output if not valid JSON BUGFIX: diff --git a/utils/lib/BPAGENERATOR.php b/utils/lib/BPAGENERATOR.php index 6a5a76de..cd08dc79 100644 --- a/utils/lib/BPAGENERATOR.php +++ b/utils/lib/BPAGENERATOR.php @@ -170,12 +170,13 @@ function send_bpa_api($url, $type = "GET", $config = null, $system_info = null, { $reply = json_decode($response, TRUE); if( $reply === null ) + { + PH::print_stdout( "RESPONSE: ".$response); derr( "invalid JSON file provided", null, FALSE ); + } + if( isset( $reply['task_id'] ) ) - { - #print_r( $reply ); $response = $reply['task_id']; - } else { print_r( $reply ); From c4e302a47cae0740c77848d925d69b28f826fca3 Mon Sep 17 00:00:00 2001 From: Sven Waschkut Date: Mon, 31 Jul 2023 11:28:05 +0200 Subject: [PATCH 3/4] type=gcp | extend for mqsql usage and bring in mysql pw in type=key-manager --- CHANGELOG.txt | 1 + lib/misc-classes/PanAPIConnector.php | 6 +- lib/rule-classes/DefaultSecurityRule.php | 2 +- utils/lib/GCP.php | 70 ++++++++++++++++++++++-- utils/lib/KEYMANGER.php | 7 ++- 5 files changed, 74 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 92cb450b..57a62b63 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ CHANGELOG 2.1.12 UTIL: * type=bpa-generator | extend response output if not valid JSON +* type=gcp | extend for mqsql usage and bring in mysql pw in type=key-manager BUGFIX: diff --git a/lib/misc-classes/PanAPIConnector.php b/lib/misc-classes/PanAPIConnector.php index bd27d063..58e80dc8 100644 --- a/lib/misc-classes/PanAPIConnector.php +++ b/lib/misc-classes/PanAPIConnector.php @@ -422,7 +422,7 @@ static public function findOrCreateConnectorFromHost($host, $apiKey = null, $pro { PH::$useExceptions = $exceptionUse; - if( $host != "bpa-apikey" && $host != "license-apikey" && $host != "ldap-password" && $host != "maxmind-licensekey" ) + if( $host != "bpa-apikey" && $host != "license-apikey" && $host != "ldap-password" && $host != "maxmind-licensekey" && $host != "gcp-mysql-password" ) { $wrongLogin = TRUE; @@ -475,7 +475,7 @@ static public function findOrCreateConnectorFromHost($host, $apiKey = null, $pro } - if( strlen($apiKey) < 19 && !( $host == "bpa-apikey" || $host == "license-apikey" || $host == "ldap-password" || $host == "maxmind-licensekey" ) ) + if( strlen($apiKey) < 19 && !( $host == "bpa-apikey" || $host == "license-apikey" || $host == "ldap-password" || $host == "maxmind-licensekey" || $host == "gcp-mysql-password" ) ) { $user = $apiKey; @@ -523,7 +523,7 @@ static public function findOrCreateConnectorFromHost($host, $apiKey = null, $pro $connector = new PanAPIConnector($host, $apiKey, 'panos', null, $port); } - if( $host == "bpa-apikey" || $host == "license-apikey" || $host == "ldap-password" || $host == "maxmind-licensekey" || strpos($host, "tsg_id") !== FALSE ) + if( $host == "bpa-apikey" || $host == "license-apikey" || $host == "ldap-password" || $host == "maxmind-licensekey" || strpos($host, "tsg_id" || $host == "gcp-mysql-password") !== FALSE ) { $checkConnectivity = false; self::$savedConnectors[] = $connector; diff --git a/lib/rule-classes/DefaultSecurityRule.php b/lib/rule-classes/DefaultSecurityRule.php index 38de900a..1115eb61 100644 --- a/lib/rule-classes/DefaultSecurityRule.php +++ b/lib/rule-classes/DefaultSecurityRule.php @@ -346,7 +346,7 @@ public function securityProfileType() public function securityProfileGroup() { if( $this->secproftype != 'group' ) - derr('Cannot be called on a rule that is of security type =' . $this->secproftype); + derr('Cannot be called on a rule that is of security profile type = "' . $this->secproftype.'"'); return $this->secprofgroup; } diff --git a/utils/lib/GCP.php b/utils/lib/GCP.php index 72dd408e..b8ae105e 100644 --- a/utils/lib/GCP.php +++ b/utils/lib/GCP.php @@ -112,6 +112,7 @@ public function main() $actionArray[] = "download"; $actionArray[] = "onboard"; $actionArray[] = "offboard"; + $actionArray[] = "mysql-validation"; if( $this->strposARRAY( strtolower($action), $actionArray ) == FALSE ) derr( "not supported ACTION - ".implode(",", $actionArray) ); } @@ -125,6 +126,7 @@ public function main() PH::print_stdout( " - actions=download tenantid=FULL"); PH::print_stdout( " - actions=onboard tenantid=XYZ"); PH::print_stdout( " - actions=offboard tenantid=XYZ"); + PH::print_stdout( " - actions=mysql-validation tenantid=XYZ"); PH::print_stdout(); derr( "argument actions= is missing", null, false ); } @@ -152,7 +154,7 @@ public function main() $this->execCLIWithOutput( $get_auth ); //get correct tenantid - if( isset(PH::$args['tenantid']) ) + if( isset(PH::$args['tenantid']) && $action != "mysql-validation" ) { $tenantIDString = $tenantID; $tenantID = $this->grepAllPods( $tenantID ); @@ -328,20 +330,78 @@ public function main() mysql> drop database `DATABASE`; */ $username = "paloalto"; - $password = "PASSWORD"; - derr("adjustment needed, correct PW in cleartext not stored in sourcecode!"); + //check if available via .panconfigkeystore + $connector = PanAPIConnector::findOrCreateConnectorFromHost( 'gcp-mysql-password' ); + $mysqlPassword = $connector->apikey; + #$database = substr($tenantID, 0, -2); $database = $tenantID; - $drop_database_string = 'mysql -h 127.0.0.1 -P 3310 -u '.$username.' -p'.$password.' drop `'.$database.'`'; + if( !is_numeric($tenantID) ) + derr( "tenantID: '".$tenantID."' - is not numeric" ); + + $drop_database_string = 'mysql -h 127.0.0.1 -P 3310 -u '.$username.' -p'.$mysqlPassword.' drop `'.$database.'`'; $this->execCLIWithOutput( $mgmtsvc.$drop_database_string ); } + elseif( $action == "mysql-validation" ) + { + $get_auth = "gcloud container clusters get-credentials admin --region ".$region." --project ".$project; + $this->execCLIWithOutput( $get_auth ); + + $mgmtsvc_tenantID = $this->grepAllPods( "mgmtsvc" ); + $mgmtsvc = "kubectl exec -it ".$mgmtsvc_tenantID[0]." -c mgmtsvc --insecure-skip-tls-verify=true -- "; + + + $username = "paloalto"; + + //check if available via .panconfigkeystore + $connector = PanAPIConnector::findOrCreateConnectorFromHost( 'gcp-mysql-password' ); + $mysqlPassword = $connector->apikey; + + + if( !is_numeric($tenantID) ) + derr( "tenantID: '".$tenantID."' - is not numeric" ); + + $cmdArray = array(); + $cmdArray[] = array("cmd" => "select * from adi_adm_customer_info where tenant_id='".$tenantID."_onprem'\G" ); + $cmdArray[] = array("cmd" => "select * from adi_migration where onprem_tenant_id='".$tenantID."_onprem'\G" ); + /* + Use $tenantID; + Select * from jobs\G + */ + $cmdArray[] = array("cmd" => "select * from jobs\G", "db" => $tenantID); + + $cmdArray[] = array("cmd" => "select * from spiffy_license_info where cdl_tenant_id='".$tenantID."'\G" ); + + $cmdArray[] = array("cmd" => "select * from adi_adm_customer_info where customer_blob like '%".$tenantID."%'\G" ); + + + $cmdArray[] = array("cmd" => "select info_status_message from adi_ext_prisma_access_sync_status where tenant_id='".$tenantID."'\G" ); + + foreach( $cmdArray as $cmd ) + { + if( isset( $cmd['db'] ) ) + $DB = $cmd['db']; + else + $DB = "admin"; + $drop_database_string = 'mysql -h 127.0.0.1 -P 3310 -u '.$username.' -U '.$DB.' -p'.$mysqlPassword.' -e "'.$cmd['cmd'].'"'; + $this->execCLIWithOutput( $mgmtsvc.$drop_database_string ); + } + } } private function execCLI( $cli, &$output, &$retValue ) { PH::print_stdout(); - PH::print_stdout( "execute: '".$cli."'"); + $cliString = $cli; + if( strpos( $cliString, "mysql" ) !== FALSE ) + { + $connector = PanAPIConnector::findOrCreateConnectorFromHost( 'gcp-mysql-password' ); + $mysqlPassword = $connector->apikey; + $cliString = str_replace($mysqlPassword, "**********", $cliString); + } + + PH::print_stdout( "execute: '".$cliString."'"); exec($cli, $output, $retValue); } diff --git a/utils/lib/KEYMANGER.php b/utils/lib/KEYMANGER.php index c3ba1376..7ebc4a27 100644 --- a/utils/lib/KEYMANGER.php +++ b/utils/lib/KEYMANGER.php @@ -31,6 +31,7 @@ public function utilStart() - php " . basename(__FILE__) . " add=license-apikey 'apikey=[ your personal company license API key account can be found via https://support.paloaltonetworks.com -> Assets -> API key management - only super user can see this ]' - php " . basename(__FILE__) . " add=bpa-apikey 'apikey=[ PAN-OS BPA key can be request via: https://customersuccess.paloaltonetworks.com/api-signup/ ]' - php " . basename(__FILE__) . " add=ldap-password 'apikey=[ LDAP password to interact with organisational ldap server ]' + - php " . basename(__FILE__) . " add=gcp-mysql-password 'apikey=[ mysql password to interact with organisational GCP mysql server ]' - php " . basename(__FILE__) . " add=maxmind-licensekey apikey=[ Maxmind license to download Maxmind geo2ip lite database. create free account: https://www.maxmind.com ] - php " . basename(__FILE__) . " add=tsg_id{{TSGID}} 'apikey={{CLIENT_ID}}%{{CLIENT_SECRET}}' | character '%' must be used as separator between client_id and client_secret"; @@ -134,7 +135,7 @@ public function main() PH::$JSON_TMP['header'] = $string; PH::$JSON_TMP[$addHost]['name'] = $addHost; - if( $addHost == "bpa-apikey" || $addHost == "license-apikey" || $addHost == "ldap-password" || $addHost == "maxmind-licensekey" || strpos($addHost, "tsg_id") !== FALSE ) + if( $addHost == "bpa-apikey" || $addHost == "license-apikey" || $addHost == "ldap-password" || $addHost == "maxmind-licensekey" || strpos($addHost, "tsg_id" || $addHost == "gcp-mysql-password") !== FALSE ) { if( strpos($addHost, "tsg_id") !== FALSE ) { @@ -223,7 +224,7 @@ public function main() PH::print_stdout( " - requested to test Host/IP '{$checkHost}'"); PH::$JSON_TMP[$checkHost]['name'] = $checkHost; - if( $checkHost == "bpa-apikey" || $checkHost == "license-apikey" || $checkHost == "ldap-password" || $checkHost == "maxmind-licensekey" ) + if( $checkHost == "bpa-apikey" || $checkHost == "license-apikey" || $checkHost == "ldap-password" || $checkHost == "maxmind-licensekey" || $addHost == "gcp-mysql-password" ) { PH::$JSON_TMP[$checkHost]['status'] = "skipped can not be tested"; continue; @@ -285,7 +286,7 @@ public function main() PH::print_stdout( " - requested to test Host/IP '{$checkHost}'"); PH::$JSON_TMP[$checkHost]['name'] = $checkHost; - if( $checkHost == "bpa-apikey" || $checkHost == "license-apikey" || $checkHost == "ldap-password" || $checkHost == "maxmind-licensekey" ) + if( $checkHost == "bpa-apikey" || $checkHost == "license-apikey" || $checkHost == "ldap-password" || $checkHost == "maxmind-licensekey" || $addHost == "gcp-mysql-password" ) { PH::$JSON_TMP[$checkHost]['status'] = "skipped can not be tested"; } From 028fd97db5cbe702776f122e7c2be15baad0e981 Mon Sep 17 00:00:00 2001 From: Sven Waschkut Date: Mon, 31 Jul 2023 11:43:48 +0200 Subject: [PATCH 4/4] type=XYZ | in=api://{MGMT-IP} actions=name-rename - bugfix for API usage --- CHANGELOG.txt | 1 + lib/object-classes/Address.php | 6 +++--- lib/object-classes/AddressGroup.php | 4 ++-- lib/object-classes/AntiSpywareProfile.php | 4 ++-- lib/object-classes/AntiVirusProfile.php | 4 ++-- lib/object-classes/DNSSecurityProfile.php | 5 +++-- lib/object-classes/DataFilteringProfile.php | 4 ++-- lib/object-classes/DecryptionProfile.php | 4 ++-- lib/object-classes/FileBlockingProfile.php | 4 ++-- lib/object-classes/Profile.php | 4 ++-- lib/object-classes/Region.php | 3 ++- lib/object-classes/SaasSecurityProfile.php | 4 ++-- lib/object-classes/Schedule.php | 4 ++-- lib/object-classes/SecurityProfileGroup.php | 4 ++-- lib/object-classes/Service.php | 4 ++-- lib/object-classes/ServiceGroup.php | 4 ++-- lib/object-classes/URLProfile.php | 4 ++-- lib/object-classes/VirusAndWildfireProfile.php | 4 ++-- lib/object-classes/VulnerabilityProfile.php | 4 ++-- lib/object-classes/WildfireProfile.php | 4 ++-- lib/object-classes/customURLProfile.php | 4 ++-- lib/rule-classes/Rule.php | 4 ++-- utils/common/actions-service.php | 2 ++ 23 files changed, 47 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 57a62b63..b88b4eda 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,6 +6,7 @@ UTIL: * type=gcp | extend for mqsql usage and bring in mysql pw in type=key-manager BUGFIX: +* type=XYZ | in=api://{MGMT-IP} actions=name-rename - bugfix for API usage GENERAL: diff --git a/lib/object-classes/Address.php b/lib/object-classes/Address.php index ed715ff8..63522ff6 100644 --- a/lib/object-classes/Address.php +++ b/lib/object-classes/Address.php @@ -345,12 +345,12 @@ public function API_setName($newName) return; } - if( !$this->setName($newName) ) - return FALSE; - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + if( !$this->setName($newName) ) + return FALSE; + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); elseif( $c->isSaseAPI() ) diff --git a/lib/object-classes/AddressGroup.php b/lib/object-classes/AddressGroup.php index 7227d97c..000a6d14 100644 --- a/lib/object-classes/AddressGroup.php +++ b/lib/object-classes/AddressGroup.php @@ -690,11 +690,11 @@ public function members() */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/AntiSpywareProfile.php b/lib/object-classes/AntiSpywareProfile.php index ebec7608..621fac5d 100644 --- a/lib/object-classes/AntiSpywareProfile.php +++ b/lib/object-classes/AntiSpywareProfile.php @@ -72,11 +72,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/AntiVirusProfile.php b/lib/object-classes/AntiVirusProfile.php index 61ed9ede..3b11155c 100644 --- a/lib/object-classes/AntiVirusProfile.php +++ b/lib/object-classes/AntiVirusProfile.php @@ -83,11 +83,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/DNSSecurityProfile.php b/lib/object-classes/DNSSecurityProfile.php index c711baca..053ce9a9 100644 --- a/lib/object-classes/DNSSecurityProfile.php +++ b/lib/object-classes/DNSSecurityProfile.php @@ -77,10 +77,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/DataFilteringProfile.php b/lib/object-classes/DataFilteringProfile.php index 57f77071..bfc56295 100644 --- a/lib/object-classes/DataFilteringProfile.php +++ b/lib/object-classes/DataFilteringProfile.php @@ -70,11 +70,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/DecryptionProfile.php b/lib/object-classes/DecryptionProfile.php index 1391a2b9..54f57e40 100644 --- a/lib/object-classes/DecryptionProfile.php +++ b/lib/object-classes/DecryptionProfile.php @@ -80,11 +80,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/FileBlockingProfile.php b/lib/object-classes/FileBlockingProfile.php index 8d13509d..0333c63c 100644 --- a/lib/object-classes/FileBlockingProfile.php +++ b/lib/object-classes/FileBlockingProfile.php @@ -70,11 +70,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/Profile.php b/lib/object-classes/Profile.php index b2027878..3f25d37a 100644 --- a/lib/object-classes/Profile.php +++ b/lib/object-classes/Profile.php @@ -80,11 +80,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/Region.php b/lib/object-classes/Region.php index 15217ef8..81be45c3 100644 --- a/lib/object-classes/Region.php +++ b/lib/object-classes/Region.php @@ -142,11 +142,12 @@ public function API_setName($newName) mwarning('renaming of TMP object in API is not possible, it was ignored'); return; } - $this->setName($newName); $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/SaasSecurityProfile.php b/lib/object-classes/SaasSecurityProfile.php index 01e521bf..1b513fb3 100644 --- a/lib/object-classes/SaasSecurityProfile.php +++ b/lib/object-classes/SaasSecurityProfile.php @@ -77,11 +77,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/Schedule.php b/lib/object-classes/Schedule.php index 32b75a2e..360a3a97 100644 --- a/lib/object-classes/Schedule.php +++ b/lib/object-classes/Schedule.php @@ -89,11 +89,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/SecurityProfileGroup.php b/lib/object-classes/SecurityProfileGroup.php index c22008d1..d213ae36 100644 --- a/lib/object-classes/SecurityProfileGroup.php +++ b/lib/object-classes/SecurityProfileGroup.php @@ -115,11 +115,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI() ) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/Service.php b/lib/object-classes/Service.php index 28ce0691..ce623f06 100644 --- a/lib/object-classes/Service.php +++ b/lib/object-classes/Service.php @@ -570,11 +570,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI()) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/ServiceGroup.php b/lib/object-classes/ServiceGroup.php index d8789c80..09846ce2 100644 --- a/lib/object-classes/ServiceGroup.php +++ b/lib/object-classes/ServiceGroup.php @@ -185,11 +185,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI()) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/URLProfile.php b/lib/object-classes/URLProfile.php index 43c2b0c4..26e62875 100644 --- a/lib/object-classes/URLProfile.php +++ b/lib/object-classes/URLProfile.php @@ -105,11 +105,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI()) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/VirusAndWildfireProfile.php b/lib/object-classes/VirusAndWildfireProfile.php index 85ceb3c4..e5a046cf 100644 --- a/lib/object-classes/VirusAndWildfireProfile.php +++ b/lib/object-classes/VirusAndWildfireProfile.php @@ -70,11 +70,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI()) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/VulnerabilityProfile.php b/lib/object-classes/VulnerabilityProfile.php index f67ea155..8bec04fe 100644 --- a/lib/object-classes/VulnerabilityProfile.php +++ b/lib/object-classes/VulnerabilityProfile.php @@ -74,11 +74,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI()) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/WildfireProfile.php b/lib/object-classes/WildfireProfile.php index 0c851e8f..6d8f05b6 100644 --- a/lib/object-classes/WildfireProfile.php +++ b/lib/object-classes/WildfireProfile.php @@ -70,11 +70,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI()) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/object-classes/customURLProfile.php b/lib/object-classes/customURLProfile.php index 1c1965b7..6eb16a35 100644 --- a/lib/object-classes/customURLProfile.php +++ b/lib/object-classes/customURLProfile.php @@ -91,11 +91,11 @@ public function setName($newName) */ public function API_setName($newName) { - $this->setName($newName); - $c = findConnectorOrDie($this); $xpath = $this->getXPath(); + $this->setName($newName); + if( $c->isAPI()) $c->sendRenameRequest($xpath, $newName); } diff --git a/lib/rule-classes/Rule.php b/lib/rule-classes/Rule.php index 6fe2bcb5..a57934a6 100644 --- a/lib/rule-classes/Rule.php +++ b/lib/rule-classes/Rule.php @@ -701,9 +701,9 @@ public function API_setName($newname) $con = findConnectorOrDie($this); $xpath = $this->getXPath(); - $con->sendRenameRequest($xpath, $newname); - $this->setName($newname); + + $con->sendRenameRequest($xpath, $newname); } public function API_clearPolicyAppUsageDATA() diff --git a/utils/common/actions-service.php b/utils/common/actions-service.php index 1c7e42f1..c291db4a 100644 --- a/utils/common/actions-service.php +++ b/utils/common/actions-service.php @@ -1052,6 +1052,8 @@ return; } + $newName = str_replace(",", "_", $newName); + $string = "new name will be '{$newName}'"; PH::ACTIONlog( $context, $string );