[PR #12305] Fix code scanning alert no. 111: Incomplete URL substring sanitization #27596

Closed
opened 2026-02-21 20:41:49 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/12305

State: closed
Merged: Yes


Fixes https://github.com/langgenius/dify/security/code-scanning/111

To fix the problem, we need to parse the URL and ensure that the host is correctly validated. Instead of using startswith and endswith, we will use the urlparse function from the urllib.parse module to extract the hostname and validate it.

  1. Parse the URL using urlparse.
  2. Check if the hostname is "github.com".
  3. Ensure the path ends with ".yml" or ".yaml".
  4. Replace the URL parts to convert it to the raw GitHub URL if the checks pass.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

**Original Pull Request:** https://github.com/langgenius/dify/pull/12305 **State:** closed **Merged:** Yes --- Fixes [https://github.com/langgenius/dify/security/code-scanning/111](https://github.com/langgenius/dify/security/code-scanning/111) To fix the problem, we need to parse the URL and ensure that the host is correctly validated. Instead of using `startswith` and `endswith`, we will use the `urlparse` function from the `urllib.parse` module to extract the hostname and validate it. 1. Parse the URL using `urlparse`. 2. Check if the hostname is "github.com". 3. Ensure the path ends with ".yml" or ".yaml". 4. Replace the URL parts to convert it to the raw GitHub URL if the checks pass. _Suggested fixes powered by Copilot Autofix. Review carefully before merging._
yindo added the pull-request label 2026-02-21 20:41:49 -05:00
yindo closed this issue 2026-02-21 20:41:49 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#27596