Add matrix params to the cachekey in the cachekey plugin (#11856)
authorBryan Call <bcall@apache.org>
Tue, 12 Nov 2024 17:51:49 +0000 (09:51 -0800)
committerDaniel Leidert <dleidert@debian.org>
Sat, 15 Feb 2025 22:30:52 +0000 (23:30 +0100)
Reviewed-By: Daniel Leidert <dleidert@debian.org>
Origin: https://github.com/apache/trafficserver/pull/11856
Bug: https://github.com/apache/trafficserver/pull/11856
Bug-Debian: https://bugs.debian.org/1087531
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2024-38479
Bug-Freexian-Security: https://deb.freexian.com/extended-lts/tracker/CVE-2024-38479

Gbp-Pq: Name CVE-2024-38479.patch

plugins/cachekey/cachekey.cc
plugins/cachekey/cachekey.h
plugins/cachekey/configs.cc
plugins/cachekey/configs.h
plugins/cachekey/plugin.cc

index 44925b3db2805ea81086722ea0d056ece5363092..127cb54d35e716e8f53acd0eeae589c4d20e7b75 100644 (file)
@@ -673,6 +673,27 @@ CacheKey::appendQuery(const ConfigQuery &config)
   }
 }
 
+void
+CacheKey::appendMatrix(const ConfigMatrix &config)
+{
+  if (config.toBeRemoved()) {
+    return;
+  }
+
+  const char *matrix;
+  int length;
+
+  matrix = TSUrlHttpParamsGet(_buf, _url, &length);
+  if (matrix == nullptr || length == 0) {
+    return;
+  }
+
+  if (matrix && length) {
+    _key.append(";");
+    _key.append(matrix, length);
+  }
+}
+
 /**
  * @brief Append User-Agent header captures specified in the Pattern configuration object.
  *
index 0b47e85984d76ca14a0f6294ca1aeb88493ca222..dc208f93bb4c427a1f00182a8c94ff42533d8c9b 100644 (file)
@@ -63,6 +63,7 @@ public:
   void appendPath(Pattern &pathCapture, Pattern &pathCaptureUri);
   void appendHeaders(const ConfigHeaders &config);
   void appendQuery(const ConfigQuery &config);
+  void appendMatrix(const ConfigMatrix &config);
   void appendCookies(const ConfigCookies &config);
   void appendUaCaptures(Pattern &config);
   bool appendUaClass(Classifier &classifier);
index 938ae1d5cadd981b65a4c64f02b247f0005c3ff6..58da358bc18b346a79addab9cde5c537e4ac1241 100644 (file)
@@ -208,6 +208,20 @@ ConfigQuery::name() const
   return _NAME;
 }
 
+bool
+ConfigMatrix::finalize()
+{
+  _remove = noIncludeExcludeRules();
+  return true;
+}
+
+const String ConfigMatrix::_NAME = "matrix parameter";
+inline const String &
+ConfigMatrix::name() const
+{
+  return _NAME;
+}
+
 /**
  * @briefs finalizes the headers related configuration.
  *
index e8712f18342ae7e379584f7edfd1a30b2cd40ac1..ad3580f17cd83acdcb608be69b3d63237c4a3831 100644 (file)
@@ -112,6 +112,16 @@ private:
   static const String _NAME;
 };
 
+class ConfigMatrix : public ConfigElements
+{
+public:
+  bool finalize() override;
+
+private:
+  const String &name() const override;
+  static const String _NAME;
+};
+
 /**
  * @brief Headers configuration class.
  */
@@ -210,6 +220,7 @@ public:
   /* Make the following members public to avoid unnecessary accessors */
   ConfigQuery _query;        /**< @brief query parameter related configuration */
   ConfigHeaders _headers;    /**< @brief headers related configuration */
+  ConfigMatrix _matrix;      /**< @brief matrix parameter related configuration */
   ConfigCookies _cookies;    /**< @brief cookies related configuration */
   Pattern _uaCapture;        /**< @brief the capture groups and the replacement string used for the User-Agent header capture */
   String _prefix;            /**< @brief cache key prefix string */
index d92c079271a955cbe9aef4842a123a462599aaee..b863b94a0d50c80b0384331eed4239b6459e338f 100644 (file)
@@ -64,6 +64,10 @@ setCacheKey(TSHttpTxn txn, Configs *config, TSRemapRequestInfo *rri = nullptr)
     if (!config->pathToBeRemoved()) {
       cachekey.appendPath(config->_pathCapture, config->_pathCaptureUri);
     }
+
+    /* Append the matrix parameters to the cache key. */
+    cachekey.appendMatrix(config->_matrix);
+
     /* Append query parameters to the cache key. */
     cachekey.appendQuery(config->_query);