Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes V2.1 #467

Merged
merged 7 commits into from
Feb 23, 2025
Merged

Bug fixes V2.1 #467

merged 7 commits into from
Feb 23, 2025

Conversation

New-dev0
Copy link
Member

@New-dev0 New-dev0 commented Feb 23, 2025

  • Telegraph no longer supports image upload, replace it by catbox
  • Update for layer fixes in Poll
  • Fixed sticker command by using cloudscraper
  • fixed img, translate, akinator, filestore

msg = await event.eor("🔍 `Getting tweet details...`")
try:
client = await get_client()
if "twitter.com" in match or "x.com" in match:

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
twitter.com
may be at an arbitrary position in the sanitized URL.

Copilot Autofix AI 9 days ago

To fix the problem, we need to parse the URL and check the hostname to ensure it matches "twitter.com" or "x.com" correctly. This will prevent malicious URLs from bypassing the check by embedding the allowed hostnames in unexpected locations.

  • Use the urlparse function from the urllib.parse module to parse the URL.
  • Extract the hostname from the parsed URL and check if it matches "twitter.com" or "x.com".
  • Update the code in the twitter_details function to implement this change.
Suggested changeset 1
plugins/twitter.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/plugins/twitter.py b/plugins/twitter.py
--- a/plugins/twitter.py
+++ b/plugins/twitter.py
@@ -83,4 +83,6 @@
         client = await get_client()
-        if "twitter.com" in match or "x.com" in match:
-            tweet_id = match.split("/")[-1].split("?")[0]
+        from urllib.parse import urlparse
+        parsed_url = urlparse(match)
+        if parsed_url.hostname in ["twitter.com", "x.com"]:
+            tweet_id = parsed_url.path.split("/")[-1].split("?")[0]
         else:
EOF
@@ -83,4 +83,6 @@
client = await get_client()
if "twitter.com" in match or "x.com" in match:
tweet_id = match.split("/")[-1].split("?")[0]
from urllib.parse import urlparse
parsed_url = urlparse(match)
if parsed_url.hostname in ["twitter.com", "x.com"]:
tweet_id = parsed_url.path.split("/")[-1].split("?")[0]
else:
Copilot is powered by AI and may make mistakes. Always verify output.
@New-dev0 New-dev0 committed this autofix suggestion 9 days ago.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
msg = await event.eor("🔍 `Getting tweet details...`")
try:
client = await get_client()
if "twitter.com" in match or "x.com" in match:

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

The string
x.com
may be at an arbitrary position in the sanitized URL.

Copilot Autofix AI 9 days ago

To fix the problem, we should parse the URL using urlparse and then check the hostname to ensure it matches "twitter.com" or "x.com". This approach is more reliable than checking for substrings within the URL.

  • Parse the URL using urlparse.
  • Extract the hostname from the parsed URL.
  • Check if the hostname is either "twitter.com" or "x.com".
  • Update the code in the twitter_media function to use this method.
Suggested changeset 1
plugins/twitter.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/plugins/twitter.py b/plugins/twitter.py
--- a/plugins/twitter.py
+++ b/plugins/twitter.py
@@ -25,2 +25,3 @@
 import os
+from urllib.parse import urlparse
 from twikit import Client
@@ -151,4 +152,5 @@
         client = await get_client()
-        if "twitter.com" in match or "x.com" in match:
-            tweet_id = match.split("/")[-1].split("?")[0]
+        parsed_url = urlparse(match)
+        if parsed_url.hostname in ["twitter.com", "x.com"]:
+            tweet_id = parsed_url.path.split("/")[-1].split("?")[0]
         else:
EOF
@@ -25,2 +25,3 @@
import os
from urllib.parse import urlparse
from twikit import Client
@@ -151,4 +152,5 @@
client = await get_client()
if "twitter.com" in match or "x.com" in match:
tweet_id = match.split("/")[-1].split("?")[0]
parsed_url = urlparse(match)
if parsed_url.hostname in ["twitter.com", "x.com"]:
tweet_id = parsed_url.path.split("/")[-1].split("?")[0]
else:
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
New-dev0 and others added 3 commits February 23, 2025 09:13
…g sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@New-dev0 New-dev0 merged commit c5c7916 into main Feb 23, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant