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


##########
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:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>CWE-22: Path Traversal Regex Too Aggressive</b></div>
   <div id="fix">
   
   The negative lookahead `(?!.*\.\.)` rejects ANY path containing `..` 
anywhere, breaking legitimate filenames like `file..`, `..hidden`, or 
`package..init`. Only path traversal (`/../`) should be rejected, not dots 
embedded in filenames. (See also: 
[CWE-22](https://cwe.mitre.org/data/definitions/22.html))
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
    --- superset/extensions/utils.py (lines 38-42) ---
    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/(?!(?:[^/]*/)?\.\.(?:/|$))(.+)$")
   ```
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #03baa9</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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