Scanning 1#4044
Conversation
…true-2694-XaudKbc6Fq fix: semgrep-subprocess-shell-true
Summary of ChangesHello @girichinna27, 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 enhances the security posture of the application by correcting an unsafe use of 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
Activity
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 correctly addresses a critical security vulnerability associated with using subprocess.Popen with shell=True. By switching to shell=False and passing the command as a list of arguments, the code is now protected against shell injection attacks. The associated removal of the single-quote replacement from the prompt is also a correct and necessary change that preserves data integrity. The implementation is clean and effectively resolves the security issue.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7db609c74
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| prompt = tokenizer.apply_chat_template(messages, tokenize = False, add_generation_prompt = True) | ||
| prompt = prompt.replace("'", "") # Subprocess does not like '' | ||
| prompt = remove_special_tokens(tokenizer, prompt) |
There was a problem hiding this comment.
Restore apostrophe normalization for GGUF comparison
This change stops removing ' from chat-template prompts, but test_hf_gguf_equivalence still parses llama-cli output with re.findall(r"([\d]{1,}) \-\> \'([^\']{1,})\'", gguf_tokens), which cannot capture tokens that contain apostrophes. With the current default messages (e.g., It's, I'm), those GGUF tokens are skipped, gguf_tokenized becomes misaligned, and the HF vs GGUF check can fail even when tokenization is actually correct.
Useful? React with 👍 / 👎.
* Fix security-regression fallout in chat templates and PDL patching * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop security regression test files from PR scope * Apply suggestion from @danielhanchen --------- Co-authored-by: Daniel Hanchen <danielhanchen@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…nslothai#4045 (unslothai#4062) * Fix security-regression fallout in chat templates and PDL patching * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Drop security regression test files from PR scope * Apply suggestion from @danielhanchen --------- Co-authored-by: Daniel Hanchen <danielhanchen@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Pull Request — Semgrep Rule Fix
Rule ID: subprocess-shell-true
Rule Message: Found 'subprocess' function 'Popen' with 'shell=True'. This is dangerous because this call will spawn the command using a shell process. Doing so propagates current shell settings and variables, which makes it much easier for a malicious actor to execute commands. Use 'shell=False' instead.
File Path: unsloth/chat_templates.py
Line: 2694