-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Support JSON output codeSuggestions Field [wip]
#139
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
Conversation
|
🤖 Hi @jajanet, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
Summary of ChangesHello @jajanet, 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 significantly enhances the markdown parsing functionality by introducing a dedicated 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request introduces a valuable feature for extracting code suggestions from markdown recommendations. The approach of parsing code blocks is effective, but the current implementation introduces a significant ReDoS (Regular Expression Denial of Service) vulnerability.
🔍 General Feedback
- The feature is a great addition and will improve the usability of the security findings.
- The tests are well-written and cover a good range of scenarios.
- The identified ReDoS vulnerability is a critical security concern that should be addressed before this change is merged. I have provided a specific recommendation to mitigate this risk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A brief, high-level assessment of the Pull Request's objective and quality (2-3 sentences).
The pull request aims to improve the markdown parser to extract code suggestions from recommendations. The implementation is straightforward, but it introduces a regular expression that is vulnerable to ReDoS.
🔍 General Feedback
- The code is well-structured and easy to read.
- The addition of tests for the new functionality is a good practice.
- The ReDoS vulnerability should be addressed before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a codeSuggestion field to the parsed output by extracting the first markdown code block from the recommendation section. The implementation is sound and the new tests effectively validate the new functionality, covering various scenarios like the absence of code blocks and text surrounding them. I've added a couple of suggestions to enhance the robustness of the code. One suggestion is to improve the regular expression for code block detection to be more flexible, and the other is to make a test assertion more specific to ensure the test suite's reliability. Overall, this is a valuable enhancement to the parser's output.
This enhances the markdown regex parser to identify and extract code snippets provided within the
Recommendationinto a new optionalCode Suggestionsfield.Before, code blocks within recommendations returned as raw text:
{ "vulnerability": "Path Traversal", "recommendation": "First, sanitize the input using a whitelist. \n```typescript\nconst safePath = path.basename(req.query.file);\nconst data = fs.readFileSync(path.join(__dirname, 'safe_dir', safePath));\n```\nAfter that, ensure permissions are restricted." }to code blocks parsed into a dedicated
codeSuggestionfield, and recommendation is cleaned to be natural language only:{ "vulnerability": "Path Traversal", "recommendation": "First, sanitize the input using a whitelist. After that, ensure permissions are restricted.", "codeSuggestion": "const safePath = path.basename(req.query.file);\nconst data = fs.readFileSync(path.join(__dirname, 'safe_dir', safePath));" }We do this using regex by finding markdown code fences (```) within the Recommendation section.
The first code block found is extracted into
codeSuggestionAlso updated tests to the following:
codeSuggestionis null when no code block is present,