-
Notifications
You must be signed in to change notification settings - Fork 81
Plugin testing #152
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
base: main
Are you sure you want to change the base?
Plugin testing #152
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,69 @@ | ||||||
| The plugin is just dropped in a folder - so the easiest way is to symlink the working source from your app folder like so: | ||||||
|
|
||||||
| `ln -s ~/firebase/agent-skills/.antigravity-plugin ~/myappdirectory/.agents/plugins/firebase-antigravity-plugin` | ||||||
|
|
||||||
| Pre-flight checks: | ||||||
| - ensure you're not using corp - this prevents new project creation (you'll get a 401) | ||||||
| - `gcloud config set account christhompsonfirebase@gmail.com` | ||||||
| - Login for ADC (if you continue to get 401 ensure you check the boxes on login) | ||||||
| - `gcloud auth application-default login` | ||||||
|
|
||||||
| FIXME: move this into a tool of some kind, create a project and app. | ||||||
| ``` | ||||||
| curl -X POST "https://cloudresourcemanager.googleapis.com/v1/projects" \ | ||||||
| -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "projectId": "agyplugintestproject1", | ||||||
| "name": "agyplugintestproject1" | ||||||
| }' | ||||||
| ``` | ||||||
|
|
||||||
| ``` | ||||||
| curl -X POST "https://firebase.googleapis.com/v1beta1/projects/agyplugintestproject1:addFirebase" \ | ||||||
| -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "locationId": "us-central" | ||||||
| }' | ||||||
| ``` | ||||||
|
|
||||||
| Since the creation of Firebase resources happens asynchronously, you can poll and monitor the creation progress by querying the returned operation name | ||||||
|
|
||||||
| ``` | ||||||
| curl -X GET "https://firebase.googleapis.com/v1beta1/operations/workflows/ZDBiYzVmMGEtNjdiNS00ODA5LTk5MDktMDhmYWZjZDY1Zjcx" \ | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The operation ID in the polling command is hardcoded. Use a placeholder like
Suggested change
|
||||||
| -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" | ||||||
| ``` | ||||||
|
|
||||||
| Create web app: | ||||||
| ``` | ||||||
| curl -X POST "https://firebase.googleapis.com/v1beta1/projects/agyplugintestproject1/webApps" \ | ||||||
| -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "displayName": "agy-plugin-web-app-1" | ||||||
| }' | ||||||
| ``` | ||||||
|
|
||||||
| Get the app ID: | ||||||
| ``` | ||||||
| curl -s -X GET "https://firebase.googleapis.com/v1beta1/projects/agyplugintestproject1/webApps" \ | ||||||
| -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ | ||||||
| -H "Content-Type: application/json" | \ | ||||||
| jq '.apps[]? | select(.displayName == "agy-plugin-web-app-1")' | ||||||
| ``` | ||||||
|
|
||||||
| enable google signin provider for firebase auth: | ||||||
| ``` | ||||||
| curl -X POST "https://identitytoolkit.googleapis.com/admin/v2/projects/your-unique-project-id/defaultSupportedIdpConfigs?idpId=google.com" \ | ||||||
| -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "enabled": true, | ||||||
| "clientId": "YOUR_GOOGLE_OAUTH_CLIENT_ID", | ||||||
| "clientSecret": "YOUR_GOOGLE_OAUTH_CLIENT_SECRET" | ||||||
| }' | ||||||
|
|
||||||
| ``` | ||||||
|
|
||||||
| TODO provisioning API call k | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| - Update new Rules logic once chliang@ is done updating the firebase skill. | ||
| - Add a gcloud rules deploy (or agent tool for making the API call) | ||
| - Add a reference to scoring rules | ||
| - Write the gcloud deploy logic | ||
| - Figure out how to test this thing | ||
| - Write system instructions | ||
| - MCP server support | ||
| - TODO: Add MCP for deployment (currently using gcloud CLI for v0) | ||
| - Sidecar ideas needed https://antigravity.google/docs/sidecars | ||
| - How about a rules analyzer that runs antagonistically to the main model | ||
| - wait for cloud run deployment and reports success or failure to the main model | ||
| - "Sidecars can use the agentapi CLI to programmatically interact with Antigravity. The executable is automatically added to the sidecar’s path and available as agentapi." | ||
| - Depends on AG environment (windows vs linux, python? etc) | ||
| - Emulators? Interesting idea | ||
| - Hooks | ||
| - Check rules score before deploying rules? | ||
| - Does an MCP tool command work? The docs seem to suggest that only the AGY tools are matchable. Gemini says MCP tools work | ||
| - ** This is a big deal - anything that we want to hook on should be an MCP tool execution ** | ||
| - Metrics tracking - lots of opportunities here | ||
| - Subagents ? can we have a rules subagent? | ||
|
|
||
|
|
||
| Deployment environments: | ||
| - Plugin works in CLI too hm? | ||
| - Antigravity (Google’s AI coding tool powered by Gemini) as an assistant directly inside Claude Code |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||
| { | ||||||
| "hooks": [ | ||||||
| { | ||||||
| "id": "evaluate_rules_before_deploy", | ||||||
| "type": "pre_command", | ||||||
| "command_pattern": ".*firebase deploy --only firestore(:rules)?.*", | ||||||
| "action": { | ||||||
| "type": "evaluate", | ||||||
| "rubric_file": "./skills/firebase-score-rules.md", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The path to the rubric file is incorrect. It points to
Suggested change
|
||||||
| "threshold": 3, | ||||||
| "on_failure": "block" | ||||||
| }, | ||||||
| "description": "Blocks Firestore rules deployment if the rules score below a 3 based on the firebase-score-rules rubric." | ||||||
| } | ||||||
| ] | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "firebase-antigravity-plugin", | ||
| "version": "0.1.0", | ||
| "description": "Opinionated Firebase plugin for Antigravity, mimicking AI Studio capabilities.", | ||
| "skills": "./skills", | ||
| "rules": "./rules", | ||
| "hooks": "hooks.json" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Whenever you update an application that uses firestore is modified, be sure to update your rules following the firebase-write-rules skill. After that you can deploy using the firebase-rules-deploy skill. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Firebase Plugin System Instructions | ||
|
|
||
| When working within this project, you are utilizing the Antigravity Firebase plugin. Follow these constraints: | ||
|
|
||
| 1. **Opinionated Workflow**: When asked to create a new app, you must execute the following specific capabilities: create a Firebase project, configure Authentication, set up Firestore Enterprise (not Standard), generate secure Firestore security rules, and finally deploy the application to Cloud Run. | ||
| 2. **Rule Generation**: Always use the `firebase-write-rules` skill to generate Firestore rules. | ||
| 3. **Rule Deployment**: Use the `firebase-rules-deploy` skill. | ||
| 4. **Security First**: All generated rules must score at least a 3 based on the `firebase-score-rules` rubric. Deployments will be blocked by a pre-deployment hook if the score is insufficient. | ||
| 5. **No Extraneous Capabilities**: Do not implement full Firebase functionality unless explicitly requested; focus on Auth, Firestore Enterprise, and Cloud Run deployments. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||
| Use the following curl command to create a new project: | ||||||
|
|
||||||
| ``` | ||||||
| curl -X POST https://firebase.googleapis.com/v1alpha/firebase:provisionFirebaseApp \ | ||||||
| -H "Authorization: Bearer $(gcloud auth print-access-token)" \ | ||||||
| -H "X-Goog-User-Project: ctfdc1" \ | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "app_namespace": "com.example.my_app", | ||||||
| "display_name": "My Firebase App", | ||||||
| "location": "us-central1", | ||||||
| "web_input": {} | ||||||
| }' | ||||||
| ``` | ||||||
|
|
||||||
| Listen on the operations endpoint for the result: | ||||||
| ``` | ||||||
| curl -X GET "https://firebase.googleapis.com/v1beta1/operations/workflows/ZDBiYzVmMGEtNjdiNS00ODA5LTk5MDktMDhmYWZjZDY1Zjcx" \ | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The operation ID in the polling command is hardcoded. Since this is a skill definition used by an AI agent, the agent will attempt to poll this static ID instead of the actual operation ID returned by the previous project creation step. Use a placeholder so the agent knows to replace it dynamically.
Suggested change
|
||||||
| -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" | ||||||
| ``` | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Deploy Application to Cloud Run | ||
|
|
||
| When asked to deploy the application to Cloud Run, follow these instructions: | ||
|
|
||
| 1. **Prerequisites**: Ensure you are in the root directory of the web application. | ||
| 2. **Deployment Command**: Use the `gcloud run deploy` command to deploy directly from source. | ||
| 3. **Arguments**: | ||
| - `--source .`: Use the current directory as the source for the build. | ||
| - `--allow-unauthenticated`: Ensure the deployed app is publicly viewable by third parties. | ||
| - Supply a `SERVICE_NAME` and `REGION` (e.g., `us-central1`), picking sensible defaults if none are provided. | ||
|
|
||
| **Example Command**: | ||
| ```bash | ||
| gcloud run deploy my-web-app --source . --region us-central1 --allow-unauthenticated | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| --- | ||
| name: firebase-score-rules | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| description: A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust. | ||
| --- | ||
|
|
||
| # Overview | ||
|
|
||
| This skill acts as an auditor for Firebase Security Rules, evaluating them | ||
| against a rigorous set of criteria to ensure they are secure, robust, and | ||
| correctly implemented. | ||
|
|
||
| # Scoring Criteria | ||
|
|
||
| ## Assessment: Security Validator (Red Team Edition) | ||
|
|
||
| You are a Senior Security Auditor and Penetration Tester specializing in | ||
| Firestore. Your goal is to find "the hole in the wall." Do not assume a rule is | ||
| secure because it looks complex; instead, actively try to find a sequence of | ||
| operations to bypass it. | ||
|
|
||
| ### Mandatory Audit Checklist: | ||
|
|
||
| 1. **The Update Bypass:** Compare 'create' and 'update' rules. Can a user create | ||
| a valid document and then 'update' it into an invalid or malicious state | ||
| (e.g., changing their role, bypassing size limits, or corrupting data types)? | ||
| 1. **Authority Source:** Does the security rely on user-provided data | ||
| (request.resource.data) for sensitive fields like 'role', 'isAdmin', or | ||
| 'ownerId'? Carefully consider the source for that authority. | ||
| 1. **Business Logic vs. Rules:** Does the rule set actually support the app's | ||
| purpose? (e.g., In a collaboration app, can collaborators actually read the | ||
| data? If not, the rules are "broken" or will force insecure workarounds). | ||
| 1. **Storage Abuse:** Are there string length or array size limits? If not, | ||
| label it as a "Resource Exhaustion/DoS" risk. | ||
| 1. **Type Safety:** Are fields checked with 'is string', 'is int', or 'is | ||
| timestamp'? | ||
| 1. **Field-Level vs. Identity-Level Security:** Be careful with rules that use | ||
| \`hasOnly()\` or \`diff()\`. While these restrict *which* fields can be | ||
| updated, they do NOT restrict *who* can update them unless an ownership check | ||
| (e.g., \`resource.data.uid == request.auth.uid\`) is also present. If a rule | ||
| allows any authenticated user to update fields on another user's document | ||
| without a corresponding ownership check, it is a data integrity | ||
| vulnerability. | ||
|
|
||
| ### Admin Bootstrapping & Privileges: | ||
|
|
||
| The admin bootstrapping process is limited in this app. If the rules use a | ||
| single hardcoded admin email (e.g., checking request.auth.token.email == | ||
| 'admin@example.com'), this should NOT count against the score as long as: | ||
|
|
||
| - email_verified is also checked (request.auth.token.email_verified == true). | ||
| - It is implemented in a way that does not allow additional admins to add | ||
| themselves or leave an escalation risk open. | ||
|
|
||
| ### Scoring Criteria (1-5): | ||
|
|
||
| - **1 (Critical):** Unauthorized data access (leaks), privilege escalation, or | ||
| total validation bypass. | ||
| - **2 (Major):** Broken business logic, self-assigned roles, bypass of controls. | ||
| - **3 (Moderate):** PII exposure (e.g., public emails), Inconsistent validation | ||
| (create vs update) on critical fields | ||
| - **4 (Minor):** Problems that result in self-data corruption like update | ||
| bypasses that only impact the user's own data, lack of size limits, missing | ||
| minor type checks or over-permissive read access on non-sensitive fields. | ||
| - **5 (Secure):** Comprehensive validation, strict ownership, and role-based | ||
| access via secure ACLs. | ||
|
|
||
| Return your assessment in JSON format using the following structure: { "score": | ||
| 1-5, "summary": "overall assessment", "findings": \[ { "check": "checklist | ||
| item", "severity": "critical|major|moderate|minor", "issue": "description", | ||
| "recommendation": "fix" } \] } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Deploy Firestore Rules | ||
|
|
||
| Use `firebase deploy --only firestore:rules`. All other deployments should use the `gcloud` CLI. |
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.
Avoid hardcoding personal email addresses in the testing instructions. Use a generic placeholder instead.