From 31fb9390c21558f4ffe1c6ccab0564c836d2ce93 Mon Sep 17 00:00:00 2001 From: szedenik-adam Date: Thu, 7 Aug 2025 10:22:42 +0200 Subject: [PATCH] Replaced string parameters with string_view in AuditLog --- headers/modsecurity/audit_log.h | 16 ++++++++-------- src/audit_log/audit_log.cc | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/headers/modsecurity/audit_log.h b/headers/modsecurity/audit_log.h index 5f546417..42d4e6ba 100644 --- a/headers/modsecurity/audit_log.h +++ b/headers/modsecurity/audit_log.h @@ -153,18 +153,18 @@ class AuditLog { bool setStorageDirMode(int permission); bool setFileMode(int permission); bool setStatus(AuditLogStatus new_status); - bool setRelevantStatus(const std::basic_string& new_relevant_status); - bool setFilePath1(const std::basic_string& path); - bool setFilePath2(const std::basic_string& path); - bool setStorageDir(const std::basic_string& path); - bool setHeader(const std::basic_string& header); + bool setRelevantStatus(std::string_view new_relevant_status); + bool setFilePath1(std::string_view path); + bool setFilePath2(std::string_view path); + bool setStorageDir(std::string_view path); + bool setHeader(std::string_view header); bool setFormat(AuditLogFormat fmt); int getDirectoryPermission() const; int getFilePermission() const; int getParts() const; - bool setParts(const std::basic_string& new_parts); + bool setParts(std::string_view new_parts); bool setType(AuditLogType audit_type); bool init(std::string *error); @@ -174,8 +174,8 @@ class AuditLog { bool saveIfRelevant(Transaction *transaction, int parts); bool isRelevant(int status); - static int addParts(int parts, const std::string& new_parts); - static int removeParts(int parts, const std::string& new_parts); + static int addParts(int parts, std::string_view new_parts); + static int removeParts(int parts, std::string_view new_parts); void setCtlAuditEngineActive() { m_ctlAuditEngineActive = true; diff --git a/src/audit_log/audit_log.cc b/src/audit_log/audit_log.cc index d082fd00..397edefb 100644 --- a/src/audit_log/audit_log.cc +++ b/src/audit_log/audit_log.cc @@ -109,31 +109,31 @@ bool AuditLog::setStatus(AuditLogStatus status) { } -bool AuditLog::setRelevantStatus(const std::basic_string& status) { +bool AuditLog::setRelevantStatus(std::string_view status) { this->m_relevant = std::string(status); return true; } -bool AuditLog::setStorageDir(const std::basic_string& path) { +bool AuditLog::setStorageDir(std::string_view path) { this->m_storage_dir = path; return true; } -bool AuditLog::setFilePath1(const std::basic_string& path) { +bool AuditLog::setFilePath1(std::string_view path) { this->m_path1 = path; return true; } -bool AuditLog::setFilePath2(const std::basic_string& path) { +bool AuditLog::setFilePath2(std::string_view path) { this->m_path2 = path; return true; } -bool AuditLog::setHeader(const std::basic_string& header) { +bool AuditLog::setHeader(std::string_view header) { this->m_header = header; return true; } @@ -144,7 +144,7 @@ bool AuditLog::setFormat(AuditLogFormat fmt) { return true; } -int AuditLog::addParts(int parts, const std::string& new_parts) { +int AuditLog::addParts(int parts, std::string_view new_parts) { PARTS_CONSTAINS('A', AAuditLogPart) PARTS_CONSTAINS('B', BAuditLogPart) PARTS_CONSTAINS('C', CAuditLogPart) @@ -162,7 +162,7 @@ int AuditLog::addParts(int parts, const std::string& new_parts) { } -int AuditLog::removeParts(int parts, const std::string& new_parts) { +int AuditLog::removeParts(int parts, std::string_view new_parts) { PARTS_CONSTAINS_REM('A', AAuditLogPart) PARTS_CONSTAINS_REM('B', BAuditLogPart) PARTS_CONSTAINS_REM('C', CAuditLogPart) @@ -180,7 +180,7 @@ int AuditLog::removeParts(int parts, const std::string& new_parts) { } -bool AuditLog::setParts(const std::basic_string& new_parts) { +bool AuditLog::setParts(std::string_view new_parts) { int parts = 0; PARTS_CONSTAINS('A', AAuditLogPart)