Loading…
Multi-Tenant Database Security Builder
Generate multi-tenant PostgreSQL Row-Level Security (RLS) SQL policies with USING and WITH CHECK clauses plus structured production incident runbooks.
Test our product-specific security engine across 10 server stacks and 8 simulated hacking scenarios for free—or lint Docker/Kubernetes manifests, generate hardened DNS zones, optimize SQL indexes, and calculate your savings.
-- 1. Enforce strict Row-Level Security (RLS) on customer_deployments
ALTER TABLE public.customer_deployments ENABLE ROW LEVEL SECURITY;
ALTER TABLE public.customer_deployments FORCE ROW LEVEL SECURITY;
-- 2. Tenant & User Isolation Policy (Zero-Trust Session Context)
CREATE POLICY "customer_deployments_tenant_isolation_policy"
ON public.customer_deployments
AS RESTRICTIVE
FOR ALL
USING (
organization_id = NULLIF(current_setting('app.current_tenant_id', true), '')
OR user_id = NULLIF(current_setting('app.current_user_id', true), '')
)
WITH CHECK (
organization_id = NULLIF(current_setting('app.current_tenant_id', true), '')
OR user_id = NULLIF(current_setting('app.current_user_id', true), '')
);
-- 3. Tamper-Evident SHA-256 Hash-Chained Audit Trigger
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE INDEX IF NOT EXISTS idx_customer_deployments_tenant_user ON public.customer_deployments (organization_id, user_id);
CREATE TABLE IF NOT EXISTS public.customer_deployments_audit_log (
id BIGSERIAL PRIMARY KEY,
op TEXT NOT NULL,
actor_id TEXT,
row_data JSONB NOT NULL,
prev_hash TEXT NOT NULL,
entry_hash TEXT NOT NULL,
recorded_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE OR REPLACE FUNCTION public.fn_customer_deployments_audit_chain()
RETURNS TRIGGER LANGUAGE plpgsql SECURITY DEFINER AS $$
DECLARE
v_prev TEXT;
v_payload JSONB;
v_actor TEXT := NULLIF(current_setting('app.current_tenant_id', true), '');
BEGIN
v_payload := CASE WHEN TG_OP = 'DELETE' THEN to_jsonb(OLD) ELSE to_jsonb(NEW) END;
SELECT entry_hash INTO v_prev FROM public.customer_deployments_audit_log ORDER BY id DESC LIMIT 1;
v_prev := COALESCE(v_prev, repeat('0', 64));
INSERT INTO public.customer_deployments_audit_log (op, actor_id, row_data, prev_hash, entry_hash)
VALUES (
TG_OP,
v_actor,
v_payload,
v_prev,
encode(digest(v_prev || '|' || TG_OP || '|' || COALESCE(v_actor, '') || '|' || v_payload::text, 'sha256'), 'hex')
);
RETURN COALESCE(NEW, OLD);
END;
$$;
DROP TRIGGER IF EXISTS trg_customer_deployments_audit ON public.customer_deployments;
CREATE TRIGGER trg_customer_deployments_audit
AFTER INSERT OR UPDATE OR DELETE ON public.customer_deployments
FOR EACH ROW EXECUTE FUNCTION public.fn_customer_deployments_audit_chain();# Incident Response & DR Runbook — Linux Cloud Server (Ubuntu / Debian / Rocky / Alpine) - **Stack Profile**: Linux VPS Stack (Linux Kernel 6.x, OpenSSH Server, systemd, nftables / UFW) - **Primary Compute**: Intel® Xeon® Platinum · ECC Registered DDR4 RAM - **Storage Protection**: SAS Enterprise ZFS RAID-Z3 Storage (Plan-Configured Volume Protection & Snapshots) ## 1. Immediate Containment (0–5 Min) 1. Isolate compromised ingress in Dashboard → Networks & Firewall (Switch default policy to DENY). 2. Snapshot live volume before forensic changes: `openstack volume snapshot create --force`. 3. Rotate active SSH keys, API tokens, and service credentials in Dashboard → Security. ## 2. Eradication & CVE Verification (5–15 Min) 1. Run the 50+ Check Advanced Product Pentest in Dashboard → Security → Pentest. 2. Verify service banners against CISA KEV advisories in /tools (Tab 2). 3. Restore clean configuration from /root/sau-restore/<runId> or ZFS snapshot.
Add a clean, ad-free interactive frame to technical tutorials, runbooks, Notion pages, or courseware—zero API key required.
Explore With AI & Cite This Page
Open a grounded prompt in your AI assistant or copy a clean Markdown, HTML, or APA reference link.
| SQL Directive | Purpose | Pitfall If Omitted | Best Practice |
|---|---|---|---|
| ENABLE ROW LEVEL SECURITY | Activates RLS policy evaluation on table | Default deny for non-owners once enabled | Pair immediately with explicit policies |
| FORCE ROW LEVEL SECURITY | Applies RLS to table owner role too | App connecting as table owner bypasses RLS! | Always enable on multi-tenant tables |
| USING (expr) | Filters existing rows for SELECT/UPDATE/DELETE | Cross-tenant read leak if predicate is overly broad | Index the tenant_id column referenced |
| WITH CHECK (expr) | Validates new rows on INSERT/UPDATE | Tenant A could INSERT a row tagged with Tenant B ID | Mirror USING tenant check in WITH CHECK |
Build on infrastructure you can see
Every product page shows its price and whether you can buy it today. What is on sale is set up automatically after payment.