git: 2782fc98996b - main - net-mgmt/librenms: Update to 24.12.0

From: Dan Langille <dvl_at_FreeBSD.org>
Date: Mon, 23 Dec 2024 21:05:03 UTC
The branch main has been updated by dvl:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2782fc98996b3597d00b2aceff7c30e4ea4b892a

commit 2782fc98996b3597d00b2aceff7c30e4ea4b892a
Author:     Dan Langille <dvl@FreeBSD.org>
AuthorDate: 2024-12-23 21:01:35 +0000
Commit:     Dan Langille <dvl@FreeBSD.org>
CommitDate: 2024-12-23 21:05:00 +0000

    net-mgmt/librenms: Update to 24.12.0
    
    re https://github.com/librenms/librenms/releases/tag/24.12.0
    
    patched to fix URL validation issue - taken from this merge request:
    
    https://github.com/librenms/librenms/pull/16900
---
 net-mgmt/librenms/Makefile                         |  4 +--
 net-mgmt/librenms/distinfo                         | 10 +++----
 .../files/patch-LibreNMS_Validations_WebServer.php | 34 ++++++++++++++++++++++
 3 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/net-mgmt/librenms/Makefile b/net-mgmt/librenms/Makefile
index 4d8eb30ab1a2..ec492e0d931a 100644
--- a/net-mgmt/librenms/Makefile
+++ b/net-mgmt/librenms/Makefile
@@ -1,5 +1,5 @@
 PORTNAME=	librenms
-PORTVERSION=	24.11.0
+PORTVERSION=	24.12.0
 PORTEPOCH=	1
 CATEGORIES=	net-mgmt
 MASTER_SITES=	LOCAL/dvl:vendor
@@ -128,7 +128,7 @@ _SCRIPT_FILES=		daily.sh lnms
 # _RELEASE_TIMESTAMP is used for a patch inside the vendor code
 # it represents the release date via: git show --pretty='%H|%ct' -s 1.42.01
 # It sits here so you remember to update it with each release
-_RELEASE_TIMESTAMP=	1732114734
+_RELEASE_TIMESTAMP=	1734479713
 _ROOT_DIRS=		LibreNMS app bootstrap config database doc html \
 			includes lang licenses mibs misc resources routes \
 			scripts tests
diff --git a/net-mgmt/librenms/distinfo b/net-mgmt/librenms/distinfo
index bfd6e01422f8..d9c0d41f1cf0 100644
--- a/net-mgmt/librenms/distinfo
+++ b/net-mgmt/librenms/distinfo
@@ -1,5 +1,5 @@
-TIMESTAMP = 1732119849
-SHA256 (librenms-vendor-24.11.0.tar.gz) = 1014e59cd1a70a908307d72bd4ed54a6cb9a59bd37195199bd67e76290ec7fa6
-SIZE (librenms-vendor-24.11.0.tar.gz) = 28809754
-SHA256 (librenms-librenms-24.11.0_GH0.tar.gz) = de8f81f244852dabc82dc31a01509d5cc2a05486965007ba19d1dcf55e06e2c6
-SIZE (librenms-librenms-24.11.0_GH0.tar.gz) = 64503103
+TIMESTAMP = 1734480371
+SHA256 (librenms-vendor-24.12.0.tar.gz) = e7211b4b09793eaa46c08951c5b1c4535112144a5ad548e5b2ebafbbafb1712e
+SIZE (librenms-vendor-24.12.0.tar.gz) = 28817646
+SHA256 (librenms-librenms-24.12.0_GH0.tar.gz) = 16510909a7a5d8df82fb0c90d48efc93dff8065704d02230cdcb61744d2e64d4
+SIZE (librenms-librenms-24.12.0_GH0.tar.gz) = 65974321
diff --git a/net-mgmt/librenms/files/patch-LibreNMS_Validations_WebServer.php b/net-mgmt/librenms/files/patch-LibreNMS_Validations_WebServer.php
new file mode 100644
index 000000000000..3a7e1c053e74
--- /dev/null
+++ b/net-mgmt/librenms/files/patch-LibreNMS_Validations_WebServer.php
@@ -0,0 +1,34 @@
+--- LibreNMS/Validations/WebServer.php.orig	2024-12-17 23:55:13 UTC
++++ LibreNMS/Validations/WebServer.php
+@@ -45,22 +45,28 @@ class WebServer extends BaseValidation
+     {
+         if (! app()->runningInConsole()) {
+             $url = $this->removeStandardPorts(request()->url());
+-            $expected = $this->removeStandardPorts(Str::finish(Config::get('base_url'), '/') . 'validate/results');
++            $base_url = Config::get('base_url');
++            $expected = $this->removeStandardPorts(Str::finish($base_url, '/') . 'validate/results');
++            $correct_base = str_replace('/validate/results', '', $url);
+ 
+             if ($url !== $expected) {
+                 preg_match($this->host_regex, $url, $actual_host_match);
+                 preg_match($this->host_regex, $expected, $expected_host_match);
+                 $actual_host = $actual_host_match[1] ?? '';
+                 $expected_host = $expected_host_match[1] ?? "parse failure ($expected)";
+-                if ($actual_host != $expected_host) {
++
++                if ($base_url == '/' && ! str_contains($actual_host, '/')) {
++                    $validator->warn('base_url could be more specific', "lnms config:set base_url $correct_base");
++                } elseif ($actual_host != $expected_host) {
+                     $nginx = Str::startsWith(request()->server->get('SERVER_SOFTWARE'), 'nginx');
+                     $server_name = $nginx ? 'server_name' : 'ServerName';
+                     $fix = $nginx ? "server_name $actual_host;" : "ServerName $actual_host";
+                     $validator->fail("$server_name is set incorrectly for your webserver, update your webserver config. $actual_host $expected_host", $fix);
+                 } else {
+-                    $correct_base = str_replace('validate/results', '', $url);
+                     $validator->fail('base_url is not set correctly', "lnms config:set base_url $correct_base");
+                 }
++            } elseif (preg_replace('#/$#', '', \config('app.url')) !== $correct_base) {
++                $validator->fail("APP_URL is not set correctly. It should be set to $correct_base");
+             }
+ 
+             if (request()->secure() && ! \config('session.secure')) {