Skip to content

Commit ee68659

Browse files
authored
fix(compose): postgres init RLS syntax for F21 smoke (#151)
Fix invalid FOR ALL TO ALL RLS policies in scripts/db/init.sql that caused postgres docker-entrypoint-initdb.d to exit 3 during F21 compose smoke. Also split ledger DB, fix ledger ESM/healthcheck, ship abac.yaml, and scope F21 --wait to core services.
1 parent c5dd950 commit ee68659

10 files changed

Lines changed: 45 additions & 16 deletions

File tree

.github/workflows/integration.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ on:
1010
- "runtime/**"
1111
- "tests/integration/**"
1212
- ".github/workflows/integration.yaml"
13+
- "docker-compose.yml"
14+
- "scripts/db/**"
15+
- "scripts/docker-compose-smoke.sh"
1316
pull_request:
1417
paths:
1518
- "runtime/**"
1619
- "tests/integration/**"
1720
- ".github/workflows/integration.yaml"
21+
- "docker-compose.yml"
22+
- "scripts/db/**"
23+
- "scripts/docker-compose-smoke.sh"
1824

1925
jobs:
2026
integration:

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
volumes:
2222
- postgres_data:/var/lib/postgresql/data
2323
- ./scripts/db/init.sql:/docker-entrypoint-initdb.d/init.sql
24+
- ./scripts/db/init-ledger-db.sh:/docker-entrypoint-initdb.d/init-ledger-db.sh
2425
ports:
2526
- "5432:5432"
2627
healthcheck:
@@ -200,7 +201,7 @@ services:
200201
- PORT=4000
201202
- PF_ENFORCE_DSSE=1
202203
- PF_ENABLED_TOOLS=
203-
- DATABASE_URL=postgresql://sentinelops:sentinelops_password@postgres:5432/sentinelops?schema=public
204+
- DATABASE_URL=postgresql://sentinelops:sentinelops_password@postgres:5432/ledger?schema=public
204205
- SIDECAR_URL=http://runtime-sidecar:8006
205206
depends_on:
206207
postgres:

runtime/ledger/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ FROM node:20-bookworm-slim AS runner
1919

2020
WORKDIR /app
2121

22-
RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-certificates \
22+
RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-certificates curl \
2323
&& rm -rf /var/lib/apt/lists/*
2424

2525
COPY --from=builder /app/dist ./dist

runtime/ledger/src/auth.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { expressjwt as jwt } from 'express-jwt'
66
import jwksRsa from 'jwks-rsa'
77
import { PrismaClient } from '@prisma/client'
88
import type { PeerCertificate } from 'tls'
9+
import https from 'node:https'
10+
import crypto from 'node:crypto'
911

1012
const prisma = new PrismaClient()
1113

@@ -28,11 +30,11 @@ export const authMiddleware = jwt({
2830
jwksRequestsPerMinute: 5,
2931
jwksUri: process.env.JWKS_URI || `https://${process.env.AUTH0_DOMAIN}/.well-known/jwks.json`,
3032
// Add certificate chain pinning
31-
requestAgent: new (require('https').Agent)({
33+
requestAgent: new https.Agent({
3234
checkServerIdentity: (host: string, cert: PeerCertificate) => {
3335
// Certificate chain pinning validation
3436
const expectedPins = process.env.CERTIFICATE_PINS?.split(',') || [];
35-
const certFingerprint = require('crypto')
37+
const certFingerprint = crypto
3638
.createHash('sha256')
3739
.update(cert.raw)
3840
.digest('base64');

runtime/ledger/src/mcp/mcp-proxy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { Request, Response, NextFunction } from 'express';
1010
import { PrismaClient } from '@prisma/client';
1111
import winston from 'winston';
1212
import axios from 'axios';
13-
import { ToolSignatureManager } from './tool-signature-manager';
14-
import { CertificateManager } from './certificate-manager';
15-
import { EgressProfileManager } from './egress-profile-manager';
16-
import { JCSValidator } from './jcs-validator';
13+
import { ToolSignatureManager } from './tool-signature-manager.js';
14+
import { CertificateManager } from './certificate-manager.js';
15+
import { EgressProfileManager } from './egress-profile-manager.js';
16+
import { JCSValidator } from './jcs-validator.js';
1717
import type {
1818
JsonRpcRequest,
1919
PolicyEnforcementResult,

runtime/ledger/src/profiles/production.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { PrismaClient } from '@prisma/client'
55
import express from 'express'
66
import { ApolloServer } from '@apollo/server'
77
import { expressMiddleware } from '@apollo/server/express4'
8-
import { json } from 'body-parser'
8+
import bodyParser from 'body-parser'
99
import cors from 'cors'
1010
import winston from 'winston'
1111
import {
@@ -52,7 +52,7 @@ export async function startProductionProfile(): Promise<void> {
5252
await mcpService.initialize()
5353

5454
app.use(cors())
55-
app.use(json())
55+
app.use(bodyParser.json())
5656

5757
registerRestRoutes(app, {
5858
prisma,

runtime/retrieval-gateway/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ RUN cargo build --release -p retrieval-gateway
2121
FROM debian:bookworm-slim
2222
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates wget \
2323
&& rm -rf /var/lib/apt/lists/*
24+
WORKDIR /app
25+
COPY runtime/retrieval-gateway/abac.yaml ./abac.yaml
2426
COPY --from=builder /app/target/release/retrieval-gateway /usr/local/bin/
2527
EXPOSE 8080
2628
ENV PORT=8080

scripts/db/init-ledger-db.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
# Copyright 2025 SentinelOps Platform Contributors
4+
#
5+
# Ledger Prisma migrate deploy requires an empty database. Platform tables from
6+
# init.sql live in POSTGRES_DB (sentinelops); ledger uses a separate database.
7+
8+
set -euo pipefail
9+
10+
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
11+
CREATE DATABASE ledger;
12+
GRANT ALL PRIVILEGES ON DATABASE ledger TO ${POSTGRES_USER};
13+
EOSQL

scripts/db/init.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ALTER TABLE certificates ENABLE ROW LEVEL SECURITY;
3737

3838
-- Create RLS policy for tenant isolation
3939
CREATE POLICY tenant_isolation ON certificates
40-
FOR ALL TO ALL
40+
FOR ALL
4141
USING (tenant_id = current_setting('app.current_tenant', true));
4242

4343
-- Create audit_logs table for hash chain
@@ -63,7 +63,7 @@ CREATE INDEX IF NOT EXISTS idx_audit_logs_hash ON audit_logs(hash);
6363
ALTER TABLE audit_logs ENABLE ROW LEVEL SECURITY;
6464

6565
CREATE POLICY audit_tenant_isolation ON audit_logs
66-
FOR ALL TO ALL
66+
FOR ALL
6767
USING (tenant_id = current_setting('app.current_tenant', true));
6868

6969
-- Create policy_versions table
@@ -94,7 +94,7 @@ CREATE INDEX IF NOT EXISTS idx_policy_versions_status ON policy_versions(status)
9494
ALTER TABLE policy_versions ENABLE ROW LEVEL SECURITY;
9595

9696
CREATE POLICY policy_tenant_isolation ON policy_versions
97-
FOR ALL TO ALL
97+
FOR ALL
9898
USING (tenant_id = current_setting('app.current_tenant', true));
9999

100100
-- Create epochs table
@@ -117,7 +117,7 @@ CREATE INDEX IF NOT EXISTS idx_epochs_created_at ON epochs(created_at);
117117
ALTER TABLE epochs ENABLE ROW LEVEL SECURITY;
118118

119119
CREATE POLICY epoch_tenant_isolation ON epochs
120-
FOR ALL TO ALL
120+
FOR ALL
121121
USING (tenant_id = current_setting('app.current_tenant', true));
122122

123123
-- Create replay_jobs table
@@ -147,7 +147,7 @@ CREATE INDEX IF NOT EXISTS idx_replay_jobs_started_at ON replay_jobs(started_at)
147147
ALTER TABLE replay_jobs ENABLE ROW LEVEL SECURITY;
148148

149149
CREATE POLICY replay_tenant_isolation ON replay_jobs
150-
FOR ALL TO ALL
150+
FOR ALL
151151
USING (tenant_id = current_setting('app.current_tenant', true));
152152

153153
-- Insert sample data for demo

scripts/docker-compose-smoke.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ fi
2727
$COMPOSE config >/dev/null
2828
echo "compose config: OK"
2929

30-
$COMPOSE up -d --wait --timeout 180
30+
# Long-running services exercised by this smoke (health curls below). Omit batch CLIs,
31+
# demo apps, and platform microservices not required for compose/DB validation.
32+
SMOKE_SERVICES=(
33+
postgres redis runtime-sidecar ledger retrieval-gateway
34+
)
35+
$COMPOSE up -d --wait --timeout 180 "${SMOKE_SERVICES[@]}"
3136
echo "compose up --wait: OK"
3237

3338
# Health endpoints for core services in full profile

0 commit comments

Comments
 (0)