Skip to content

Commit 9c30e12

Browse files
Add registered prompt and gemini md updates for enabling notation usa… (#107)
* Add registered prompt and gemini md updates for enabling notation usage in security extension * fix: folder location wording in gemini .md * fix: merge into main * fix: folder location wording in gemini .md * fix: remove merge remnants * fix: make prompt less error prone by enforcing directory * fix: move whitelist directory to .gemini_security * fix: remove mentions of unused security notes folder from gemini md * fix: add language that suggests to skip if note doesnt exist * fix: whitelist -> allowlist * fix: remove clause that allows modifying files outside of gemini security --------- Co-authored-by: QuinnDACollins <qnn@google.com>
1 parent f7f778d commit 9c30e12

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

GEMINI.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ For every potential finding, you must perform a quick "So What?" test. If a theo
219219
220220
* **Example:** A piece of code might use a slightly older, but not yet broken, cryptographic algorithm for a non-sensitive, internal cache key. While technically not "best practice," it may have zero actual security impact. In contrast, using the same algorithm to encrypt user passwords would be a critical finding. You must use your judgment to differentiate between theoretical and actual risk.
221221
222+
### 5. Allowlisting Vulnerabilities
223+
When a user disagrees with one of your findings, you **MUST** allowlist the disagreed upon vulnerability.
224+
225+
* **YOU MUST** Use the MCP Prompt `note-adder` to create a new notation in the `.gemini_security/vuln_allowlist.txt` file with the following format:
226+
```
227+
Vulnerability:
228+
Location:
229+
Line Content:
230+
Justification:
231+
```
232+
222233
---
223234
### Your Final Review Filter
224235
Before you add a vulnerability to your final report, it must pass every question on this checklist:

commands/security/analyze.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ For EVERY task, you MUST follow this procedure. This loop separates high-level s
4040
* **Action:** If it does not already exist, create a new folder named `.gemini_security` in the user's workspace.
4141
* **Action:** Create a new file named `SECURITY_ANALYSIS_TODO.md` in `.gemini_security`, and write the initial, high-level objectives from the prompt into it.
4242
* **Action:** Create a new, empty file named `DRAFT_SECURITY_REPORT.md` in `.gemini_security`.
43+
* **Action"** Prep yourself using the following possible notes files under `.gemini_security/`. If they do not exist, skip them.
44+
* `vuln_allowlist.txt`: The allowlist file has vulnerabilities to ignore during your scan. If you match a vulernability to this file, notify the user and skip it in your scan.
4345
4446
2. **Phase 1: Dynamic Execution & Planning**
4547
* **Action:** Read the `SECURITY_ANALYSIS_TODO.md` file and execute the first task about determinig the scope of the analysis.

mcp-server/src/index.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,50 @@ server.tool(
5050
}
5151
);
5252

53+
server.registerPrompt(
54+
'security:note-adder',
55+
{
56+
title: 'Note Adder',
57+
description: 'Creates a new note file or adds a new entry to an existing one, ensuring content consistency.',
58+
argsSchema: {
59+
notePath: z.string().describe('The path to the note file.'),
60+
content: z.string().describe('The content of the note entry to add.'),
61+
},
62+
},
63+
({ notePath, content }) => ({
64+
messages: [
65+
{
66+
role: 'user',
67+
content: {
68+
type: 'text',
69+
text: `You are a helpful assistant that helps users maintain notes. Your task is to add a new entry to the notes file at '.gemini_security/${notePath}'.
70+
71+
You MUST use the 'ReadFile' and 'WriteFile' tools.
72+
73+
**Workflow:**
74+
75+
1. **Read the file:** First, you MUST attempt to read the file at '.gemini_security/${notePath}' using the 'ReadFile' tool.
76+
77+
2. **Handle the result:**
78+
* **If the file exists:**
79+
* Analyze the existing content to understand its structure and format.
80+
* **Check for consistency:** Before adding the new entry, you MUST check if the provided content (\`\`\`${content}\`\`\`) is consistent with the existing entries.
81+
* **If it is not consistent:** You MUST ask the user for clarification. Show them the existing format and ask them to provide the content in the correct format.
82+
* Once you have a consistent entry, append it to the content, ensuring it perfectly matches the existing format.
83+
* Use the 'WriteFile' tool to write the **entire updated content** back to the file.
84+
* **If the file does NOT exist (ReadFile returns an error):**
85+
* First, if the '.gemini_security' directory doesn't exist, create it.
86+
* This is a new note. You MUST ask the user to define a template for this note.
87+
* Once the user provides a template, construct the initial file content. The content MUST include the user-defined template and the new entry (\`\`\`${content}\`\`\`) as the first entry.
88+
* Use the 'WriteFile' tool to create the new file with the complete initial content.
89+
90+
Your primary goal is to maintain strict consistency with the format of the note file. Do not introduce any formatting changes.`,
91+
},
92+
},
93+
],
94+
}),
95+
);
96+
5397
async function startServer() {
5498
const transport = new StdioServerTransport();
5599
await server.connect(transport);

0 commit comments

Comments
 (0)