github-actions[bot] opened a new pull request, #65345:
URL: https://github.com/apache/airflow/pull/65345

   * Refuse to follow log symlinks that resolve outside the base log folder
   
   FileTaskHandler._read_from_local used to open every file that matched
   the task's log glob pattern, including symlinks whose real path was
   outside the configured base_log_folder. On deployments where worker
   logs are accessible from the api-server, that meant the log viewer
   could end up streaming content from files outside the configured log
   tree whenever a symlink in the task log directory happened to match
   the glob pattern.
   
   Canonicalise self.local_base once via os.path.realpath and, for every
   glob hit, resolve the path with os.path.realpath and skip it if the
   resolved form is not contained in the canonicalised base log folder
   (using os.path.commonpath, with a ValueError fallback for the
   different-drive case on Windows). Open the resolved path rather than
   the original glob hit so the file we open is the one we just
   validated. Append to sources only after a successful open so sources
   and log_streams stay aligned.
   
   Drop the @staticmethod decorator so the method can read
   self.local_base; existing call sites already invoke it via self.
   
   Add a test class covering: regular-file-inside-base is still streamed;
   a symlink whose real path is outside base_log_folder is skipped; a
   symlink that stays inside base_log_folder is followed (legitimate
   rotation case); and base_log_folder itself being a symlink works.
   
   Generated-by: Claude Opus 4.6 (1M context) following the guidelines at
   
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
   
   * Fix test__read_from_local to use valid base_log_folder
   
   The existing test passed an empty string as base_log_folder, which
   after the containment check resolves to CWD via os.path.realpath(""),
   causing all files under tmp_path to be rejected. Use tmp_path instead.
   (cherry picked from commit 3eda84547e743397ec1027733f97d37ab2e628b4)
   
   Co-authored-by: Jarek Potiuk <[email protected]>


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