Skip to content

Commit ea45bf3

Browse files
authored
Merge pull request #8 from HenkDz/codex-postgres-mcp-hardening
Release 2.0.0 security boundary hardening
2 parents 3873a78 + c145b9e commit ea45bf3

76 files changed

Lines changed: 17534 additions & 6683 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
verify:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '18'
24+
cache: npm
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run linter
30+
run: npm run lint
31+
32+
- name: Run prepublish checks
33+
run: npm run prepublishOnly
34+
35+
- name: Test built CLI help
36+
run: node build/index.js --help
37+
38+
- name: Verify dry-run package
39+
run: npm pack --dry-run --cache .npm-cache
40+
41+
postgres-integration:
42+
runs-on: ubuntu-latest
43+
44+
services:
45+
postgres:
46+
image: postgres:17-alpine
47+
env:
48+
POSTGRES_PASSWORD: postgres
49+
POSTGRES_DB: postgres
50+
ports:
51+
- 5432:5432
52+
options: >-
53+
--health-cmd "pg_isready -U postgres -d postgres"
54+
--health-interval 5s
55+
--health-timeout 5s
56+
--health-retries 12
57+
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
62+
- name: Setup Node.js
63+
uses: actions/setup-node@v4
64+
with:
65+
node-version: '18'
66+
cache: npm
67+
68+
- name: Install dependencies
69+
run: npm ci
70+
71+
- name: Run PostgreSQL integration tests
72+
run: npm run test:integration
73+
env:
74+
POSTGRES_MCP_INTEGRATION_CONNECTION_STRING: postgresql://postgres:postgres@localhost:5432/postgres

.github/workflows/publish.yml

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,56 @@ on:
55
types: [published]
66

77
jobs:
8-
publish:
9-
runs-on: ubuntu-latest
10-
permissions:
11-
contents: read
12-
id-token: write # For npm provenance
13-
14-
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
17-
18-
- name: Setup Node.js
19-
uses: actions/setup-node@v4
20-
with:
21-
node-version: '18'
22-
registry-url: 'https://registry.npmjs.org'
23-
24-
- name: Install dependencies
25-
run: npm ci
26-
27-
- name: Run linter
28-
run: npm run lint
29-
30-
- name: Build project
31-
run: npm run build
32-
33-
- name: Test CLI
34-
run: node build/index.js --help
35-
36-
- name: Publish to npm
37-
run: npm publish --access public --provenance
38-
env:
39-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
id-token: write # For npm provenance
13+
services:
14+
postgres:
15+
image: postgres:17-alpine
16+
env:
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: postgres
19+
ports:
20+
- 5432:5432
21+
options: >-
22+
--health-cmd "pg_isready -U postgres -d postgres"
23+
--health-interval 5s
24+
--health-timeout 5s
25+
--health-retries 12
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: '18'
35+
registry-url: 'https://registry.npmjs.org'
36+
37+
- name: Install dependencies
38+
run: npm ci
39+
40+
- name: Run linter
41+
run: npm run lint
42+
43+
- name: Run prepublish checks
44+
run: npm run prepublishOnly
45+
46+
- name: Run PostgreSQL integration tests
47+
run: npm run test:integration
48+
env:
49+
POSTGRES_MCP_INTEGRATION_CONNECTION_STRING: postgresql://postgres:postgres@localhost:5432/postgres
50+
51+
- name: Test CLI
52+
run: node build/index.js --help
53+
54+
- name: Verify package contents
55+
run: npm pack --dry-run
56+
57+
- name: Publish to npm
58+
run: npm publish --access public --provenance
59+
env:
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules/
22
build/
3+
.npm-cache/
34
*.log
45
.env*
56
.cursor/mcp.json

.npmignore

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ tsconfig.json
1010
.env*
1111
.editorconfig
1212

13-
# Documentation (development only)
14-
docs/
15-
examples/
16-
REFACTOR_PROGRESS.md
17-
TOOLS.md
18-
CONSOLIDATION_PROGRESS.md
13+
examples/
14+
REFACTOR_PROGRESS.md
15+
TOOLS.md
16+
CONSOLIDATION_PROGRESS.md
1917

2018
# Build tools
2119
Dockerfile
@@ -36,4 +34,4 @@ yarn.lock
3634
# Misc
3735
*.tsbuildinfo
3836
.DS_Store
39-
Thumbs.db
37+
Thumbs.db

Dockerfile

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
1-
# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile
2-
FROM node:lts-alpine
1+
FROM node:20-alpine AS build
32
WORKDIR /app
43

5-
# Copy package files and install dependencies
64
COPY package.json package-lock.json ./
75
RUN npm ci --ignore-scripts
86

9-
# Copy TypeScript configuration
107
COPY tsconfig.json ./
8+
COPY src ./src
119

12-
# Copy all source files
13-
COPY . .
14-
15-
# Build the TypeScript source
1610
RUN npm run build
11+
RUN npm prune --omit=dev --ignore-scripts
1712

18-
# Copy and set up entrypoint script
19-
COPY docker-entrypoint.sh /usr/local/bin/
20-
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
21-
22-
# Create non-root user for security
23-
RUN addgroup -g 1001 -S nodejs
24-
RUN adduser -S postgres-mcp -u 1001
13+
FROM node:20-alpine AS runtime
14+
WORKDIR /app
2515

26-
# Change ownership of the app directory
27-
RUN chown -R postgres-mcp:nodejs /app
28-
USER postgres-mcp
16+
ENV NODE_ENV=production
2917

30-
# Expose any necessary ports if needed (optional)
31-
# EXPOSE 3000
18+
COPY --from=build --chown=node:node /app/package.json ./package.json
19+
COPY --from=build --chown=node:node /app/node_modules ./node_modules
20+
COPY --from=build --chown=node:node /app/build ./build
21+
COPY --chown=node:node docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
22+
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh
3223

33-
# Use entrypoint script for flexible configuration
24+
USER node
3425
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
3526
CMD []

0 commit comments

Comments
 (0)