Conversation
2. support veo gen video by multi reference_images 3. /cost display fix
2. support veo gen video by multi reference_images 3. /cost display fix
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces significant enhancements to the video generation capabilities by integrating 'together_video' as the new default provider and enabling the use of multiple reference images for more nuanced video creation. Additionally, it includes a minor but helpful update to the display of token usage in cost reports, improving clarity for users tracking resource consumption. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for multi-reference image video generation, changes the default diffusion provider, and fixes a display issue. However, it introduces a significant security vulnerability (LFI) in the video generation provider logic due to a lack of path validation when reading local files based on LLM-supplied paths, posing a high risk. Additionally, there are opportunities to improve code clarity, maintainability, and robustness, specifically concerning a confusing variable name, a broad exception catch, and a redundant condition.
| mime = None # infer from bytes | ||
|
|
||
| if not b64_str and image_path: | ||
| b64_str = VideoGenProviderBase.read_file_as_base64(image_path) |
There was a problem hiding this comment.
The function _parse_image_for_veo_payload is vulnerable to Local File Inclusion (LFI) / Path Traversal. It uses VideoGenProviderBase.read_file_as_base64(image_path) to read a file from a path provided in the image_path argument, which is derived from untrusted LLM output (via tool call arguments). An attacker can use prompt injection to force the LLM to provide a malicious path (e.g., /etc/passwd), allowing the attacker to read arbitrary files from the system that the process has access to. The base64-encoded content is then sent to the video generation provider, which could lead to data exfiltration.
if not b64_str and image_path:
# TODO: Implement strict path validation here.
# Ensure image_path is within an allowed directory and does not contain traversal sequences.
b64_str = VideoGenProviderBase.read_file_as_base64(image_path)| reference_images = [ | ||
| _resolve_image_url_to_base64(image_url) | ||
| for image_url in reference_images | ||
| ] |
There was a problem hiding this comment.
The loop variable image_url in this list comprehension shadows the outer variable image_url defined on line 194. While this is functionally correct in Python 3 due to list comprehensions having their own scope, it is very confusing to read and maintain. A future reader could easily mistake this for a bug where the outer image_url is being used repeatedly. To improve clarity, please use a different name for the loop variable.
| reference_images = [ | |
| _resolve_image_url_to_base64(image_url) | |
| for image_url in reference_images | |
| ] | |
| reference_images = [ | |
| _resolve_image_url_to_base64(ref_image_url) | |
| for ref_image_url in reference_images | |
| ] |
| if data.startswith(b"RIFF") and len(data) >= 12 and data[8:12] == b"WEBP": | ||
| return "image/webp" | ||
| for sig, mime in _IMAGE_MAGIC.items(): | ||
| if sig != b"RIFF" and data.startswith(sig): |
| pad = (4 - len(chunk) % 4) % 4 | ||
| raw = base64.b64decode(chunk + "=" * pad) | ||
| mime = _infer_image_mime_from_bytes(raw) | ||
| except Exception: |
There was a problem hiding this comment.
Using a bare except Exception: is risky as it can swallow any error, including ones you didn't anticipate (like KeyboardInterrupt), making debugging harder. Please narrow the exception type to only what you expect from the try block, such as errors related to base64 decoding (e.g., binascii.Error). This helps ensure that other unexpected errors are not accidentally hidden.
Uh oh!
There was an error while loading. Please reload this page.