Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SentinelRAG 🛡️

A production-ready security intelligence engine. Query CVE vulnerabilities using natural language, powered by RAG with LangChain and pgvector.

Features

  • Semantic Search: Query 330,000+ CVEs using natural language
  • Real-time Ingestion: Automated CVE fetching from NVD API
  • LangSmith Tracing: Full observability for debugging and evaluation
  • Flexible LLM: Powered by Google Gemini

Tech Stack

Component Technology
Frontend Streamlit
Orchestration LangChain
Database Neon Postgres + pgvector
Embeddings Google Gemini (text-embedding-004)
Observability LangSmith

Quick Start

Prerequisites

  • uv (Python package manager)
  • Neon account (free Postgres with pgvector)
  • LangSmith account (free tracing)
  • NVD API Key (free, optional but recommended)

1. Clone & Configure

git clone https://github.com/yourusername/SentinelRAG.git
cd SentinelRAG

# Copy environment template
cp .env.example .env

Edit .env with your credentials:

# LLM (Google Gemini)
GOOGLE_API_KEY=your-api-key
LLM_MODEL=gemini-1.5-flash
EMBEDDING_MODEL=models/text-embedding-004
EMBEDDING_DIMENSIONS=768

# Database (from Neon dashboard)
NEON_DATABASE_URL=postgresql://user:pass@host.neon.tech/db?sslmode=require

# LangSmith (Settings → Access Tokens)
LANGSMITH_API_KEY=lsv2_pt_xxxxx
LANGSMITH_PROJECT=SentinelRAG-dev
LANGCHAIN_TRACING_V2=true

# NVD API (optional - 10x faster ingestion)
NVD_API_KEY=your-nvd-key

2. Install Dependencies

uv sync

3. Initialize Database

uv run python -m src.db_setup

You should see:

✅ Connected to Neon Postgres database.
📦 Enabling pgvector extension...
📊 Creating vulnerabilities table...
✅ Database setup complete!

4. Ingest CVE Data

Quick test (last 7 days, ~750 CVEs):

uv run python -m src.cve_ingestion --recent --days 7

Full database (all 330k CVEs, ~30 min with API key):

uv run python -m src.cve_ingestion --full

5. Run the App

uv run streamlit run app.py

Open http://localhost:8501 and start querying!


Example Queries

  • "What are the most critical vulnerabilities in Apache Log4j?"
  • "Show me recent CVEs affecting Windows with remote code execution"
  • "Find SQL injection vulnerabilities in web frameworks"

Project Structure

SentinelRAG/
├── app.py                 # Streamlit UI
├── src/
│   ├── config.py          # Environment configuration
│   ├── db_setup.py        # Database initialization
│   ├── cve_ingestion.py   # NVD CVE fetcher
│   └── rag_chain.py       # LangChain RAG pipeline
├── .env.example           # Environment template
├── pyproject.toml         # Dependencies (uv)
└── GEMINI.md              # Project memory & architecture

Deployment

Streamlit Community Cloud (Free)

  1. Push to GitHub:

    git add .
    git commit -m "Prepare for deployment"
    git push origin main
  2. Deploy on Streamlit Cloud:

    • Go to share.streamlit.io
    • Sign in with GitHub
    • Click "New app" → Select your repo
    • Set main file: app.py
    • Click "Deploy"
  3. Configure Secrets:

    In Streamlit Cloud dashboard → SettingsSecrets, add:

    GOOGLE_API_KEY = "your-api-key"
    LLM_MODEL = "gemini-1.5-flash"
    EMBEDDING_MODEL = "models/text-embedding-004"
    EMBEDDING_DIMENSIONS = 768
    NEON_DATABASE_URL = "postgresql://user:pass@host.neon.tech/db?sslmode=require"
    LANGSMITH_API_KEY = "lsv2_pt_xxxxx"
    LANGSMITH_PROJECT = "SentinelRAG-prod"
    APP_PASSWORD = "your-secret-password"
  4. Reboot the app after adding secrets.

Note: Your Neon database persists across deployments. CVE data only needs to be ingested once.

Password Protection

Set APP_PASSWORD in your secrets to require authentication. Leave empty for open access.

License

MIT

About

A production-ready security intelligence engine. Implements RAG with Python, LangChain, and Neon (pgvector) to query real-time vulnerability data. Features systematic LLM evaluation via RAGAS and observability tracing with LangSmith to eliminate "vibe-check" engineering.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages