(trafficserver) branch master updated: Added namespace fmt to function call format_to in Cripts (#11116)

2024-02-29 Thread bcall
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 4c933c730e Added namespace fmt to function call format_to in Cripts 
(#6)
4c933c730e is described below

commit 4c933c730ecfa1f8ed918b279162e7e93fc6642b
Author: Bryan Call 
AuthorDate: Thu Feb 29 16:10:44 2024 -0800

Added namespace fmt to function call format_to in Cripts (#6)
---
 include/cripts/Crypto.hpp  |  6 +++---
 include/cripts/Headers.hpp |  6 +++---
 include/cripts/Lulu.hpp| 12 ++--
 include/cripts/Time.hpp|  2 +-
 include/cripts/Urls.hpp| 14 +++---
 5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/include/cripts/Crypto.hpp b/include/cripts/Crypto.hpp
index 25dcf145c5..f7e856787c 100644
--- a/include/cripts/Crypto.hpp
+++ b/include/cripts/Crypto.hpp
@@ -264,7 +264,7 @@ template <> struct formatter {
   auto
   format(Crypto::SHA256 , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", sha.hex());
+return fmt::format_to(ctx.out(), "{}", sha.hex());
   }
 };
 
@@ -279,7 +279,7 @@ template <> struct formatter {
   auto
   format(Crypto::SHA512 , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", sha.hex());
+return fmt::format_to(ctx.out(), "{}", sha.hex());
   }
 };
 
@@ -294,7 +294,7 @@ template <> struct formatter {
   auto
   format(Crypto::AES256 , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", Crypto::Base64::encode(sha.message()));
+return fmt::format_to(ctx.out(), "{}", 
Crypto::Base64::encode(sha.message()));
   }
 };
 
diff --git a/include/cripts/Headers.hpp b/include/cripts/Headers.hpp
index 560e00deec..d9b90b1d26 100644
--- a/include/cripts/Headers.hpp
+++ b/include/cripts/Headers.hpp
@@ -571,7 +571,7 @@ template <> struct formatter {
   auto
   format(Header::Method , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", method.getSV());
+return fmt::format_to(ctx.out(), "{}", method.getSV());
   }
 };
 
@@ -586,7 +586,7 @@ template <> struct formatter {
   auto
   format(Header::String , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", str.getSV());
+return fmt::format_to(ctx.out(), "{}", str.getSV());
   }
 };
 
@@ -601,7 +601,7 @@ template <> struct formatter {
   auto
   format(Header::Name , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", name.getSV());
+return fmt::format_to(ctx.out(), "{}", name.getSV());
   }
 };
 
diff --git a/include/cripts/Lulu.hpp b/include/cripts/Lulu.hpp
index 8dcc7caa1b..02ed324a84 100644
--- a/include/cripts/Lulu.hpp
+++ b/include/cripts/Lulu.hpp
@@ -574,7 +574,7 @@ template <> struct formatter {
   auto
   format(Versions , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", version.getSV());
+return fmt::format_to(ctx.out(), "{}", version.getSV());
   }
 };
 
@@ -589,7 +589,7 @@ template <> struct formatter {
   auto
   format(Versions::Major , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", integer(major));
+return fmt::format_to(ctx.out(), "{}", integer(major));
   }
 };
 
@@ -604,7 +604,7 @@ template <> struct formatter {
   auto
   format(Versions::Minor , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", integer(minor));
+return fmt::format_to(ctx.out(), "{}", integer(minor));
   }
 };
 
@@ -619,7 +619,7 @@ template <> struct formatter {
   auto
   format(Versions::Patch , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", integer(patch));
+return fmt::format_to(ctx.out(), "{}", integer(patch));
   }
 };
 
@@ -634,7 +634,7 @@ template <> struct formatter {
   auto
   format(const TSHttpStatus , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", static_cast(stat));
+return fmt::format_to(ctx.out(), "{}", static_cast(stat));
   }
 };
 
@@ -649,7 +649,7 @@ template <> struct formatter {
   auto
   format(const Cript::StringViewWrapper , FormatContext ) -> 
decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", sv.getSV());
+return fmt::format_to(ctx.out(), "{}", sv.getSV());
   }
 };
 
diff --git a/include/cripts/Time.hpp b/include/cripts/Time.hpp
index e01e71efe9..d30d90481a 100644
--- a/include/cripts/Time.hpp
+++ b/include/cripts/Time.hpp
@@ -138,7 +138,7 @@ template <> struct formatter {
   auto
   format(Time::Local , FormatContext ) -> decltype(ctx.out())
   {
-return format_to(ctx.out(), "{}", time.epoch());
+return fmt::format_to(ctx.out(), "{}", time.epoch());
   }
 };
 } // namespace fmt
diff --git a/include/cripts/Urls.hpp b/include/cripts/Urls.hpp
index 8e17f956c8..f357b05d9a 100644
--- a/include/cripts/Urls.hpp

(trafficserver) branch master updated: Use EMERGENCY instead of FATAL for some certificate loading errors (#11108)

2024-02-29 Thread lzx404243
This is an automated email from the ASF dual-hosted git repository.

lzx404243 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 67bcbf4b33 Use EMERGENCY instead of FATAL for some certificate loading 
errors (#11108)
67bcbf4b33 is described below

commit 67bcbf4b33d43f2e0a1186d725b19e712971f886
Author: Zhengxi Li 
AuthorDate: Thu Feb 29 15:17:12 2024 -0500

Use EMERGENCY instead of FATAL for some certificate loading errors (#11108)

* Use EMERGENCY instead of FATAL for certificate loading errors
---
 src/iocore/net/SSLConfig.cc | 4 ++--
 tests/gold_tests/tls/exit_on_cert_load_fail.test.py | 4 ++--
 tests/gold_tests/tls/ssl_multicert_loader.test.py   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/iocore/net/SSLConfig.cc b/src/iocore/net/SSLConfig.cc
index fc84ce517d..f275d1b051 100644
--- a/src/iocore/net/SSLConfig.cc
+++ b/src/iocore/net/SSLConfig.cc
@@ -550,7 +550,7 @@ SSLConfigParams::initialize()
   }
   // Can't get SSL client context.
   if (this->clientCertExitOnLoadError) {
-Fatal("Can't initialize the SSL client, HTTPS in remap rules will not 
function");
+Emergency("Can't initialize the SSL client, HTTPS in remap rules will not 
function");
   } else {
 SSLError("Can't initialize the SSL client, HTTPS in remap rules will not 
function");
   }
@@ -637,7 +637,7 @@ SSLCertificateConfig::startup()
   // proxy.config.ssl.server.multicert.exit_on_load_fail is true
   SSLConfig::scoped_config params;
   if (!reconfigure() && params->configExitOnLoadError) {
-Fatal("failed to load SSL certificate file, %s", params->configFilePath);
+Emergency("failed to load SSL certificate file, %s", 
params->configFilePath);
   }
 
   return true;
diff --git a/tests/gold_tests/tls/exit_on_cert_load_fail.test.py 
b/tests/gold_tests/tls/exit_on_cert_load_fail.test.py
index f578665c48..c075e1a357 100644
--- a/tests/gold_tests/tls/exit_on_cert_load_fail.test.py
+++ b/tests/gold_tests/tls/exit_on_cert_load_fail.test.py
@@ -85,9 +85,9 @@ class Test_exit_on_cert_load_fail:
 self._ts.Disk.diags_log.Content = Testers.ContainsExpression("ERROR:", 
"These tests should have error logs.")
 
 if self.enable_exit_on_load:
-self._ts.ReturnCode = 70
+self._ts.ReturnCode = 33
 self._ts.Disk.diags_log.Content += Testers.ContainsExpression(
-"FATAL: ", "Failure loading the certs results in a fatal 
error.")
+"EMERGENCY: ", "Failure loading the certs results in an 
emergency error.")
 self._ts.Disk.diags_log.Content += Testers.ExcludesExpression(
 "Traffic Server is fully initialized", "Traffic Server should 
exit upon the load failure.")
 else:
diff --git a/tests/gold_tests/tls/ssl_multicert_loader.test.py 
b/tests/gold_tests/tls/ssl_multicert_loader.test.py
index ddcc231825..27b90b4f83 100644
--- a/tests/gold_tests/tls/ssl_multicert_loader.test.py
+++ b/tests/gold_tests/tls/ssl_multicert_loader.test.py
@@ -102,8 +102,8 @@ tr4.Processes.Default.Command = 'echo Waiting'
 tr4.Processes.Default.ReturnCode = 0
 tr4.Processes.Default.StartBefore(ts2)
 
-ts2.ReturnCode = 70  # ink_fatal will exit with EX_SOFTWARE.
+ts2.ReturnCode = 33  # ink_emergency will exit with UNRECOVERABLE_EXIT.
 ts2.Ready = 0  # Need this to be 0 because we are testing shutdown, this is to 
make autest not think ats went away for a bad reason.
 ts2.Disk.traffic_out.Content = Testers.ExcludesExpression(
 'Traffic Server is fully initialized', 'process should fail when invalid 
certificate specified')
-ts2.Disk.diags_log.Content = Testers.IncludesExpression('FATAL: failed to load 
SSL certificate file', 'check diags.log"')
+ts2.Disk.diags_log.Content = Testers.IncludesExpression('EMERGENCY: failed to 
load SSL certificate file', 'check diags.log"')



(trafficserver) branch master updated: Change Regex class to use PCRE2 (#11014)

2024-02-29 Thread bcall
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 8e1c1b9faf Change Regex class to use PCRE2 (#11014)
8e1c1b9faf is described below

commit 8e1c1b9fafb13df87ca431a1e855f64223b06ffb
Author: Bryan Call 
AuthorDate: Thu Feb 29 12:06:24 2024 -0800

Change Regex class to use PCRE2 (#11014)
---
 CMakeLists.txt |   2 +-
 include/proxy/http/remap/UrlRewrite.h  |   2 +-
 include/tsutil/Regex.h | 106 +---
 plugins/experimental/tls_bridge/CMakeLists.txt |   2 +-
 src/proxy/http/remap/UrlRewrite.cc |  14 +-
 src/tsutil/CMakeLists.txt  |   3 +-
 src/tsutil/Regex.cc| 329 +
 src/tsutil/unit_tests/test_Regex.cc| 138 ++-
 8 files changed, 440 insertions(+), 156 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 63ec25723a..a276d827cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -253,7 +253,7 @@ if(LibLZMA_FOUND)
 endif()
 
 find_package(PCRE REQUIRED)
-find_package(PCRE2 COMPONENTS 8BIT)
+pkg_check_modules(PCRE2 REQUIRED IMPORTED_TARGET libpcre2-8)
 
 include(CheckOpenSSLIsBoringSSL)
 include(CheckOpenSSLIsQuictls)
diff --git a/include/proxy/http/remap/UrlRewrite.h 
b/include/proxy/http/remap/UrlRewrite.h
index 86dcb50a07..797ad94c47 100644
--- a/include/proxy/http/remap/UrlRewrite.h
+++ b/include/proxy/http/remap/UrlRewrite.h
@@ -232,7 +232,7 @@ private:
 int request_host_len);
   bool _regexMappingLookup(RegexMappingList _mappings, URL *request_url, 
int request_port, const char *request_host,
int request_host_len, int rank_ceiling, 
UrlMappingContainer _container);
-  int _expandSubstitutions(int *matches_info, const RegexMapping *reg_map, 
const char *matched_string, char *dest_buf,
+  int _expandSubstitutions(size_t *matches_info, const RegexMapping *reg_map, 
const char *matched_string, char *dest_buf,
int dest_buf_size);
   void _destroyTable(std::unique_ptr _table);
   void _destroyList(RegexMappingList );
diff --git a/include/tsutil/Regex.h b/include/tsutil/Regex.h
index a1c51e3661..c4ca8feb03 100644
--- a/include/tsutil/Regex.h
+++ b/include/tsutil/Regex.h
@@ -28,24 +28,60 @@
 #include 
 #include 
 
-#include "swoc/MemSpan.h"
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include 
 
-/// Match flags for regular expression evaluation.
+/// @brief Match flags for regular expression evaluation.
 enum REFlags {
-  RE_CASE_INSENSITIVE = 0x0001, ///< Ignore case (default: case sensitive).
-  RE_UNANCHORED   = 0x0002, ///< Unanchored (DFA defaults to anchored).
-  RE_ANCHORED = 0x0004, ///< Anchored (Regex defaults to unanchored).
+  RE_CASE_INSENSITIVE = PCRE2_CASELESS,  ///< Ignore case (default: case 
sensitive).
+  RE_UNANCHORED   = PCRE2_MULTILINE, ///< Unanchored (DFA defaults to 
anchored).
+  RE_ANCHORED = PCRE2_ANCHORED,  ///< Anchored (Regex defaults to 
unanchored).
 };
 
-/** Wrapper for PCRE evaluation.
- *
- */
-class Regex
+/// @brief Wrapper for PCRE2 match data.
+class RegexMatches
 {
+  friend class Regex;
+
 public:
-  /// Default number of capture groups.
-  static constexpr size_t DEFAULT_GROUP_COUNT = 10;
+  /** Construct a new RegexMatches object.
+   *
+   * @param size The number of matches to allocate space for.
+   */
+  RegexMatches(uint32_t size = DEFAULT_MATCHES);
+  ~RegexMatches();
+
+  /** Get the match at the given index.
+   *
+   * @return The match at the given index.
+   */
+  std::string_view operator[](size_t index) const;
+  /** Get the ovector pointer for the capture groups.  Don't use this unless 
you know what you are doing.
+   *
+   * @return ovector pointer.
+   */
+  size_t *get_ovector_pointer();
+  int32_t size() const;
+
+protected:
+  pcre2_match_data *get_match_data();
+  void set_subject(std::string_view subject);
+  void set_size(int32_t size);
+
+private:
+  constexpr static uint32_t DEFAULT_MATCHES = 10;
+  static void *malloc(size_t size, void *caller);
+  pcre2_match_data *_match_data = nullptr;
+  std::string_view _subject;
+  char _buffer[24 + 96 + 16 * DEFAULT_MATCHES]; // 24 bytes for the general 
context, 96 bytes overhead, 16 bytes per match.
+  size_t _buffer_bytes_used = 0;
+  int32_t _size = 0;
+};
 
+/// @brief Wrapper for PCRE2 regular expression.
+class Regex
+{
+public:
   Regex()  = default;
   Regex(Regex const &) = delete; // No copying.
   Regex(Regex &) noexcept;
@@ -59,46 +95,43 @@ public:
*
* @a flags should be the bitwise @c or of @c REFlags values.
*/
-  bool compile(const char *pattern, unsigned flags = 0);
+  bool compile(std::string_view pattern, uint32_t flags = 0);
 
-  /** Execute the regular expression.
+  

(trafficserver) branch master updated (5ed1504a37 -> 20bae7ff5c)

2024-02-29 Thread bneradt
This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


from 5ed1504a37 add back EVENT_INTERVAL (#11072)
 add 20bae7ff5c Add libswoc unit tests (#11106)

No new revisions were added by this update.

Summary of changes:
 lib/swoc/CMakeLists.txt|4 +
 lib/swoc/include/swoc/IntrusiveHashMap.h   |9 +
 lib/swoc/include/swoc/TextView.h   |2 +-
 lib/swoc/unit_tests/CMakeLists.txt |   51 +
 lib/swoc/unit_tests/ex_IntrusiveDList.cc   |  215 ++
 lib/swoc/unit_tests/ex_Lexicon.cc  |  130 ++
 lib/swoc/unit_tests/ex_MemArena.cc |  224 ++
 lib/swoc/unit_tests/ex_TextView.cc |  319 +++
 lib/swoc/unit_tests/ex_UnitParser.cc   |  183 ++
 lib/swoc/unit_tests/ex_bw_format.cc|  691 +++
 lib/swoc/unit_tests/ex_ipspace_properties.cc   |  639 ++
 lib/swoc/unit_tests/examples/resolver.txt  |   21 +
 lib/swoc/unit_tests/test_BufferWriter.cc   |  506 +
 lib/swoc/unit_tests/test_Errata.cc |  430 
 lib/swoc/unit_tests/test_IntrusiveDList.cc |  272 +++
 lib/swoc/unit_tests/test_IntrusiveHashMap.cc   |  274 +++
 lib/swoc/unit_tests/test_Lexicon.cc|  276 +++
 lib/swoc/unit_tests/test_MemArena.cc   |  663 ++
 lib/swoc/unit_tests/test_MemSpan.cc|  310 +++
 lib/swoc/unit_tests/test_Scalar.cc |  257 +++
 lib/swoc/unit_tests/test_TextView.cc   |  651 ++
 lib/swoc/unit_tests/test_Vectray.cc|   82 +
 lib/swoc/unit_tests/test_bw_format.cc  |  694 +++
 lib/swoc/unit_tests/test_ip.cc | 2186 
 lib/swoc/unit_tests/test_meta.cc   |  119 ++
 lib/swoc/unit_tests/test_range.cc  |   39 +
 lib/swoc/unit_tests/test_swoc_file.cc  |  341 +++
 .../swoc}/unit_tests/unit_test_main.cc |   11 +-
 lib/swoc/unit_tests/unit_tests.part|   42 +
 src/proxy/http/HttpSessionManager.cc   |   44 +-
 30 files changed, 9663 insertions(+), 22 deletions(-)
 create mode 100644 lib/swoc/unit_tests/CMakeLists.txt
 create mode 100644 lib/swoc/unit_tests/ex_IntrusiveDList.cc
 create mode 100644 lib/swoc/unit_tests/ex_Lexicon.cc
 create mode 100644 lib/swoc/unit_tests/ex_MemArena.cc
 create mode 100644 lib/swoc/unit_tests/ex_TextView.cc
 create mode 100644 lib/swoc/unit_tests/ex_UnitParser.cc
 create mode 100644 lib/swoc/unit_tests/ex_bw_format.cc
 create mode 100644 lib/swoc/unit_tests/ex_ipspace_properties.cc
 create mode 100644 lib/swoc/unit_tests/examples/resolver.txt
 create mode 100644 lib/swoc/unit_tests/test_BufferWriter.cc
 create mode 100644 lib/swoc/unit_tests/test_Errata.cc
 create mode 100644 lib/swoc/unit_tests/test_IntrusiveDList.cc
 create mode 100644 lib/swoc/unit_tests/test_IntrusiveHashMap.cc
 create mode 100644 lib/swoc/unit_tests/test_Lexicon.cc
 create mode 100644 lib/swoc/unit_tests/test_MemArena.cc
 create mode 100644 lib/swoc/unit_tests/test_MemSpan.cc
 create mode 100644 lib/swoc/unit_tests/test_Scalar.cc
 create mode 100644 lib/swoc/unit_tests/test_TextView.cc
 create mode 100644 lib/swoc/unit_tests/test_Vectray.cc
 create mode 100644 lib/swoc/unit_tests/test_bw_format.cc
 create mode 100644 lib/swoc/unit_tests/test_ip.cc
 create mode 100644 lib/swoc/unit_tests/test_meta.cc
 create mode 100644 lib/swoc/unit_tests/test_range.cc
 create mode 100644 lib/swoc/unit_tests/test_swoc_file.cc
 copy {plugins/experimental/txn_box => lib/swoc}/unit_tests/unit_test_main.cc 
(86%)
 create mode 100644 lib/swoc/unit_tests/unit_tests.part