bito-code-review[bot] commented on code in PR #40664:
URL: https://github.com/apache/superset/pull/40664#discussion_r3338307320


##########
superset/extensions/utils.py:
##########
@@ -36,7 +36,9 @@
 logger = logging.getLogger(__name__)
 
 FRONTEND_REGEX = re.compile(r"^frontend/dist/([^/]+)$")
-BACKEND_REGEX = re.compile(r"^backend/src/(.+)$")
+# Reject parent ("..") path components so a crafted entry name cannot produce
+# a traversal-style module path (defense in depth; check_is_safe_zip runs 
first).
+BACKEND_REGEX = re.compile(r"^backend/src/(?!.*\.\.)(.+)$")

Review Comment:
   <!-- Bito Reply -->
   The suggestion provided by Bito aims to address a potential path traversal 
vulnerability by adjusting the regex pattern. However, the user's response 
indicates that the current pattern is intentionally conservative and that the 
proposed change might introduce unintended behavior by allowing certain forms 
of traversal. Given the user's explanation and the context of the code, it 
seems that the current implementation is a deliberate design choice to ensure 
security. Therefore, Bito should consider the user's feedback and potentially 
refine the suggestion to align with the intended security measures.
   
   **superset/extensions/utils.py**
   ```
   38: FRONTEND_REGEX = re.compile(r""^frontend/dist/([^/]+)$"")
   39: # Reject parent ("".."") path components so a crafted entry name cannot 
produce
   40: # a traversal-style module path (defense in depth; check_is_safe_zip 
runs first).
   41: -BACKEND_REGEX = re.compile(r""^backend/src/(?!.*\.\.)(.+)$"")
   41: +BACKEND_REGEX = 
re.compile(r""^backend/src/(?!(?:[^/]*/)?\.\.(?:/|$))(.+)$"")
   ```



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