-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[git-tool] do not use GITHUB_TOKEN #11730
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
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.
Summary of Changes
Hello @bukepo, 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 improves the security posture of the git-tool script by removing its direct reliance on the GITHUB_TOKEN for fetching pull request information. The change refactors the script to receive necessary PR body content externally, enhancing security and simplifying the internal logic.
Highlights
- Security Enhancement: Eliminated the direct use of
GITHUB_TOKENwithin thescript/git-toolby removing theget_pr_bodyfunction, which previously fetched PR details using the token. - Refactoring: Updated the
apply_dependenciesfunction to consume the PR body from thePR_BODYenvironment variable (or similar input) instead of fetching it internally. - Code Simplification: Removed calls to the now-defunct
get_pr_bodyfunction fromtry_updateandtry_clone, streamlining the script's logic.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 is currently in preview and 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 to provide feedback.
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
-
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. ↩
This commit stops using GITHUB_TOKEN in git-tool for better security.
da1c21e to
46788fa
Compare
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 improves security by removing the usage of GITHUB_TOKEN within the git-tool script, instead relying on a PR_BODY environment variable. The change is straightforward and effectively decouples the script from requiring direct GitHub API access.
My review identified a significant pre-existing bug in the grep pattern used to find dependent PRs. This bug would prevent the script's primary functionality from working correctly with URL-based Depends-On: declarations. I've provided a suggestion to fix this on the modified line to ensure the script functions as expected.
Library files
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11730 +/- ##
==========================================
- Coverage 75.29% 75.12% -0.18%
==========================================
Files 644 644
Lines 100136 95863 -4273
==========================================
- Hits 75400 72013 -3387
+ Misses 24736 23850 -886 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR removes the use of GITHUB_TOKEN in the git-tool script by passing the pull request body via a new PR_BODY environment variable, and updates all CI workflows to set PR_BODY instead of exporting GITHUB_TOKEN.
- script/git-tool no longer fetches the PR body via the GitHub API and has removed the
get_pr_bodyfunction; it now reads dependencies directly fromPR_BODY. - All GitHub Actions workflow files are updated to inject
PR_BODY: "${{ github.event.pull_request.body }}"and no longer exposeGITHUB_TOKENto the script.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| script/git-tool | Removed get_pr_body, updated apply_dependencies to use PR_BODY |
| .github/workflows/toranj.yml | Replaced GITHUB_TOKEN with PR_BODY env |
| .github/workflows/simulation-1.1.yml | Replaced GITHUB_TOKEN with PR_BODY env |
| .github/workflows/posix.yml | Replaced GITHUB_TOKEN with PR_BODY env |
| .github/workflows/otns.yml | Replaced GITHUB_TOKEN with PR_BODY env |
| .github/workflows/otbr.yml | Replaced GITHUB_TOKEN with PR_BODY env |
| .github/workflows/build.yml | Replaced GITHUB_TOKEN with PR_BODY env |
Comments suppressed due to low confidence (2)
script/git-tool:50
- Consider adding a comment or usage note explaining that
PR_BODYmust be set in the environment for dependency resolution to work, or provide a fallback/error whenPR_BODYis empty.
done < <(grep -E "^Depends-On: *${project_name}" <<<"${PR_BODY:-}" || true)
.github/workflows/toranj.yml:75
- [nitpick] This
envblock is repeated across multiple workflows; consider definingPR_BODYat a higher level (e.g., top-levelenv) or using a reusable workflow to reduce duplication.
PR_BODY: "${{ github.event.pull_request.body }}"
This commit stops using GITHUB_TOKEN in git-tool for better security.
Depends-On: openthread/ot-nrf528xx#989