Loading...
Loading...
Compare original and translation side by side
activate_skill(name="security-audit-pro")activate_skill(name="auditor-pro")activate_skill(name="db-enforcer")activate_skill(name="security-audit-pro")activate_skill(name="auditor-pro")activate_skill(name="db-enforcer")service_rolepgauditservice_rolepgauditctx.auth.getUserIdentity()transferOwnershipctx.auth.getUserIdentity()transferOwnershipaudit_logold_datanew_dataactor_idaudit_logold_datanew_dataactor_id-- Enable RLS
ALTER TABLE sensitive_data ENABLE ROW LEVEL SECURITY;
-- Create a policy for "Teams" where users can only see data from their own team
CREATE POLICY user_team_access ON sensitive_data
FOR SELECT
TO authenticated
USING (
team_id IN (
SELECT team_id FROM team_members WHERE user_id = auth.uid()
)
);
-- Optimization: Wrap in a function and use indexing on team_id-- Enable RLS
ALTER TABLE sensitive_data ENABLE ROW LEVEL SECURITY;
-- Create a policy for "Teams" where users can only see data from their own team
CREATE POLICY user_team_access ON sensitive_data
FOR SELECT
TO authenticated
USING (
team_id IN (
SELECT team_id FROM team_members WHERE user_id = auth.uid()
)
);
-- Optimization: Wrap in a function and use indexing on team_idimport { query } from "./_generated/server";
import { v } from "convex/values";
export const getSecureData = query({
args: { id: v.id("items") },
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) throw new Error("Unauthenticated");
const item = await ctx.db.get(args.id);
if (!item || item.ownerId !== identity.subject) {
throw new Error("Unauthorized access attempt logged.");
}
return item;
},
});import { query } from "./_generated/server";
import { v } from "convex/values";
export const getSecureData = query({
args: { id: v.id("items") },
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) throw new Error("Unauthenticated");
const item = await ctx.db.get(args.id);
if (!item || item.ownerId !== identity.subject) {
throw new Error("Unauthorized access attempt logged.");
}
return item;
},
});anonSELECTauth.uid() = user_iduser_idservice_roleanonSELECTuser_idauth.uid() = user_idservice_rolescripts/simulate-leak.tsscripts/extract-audit-report.pyscripts/simulate-leak.tsscripts/extract-audit-report.py