Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions backend/src/dependency-vulnerability-scanning/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
name: CI

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

jobs:
# ──────────────────────────────────────────────
# Job 1: Validate environment variables
# Must pass before the build job starts.
# ──────────────────────────────────────────────
validate-env:
name: Validate Environment Variables
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Validate client environment variables
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}
run: node client/scripts/validate-env.js

- name: Validate backend environment variables
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
PORT: ${{ secrets.PORT }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_USER: ${{ secrets.SMTP_USER }}
SMTP_PASS: ${{ secrets.SMTP_PASS }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
SOROBAN_CONTRACT_ADDRESS: ${{ secrets.SOROBAN_CONTRACT_ADDRESS }}
STELLAR_NETWORK_URL: ${{ secrets.STELLAR_NETWORK_URL }}
run: node backend/scripts/validate-env.js

# ──────────────────────────────────────────────
# Job 2: npm audit (client) — blocks build on high/critical CVEs
# ──────────────────────────────────────────────
audit-client:
name: Security Audit – Client
runs-on: ubuntu-latest
needs: validate-env

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: client/package-lock.json

- name: Install client dependencies
working-directory: client
run: npm ci --ignore-scripts

- name: Security audit – client
working-directory: client
run: npm audit --audit-level=high

# ──────────────────────────────────────────────
# Job 3: pnpm audit (backend) — blocks build on high/critical CVEs
# ──────────────────────────────────────────────
audit-backend:
name: Security Audit – Backend
runs-on: ubuntu-latest
needs: validate-env

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Install backend dependencies
working-directory: backend
run: pnpm install --frozen-lockfile --ignore-scripts

- name: Security audit – backend
working-directory: backend
run: pnpm audit --audit-level high

# ──────────────────────────────────────────────
# Job 4: Build the client
# Only runs if validate-env AND audit-client pass.
# ──────────────────────────────────────────────
build-client:
name: Build Client
runs-on: ubuntu-latest
needs: [validate-env, audit-client]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: client/package-lock.json

- name: Install client dependencies
working-directory: client
run: npm ci

- name: Build client
working-directory: client
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}
run: npm run build

# ──────────────────────────────────────────────
# Job 5: Run backend tests
# Only runs if validate-env AND audit-backend pass.
# ──────────────────────────────────────────────
test-backend:
name: Test Backend
runs-on: ubuntu-latest
needs: [validate-env, audit-backend]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Install backend dependencies
working-directory: backend
run: pnpm install

- name: Run backend tests
working-directory: backend
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
PORT: ${{ secrets.PORT }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_USER: ${{ secrets.SMTP_USER }}
SMTP_PASS: ${{ secrets.SMTP_PASS }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
SOROBAN_CONTRACT_ADDRESS: ${{ secrets.SOROBAN_CONTRACT_ADDRESS }}
STELLAR_NETWORK_URL: ${{ secrets.STELLAR_NETWORK_URL }}
run: pnpm test
83 changes: 83 additions & 0 deletions backend/src/dependency-vulnerability-scanning/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
version: 2
updates:
# ── Frontend (Next.js client) ───────────────────────────────────────────
- package-ecosystem: npm
directory: /client
schedule:
interval: weekly
day: monday
time: "09:00"
timezone: "UTC"
open-pull-requests-limit: 5
labels:
- dependencies
- client
groups:
# Batch minor + patch bumps for Next.js ecosystem together
next-ecosystem:
patterns:
- "next"
- "react"
- "react-dom"
- "@types/react*"
# Batch Supabase client updates
supabase-client:
patterns:
- "@supabase/*"
ignore:
# Pin major version bumps — review manually
- dependency-name: "*"
update-types: ["version-update:semver-major"]

# ── Backend (NestJS) ────────────────────────────────────────────────────
- package-ecosystem: npm
directory: /backend
schedule:
interval: weekly
day: monday
time: "09:00"
timezone: "UTC"
open-pull-requests-limit: 5
labels:
- dependencies
- backend
groups:
# Keep NestJS core packages in sync
nestjs-core:
patterns:
- "@nestjs/*"
# Batch Stellar SDK updates
stellar:
patterns:
- "@stellar/*"
- "stellar-sdk"
- "stellar-base"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]

# ── Smart Contracts (Rust / Cargo) ──────────────────────────────────────
- package-ecosystem: cargo
directory: /contracts
schedule:
interval: weekly
day: tuesday
time: "09:00"
timezone: "UTC"
open-pull-requests-limit: 5
labels:
- dependencies
- contracts

# ── GitHub Actions ───────────────────────────────────────────────────────
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: monday
time: "09:00"
timezone: "UTC"
open-pull-requests-limit: 5
labels:
- dependencies
- ci
Loading
Loading