Skip to content

Conversation

@cgwalters
Copy link
Contributor

This skill generates quizzes based on git diffs to help verify that human submitters have meaningful understanding of code they're proposing — particularly relevant when AI tools assisted in generating the code.

Migrated from bootc-dev/infra#65.

Assisted-by: OpenCode (Claude Sonnet 4)

This skill generates quizzes based on git diffs to help verify that human
submitters have meaningful understanding of code they're proposing —
particularly relevant when AI tools assisted in generating the code.

Migrated from bootc-dev/infra#65.

Assisted-by: OpenCode (Claude Sonnet 4)
Signed-off-by: Colin Walters <walters@verbum.org>
@gemini-code-assist
Copy link

Summary of Changes

Hello @cgwalters, 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 a crucial new diff-quiz skill aimed at enhancing code review processes by ensuring human comprehension of proposed changes. It addresses the growing need to validate understanding, particularly when AI tools are involved in code generation, by providing a structured way to quiz developers on the specifics and implications of their contributions. This helps maintain code quality and ensures that developers can effectively maintain and debug the code in the future.

Highlights

  • New diff-quiz Skill: Introduces a new skill named diff-quiz designed to generate quizzes based on git diffs.
  • Verify Human Understanding: The primary purpose of the diff-quiz skill is to verify that human submitters have a meaningful understanding of code changes, especially when AI tools have assisted in generating the code.
  • Difficulty Levels and Output Formats: The skill supports easy, medium, and hard difficulty levels for quizzes and can output them in Markdown, JSON, or as a self-contained Bash script.
  • Interactive Quiz Tool: A new Python script, quiztool, is added to allow interactive running and display of quizzes generated in JSON format, including saving user answers.
  • Documentation Update: The README.md has been updated to list and briefly describe the new diff-quiz skill, alongside an existing perform-forge-review skill.

🧠 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.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 new diff-quiz skill, a valuable tool for verifying code comprehension. However, a high-severity Path Traversal vulnerability has been identified in the quiztool script, which could allow an attacker to read arbitrary files. Additionally, there are suggestions to enhance the robustness of the example script in the documentation and improve error handling in the Python tool for invalid input files.

Comment on lines +45 to +50
quiz_file = Path(args.quiz_file)
if not quiz_file.exists():
die(f"Quiz file not found: {quiz_file}")

with quiz_file.open() as f:
quiz = json.load(f)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

This section of the quiztool script is vulnerable to Path Traversal, as it accepts a quiz_file path from the command line and uses it to open a file without proper validation. This could allow an attacker to read arbitrary files from the filesystem. The provided suggestion mitigates this by resolving the path and checking against the current working directory. Additionally, consider adding error handling for json.JSONDecodeError if the quiz file is malformed, and other OSError scenarios (e.g., permission issues) to ensure robust file processing.

Suggested change
quiz_file = Path(args.quiz_file)
if not quiz_file.exists():
die(f"Quiz file not found: {quiz_file}")
with quiz_file.open() as f:
quiz = json.load(f)
resolved_path = Path(args.quiz_file).resolve()
if not resolved_path.exists() or not str(resolved_path).startswith(str(Path.cwd().resolve())):
die(f"File not found or path traversal detected: {args.quiz_file}")
with resolved_path.open() as f:
quiz = json.load(f)

Comment on lines +270 to +273
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "Stopping early. Your answers so far have been saved."
# jump to completion message
fi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for stopping the quiz early in the example bash script is flawed. If a user enters 'n' to stop, the script prints a message but then continues to execute and will ask the subsequent questions. The script should exit immediately to prevent further questions from being asked.

Suggested change
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "Stopping early. Your answers so far have been saved."
# jump to completion message
fi
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "Stopping early. Your answers so far have been saved."
exit 0
fi

Comment on lines +133 to +134
with quiz_file.open() as f:
quiz = json.load(f)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to cmd_run, this function doesn't handle potential json.JSONDecodeError or OSError when reading the quiz file. This can lead to an ungraceful crash with a traceback. It's better to handle these exceptions and provide a clear error message to the user.

Suggested change
with quiz_file.open() as f:
quiz = json.load(f)
try:
with quiz_file.open() as f:
quiz = json.load(f)
except json.JSONDecodeError as e:
die(f"Invalid JSON in quiz file {quiz_file}: {e}")
except OSError as e:
die(f"Could not read quiz file {quiz_file}: {e}")

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