Skip to content

About

Resources

Code of conduct

Contributing

Security policy

Stars

16 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

2,989 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎭 SecureFlow

The Digital Heist Defense System β€” AI-Powered GitHub Pull Request Security Scanner

GitHub stars GitHub forks GitHub issues GitHub license PRs Welcome Made with Next.js TypeScript Prisma Tailwind CSS SecureFlow Status

"In this heist, we're not stealing β€” we're protecting." SecureFlow automatically detects vulnerabilities, hardcoded secrets, and code flaws before they reach production.

Nexus Spring of Code

Featured in Nexus Spring of Code


πŸ“‹ Table of Contents

Click to expand

SecureFlow integrates directly with GitHub via a GitHub App and webhooks. Every time a Pull Request is opened or updated, The Professor β€” SecureFlow's AI mastermind β€” extracts the code diff, runs it through Groq's LLM (GPT-OSS-20B), and returns actionable security findings with AI-written explanations and remediation steps, all visible on a centralized Mission Control dashboard.

Think of every Pull Request as a member of the crew trying to get into The Vault (your codebase). The Professor checks their credentials at the door β€” no leaked keys, no sloppy code, no breaches on his watch.

🌟 The Crew's Abilities (Features)

πŸ€– AI-Powered Detection

Uses Groq's GPT-OSS-20B to detect hardcoded secrets, vulnerabilities, and misconfigurations in your code.

⚑ Real-time Scanning

Automatically scans every opened or updated Pull Request as soon as it's created β€” The Professor never sleeps.

πŸ›‘οΈ Smart Remediation

Generates precise explanations and concrete code fixes for each security finding.

πŸ“Š Mission Control Dashboard

View all your repositories, PRs, findings, and audit logs in one unified command center. Includes a keyboard-accessible Command Palette (Ctrl+K or ⌘K) for rapid navigation and quick actions across sections.

πŸ’¬ GitHub PR Comments

Posts detailed security reports directly on your PRs with collapsible remediation blocks.

βœ… GitHub Check Runs

Sets Pass/Review Required/Blocked status on PR commits for clear CI/CD integration.

🎯 Custom Policies & Project Rules

Create, toggle, and manage security policies per user or organization through the dashboard. Teams can also configure project-specific regex rules in .secureflow.json (with ReDoS backtracking protection) to catch internal tokens and banned APIs.

🚫 Smart Exclusions

Intelligently ignores non-executable files and mock placeholders to reduce noise.

πŸ›‘οΈ Finding Triage & Dismissal

Maintainers can dismiss findings directly from the dashboard:

  • Status & Reason: Triage findings as DISMISSED with a required reason category (False positive, Accepted risk, or Won't fix) and an optional explanation note.
  • Stable Fingerprints: Findings generate deterministic SHA-256 fingerprints (repositoryId + fileLocation + type + codeSnippet) so dismissals reliably persist across commits and subsequent scans.
  • Scan-time Suppression: Dismissed findings are automatically suppressed during PR scansβ€”they do not block pull requests or inflate open finding tallies, and are reported as previously dismissed in PR scan summaries.
  • Audit Trail & Reversal: Every dismissal and reopening action is logged in the Vault Audit Log with actor identity, timestamp, and notes. Reopening restores findings to OPEN status instantly.
  • Current PR Verdict: Triage refreshes the latest saved scan and its existing GitHub check when that scan matches the PR's current commit. Older scans without a recorded commit, or PRs with a newer unscanned commit, need a fresh scan before the verdict changes. The dashboard shows this pending state after saving.

⚑ GitHub Action (CI/CD Integration)

Using SecureFlow in any repository requires just a few lines of workflow YAMLβ€”no custom scripts or dependencies needed.

Copy-Paste Minimal Workflow (<10 lines)

Add this file as .github/workflows/security.yml:

name: Security Scan
on: [push, pull_request]
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: GauravKarakoti/SecureFlow@main

Advanced Workflow with Inputs & Outputs

name: Security Scan
on: [push, pull_request]
jobs:
  scan:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
      security-events: write
    steps:
      - uses: actions/checkout@v4

      - name: Run SecureFlow Security Scan
        id: secureflow
        uses: GauravKarakoti/SecureFlow@main
        with:
          paths: '.'
          severity: 'low'
          fail-threshold: 'high'
          comment-on-pr: 'true'
          format: 'sarif'
          output: 'results.sarif'
          github-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload SARIF to GitHub Code Scanning
        if: always()
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: ${{ steps.secureflow.outputs.sarif-file }}

      - name: Inspect Findings
        run: |
          echo "Total findings: ${{ steps.secureflow.outputs.total-findings }}"
          echo "Highest severity: ${{ steps.secureflow.outputs.highest-severity }}"

Action Inputs Reference

Input Description Required Default
paths Directory path or file pattern to scan No .
severity Minimum severity to report (critical, high, medium, low, info) No low
fail-threshold Quality gate threshold to fail the workflow (critical, high, medium, low, none) No high
comment-on-pr Post an automated summary comment with scan time & commit SHA on PRs No true
github-token GitHub token for posting comments and querying pull requests No ${{ github.token }}
format Output report format (sarif, text, json, markdown, html) No sarif
output Destination output file path No secureflow-results.sarif

Action Outputs Reference

Output Description Example
total-findings Total number of security findings detected 3
highest-severity Highest severity level among all detected findings HIGH
has-findings Boolean flag indicating whether any findings were detected true
sarif-file File path to the generated SARIF report file secureflow-results.sarif

🧠 The Blueprint (How It Works)

Developer opens or updates a Pull Request
              ↓
GitHub sends a webhook event to SecureFlow
              ↓
Octokit extracts the code diff (added/modified lines only)
              ↓
ArmorIQScanner sends the diff to Groq LLM with active policy context
              ↓
LLM returns structured findings (type, severity, file, snippet)
              ↓
For each finding β†’ The Professor generates explanation + remediation steps
              ↓
Findings saved to PostgreSQL via Prisma β€” the Vault Logs
              ↓
Results posted as a GitHub PR comment + commit check status
              ↓
Everything visible on the SecureFlow Mission Control Dashboard

What Gets Detected

Category Examples
πŸ”‘ Hardcoded Secrets API keys, passwords, tokens committed in code
πŸ“€ Contextual Leaks console.log(process.env), logging sensitive objects
βš™οΈ Misconfigurations Wildcard CORS, disabled auth, insecure headers
🧱 Code Vulnerabilities SQL injection patterns, unsafe deserialization
☁️ IaC Issues Public S3 buckets, root container execution

πŸ” Deterministic Secret Pre-Screen

Before a PR diff is sent to the LLM, SecureFlow runs a rule-based secret scan (src/lib/armor/secret-detector.ts) over the added lines only.

  • Detects: AWS access key IDs, GitHub tokens, Slack tokens, PEM private key headers, and high-entropy values assigned to secret-named variables (password, secret, token, apiKey).
  • Severity: every deterministic secret finding is CRITICAL.
  • No false alarms on samples: values labelled EXAMPLE / changeme, env lookups, and low-entropy values are not flagged.
  • Masked everywhere: stored findings, PR comments and dashboards only show a masked form of the value. The raw secret is never persisted or posted, and it is not part of the request sent to Groq.
  • Merge and de-duplicate: if the LLM reports the same file and line as a deterministic finding, only one finding is shown (the deterministic one wins).
  • Graceful degradation: if the LLM call fails or times out, the deterministic findings are still saved and reported.

Run its tests:

npx vitest run src/lib/armor/secret-detector.test.ts src/lib/armor/secret-detector.prescreen.test.ts src/lib/armor/secret-detector.llm-payload.test.ts

πŸ› οΈ Tech Stack

Layer Technology
Framework Next.js 16 - App Router + Turbopack
Database PostgreSQL + Prisma ORM
Authentication NextAuth.js v5 with GitHub OAuth
AI / LLM Groq SDK (openai/gpt-oss-20b) + Genkit
GitHub Integration Octokit
UI Tailwind CSS + Radix UI + Recharts

πŸ“ Project Structure

secureflow/
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ api.md                   # API route endpoints and specifications
β”‚   β”œβ”€β”€ blueprint.md             # Brand, style guidelines, and terminology dictionary
β”‚   β”œβ”€β”€ runbook.md               # Operations runbook for diagnosing failed scans and outages
β”‚   └── security/
β”‚       └── prompt-injection.md  # Security controls and defenses for LLM prompt injections
β”‚
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ migrations/              # Database migration history
β”‚   β”œβ”€β”€ schema.prisma            # Database schema (User, Repo, PR, Finding, etc.)
β”‚   └── seed.ts                  # Seeds default security policy templates
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ ai/
β”‚   β”‚   └── flows/
β”‚   β”‚       └── developer-receives-ai-security-explanations.ts  # The Professor's Genkit AI flow
β”‚   β”‚
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/            # NextAuth route handler
β”‚   β”‚   β”‚   └── webhooks/
β”‚   β”‚   β”‚       └── github/
β”‚   β”‚   β”‚           └── route.ts # Main webhook handler (PR scanning logic)
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”‚   β”œβ”€β”€ audit/           # Vault Logs (audit log page)
β”‚   β”‚   β”‚   β”œβ”€β”€ findings/        # Breach Attempts (security findings page)
β”‚   β”‚   β”‚   β”œβ”€β”€ policies/        # Defense Strategy (policy management page)
β”‚   β”‚   β”‚   └── page.tsx         # Mission Control (main dashboard overview)
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ login/               # Login page
β”‚   β”‚   └── setup/               # GitHub App installation setup page
β”‚   β”‚
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ui/                  # Radix UI + shadcn components
β”‚   β”‚   └── dashboard-nav.tsx    # Sidebar navigation
β”‚   β”‚
β”‚   └── lib/
β”‚       β”œβ”€β”€ armor/
β”‚       β”‚   β”œβ”€β”€ scanner.ts       # ArmorIQScanner β€” core LLM scanning engine
β”‚       β”‚   └── iq.ts            # ArmorIQ policy engine + evaluation logic
β”‚       └── prisma.ts            # Prisma client singleton

πŸš€ Joining the Resistance (Getting Started)

Prerequisites

Make sure you have the following installed and ready before the heist begins:


1. Fork & Clone

  • Fork the repo on GitHub first, then:
git clone https://github.com/YOUR_USERNAME/secureflow.git
cd secureflow
npm install

2. Environment Variables

cp .env.example .env

⚠️ Important: Fill in your .env file. See Environment Variables Reference for details on each value.


3. GitHub App Setup

SecureFlow requires a GitHub App to receive webhook events and post PR comments.

  1. Go to GitHub β†’ Settings β†’ Developer Settings β†’ GitHub Apps β†’ New GitHub App
  2. Fill in the following:
    • Homepage URL: http://localhost:9002
    • Webhook URL: Your public URL + /api/webhooks/github (use ngrok for local dev: ngrok http 9002)
    • Webhook Secret: Any random string β€” copy it to GITHUB_WEBHOOK_SECRET in .env
  3. Set these Repository Permissions:
    • Contents: Read
    • Pull Requests: Read & Write
    • Checks: Read & Write
  4. Subscribe to these Webhook Events:
    • Pull request
    • Installation
    • Installation repositories
  5. After creating the app:
    • Copy the App ID β†’ GITHUB_APP_ID
    • Generate a Private Key β†’ download the .pem file, copy its contents β†’ GITHUB_PRIVATE_KEY
    • Create a Client ID & Secret under OAuth β†’ GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRET

4. Database Setup

Option A β€” Local PostgreSQL (Development):

-- In psql or pgAdmin:
CREATE DATABASE secureflow;

Set your local connection string in .env:

DATABASE_URL="postgresql://postgres:yourpassword@localhost:5432/secureflow"

Option B β€” Production Serverless with Connection Pooling (Neon / PgBouncer):

In serverless environments (Next.js API routes on Vercel/AWS Lambda), multiple concurrent function instances spin up rapidly under heavy traffic. Without connection pooling, this can quickly exhaust PostgreSQL connection limits.

SecureFlow supports connection poolers (e.g. Neon Pooler or PgBouncer) paired with Prisma's native pg driver pool adapter (@prisma/adapter-pg).

Configure your production .env / environment settings with database connection strings:

# Standard / Direct Database connection string (Used by Prisma CLI for migrations & fallback)
DATABASE_URL="postgresql://neondb_owner:[email protected]/neondb?sslmode=verify-full"

# Application Runtime Query Pooler URL (Optional: PgBouncer / Neon connection pooler)
DATABASE_POOL_URL="postgresql://neondb_owner:[email protected]/neondb?sslmode=verify-full"

# Optional: Max connections per serverless function instance pool (default: 10)
DB_POOL_MAX=10

πŸ’‘ Why database pooler? SecureFlow uses DATABASE_POOL_URL for application runtime queries in serverless production environments while Prisma CLI migrations automatically use DATABASE_URL (direct connection string).

Then run database setup:

  • Generate Prisma Client
npm run db:gen
  • Apply migrations (creates all tables using DATABASE_URL)
npm run db:migrate
  • Seed default security policy templates
npm run db:seed

5. Run the App

npm run dev

Open http://localhost:9002 in your browser.

  • Sign in with GitHub
  • Install the GitHub App on your repositories via the Setup page
  • Open a Pull Request on any linked repo to trigger a scan β€” and let The Professor take it from there

Optional β€” Genkit AI dev environment (for working on AI explanation flows):

npm run genkit:dev

🐳 Docker Setup

  1. Copy .env.example to .env and fill in values (note: DATABASE_URL is auto-set by compose)
  2. docker compose up --build
  3. App runs at http://localhost:9002

Container Security & Non-Root Execution

SecureFlow's Docker image uses a secure multi-stage build running as an unprivileged user:

  • Non-root execution: The final runtime container creates and runs under the unprivileged nextjs user (UID 1001, GID 1001), ensuring processes never run as root (id verifies non-zero UID).
  • Multi-stage isolation: Build tools and dev dependencies are discarded; only the Next.js standalone bundle, public assets, and production client artifacts are included.
  • Built-in HEALTHCHECK: Container liveness is continuously monitored via a native HEALTHCHECK directive.
  • Database migrations: Managed cleanly via dedicated one-shot migrator or Kubernetes hooks with non-root privileges.

πŸ” Container Image Signing & Supply Chain Verification

All official SecureFlow container images (ghcr.io/gauravkarakoti/secureflow) are cryptographically signed with Sigstore Cosign via GitHub OIDC, and published with attached CycloneDX SBOM and SLSA Build Provenance attestations.

1. Verify Image Signature:

cosign verify \
  --certificate-identity-regexp "^https://github\.com/GauravKarakoti/SecureFlow/\.github/workflows/docker-publish\.yml@refs/tags/v.*" \
  --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
  ghcr.io/gauravkarakoti/secureflow:latest

2. Verify CycloneDX SBOM Attestation:

cosign verify-attestation \
  --type cyclonedx \
  --certificate-identity-regexp "^https://github\.com/GauravKarakoti/SecureFlow/\.github/workflows/docker-publish\.yml@refs/tags/v.*" \
  --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
  ghcr.io/gauravkarakoti/secureflow:latest

3. Verify SLSA Build Provenance:

gh attestation verify oci://ghcr.io/gauravkarakoti/secureflow:latest \
  --repo GauravKarakoti/SecureFlow

For detailed provenance extraction and Kubernetes admission controller (Kyverno) policies, see the Container Image Verification Guide.

Upgrading SecureFlow

When upgrading between releases, follow our step-by-step checklist covering database backups, migration execution, health validation, and rollback procedures in the Safe Upgrade Guide.


πŸ”‘ Environment Variables Reference

Variable Required Description
DATABASE_URL βœ… PostgreSQL connection string (Direct/Standard)
DATABASE_POOL_URL ⬜ Recommended for production serverless connection pooler (PgBouncer/Neon Pooler)
DB_POOL_MAX ⬜ Max connections per serverless function instance (default: 10)
GROQ_API_KEY βœ… API key from console.groq.com
AI_PROVIDER ⬜ AI provider for remediation & explanations: groq (default), ollama, vllm, openai, custom
AI_MODEL ⬜ Model identifier override (e.g. openai/gpt-oss-20b, llama-3.3-70b-versatile, llama3, gpt-4o-mini)
AI_BASE_URL ⬜ Optional API base URL override for local or custom inference gateways (e.g. http://localhost:11434/v1)
GITHUB_APP_ID βœ… Numeric ID of your GitHub App
GITHUB_WEBHOOK_SECRET βœ… Secret used to verify webhook payloads
GITHUB_PRIVATE_KEY βœ… RSA private key from your GitHub App (.pem contents)
GITHUB_APP_URL βœ… Public URL of your GitHub App (e.g. https://github.com/apps/your-app)
GITHUB_CLIENT_ID βœ… OAuth Client ID for GitHub login
GITHUB_CLIENT_SECRET βœ… OAuth Client Secret for GitHub login
AUTH_SECRET βœ… Random secret for NextAuth session encryption β€” generate with openssl rand -base64 32
ARMORIQ_API_KEY ⬜ Optional β€” ArmorIQ SDK key for advanced policy features
USER_ID ⬜ Optional β€” ArmorIQ user ID
AGENT_ID ⬜ Optional β€” ArmorIQ agent ID
TRUSTED_PROXY_HOP_COUNT ⬜ Trusted proxies in front of the app (default: 0). Set 1 behind a single proxy β€” see below
TRUSTED_PROXY_IPS ⬜ Optional β€” comma-separated proxy addresses / IPv4 CIDRs, used instead of a fixed hop count
DATA_RETENTION_DAYS ⬜ Optional β€” Auto-cleanup older findings, scans, and audit logs (default: unset / keep forever)
SCAN_CACHE_TTL_SECONDS ⬜ Scan deduplication cache TTL in seconds (default: 86400 / 24 hours)

Trusted proxies and rate limiting

Rate limits are bucketed per client IP, and that IP is derived from X-Forwarded-For. Because any caller can put whatever they like at the front of that header, the app has to know how many hops in front of it are actually trustworthy β€” otherwise a caller can vary the header and land in a fresh bucket on every request, which makes every rate limit unenforceable.

Set TRUSTED_PROXY_HOP_COUNT to the number of proxies between the internet and the app:

Deployment Value
Vercel / Render / Fly / a single nginx 1
Cloudflare in front of one of the above 2
App exposed directly, no proxy 0 (the default)

With 0 (or when the variable is unset), the forwarding headers are ignored entirely β€” nothing in front of the app is authoritative, so nothing in them is believed. Every caller then shares one rate-limit bucket, so behind a proxy you must set this, or one busy client throttles everyone. The app logs a one-time warning when it sees forwarding headers with the variable unset.

If the hop count varies (multiple ingress paths), set TRUSTED_PROXY_IPS instead β€” e.g. TRUSTED_PROXY_IPS=10.0.0.0/8,192.168.1.1. The chain is then walked from the right past known proxies rather than counting a fixed number of hops. IPv4 CIDR blocks and bare addresses are supported; IPv6 entries are matched exactly.

Data retention and automated cleanup

Findings and audit logs accumulate over time. Self-hosters can bound storage growth by configuring DATA_RETENTION_DAYS:

# Optional: Auto-cleanup findings and audit logs older than N days (off by default)
DATA_RETENTION_DAYS=90

Retention operations can be executed via the unified CLI script:

  • CLI Dry Run (default): npm run retention (reports eligible counts without modifying the database)
  • CLI Applied Deletion: npm run retention -- --apply (purges eligible older records in batches)
  • CLI Custom Window: npm run retention -- --days=30 --apply
  • CLI Custom Batch Size: npm run retention -- --batch-size=200 --apply
  • CLI Target Isolation: npm run retention -- --only=auditLog --apply

πŸ›‘οΈ Safety Guarantee: The retention cleanup strictly deletes older Finding, ScanResult, and AuditLog rows in safe batches. It never deletes users, repositories, or policies.

πŸ€– Configurable AI Models for Remediation & Explanations

The AI model powering vulnerability remediation patches and interactive security explanations can be configured via environment variables without modifying code. This enables operators to choose faster, cheaper, or air-gapped local models.

Variable Supported Values Default Description
AI_PROVIDER groq, ollama, vllm, openai, custom groq Backend inference provider
AI_MODEL Any model identifier or tag openai/gpt-oss-20b (for groq), llama3 (for ollama), meta-llama/Meta-Llama-3-8B-Instruct (for vllm), gpt-4o-mini (for openai) Model used for analysis and patch generation
AI_BASE_URL Valid HTTP/HTTPS endpoint Provider default (http://localhost:11434/v1 for Ollama, http://localhost:8000/v1 for vLLM) Endpoint base URL for custom gateways or local engines

Examples

Alternative cloud models with Groq:

AI_PROVIDER=groq
AI_MODEL=groq/llama-3.3-70b-versatile

Local air-gapped inference with Ollama:

AI_PROVIDER=ollama
AI_MODEL=codellama
AI_BASE_URL=http://localhost:11434/v1

Enterprise custom or on-prem gateway:

AI_PROVIDER=custom
AI_MODEL=my-fine-tuned-model
AI_BASE_URL=https://llm.corp.internal/v1

Startup Validation & Verbose Mode

At application or CLI startup, configuration values are validated immediately to prevent silent failures. Run with --verbose (or set LOG_LEVEL=verbose) to inspect the active model:

secureflow scan --verbose
# Output:
# ℹ️  [SecureFlow] Active AI model: provider=groq, model=openai/gpt-oss-20b

CI/CD Quality Gates (--fail-on) & Exit Codes

Configure failure thresholds for CI/CD pipelines to fail only when findings reach a chosen severity:

# Fail only if critical or high findings are detected
secureflow scan --fail-on high

# Zero-tolerance mode: fail on any finding
secureflow scan --fail-on low

# Advisory mode: report findings without failing the pipeline
secureflow scan --fail-on none
Exit Code Meaning
0 Scan passed; findings are strictly below the --fail-on threshold (or 0 findings).
1 Scan threshold met or exceeded; findings at or above the threshold were found.
2 Scan error (e.g. git failure, missing repository, or unreadable scan tree).

Before exiting, SecureFlow outputs a concise one-line count per severity:

Findings by severity: critical: 0, high: 2, medium: 1, low: 0

πŸ“ Available Scripts

Script Description
npm run dev Start dev server on port 9002 with Turbopack
npm run build Build for production
npm run start Start production server
npm run lint Run ESLint
npm run typecheck Run TypeScript compiler checks
npm run db:gen Generate Prisma Client
npm run db:migrate Run Prisma migrations
npm run db:push Push schema to DB without migrations
npm run db:seed Seed default policy templates
npm run db:backup Create timestamped compressed PostgreSQL backup (pg_dump)
npm run db:restore Restore backup into PostgreSQL (pg_restore, requires --force for non-empty DB)
npm run db:verify-backup Restore into ephemeral database and verify table counts & migrations
npm run genkit:dev Start Genkit AI development environment
npm run retention Unified data retention runner (dry-run default; pass -- --apply to delete)

πŸ”’ Defense Strategy (Security Policies)

SecureFlow ships with pre-built policy templates that are seeded into the database. Users can toggle them on/off from the dashboard β€” think of it as briefing the crew before every job.

Policy Severity Default
Enforce Parameterized Queries HIGH βœ… On
Prevent PII Logging CRITICAL Off
Block Internal Network Requests (SSRF) HIGH Off
Enforce Strict CORS Policies MEDIUM Off
Prevent Unsafe Deserialization CRITICAL Off
Deprecate Weak Hashing Algorithms HIGH Off
Deny Public Cloud Storage CRITICAL Off
Prevent Root Execution in Containers MEDIUM Off
Enforce Smart Contract Reentrancy Guards CRITICAL Off

πŸ“Š Architecture

SecureFlow links local developer workflows, automated CI/CD pipelines, and pull request audits with a centralized Mission Control dashboard:

  • CLI (cli/): Standalone developer scanner and git pre-commit hook (.husky/pre-commit) providing local secret checking, scan caching, and --fail-on quality gates.
  • GitHub Action (.github/workflows/): Automated CI security analysis via npx secureflow-cli, exporting SARIF code scanning reports to GitHub Security.
  • Backend Ingestion & Workers: Event-driven webhook handler (/api/webhooks/github), Redis delivery deduplication, BullMQ fair queue scheduling, and distributed workers.
  • Scanning & Rules Engine: High-speed deterministic rules for secrets, workflows (.github/workflows/*.yml), package dependencies, and IaC manifests.
  • AI Inference Layer: Groq, Ollama, vLLM, or OpenAI-compatible models producing contextual findings, explanations, and verified remediation diffs via Genkit.
  • Policy Engine (IQEngine): Evaluates base-branch gate policies (.secureflow.yml) and suppresses dismissed triage findings.
  • Mission Control Dashboard (src/app/dashboard/): Next.js App Router command center for repository monitoring, findings triage, policy management, and audit logs.
  • Database: PostgreSQL with Prisma ORM for persistent scan telemetry and cryptographic audit ledgers.

πŸ“ For the complete architecture, interactive Mermaid diagrams of data flow from scan to dashboard, and step-by-step contributor guides on adding rules, AI providers, and dashboard pages, see the Architecture & Contributor Guide.


πŸ“– Technical Documentation

For more in-depth details about the architecture, developer API, and security practices of SecureFlow, check out:

  • Architecture & Contributor Guide: Comprehensive architectural blueprint explaining how the CLI, GitHub Action, Dashboard, and AI layer connect, complete Mermaid data flow diagrams from scan to dashboard, and contributor extension guides for adding rules, AI providers, and dashboard pages.
  • Safe Upgrade Guide: Standardized step-by-step operator checklist for upgrading SecureFlow releases, applying Prisma migrations, verifying /api/health and /api/version, and executing zero-data-loss rollbacks.
  • Database Backup, Restore & Verification Guide: Procedures for compressed PostgreSQL dumps (pg_dump), safe restores with non-empty database safety guards, ephemeral database verification, Linux cron, and Kubernetes CronJob scheduling.
  • Local Development Setup: Step-by-step guide to acquiring every credential (Prisma/PostgreSQL, Groq, GitHub App, GitHub OAuth/NextAuth, Redis) needed to run SecureFlow locally.
  • Kubernetes Deployment & Egress Hardening: Production deployment architecture, zero-trust network policies, and egress rule whitelisting for backend worker pods.
  • System Blueprint: Explains the application blueprint, core capabilities, style guidelines, visual tokens, and heist-themed copywriting dictionary.
  • API Reference: Provides exhaustive details on HTTP endpoints, authentication, rate limits, error formats, and system types.
  • Threat Model & STRIDE Analysis: Comprehensive threat modeling across webhook ingestion, BullMQ worker queues, static scanning, LLM providers, PostgreSQL audit ledgers, and outbound dispatchers, detailing mitigations, trust boundaries, and residual risks.
  • AI Security & Prompt Injection Defense: Documents the threat vector, policy isolation boundaries, pre-filtering layers, and UI indicators used to protect against LLM prompt injection attacks.
  • Threat Intelligence MCP Server: Guide to connecting IDE agents (Cursor, Claude Desktop, Windsurf) to the SecureFlow CLI MCP server with ArmorIQ cryptographic intent verification.
  • Local Inference & VRAM Guide: Hardware/VRAM requirements, memory management, and environment variables for air-gapped scanning with local Ollama and vLLM models.
  • Operator Runbook: Operational troubleshooting guide for scan outages, webhook delivery failures, queue/Redis stalls, Groq rate limits, database pooling errors, and proxy configuration.
  • Webhook Load Testing: Performance benchmarks and k6 load testing suite for webhook ingestion throughput and response latency.
  • Status Badge: Embed a live SVG badge in your README showing the latest scan status.

🏷️ Status Badge

Add a live security-status badge to your repository README:

![SecureFlow](https://secure-flow-six.vercel.app/api/badge/OWNER/REPO)

The badge reflects the latest scan: passing (green), review required (yellow), blocked (red), or unknown (grey). Enable it in your repository settings β€” see the Status Badge docs for details.


🀝 Contributing

Every good heist needs a crew! Contributions are welcome from developers of all skill levels.

For a comprehensive, self-contained guide covering prerequisites, running the CLI and dashboard locally, running tests with zero cloud credentials, and our full PR checklist, please read CONTRIBUTING.md. To understand how the CLI, GitHub Action, Dashboard, and AI layer connect, explore the Architecture & Contributor Guide.

🎯 Issue Difficulty Labels

We label open issues by difficulty so you can immediately find work suited to your experience:

  • 🟒 level1 (Beginner / Good First Issue): Isolated bug fixes, documentation, styling, accessibility contrast, and unit tests (1–2 files).
    Examples: Severity badge contrast ratios, --no-color CLI support, snapshot tests.
    πŸ‘‰ Browse level1 issues
  • 🟑 level2 (Intermediate / Feature Enhancement): CLI subcommands, UI components, state synchronization, and database migrations (3–6 files).
    Examples: Interactive secureflow init command, --since REF diff scanning, Dark mode toggle, side-by-side code viewer.
    πŸ‘‰ Browse level2 issues
  • πŸ”΄ level3 (Advanced / Architectural Work): Core scanning engines, BullMQ queue workers, LLM orchestration, and cryptography (7+ files).
    Examples: Configurable AI model providers, DLQ auto-retries, HMAC audit trail chain, k6 load testing.
    πŸ‘‰ Browse level3 issues

πŸ“– Full Details & Matrix: See the Issue Difficulty Comparison Matrix in CONTRIBUTING.md for detailed expectations and guidelines.

Branch Naming Conventions

Create a branch from main following the <type>/<description> format:

git checkout -b fix/your-issue-name   # bug fix
git checkout -b feat/your-feature     # new feature
git checkout -b docs/update-readme    # documentation
git checkout -b test/add-unit-tests   # testing

Commit Guidelines

Use Conventional Commits for all commit messages:

git commit -m "fix: description of what you fixed"
git commit -m "feat(cli): description of new feature"
git commit -m "docs: description of documentation change"

❓ FAQ

How does SecureFlow protect my secrets? SecureFlow uses AI to detect hardcoded secrets and sensitive data in your code. It's designed to catch API keys, passwords, tokens, and other credentials that might accidentally be committed to your repository.

Can I customize the scanning rules? Yes! You can create, toggle, and manage custom policies through the dashboard. You can also define custom regex rules directly in .secureflow.json (e.g. for internal token formats or banned APIs) with built-in ReDoS backtracking protection.

Can I define custom rules for internal tokens or banned APIs? Yes! In .secureflow.json, define rules with an id, pattern, globs, severity, and message. Evaluations are sandboxed with timeouts to prevent regex backtracking hangs, and findings are labeled with [Custom Rule: <id>].

Is my data sent to external services? Your code diffs are sent to Groq's LLM service for analysis. We do not store your code or share it with third parties. The service is compliant with data protection standards.

How much does it cost to use SecureFlow? SecureFlow is open-source and free to self-host. You'll need a Groq API key (free tier available) and your own PostgreSQL database.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❀️ to make every Pull Request safer.

"The vault is empty. Zero traces left behind." β€” every clean audit, thanks to The Professor.

⭐ Star us on GitHub β€” it helps!

Report Bug Β· Request Feature Β· View Demo

About

Resources

Code of conduct

Contributing

Security policy

Stars

16 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages