git: bc5b1b25e4d7 - main - security/wazuh-agent: Fix issue when protocol is equal to udp46 or tcp46 on FreBSD
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 18 Feb 2025 00:15:21 UTC
The branch main has been updated by acm: URL: https://cgit.FreeBSD.org/ports/commit/?id=bc5b1b25e4d7169567eec0c740130a3a14801add commit bc5b1b25e4d7169567eec0c740130a3a14801add Author: Jose Alonso Cardenas Marquez <acm@FreeBSD.org> AuthorDate: 2025-02-18 00:10:51 +0000 Commit: Jose Alonso Cardenas Marquez <acm@FreeBSD.org> CommitDate: 2025-02-18 00:15:12 +0000 security/wazuh-agent: Fix issue when protocol is equal to udp46 or tcp46 on FreBSD - Bump PORTREVISION Sponsored by: Entersekt --- security/wazuh-agent/Makefile | 1 + .../patch-src-data_provider-src_sysInfoFreeBSD.cpp | 35 +++++++++++++--------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/security/wazuh-agent/Makefile b/security/wazuh-agent/Makefile index fde3d42815be..dc8e91f5eeb1 100644 --- a/security/wazuh-agent/Makefile +++ b/security/wazuh-agent/Makefile @@ -1,6 +1,7 @@ PORTNAME= wazuh DISTVERSION= 4.10.1 DISTVERSIONPREFIX= v +PORTREVISION= 1 CATEGORIES= security MASTER_SITES= https://packages.wazuh.com/deps/35/libraries/sources/:wazuh_sources PKGNAMESUFFIX= -agent diff --git a/security/wazuh-agent/files/patch-src-data_provider-src_sysInfoFreeBSD.cpp b/security/wazuh-agent/files/patch-src-data_provider-src_sysInfoFreeBSD.cpp index 042232ae93e4..86f1fdf985af 100644 --- a/security/wazuh-agent/files/patch-src-data_provider-src_sysInfoFreeBSD.cpp +++ b/security/wazuh-agent/files/patch-src-data_provider-src_sysInfoFreeBSD.cpp @@ -1,5 +1,5 @@ ---- src/data_provider/src/sysInfoFreeBSD.cpp 2024-04-25 01:44:26.000000000 -0700 -+++ src/data_provider/src/sysInfoFreeBSD.cpp 2024-05-10 01:08:00.203056000 -0700 +--- src/data_provider/src/sysInfoFreeBSD.cpp 2025-01-15 06:26:54.000000000 -0800 ++++ src/data_provider/src/sysInfoFreeBSD.cpp 2025-02-17 14:38:11.834720000 -0800 @@ -11,6 +11,7 @@ #include "sysInfo.hpp" #include "cmdHelper.h" @@ -95,17 +95,18 @@ if (uname(&uts) >= 0) { ret["sysname"] = uts.sysname; -@@ -215,18 +234,137 @@ +@@ -215,18 +234,145 @@ nlohmann::json SysInfo::getPorts() const { - // Currently not supported for this OS. - return nlohmann::json {}; --} + const auto query{Utils::exec(R"(sockstat -46qs)")}; ++ ++ /* USER COMMAND PID FD PROTO LOCAL_ADDRESS FOREIGN_ADDRESS PATH_STATE CONN_STATE */ ++ + nlohmann::json ports {}; - --void SysInfo::getProcessesInfo(std::function<void(nlohmann::json&)> /*callback*/) const ++ + if (!query.empty()) + { + const auto lines{Utils::split(Utils::trimToOneSpace(query), '\n')}; @@ -117,6 +118,7 @@ + std::string remoteip = ""; + std::string remoteport = ""; + std::string statedata = ""; ++ + const auto data{Utils::split(line, ' ')}; + auto localdata{Utils::split(data[5], ':')}; + auto remotedata{Utils::split(data[6], ':')}; @@ -126,7 +128,7 @@ + remoteip = remotedata[0]; + remoteport = remotedata[1]; + -+ if((data[4] != "udp4") && (data[4] != "udp6")) { ++ if((data[4] != "udp4") && (data[4] != "udp6") && (data[4] != "udp46")) { + statedata = Utils::toLowerCase(data[7]); + } + @@ -137,10 +139,12 @@ + if(localdata.size() == 4) { + localip = localdata[0] + ":"+ localdata[1] + ":" + localdata[2]; + localport = localdata[3]; -+ } else if(localip == "*") { ++ } ++ ++ if(localip == "*") { + if((data[4] == "tcp6") || (data[4] == "udp6")) { + localip = "0:0:0:0:0:0:0:0"; -+ } else { ++ } else if((data[4] == "tcp4") || (data[4] == "udp4")) { + localip = "0.0.0.0"; + } + } @@ -152,7 +156,9 @@ + if(remotedata.size() == 4) { + remoteip = remotedata[0] + ":"+ remotedata[1] + ":" + remotedata[2]; + remoteport = remotedata[3]; -+ } else if(remoteport == "*") { ++ } ++ ++ if(remoteport == "*") { + remoteip = ""; + remoteport = "0"; + } @@ -177,8 +183,9 @@ + } + + return ports; -+} -+ + } + +-void SysInfo::getProcessesInfo(std::function<void(nlohmann::json&)> /*callback*/) const +void SysInfo::getProcessesInfo(std::function<void(nlohmann::json&)> callback) const { - // Currently not supported for this OS. @@ -219,7 +226,7 @@ + jsProcessInfo["vm_size"] = process["virtual-size"].get<std::string>(); + jsProcessInfo["resident"] = process["rss"].get<std::string>(); + //jsProcessInfo["share"] = process["percent-memory"].get<std::string>(); -+ jsProcessInfo["start_time"] = process["elapsed-times"].get<std::string>(); ++ jsProcessInfo["start_time"] = process["elapsed-times"].get<std::string>() == "-" ? "0" : process["elapsed-times"].get<std::string>(); + jsProcessInfo["pgrp"] = process["process-group"].get<std::string>(); + jsProcessInfo["session"] = process["sid"].get<std::string>(); + jsProcessInfo["tgid"] = process["terminal-process-gid"].get<std::string>(); @@ -239,7 +246,7 @@ if (!query.empty()) { -@@ -235,18 +373,22 @@ +@@ -235,18 +381,22 @@ for (const auto& line : lines) { const auto data{Utils::split(line, '|')};