From 38c7bcc0611d0dc5ee79a66d097e8495afd2cf2e Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Thu, 4 Aug 2022 10:10:20 +0200 Subject: [PATCH 1/2] fix errors ipam pandora_enterprise#9282 --- pandora_console/include/functions.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 3f84a31b13..3235045817 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -5996,6 +5996,26 @@ function send_test_email( } +/** + * Check ip is valid into network + * + * @param string $ip Ip XXX.XXX.XXX.XXX. + * @param string $cidr Network XXX.XXX.XXX.XXX/XX. + * + * @return boolean + */ +function cidr_match($ip, $cidr) +{ + list($subnet, $mask) = explode('/', $cidr); + + if ((ip2long($ip) & ~((1 << (32 - $mask)) - 1) ) == ip2long($subnet)) { + return true; + } + + return false; +} + + /** * Microtime float number. * From 1e4fa9573038a3962ab75081adf7256e9b425b4a Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Mon, 8 Aug 2022 12:24:04 +0200 Subject: [PATCH 2/2] discovery server to none pandora_enterprise#9282 --- pandora_console/extras/mr/56.sql | 4 ++++ pandora_console/pandoradb.sql | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_console/extras/mr/56.sql b/pandora_console/extras/mr/56.sql index da07b1612e..f47fe49e46 100644 --- a/pandora_console/extras/mr/56.sql +++ b/pandora_console/extras/mr/56.sql @@ -38,6 +38,10 @@ ALTER TABLE `tautoconfig` ADD COLUMN `executed` TINYINT UNSIGNED NOT NULL DEFAUL ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`; +ALTER TABLE `tipam_network` DROP FOREIGN KEY `tipam_network_ibfk_1`; +ALTER TABLE `tipam_network` MODIFY COLUMN `id_recon_task` INT UNSIGNED DEFAULT 0; +ALTER TABLE `tipam_network` ADD CONSTRAINT `tipam_network_ibfk_1` FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE SET NULL ON UPDATE CASCADE; + ALTER TABLE `tevent_filter` ADD COLUMN `search_secondary_groups` INT NOT NULL DEFAULT 0; COMMIT; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index fe41d0ce80..dc47b032af 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3889,7 +3889,7 @@ CREATE TABLE IF NOT EXISTS `tipam_network` ( `name_network` VARCHAR(255) DEFAULT '', `description` TEXT, `location` INT UNSIGNED NULL, - `id_recon_task` INT UNSIGNED NOT NULL, + `id_recon_task` INT UNSIGNED DEFAULT 0, `scan_interval` TINYINT DEFAULT 1, `monitoring` TINYINT DEFAULT 0, `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, @@ -3898,7 +3898,7 @@ CREATE TABLE IF NOT EXISTS `tipam_network` ( `id_site` BIGINT UNSIGNED, `vrf` INT UNSIGNED, PRIMARY KEY (`id`), - FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE, + FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE, FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE