Copilot commented on code in PR #13586:
URL: https://github.com/apache/trafficserver/pull/13586#discussion_r3876572924


##########
tests/gold_tests/pluginTest/abuse_shield/idle_connections.py:
##########
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+"""Open plain TCP connections without sending HTTP requests."""
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements. See the NOTICE file
+#  distributed with this work for additional information regarding
+#  copyright ownership. The ASF licenses this file to you under the Apache
+#  License, Version 2.0 (the "License"); you may not use this file except in
+#  compliance with the License. You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+

Review Comment:
   The module docstring appears before the ASF license header. New test/helper 
scripts in this PR (e.g. h2_rate_client.py) place the license header 
immediately after the shebang, which makes provenance unambiguous and matches 
the repo’s license-header convention for new files.



##########
plugins/experimental/abuse_shield/UdiTable.h:
##########
@@ -0,0 +1,474 @@
+/** @file
+
+  Private fixed-size table used by the abuse_shield plugin.
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+  agreements.  See the NOTICE file distributed with this work for additional 
information regarding
+  copyright ownership.  The ASF licenses this file to you under the Apache 
License, Version 2.0
+  (the "License"); you may not use this file except in compliance with the 
License.  You may obtain
+  a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software 
distributed under the License
+  is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+  or implied. See the License for the specific language governing permissions 
and limitations under
+  the License.
+*/
+
+#pragma once
+
+#include <algorithm>
+#include <atomic>
+#include <chrono>
+#include <cstdint>
+#include <functional>
+#include <memory>
+#include <mutex>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+namespace abuse_shield
+{
+
+/** A fixed-size hash table using the Udi "King of the Hill" algorithm.
+ *
+ * Instantiations of this table track the keys/entities (IPs, URLs, etc.) with
+ * the highest rates of events (e.g. number of requests, number of errors, 
etc.).
+ *
+ * Key properties:
+ * - Fixed memory: N slots = bounded memory, no unbounded growth
+ * - Self-cleaning: No cleanup thread needed, table manages itself
+ * - Hot tracking: High-score entries naturally stay in the table
+ * - Simple locking: Single mutex for all operations
+ * - Safe references: Returns shared_ptr so data survives eviction
+ *
+ * @tparam Key The entity type (e.g., IP address, URL)
+ * @tparam Data User's custom data type to associate with each entry
+ * @tparam Hash Hash function for keys (defaults to std::hash)
+ *
+ * The table owns the key and score for each entry. Users provide only their 
custom
+ * Data type which is stored in a shared_ptr for safe access.

Review Comment:
   UdiTable::contest() requires Data to provide `is_evictable()` (it calls 
`slot.data->is_evictable()`), but the template’s public documentation currently 
describes Data as an arbitrary user type without mentioning this required 
interface. This can surprise future users and makes compiler errors harder to 
interpret.



##########
plugins/experimental/jax_fingerprint/context_map.h:
##########
@@ -52,12 +53,22 @@
  * to a string literal with static storage duration, so storing the view
  * is safe).
  */
-class ContextMap
+class ContextMap : public jax_fingerprint::RegistryV1
 {
 public:
   static constexpr std::size_t MAX_METHODS = JAX_FINGERPRINT_MAX_METHODS;
   static_assert(MAX_METHODS >= 1, "Must accommodate at least one 
fingerprinting method");
 
+  ContextMap()
+  {
+    magic       = jax_fingerprint::REGISTRY_MAGIC;
+    abi_version = jax_fingerprint::REGISTRY_ABI_VERSION;
+    struct_size = sizeof(jax_fingerprint::RegistryV1);
+    entry_size  = sizeof(jax_fingerprint::RegistryEntryV1);
+    entry_count = 0;
+    entries     = _entries.data();
+  }

Review Comment:
   ContextMap inherits from RegistryV1, but the constructor does not initialize 
the `reserved` field. Because the registry is treated as an ABI contract, 
leaving any header fields uninitialized can leak nondeterministic values and 
complicate debugging / tooling that inspects the struct.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to