Copilot commented on code in PR #62111:
URL: https://github.com/apache/doris/pull/62111#discussion_r3033415966


##########
fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java:
##########
@@ -1737,7 +1737,9 @@ private boolean loadTxnCommitImpl(TLoadTxnCommitRequest 
request) throws UserExce
         if (request.isSetAuthCode()) {
             // TODO: deprecated, removed in 3.1, use token instead.
         } else if (request.isSetToken()) {
-            checkToken(request.getToken());
+            if (!checkToken(request.getToken())) {
+                throw new AuthenticationException("Invalid token: " + 
request.getToken());
+            }

Review Comment:
   PR description/title says invalid tokens are now rejected on stream load 
commit *and rollback*, but rollback code paths in this same class still ignore 
the boolean return of checkToken() (e.g. loadTxnRollbackImpl and 
rollbackTxnImpl call checkToken(token) without checking the result). As a 
result, invalid tokens still appear to be accepted for rollback requests. 
Please update the rollback implementations to fail when checkToken(...) returns 
false (consistent with the new commit behavior).



##########
fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java:
##########
@@ -1874,7 +1876,9 @@ private boolean commitTxnImpl(TCommitTxnRequest request) 
throws UserException {
         if (request.isSetAuthCode()) {
             // TODO: deprecated, removed in 3.1, use token instead.
         } else if (request.isSetToken()) {
-            checkToken(request.getToken());
+            if (!checkToken(request.getToken())) {
+                throw new AuthenticationException("Invalid token: " + 
request.getToken());

Review Comment:
   The exception message includes the full token value. Tokens are credentials 
and should not be echoed back in exceptions/logs; this can leak secrets to 
clients and into FE logs (the message is logged on failures). Prefer a generic 
message (e.g. "Invalid token") and, if needed for debugging, log a redacted 
form server-side.
   ```suggestion
                   throw new AuthenticationException("Invalid token");
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java:
##########
@@ -1737,7 +1737,9 @@ private boolean loadTxnCommitImpl(TLoadTxnCommitRequest 
request) throws UserExce
         if (request.isSetAuthCode()) {
             // TODO: deprecated, removed in 3.1, use token instead.
         } else if (request.isSetToken()) {
-            checkToken(request.getToken());
+            if (!checkToken(request.getToken())) {
+                throw new AuthenticationException("Invalid token: " + 
request.getToken());
+            }

Review Comment:
   This change introduces new authentication behavior (token invalid now fails) 
but there doesn't appear to be a regression test covering commit/rollback token 
validation in FrontendServiceImplTest (tests exist for other 
FrontendServiceImpl RPCs). Adding a unit test that asserts invalid tokens are 
rejected for commitTxn/loadTxnCommit (and rollback once fixed) would help 
prevent this from regressing again.



##########
fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java:
##########
@@ -1737,7 +1737,9 @@ private boolean loadTxnCommitImpl(TLoadTxnCommitRequest 
request) throws UserExce
         if (request.isSetAuthCode()) {
             // TODO: deprecated, removed in 3.1, use token instead.
         } else if (request.isSetToken()) {
-            checkToken(request.getToken());
+            if (!checkToken(request.getToken())) {
+                throw new AuthenticationException("Invalid token: " + 
request.getToken());

Review Comment:
   The exception message includes the full token value. Tokens are credentials 
and should not be echoed back in exceptions/logs; this can leak secrets to 
clients and into FE logs (the message is logged on failures). Prefer a generic 
message (e.g. "Invalid token") and, if needed for debugging, log a redacted 
form server-side.
   ```suggestion
                   throw new AuthenticationException("Invalid token");
   ```



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