github-advanced-security[bot] commented on code in PR #7812:
URL: https://github.com/apache/incubator-seata/pull/7812#discussion_r2570191242


##########
seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/main/java/org/apache/seata/spring/boot/autoconfigure/controller/ClientConnectionPoolController.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+package org.apache.seata.spring.boot.autoconfigure.controller;
+
+import org.apache.seata.core.model.PoolConfigUpdateRequest;
+import org.apache.seata.core.rpc.netty.DataSourceConnectionPoolCollector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * Client-side REST controller for handling connection pool configuration 
updates.
+ *
+ */
+@RestController
+@RequestMapping("/client/pool")
+public class ClientConnectionPoolController {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(ClientConnectionPoolController.class);
+
+    /**
+     * Update connection pool configuration.
+     * This endpoint is called by the Seata server to update client-side 
connection pool settings.
+     *
+     * @param request the configuration update request containing new 
parameter values
+     * @return ResponseEntity indicating success or failure
+     */
+    @PostMapping("/update")
+    public ResponseEntity<String> updateConfig(@RequestBody 
PoolConfigUpdateRequest request) {
+        try {
+            // Validate request parameters
+            if (request == null
+                    || request.getPoolName() == null
+                    || request.getPoolName().trim().isEmpty()) {
+                LOGGER.warn("Invalid configuration update request: {}", 
request);
+                return ResponseEntity.badRequest().body("Invalid request: 
poolName is required");
+            }
+
+            LOGGER.info("Received connection pool configuration update request 
for pool: {}", request.getPoolName());
+            LOGGER.debug("Configuration update details: {}", request);
+
+            // Validate configuration parameters
+            if (!isValidConfigRequest(request)) {
+                LOGGER.warn("Invalid configuration parameters in request: {}", 
request);
+                return ResponseEntity.badRequest().body("Invalid configuration 
parameters");
+            }
+
+            // Apply configuration update using 
DataSourceConnectionPoolCollector
+            boolean success = 
DataSourceConnectionPoolCollector.updateConfig(request.getPoolName(), request);
+
+            if (success) {
+                LOGGER.info("Successfully updated connection pool 
configuration for pool: {}", request.getPoolName());
+                return ResponseEntity.ok("Configuration updated successfully");
+            } else {
+                LOGGER.warn("Failed to update connection pool configuration 
for pool: {}", request.getPoolName());
+                return ResponseEntity.internalServerError().body("Failed to 
update configuration");
+            }
+
+        } catch (Exception e) {
+            LOGGER.error(
+                    "Error processing configuration update request for pool: 
{}",
+                    request != null ? request.getPoolName() : "unknown",
+                    e);
+            return ResponseEntity.internalServerError().body("Internal server 
error: " + e.getMessage());

Review Comment:
   ## Information exposure through an error message
   
   [Error information](1) can be exposed to an external user.
   [Error information](2) can be exposed to an external user.
   [Error information](3) can be exposed to an external user.
   
   [Show more 
details](https://github.com/apache/incubator-seata/security/code-scanning/51)



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to