Skip to content

Commit 690c9e0

Browse files
authored
Merge branch 'gemini-cli-extensions:main' into main
2 parents 60aa578 + 0fb437b commit 690c9e0

File tree

10 files changed

+263
-25
lines changed

10 files changed

+263
-25
lines changed
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: '🔎 Gemini Review & Security Analysis'
2+
3+
on:
4+
pull_request:
5+
types:
6+
- 'opened'
7+
issue_comment:
8+
types:
9+
- 'created'
10+
11+
concurrency:
12+
group: '${{ github.workflow }}-review-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.issue.number }}'
13+
cancel-in-progress: true
14+
15+
defaults:
16+
run:
17+
shell: 'bash'
18+
19+
jobs:
20+
review:
21+
if: |
22+
(github.event_name == 'pull_request' && github.event.action == 'opened') ||
23+
(github.event_name == 'issue_comment' && github.event.comment.body == '@gemini-cli /review')
24+
runs-on: 'ubuntu-latest'
25+
timeout-minutes: 15
26+
permissions:
27+
contents: 'read'
28+
id-token: 'write'
29+
issues: 'write'
30+
pull-requests: 'write'
31+
steps:
32+
- name: 'Mint identity token'
33+
id: 'mint_identity_token'
34+
if: |-
35+
${{ vars.APP_ID }}
36+
uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b' # ratchet:actions/create-github-app-token@v2
37+
with:
38+
app-id: '${{ vars.APP_ID }}'
39+
private-key: '${{ secrets.APP_PRIVATE_KEY }}'
40+
permission-contents: 'read'
41+
permission-issues: 'write'
42+
permission-pull-requests: 'write'
43+
44+
- name: 'Acknowledge request'
45+
env:
46+
GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}'
47+
ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
48+
MESSAGE: |-
49+
🤖 Hi @${{ github.actor }}, I've received your request, and I'm working on it now! You can track my progress [in the logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details.
50+
REPOSITORY: '${{ github.repository }}'
51+
run: |-
52+
gh issue comment "${ISSUE_NUMBER}" \
53+
--body "${MESSAGE}" \
54+
--repo "${REPOSITORY}"
55+
56+
- name: 'Checkout repository'
57+
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
58+
59+
- name: 'Run Gemini pull request review'
60+
uses: 'google-github-actions/run-gemini-cli@main' # ratchet:exclude
61+
id: 'gemini_pr_review'
62+
env:
63+
GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}'
64+
ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}'
65+
ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}'
66+
PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
67+
REPOSITORY: '${{ github.repository }}'
68+
with:
69+
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
70+
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
71+
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
72+
gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
73+
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
74+
gemini_cli_version: '${{ vars.GEMINI_CLI_VERSION }}'
75+
gemini_debug: '${{ fromJSON(vars.DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}'
76+
gemini_model: '${{ vars.GEMINI_MODEL }}'
77+
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
78+
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
79+
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
80+
settings: |-
81+
{
82+
"model": {
83+
"maxSessionTurns": 25
84+
},
85+
"telemetry": {
86+
"enabled": ${{ vars.GOOGLE_CLOUD_PROJECT != '' }},
87+
"target": "gcp"
88+
},
89+
"mcpServers": {
90+
"github": {
91+
"command": "docker",
92+
"args": [
93+
"run",
94+
"-i",
95+
"--rm",
96+
"-e",
97+
"GITHUB_PERSONAL_ACCESS_TOKEN",
98+
"ghcr.io/github/github-mcp-server"
99+
],
100+
"includeTools": [
101+
"add_comment_to_pending_review",
102+
"create_pending_pull_request_review",
103+
"pull_request_read",
104+
"submit_pending_pull_request_review"
105+
],
106+
"env": {
107+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
108+
}
109+
}
110+
},
111+
"tools": {
112+
"core": [
113+
"run_shell_command(cat)",
114+
"run_shell_command(echo)",
115+
"run_shell_command(grep)",
116+
"run_shell_command(head)",
117+
"run_shell_command(tail)"
118+
]
119+
}
120+
}
121+
prompt: '/gemini-review'
122+
- name: 'Run Gemini security analysis review'
123+
uses: 'google-github-actions/run-gemini-cli@main' # ratchet:exclude
124+
id: 'gemini_security_analysis'
125+
env:
126+
GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}'
127+
ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}'
128+
ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}'
129+
PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
130+
REPOSITORY: '${{ github.repository }}'
131+
with:
132+
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
133+
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
134+
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
135+
gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
136+
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
137+
gemini_cli_version: '${{ vars.GEMINI_CLI_VERSION }}'
138+
gemini_debug: '${{ fromJSON(vars.DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}'
139+
gemini_model: '${{ vars.GEMINI_MODEL }}'
140+
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
141+
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
142+
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
143+
extensions: |
144+
[
145+
"https://github.com/gemini-cli-extensions/security.git"
146+
]
147+
settings: |-
148+
{
149+
"model": {
150+
"maxSessionTurns": 100
151+
},
152+
"telemetry": {
153+
"enabled": ${{ vars.GOOGLE_CLOUD_PROJECT != '' }},
154+
"target": "gcp"
155+
},
156+
"mcpServers": {
157+
"github": {
158+
"command": "docker",
159+
"args": [
160+
"run",
161+
"-i",
162+
"--rm",
163+
"-e",
164+
"GITHUB_PERSONAL_ACCESS_TOKEN",
165+
"ghcr.io/github/github-mcp-server"
166+
],
167+
"includeTools": [
168+
"add_comment_to_pending_review",
169+
"create_pending_pull_request_review",
170+
"pull_request_read",
171+
"submit_pending_pull_request_review"
172+
],
173+
"env": {
174+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
175+
}
176+
}
177+
},
178+
"tools": {
179+
"core": [
180+
"run_shell_command(cat)",
181+
"run_shell_command(echo)",
182+
"run_shell_command(grep)",
183+
"run_shell_command(head)",
184+
"run_shell_command(tail)"
185+
]
186+
}
187+
}
188+
prompt: '/security:analyze-github-pr'

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
.env
2+
13
dist/
2-
node_modules/
4+
node_modules/

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.2.0"
2+
".": "0.3.0"
33
}

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Changelog
22

3+
## [0.3.0](https://github.com/gemini-cli-extensions/security/compare/v0.2.0...v0.3.0) (2025-10-20)
4+
5+
6+
### Features
7+
8+
* add folder to contain artifacts ([e03b2c6](https://github.com/gemini-cli-extensions/security/commit/e03b2c60d7b0ca3256533125175f43c9758236ce))
9+
* add folder to contain security artifacts ([2fe3588](https://github.com/gemini-cli-extensions/security/commit/2fe35888d5cff981c88ef31fae3daf39c6a695ef))
10+
* Add preamble to security scan to make confirms user's decision to use command or manual security auditing ([67658d5](https://github.com/gemini-cli-extensions/security/commit/67658d587472be8283bc5aa00864429786bd1500))
11+
* **GHA workflows:** Add run-gemini-cli GHA workflows to repo PR's ([facc88b](https://github.com/gemini-cli-extensions/security/commit/facc88be48db43b3b8482ff6a6d19d34fd0513e1))
12+
* **GitHub Action:** Add /security:github-pr command for use with run-gemini-cli GitHub Action ([59db0ad](https://github.com/gemini-cli-extensions/security/commit/59db0add3f6aee54821570725f1c33859c24bc4d))
13+
14+
15+
### Bug Fixes
16+
17+
* Diff issues were due to non remote repositories, support local changes by defulating to ([53a52c6](https://github.com/gemini-cli-extensions/security/commit/53a52c650c07575a18840b5b357eb80d8941c304))
18+
* **GHA:** Gemini-review MCP calls and prompt changes ([6d2d20f](https://github.com/gemini-cli-extensions/security/commit/6d2d20f070e034a90fdb7b6369b600f71d539430))
19+
* **GHA:** Gemini-review MCP calls and prompt changes ([ad93687](https://github.com/gemini-cli-extensions/security/commit/ad936878615d772cf00e17eb9e24d2c813e37a61))
20+
* **GHA:** Update github-mcp-server calls ([2c1e176](https://github.com/gemini-cli-extensions/security/commit/2c1e176bebee987e6beba630b7d1409a14f4f76f))
21+
* nit white space and revert deletion prompt to only affect temp files ([9d64b30](https://github.com/gemini-cli-extensions/security/commit/9d64b307eec2946b2f155a062febefae1c7f03bb))
22+
* phrasing and whitespace ([4fb13d6](https://github.com/gemini-cli-extensions/security/commit/4fb13d651822619d1f442bdd4226d81ec9ec4bac))
23+
* remove additional test causing gemini cli to try to run a command ([2caa615](https://github.com/gemini-cli-extensions/security/commit/2caa615f2f4563034ecc92842fec7583dbd102d1))
24+
* suggest user to run commands themselves, since gemini cli cannot correctly run it's own commands. ([caafd73](https://github.com/gemini-cli-extensions/security/commit/caafd7399b3ddae851f701885a74468a55a36424))
25+
* suggest user to run commands themselves, since gemini cli cannot… ([96f84f9](https://github.com/gemini-cli-extensions/security/commit/96f84f95d327482f4c5d8ddc267ea3f271aebcdb))
26+
* use to store line number mappings in the MCP server ([#91](https://github.com/gemini-cli-extensions/security/issues/91)) ([909c901](https://github.com/gemini-cli-extensions/security/commit/909c901fd0a9b181b13a6462d50de7ca5acf4a5e))
27+
* Use a command available on all platforms to generate a file diff ([21fc350](https://github.com/gemini-cli-extensions/security/commit/21fc35037b22b7acf51e7c78a5eb233d2f02cff3))
28+
* Use a command available on all platforms to generate a file diff ([f1fca9b](https://github.com/gemini-cli-extensions/security/commit/f1fca9bd98bef7f10f957701d5ca4fd69c9f2e9c))
29+
* whitespace at end fo file ([4257532](https://github.com/gemini-cli-extensions/security/commit/4257532aaa734171bfcf083deba8472c6e8453a7))
30+
331
## [0.2.0](https://github.com/gemini-cli-extensions/security/compare/v0.1.0...v0.2.0) (2025-10-07)
432

533

GEMINI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ You are a highly skilled senior security and privacy engineer. You are meticulou
2525
2. **Manual Review**: I can manually review the code for potential vulnerabilities based on our conversation.
2626
```
2727
* Explicitly ask the user which they would prefer before proceeding. The manual analysis is your default behavior if the user doesn't choose the command. If the user chooses the command, remind them that they must run it on their own.
28-
* During the security analysis, you **MUST NOT** write, modify, or delete any files unless explicitly instructed by a command (eg. `/security:analyze`)
28+
* During the security analysis, you **MUST NOT** write, modify, or delete any files unless explicitly instructed by a command (eg. `/security:analyze`). Artifacts created during security analysis should be stored in a `.gemini_security/` directory in the user's workspace.
2929

3030
## Skillset: SAST Vulnerability Analysis
3131

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,23 @@ By default, the `/security:analyze` command determines the scope of the analysis
3939

4040
## GitHub Integration
4141

42-
Coming soon!
42+
### I already use [run-gemini-cli](https://github.com/google-github-actions/run-gemini-cli) workflows in my repository:
43+
44+
* Replace your existing `gemini-review.yml` with this [updated workflow](https://github.com/gemini-cli-extensions/security/blob/main/.github/workflows/gemini-review.yml), which includes the new Security Analysis step.
45+
46+
### I don't use [run-gemini-cli](https://github.com/google-github-actions/run-gemini-cli) workflows in my repository yet:
47+
48+
1. Integrate the Gemini CLI Security Extension into your GitHub workflow to analyze incoming code:
49+
50+
2. Follow Steps 1-3 in this [Quick Start](https://github.com/google-github-actions/run-gemini-cli?tab=readme-ov-file#quick-start).
51+
52+
3. Create a `.github/workflows` directory in your repository's root (if it doesn't already exist).
53+
54+
4. Copy this [Example Workflow](https://github.com/gemini-cli-extensions/security/blob/main/.github/workflows/gemini-review.yml) into the `.github/workflows` directory. See the run-gemini-cli [configuration](https://github.com/google-github-actions/run-gemini-cli?tab=readme-ov-file#configuration) to make changes to the workflow.
55+
56+
5. Ensure the new workflow file is committed and pushed to GitHub.
57+
58+
6. Open a new pull request, or comment `@gemini-cli /review` on an existing PR, to run the Gemini CLI Code Review along with Security Analysis.
4359

4460
## Benchmark
4561

commands/security/analyze-github-pr.toml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
description = "Only to be used with the run-gemini-cli GitHub Action. Analyzes code changes on a GitHub PR for common security vulnerabilities"
2-
prompt = """You are a highly skilled senior security analyst. You operate within a secure GitHub Actions environment. Your primary task is to conduct a security audit of the current pull request.
2+
prompt = """
3+
You are a highly skilled senior security analyst. You operate within a secure GitHub Actions environment. Your primary task is to conduct a security audit of the current pull request.
34
Utilizing your skillset, you must operate by strictly following the operating principles defined in your context.
45
56
@@ -108,12 +109,12 @@ You will now begin executing the plan. The following are your precise instructio
108109
1. **To complete the 'Define the audit scope' task:**
109110
110111
* Input Data
111-
- Retrieve the GitHub repository name from the environment variable "${REPOSITORY}".
112-
- Retrieve the GitHub pull request number from the environment variable "${PULL_REQUEST_NUMBER}".
113-
- Retrieve the additional user instructions and context from the environment variable "${ADDITIONAL_CONTEXT}".
114-
- Use `mcp__github__get_pull_request` to get the title, body, and metadata about the pull request.
115-
- Use `mcp__github__get_pull_request_files` to get the list of files that were added, removed, and changed in the pull request.
116-
- Use `mcp__github__get_pull_request_diff` to get the diff from the pull request. The diff includes code versions with line numbers for the before (LEFT) and after (RIGHT) code snippets for each diff.
112+
- **GitHub Repository**: !{echo $REPOSITORY}
113+
- **Pull Request Number**: !{echo $PULL_REQUEST_NUMBER}
114+
- **Additional User Instructions**: !{echo $ADDITIONAL_CONTEXT}
115+
- Use `pull_request_read.get` to get the title, body, and metadata about the pull request.
116+
- Use `pull_request_read.get_files` to get the list of files that were added, removed, and changed in the pull request.
117+
- Use `pull_request_read.get_diff` to get the diff from the pull request. The diff includes code versions with line numbers for the before (LEFT) and after (RIGHT) code snippets for each diff.
117118
118119
* Once the command is executed and you have the list of changed files, you will mark this task as complete.
119120
@@ -129,9 +130,9 @@ After completing these two initial tasks, continue executing the dynamically gen
129130
130131
After your **Core Operational Loop** is completed, report the final report back to GitHub:
131132
132-
3.1 **Create Pending Review:** Call `mcp__github__create_pending_pull_request_review`. Ignore errors like "can only have one pending review per pull request" and proceed to the next step.
133+
3.1 **Create Pending Review:** Call `create_pending_pull_request_review`. Ignore errors like "can only have one pending review per pull request" and proceed to the next step.
133134
134-
3.2 **Add Comments and Suggestions:** For each formulated review comment, call `mcp__github__add_comment_to_pending_review`.
135+
3.2 **Add Comments and Suggestions:** For each formulated review comment, call `add_comment_to_pending_review`.
135136
136137
2a. When there is a code suggestion (preferred), structure the comment payload using this exact template:
137138
@@ -149,7 +150,7 @@ After completing these two initial tasks, continue executing the dynamically gen
149150
{{SEVERITY}} {{COMMENT_TEXT}}
150151
</COMMENT>
151152
152-
3.3 **Submit Final Review:** Call `mcp__github__submit_pending_pull_request_review` with a summary comment. **DO NOT** approve the pull request. **DO NOT** request changes. The summary comment **MUST** use this exact markdown format:
153+
3.3 **Submit Final Review:** Call `submit_pending_pull_request_review` with a summary comment. **DO NOT** approve the pull request. **DO NOT** request changes. The summary comment **MUST** use this exact markdown format:
153154
154155
<SUMMARY>
155156
## 📋 Security Analysis Summary
@@ -162,4 +163,5 @@ After completing these two initial tasks, continue executing the dynamically gen
162163
- Keep this section concise and do not repeat details already covered in inline comments.
163164
</SUMMARY>
164165
165-
Proceed with the Initial Planning Phase now."""
166+
Proceed with the Initial Planning Phase now.
167+
"""

0 commit comments

Comments
 (0)