Skip to content

build(pyproject.toml): add new dev dependencies - for type checking #9631

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

Merged
merged 14 commits into from
Mar 29, 2025

Conversation

krrishdholakia
Copy link
Contributor

Title

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on (make test-unit)[https://docs.litellm.ai/docs/extras/contributing_code]
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test

Changes

Copy link

vercel bot commented Mar 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 29, 2025 5:48pm

Comment on lines +226 to +228
if parsed_url.hostname and parsed_url.hostname.endswith(
"generativelanguage.googleapis.com"
):

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

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

Copilot Autofix

AI 3 months ago

To fix the problem, we need to ensure that the hostname is correctly parsed and validated to prevent malicious URLs from bypassing the check. The best way to fix this is to use the urlparse function to parse the URL and then check the hostname to ensure it matches the allowed domain exactly or as a subdomain.

We will modify the _get_custom_llm_provider_from_url method to use a more robust check for the hostname. Specifically, we will ensure that the hostname is either "generativelanguage.googleapis.com" or ends with ".generativelanguage.googleapis.com".

Suggested changeset 1
litellm/proxy/pass_through_endpoints/llm_provider_handlers/vertex_passthrough_logging_handler.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/litellm/proxy/pass_through_endpoints/llm_provider_handlers/vertex_passthrough_logging_handler.py b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/vertex_passthrough_logging_handler.py
--- a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/vertex_passthrough_logging_handler.py
+++ b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/vertex_passthrough_logging_handler.py
@@ -225,4 +225,5 @@
         parsed_url = urlparse(url)
-        if parsed_url.hostname and parsed_url.hostname.endswith(
-            "generativelanguage.googleapis.com"
+        if parsed_url.hostname and (
+            parsed_url.hostname == "generativelanguage.googleapis.com" or
+            parsed_url.hostname.endswith(".generativelanguage.googleapis.com")
         ):
EOF
@@ -225,4 +225,5 @@
parsed_url = urlparse(url)
if parsed_url.hostname and parsed_url.hostname.endswith(
"generativelanguage.googleapis.com"
if parsed_url.hostname and (
parsed_url.hostname == "generativelanguage.googleapis.com" or
parsed_url.hostname.endswith(".generativelanguage.googleapis.com")
):
Copilot is powered by AI and may make mistakes. Always verify output.
@krrishdholakia krrishdholakia merged commit 9b7ebb6 into main Mar 29, 2025
35 of 41 checks passed
@krrishdholakia krrishdholakia deleted the litellm_chore_linting_on_all_prs branch March 29, 2025 18:02
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