# snippets-rules **Repository Path**: mirrors_firebase/snippets-rules ## Basic Information - **Project Name**: snippets-rules - **Description**: Snippets for security rules on firebase.google.com - **Primary Language**: Unknown - **License**: CC-BY-4.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-02-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Firebase Security Rules Snippets This repository holds code snippets used in security rules documentation on [firebase.google.com](https://firebase.google.com/docs/). ## Gemini CLI Extension -- AI-based Rule Generation This Gemini CLI extension helps you generate secure Firebase Security Rules and corresponding unit tests for your project. **Note:** The rules are generated by AI and are NOT to be trusted without a human approval. Firebase Security team advises that you review the generated rules against the domain of your project and your security requirements. Additionally, also review the generated tests and execute them. ### Extension Installation ```bash # Install the Firebase MCP extension (pre-requisite for syntactically correct rule-generation) gemini extensions install https://github.com/gemini-cli-extensions/firebase # Install the Firebase Rules extension gemini extensions install https://github.com/firebase/snippets-rules --ref=master ``` ### Generating Security Rules for Firestore This command automates the creation of `firestore.rules` and accompanying unit tests by performing a comprehensive analysis of your codebase. #### Sample Usage ```bash # Generation of Firestore rules -- generates `firestore.rules` and `rules_test` directory /firebase-rules:firestore Generate rules using PROJECT ID ``. ``` _Note:_ Allow any tool usage as you deem fit during the execution. ### Generating Security Rules for Firebase Storage This command automates the creation of `storage.rules` and accompanying unit tests by performing a comprehensive analysis of your codebase. #### Sample Usage ```bash # Generation of Firebase Storage rules -- generates `storage.rules` and `storage_rules_test` directory /firebase-rules:storage Generate rules using PROJECT ID `` and BUCKET NAME ``. ``` _Note:_ Allow any tool usage as you deem fit during the execution. #### Process These command follows a rigorous, multi-phase process to ensure the generated rules are secure and reliable: 1. **Codebase Analysis:** It scans your entire project to understand your data models, collection paths, and how your application accesses Firestore. 2. **Security Rule Generation:** Based on the analysis, it crafts security rules following the principle of least privilege. 3. **Security Audit (Devil's Advocate):** It actively tries to find vulnerabilities in the generated rules by simulating attacks and unauthorized access attempts. 4. **Syntax Validation:** It uses Firebase tools to ensure the generated rules are syntactically correct. 5. **Unit Test Generation:** It creates a suite of unit tests in the same programming language as your project to verify the rules. 6. **Test Validation:** It runs the generated tests to ensure they accurately cover various scenarios, including authorized and unauthorized operations. ## Contributing We love contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines. [![Actions Status][gh-actions-badge]][gh-actions] [gh-actions]: https://github.com/firebase/snippets-rules/actions [gh-actions-badge]: https://github.com/firebase/snippets-rules/workflows/CI%20Tests/badge.svg