Repository navigation
196 lines (167 loc) · 6.57 KB
/
Copy pathci.yml
File metadata and controls
196 lines (167 loc) · 6.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: CI & Matrix Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions: read-all
jobs:
test:
name: Test (Node ${{ matrix.node }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
node: [20, 22, 24]
steps:
- name: Configure Git for consistent line endings
run: git config --global core.autocrlf false
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
version: 9
- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node }}
cache: "pnpm"
- name: Setup Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.11"
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Verify Code Quality & Style
run: pnpm run check
- name: Build TypeScript
run: pnpm run build
- name: Run Performance Benchmark
env:
PYTHONIOENCODING: "utf-8"
run: python benchmarks/proxy_overhead_benchmark.py
- name: Run Test Suite
run: pnpm test
- name: Test Python SDK
run: |
python -m pip install --require-hashes -r sdks/python/requirements-test.txt
python -m pip install --no-deps -e sdks/python
python -m pytest sdks/python/tests
- name: Verify Tarball Packaging Gate
run: npm pack --dry-run
rust-core:
name: Rust Core Tests (dbshield-core)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
with:
toolchain: stable
- name: Run Rust Core Tests
working-directory: crates/dbshield-core
run: cargo test
live-db-mcp-coverage:
name: Live PostgreSQL, MCP E2E & Coverage Gate
runs-on: ubuntu-latest
permissions:
contents: read
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: dbshield
POSTGRES_PASSWORD: dbshield_ci_password
POSTGRES_DB: dbshield_ci
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U dbshield -d dbshield_ci"
--health-interval 5s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
version: 9
- name: Setup Node.js 22
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "22"
cache: "pnpm"
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build TypeScript
run: pnpm run build
- name: Run Test Suite with Coverage Threshold
run: >-
npx tsx --test --test-concurrency=4 --experimental-test-coverage
--test-coverage-lines=40 --test-coverage-exclude="tests/**"
- name: Verify Live PostgreSQL Guardrail E2E
env:
DATABASE_URL: postgres://dbshield:dbshield_ci_password@localhost:5432/dbshield_ci
run: |
node --input-type=module -e '
import assert from "node:assert/strict";
import pg from "pg";
import { loadConfig } from "./dist/config/index.js";
import { SqlGuardEngine } from "./dist/guard/engine.js";
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
await pool.query("CREATE TABLE IF NOT EXISTS ci_items (id SERIAL PRIMARY KEY, name TEXT NOT NULL)");
await pool.query("INSERT INTO ci_items (name) VALUES ($1)", ["dbshield-e2e"]);
const res = await pool.query("SELECT id, name FROM ci_items LIMIT 1");
assert.equal(res.rows[0].name, "dbshield-e2e");
const cfg = await loadConfig();
const guard = new SqlGuardEngine({ ...cfg, safetyTier: "BALANCED" });
assert.equal(guard.evaluate("SELECT id, name FROM ci_items LIMIT 1").allowed, true);
assert.equal(guard.evaluate("DROP TABLE ci_items").allowed, false);
await pool.end();
'
- name: Verify Live MCP Stdio Handshake
run: |
node --input-type=module -e '
import assert from "node:assert/strict";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const transport = new StdioClientTransport({
command: "node",
args: ["dist/cli.js", "start"],
env: { ...process.env, DBSHIELD_STORAGE_PATH: ":memory:" },
});
const client = new Client({ name: "ci-probe", version: "1.0.0" }, { capabilities: {} });
await client.connect(transport);
const res = await client.listTools();
const names = res.tools.map((t) => t.name);
await transport.close();
assert.ok(names.includes("db_query"));
assert.ok(names.includes("db_status"));
'
security:
name: Supply-Chain & Secret Scan
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Run OSV Dependency Vulnerability Scan
run: |
curl -sSfL -o /tmp/osv-scanner https://github.com/google/osv-scanner/releases/download/v2.7.1/osv-scanner_linux_amd64
chmod +x /tmp/osv-scanner
/tmp/osv-scanner scan source -r .
- name: Run Gitleaks Secret Scan
run: |
curl -sSfL -o /tmp/gitleaks.tar.gz https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz
tar -xzf /tmp/gitleaks.tar.gz -C /tmp gitleaks
/tmp/gitleaks detect --source . --redact --no-banner