Skip to content

Conversation

@chrismclarke
Copy link
Collaborator

@chrismclarke chrismclarke commented Jan 30, 2026

TODO

  • Split DB changes from UI
  • Tidy up migration security
  • [ ]

Description

Discussion

Feedback discussion points if relevant (should also tag as Feedback Discussion)

Preview

Link to app preview if relevant

Screenshots / Videos

Include at least 1-2 screenshots of videos if visual changes

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chrismclarke, 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 application's database security posture by implementing comprehensive Row Level Security (RLS) policies and fine-grained permissions for various tables. It ensures that database interactions from serverless functions are performed with appropriate service role privileges. Additionally, the PR includes minor front-end refinements for date display and button styling, alongside a small TypeScript optimization for type imports.

Highlights

  • Database Row Level Security (RLS) and Permissions: Introduced new database migration files to establish and refine Row Level Security (RLS) policies and permissions across several key tables, including deployments, climate_station_data, climate_stations, crop_data, crop_data_downscaled, forecasts, and user_roles.
  • Database Client Usage Update: Updated serverless functions (forecast-db.ts, forecast-storage.ts, and admin functions) to use getServiceRoleClient() instead of getClient(), indicating a shift to operations with elevated database privileges.
  • TypeScript Type-Only Imports: Optimized TypeScript imports in several admin functions by changing standard imports to import type for type definitions, which can improve build performance and bundle size.
  • Minor UI and Styling Adjustments: Applied small front-end changes, including a date format correction in the month selector component and a CSS styling adjustment for chart buttons.

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

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

@nx-cloud
Copy link

nx-cloud bot commented Jan 30, 2026

View your CI Pipeline Execution ↗ for commit 3c1078b

Command Status Duration Result
nx build ✅ Succeeded 4m 11s View ↗
nx run-many --target=lint ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-31 07:00:23 UTC

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 introduces significant updates to database policies, including enabling Row Level Security (RLS) and defining access policies for several tables. It also refactors client imports in TypeScript files to consistently use getServiceRoleClient and refines date formatting in an Angular component. The changes to use import type for type-only imports are a good practice for TypeScript projects. Overall, the changes improve security and maintainability, though there are a couple of areas for clarification and correction in the SQL migration files.

@chrismclarke
Copy link
Collaborator Author

/gemini review

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 introduces database policies and makes related backend and frontend adjustments. The changes include adding Row Level Security (RLS) policies for several database tables and updating backend functions to use the service_role client for database interactions, which is appropriate for these administrative tasks. My review focuses on the security implications of the new RLS policies. Some policies are overly permissive, granting all authenticated users write access to critical data tables, which I've flagged as a high-severity issue. I have also provided suggestions to improve the clarity of another policy and pointed out a small redundancy in one of the backend functions.

Comment on lines 43 to 45
CREATE POLICY "climate_station_data:read_write:authenticated" ON public.climate_station_data
FOR ALL
TO authenticated USING (true) WITH CHECK (true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

This policy grants full SELECT, INSERT, and UPDATE access to all authenticated users on the climate_station_data table. This is a very permissive policy and effectively bypasses row-level security for any authenticated user. This pattern is repeated for other tables in this file (climate_stations, crop_data, etc.), posing a significant security risk as any authenticated user could modify critical data. It is strongly recommended to implement more restrictive policies based on user roles or data ownership. If data modification is a privileged operation, it should be handled exclusively by edge functions running with a service role, as hinted by the TODO comment at the end of the file.

id: string,
): Promise<{ data?: IDBClimateForecastRow; error?: any }> {
const supabaseClient = getClient();
const supabaseClient = getServiceRoleClient();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This local supabaseClient declaration is redundant. The class property this.supabaseClient is already initialized as a service role client on line 28. You can remove this line and use this.supabaseClient throughout this method to avoid unnecessary client creation and improve consistency.

Comment on lines +117 to +119
CREATE POLICY "forecasts:read:anon" ON public.forecasts
FOR ALL
TO anon USING (true) WITH CHECK (true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The policy for anonymous users is defined as FOR ALL with a WITH CHECK clause. However, the anon role only has SELECT privileges on this table, which makes the policy confusing. To improve clarity and precision, it's better to define the policy as FOR SELECT and remove the WITH CHECK clause, which is only relevant for INSERT and UPDATE operations.

CREATE POLICY "forecasts:read:anon" ON public.forecasts
FOR SELECT
TO anon USING (true);

@chrismclarke chrismclarke marked this pull request as draft January 30, 2026 23:41
@github-actions github-actions bot added feature and removed feature labels Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App: Dashboard Updates related to Dashboard app feature

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants