Skip to content

Refactor user-media access rules for surveys#2459

Merged
rfontanarosa merged 1 commit intomasterfrom
gino-m-patch-1
Mar 18, 2026
Merged

Refactor user-media access rules for surveys#2459
rfontanarosa merged 1 commit intomasterfrom
gino-m-patch-1

Conversation

@gino-m
Copy link
Collaborator

@gino-m gino-m commented Mar 18, 2026

Fixes #1373

@rfontanarosa PTAL?

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 enhances the security posture of user-media storage by replacing a broad authenticated access rule with a more precise, role-based access control system. The changes ensure that users can only access or modify media if they have the appropriate permissions for the associated survey, thereby preventing unauthorized data exposure or manipulation.

Highlights

  • Granular Access Control for User Media: Implemented fine-grained access rules for user-media storage based on survey permissions, moving away from a general authenticated user access.
  • New Helper Functions for Survey Access: Introduced several new functions (getSurvey, isUnlistedOrPublic, isOneOf, canViewSurvey, canCollectData) within the Firebase Storage rules to encapsulate complex survey-specific access logic.
  • Dynamic Path Matching for Survey ID: Modified the /user-media storage path to include surveyId, allowing rules to dynamically fetch and evaluate survey-specific permissions.
  • Segregated Read/Write Permissions: Separated read and create/write permissions for user media, applying canViewSurvey for read access and canCollectData for create/write operations.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 significantly refactors the Firebase Storage security rules for /user-media paths. It introduces fine-grained access control by adding several helper functions (getSurvey, isUnlistedOrPublic, isOneOf, canViewSurvey, canCollectData) to determine user permissions based on survey roles and visibility. Previously, any authenticated user could read and write to /user-media; now, the path includes a surveyId, and access is restricted: read access requires the user to be able to view the specific survey, and create/write access requires the user to be able to collect data for that survey. This change addresses a previous TODO to implement more specific permission-based access.

@rfontanarosa rfontanarosa merged commit 8de87a8 into master Mar 18, 2026
9 checks passed
@rfontanarosa rfontanarosa deleted the gino-m-patch-1 branch March 18, 2026 20:22
@gino-m gino-m added this to Ground Mar 23, 2026
@github-project-automation github-project-automation bot moved this to Done in Ground Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ACLs not enforced on uploaded photos and imagery

2 participants