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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ __v0_jsx-dev-runtime.ts

# Environment variables
.env*.local
.env
backend/.env

# Python
backend/.venv/
backend/__pycache__/
backend/temp_repo/
**/__pycache__/
*.pyc

# Common ignores
node_modules
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Vidyankshini

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
224 changes: 224 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
# SecureBob AI — Enterprise Code Security Suite

SecureBob AI is a production-grade, next-generation code security analysis suite. It combines automated static application security testing (SAST), regex-based secret scanners, and enterprise-grade AI-powered explanations to help developers find, prioritize, and remediate security issues earlier in the software development lifecycle (SDLC).

Leveraging IBM watsonx.ai and IBM Granite foundation models for code, SecureBob AI provides developer-centric explanations and refactored secure code suggestions directly alongside raw scanner findings.

---

## Technical Capabilities

SecureBob AI orchestrates six integrated capabilities designed to secure modern codebases:

1. **GitHub Repository Scanner**: Programmatic cloning and auditing of public or private git repositories using GitPython, providing comprehensive vulnerability detection across branches.
2. **Vulnerability Detection (SAST)**: Automated rulesets detecting SQL injection, Cross-Site Scripting (XSS), insecure deserialization, and other OWASP Top 10 vulnerabilities.
3. **Secret Leak Detection**: Static scanning engines mapping exposed high-entropy secrets including API keys, JWT tokens, AWS credentials, and database connection strings.
4. **Pull Request Security Review**: Staged code checking that intercepts code diffs in Pull Requests and identifies newly introduced security liabilities before they merge.
5. **Security Score Dashboard**: Aggregate threat severity weighing that computes a unified, real-time security posture score, listing severity counts and historical risk curves.
6. **AI Security Assistant**: Conversational agent powered by IBM Granite models providing immediate secure coding recommendations, custom refactoring, and educational walk-throughs.

---

## Technical Stack

* **Frontend**: Next.js 16 (App Router), React 19, TypeScript
* **Styling**: Tailwind CSS v4, Radix UI primitive systems (shadcn/ui), Lucide icons
* **Animations**: Framer Motion for hardware-accelerated micro-animations and smooth page transitions
* **Backend**: Python 3.10+, FastAPI, Pydantic, GitPython
* **Scanning Engine**: Custom regex profile scanners and Semgrep CLI rulesets
* **AI Core Orchestrator**: IBM watsonx.ai platform and IBM Granite code foundation models
* **Package Management**: pnpm (fast, deterministic node package manager)

---

## System Architecture

The architecture decouples the highly responsive Next.js frontend from the high-throughput Python FastAPI scanning service, delegating model execution to IBM watsonx.ai:

```mermaid
graph LR
User(["Developer / Security Team"]) -->|Interacts| UI["Next.js 16 Frontend (App Router)"]

subgraph Client ["Client Layer (Next.js & React 19)"]
UI --> Dashboard["Vulnerability Dashboard (/security-dashboard)"]
UI --> Scanner["Code & Git Scanner (/github-scanner)"]
UI --> Assistant["AI Assistant Chat (/ai-assistant)"]
end

subgraph Backend ["Scanning & Orchestration (FastAPI)"]
Scanner -->|POST /scan| Orchestrator["Scan Orchestrator (main.py)"]
Orchestrator -->|Clones Repo| RepoCloner["Git Repo Cloner (clone_repo.py)"]

RepoCloner --> Semgrep["Semgrep Engine (semgrep_scanner.py)"]
RepoCloner --> Secrets["Secret Engine (secret_scanner.py)"]
RepoCloner --> Custom["Custom Rules (custom_scanner.py)"]

Semgrep -->|Raw Logs| ScoreCalc["Score Calculator (score_calculator.py)"]
Secrets -->|Leaked Keys| ScoreCalc
Custom -->|Custom Hits| ScoreCalc
end

subgraph AI ["AI Intelligence Layer (IBM watsonx.ai)"]
Assistant -->|REST API Query| Watsonx["IBM watsonx.ai Platform"]
ScoreCalc -->|Aggregated Findings| Watsonx
Watsonx -->|IBM Granite LLM| AIExplainer["AI Explainer (ai_explainer.py)"]
AIExplainer -->|Remediation & Fixes| UI
end

classDef clientStyle fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#f8fafc;
classDef backendStyle fill:#1e1b4b,stroke:#818cf8,stroke-width:2px,color:#f8fafc;
classDef aiStyle fill:#062f4f,stroke:#34d399,stroke-width:2px,color:#f8fafc;

class UI,Dashboard,Scanner,Assistant clientStyle;
class Orchestrator,RepoCloner,Semgrep,Secrets,Custom,ScoreCalc backendStyle;
class Watsonx,AIExplainer aiStyle;
```

---

## Scanning Engine & Backend Services

The core analytical capabilities reside within `backend/scanners/`, driven by a lightweight FastAPI server:

* **Semgrep Scanner (`semgrep_scanner.py`)**: Runs local Semgrep rulesets targeting target directories. Focuses on insecure coding patterns, framework-specific misconfigurations, and standard security bugs.
* **Secret Scanner (`secret_scanner.py`)**: Executes scanning targeting keys and access tokens. Runs high-entropy character analysis coupled with precise pattern-matching regex profiles.
* **Custom Scanner (`custom_scanner.py`)**: Implements rule-based lexical matching for common insecure APIs, custom team guidelines, and quick-check rules.
* **Score Calculator (`score_calculator.py`)**: Scores finding counts, severities (Critical, High, Medium, Low), and computes a consolidated Security Dashboard Score (out of 100).
* **AI Explainer (`ai_explainer.py`)**: Bridges the raw JSON findings with the IBM watsonx.ai Granite models to yield remediation descriptions, insecure vs. secure code comparisons, and threat descriptions.
* **PR Review Scanner (`pr_review_scanner.py`)**: Performs automated reviews on direct code diff strings, returning inline security assessments.

---

## Project Directory Layout

```filepath
secure-bob-ai-app/
├── app/ # Next.js 16 App Router Pages
│ ├── ai-assistant/ # AI Security Assistant Interface
│ ├── features/ # Security Features Showcase
│ ├── github-scanner/ # GitHub Repository Scanner Dashboard
│ ├── pr-review/ # PR Diff Review Interface
│ ├── secret-scanner/ # Secret and Credential Leaks UI
│ ├── security-dashboard/ # Unified Posture Dashboard and Analytics
│ ├── vulnerability-scanner/ # SAST Insecure Code Scanning UI
│ ├── globals.css # Tailwind v4 Global Custom Styles
│ ├── layout.tsx # Base Shell and Theme Provider
│ └── page.tsx # Cyber-inspired Platform Landing Page
├── backend/ # Python FastAPI Scanning Backend
│ ├── github/ # Repository cloning modules
│ │ └── clone_repo.py
│ ├── scanners/ # Automated Static & AI Explainer Engines
│ │ ├── ai_explainer.py
│ │ ├── custom_scanner.py
│ │ ├── pr_review_scanner.py
│ │ ├── score_calculator.py
│ │ ├── secret_scanner.py
│ │ └── semgrep_scanner.py
│ ├── main.py # FastAPI Web Server Entrypoint
│ └── requirements.txt # Backend dependencies
├── components/ # Shared React Components
│ ├── ui/ # Base Radix primitives (Button, Card, Dialog, Toast)
│ ├── cyber-background.tsx # Immersive glowing network grid canvas
│ ├── terminal-animation.tsx # Immersive retro terminal scanner simulator
│ ├── navbar.tsx # Universal Navigation Header
│ └── footer.tsx # Dashboard Footer
├── docs/ # Architectural docs & diagrams
│ └── ARCHITECTURE.md
├── public/ # Static assets and scanner screenshots
├── package.json # Frontend package configurations
└── pnpm-lock.yaml # pnpm locked dependencies
```

---

## Local Development Setup

To run the full SecureBob AI suite locally, start both the Python FastAPI server and the Next.js development server.

### Backend Setup (Python)

1. **Navigate to the Backend Directory**:
```bash
cd backend
```

2. **Initialize Virtual Environment**:
```bash
python -m venv .venv
```

3. **Activate the Virtual Environment**:
* Windows:
```powershell
.venv\Scripts\activate
```
* macOS/Linux:
```bash
source .venv/bin/activate
```

4. **Install Dependencies**:
```bash
pip install -r requirements.txt
```

5. **Start the FastAPI Server**:
```bash
uvicorn main:app --reload --host 127.0.0.1 --port 8000
```
The backend API documentation is available at `http://127.0.0.1:8000/docs`.

---

### Frontend Setup (Next.js)

1. **Return to the Project Root**:
```bash
cd ..
```

2. **Install Node.js Dependencies**:
```bash
pnpm install
```

3. **Configure Environment Variables**:
Create a `.env.local` file at the root of the project:
```env
NEXT_PUBLIC_API_URL=http://127.0.0.1:8000
```

4. **Start the Development Server**:
```bash
pnpm dev
```
Open **`http://localhost:3000`** in your browser to view the application.

---

## Design System & Aesthetics

SecureBob AI utilizes a carefully curated developer aesthetic designed to look premium, modern, and high-tech:
* **Interactive Glowing Canvas**: Custom background animation simulating data streaming and node layouts.
* **Refined Dark Mode**: Monochromatic obsidian backdrop colors accented with neon cyber-blue, indigo, emerald, and amber alerts.
* **Micro-Animations**: Framer Motion orchestrations providing smooth slide-ins, element expansions, and interactive hover feedbacks.
* **Responsive Layout Grid**: High-fidelity CSS Grid and Flexbox layouts optimized to preserve presentation across diverse viewport resolutions.

---

## Hackathon Team

This project was built for the IBM watsonx.ai & Granite matchup:
* **Vidyankshini Vibhute** — Frontend Developer (React, Next.js, and premium UI/UX Specialist)
* **Satyam Kulkarni** — Backend & AI Developer (Python FastAPI and IBM watsonx.ai integration)
* **Siya Kale** — Security Research Lead (Cybersecurity rulesets and threat model mapping)

---

## License

This project is licensed under the **MIT License**. For details, see the LICENSE file.

---

**SecureBob AI** — *Scan Before You Push!*
32 changes: 30 additions & 2 deletions app/ai-assistant/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,37 @@ export default function AIAssistantPage() {
setShowSuggestions(false)

// Simulate AI thinking
await new Promise((resolve) => setTimeout(resolve, 1500))
await new Promise((resolve) => setTimeout(resolve, 1000))

const response = getAIResponse(messageText)
let response = ""

try {
const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:8000"
const apiResponse = await fetch(`${API_URL}/review-pr`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
code_content: messageText,
}),
})

const data = await apiResponse.json()

if (data.findings && data.findings.length > 0) {
response = data.findings
.map(
(item: any) =>
`🔒 ${item.type}\n\n${item.ai_explanation}\n\n✅ Fix: ${item.recommended_fix}`
)
.join("\n\n")
} else {
response = getAIResponse(messageText)
}
} catch (error) {
response = getAIResponse(messageText)
}

const assistantMessage: Message = {
role: "assistant",
Expand Down
75 changes: 57 additions & 18 deletions app/github-scanner/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,66 @@ export default function GitHubScannerPage() {
const [currentLog, setCurrentLog] = useState(0)
const [results, setResults] = useState<ScanResult[]>([])

const startScan = () => {
if (!repoUrl) return
setIsScanning(true)
setScanComplete(false)
setCurrentLog(0)
setResults([])
const startScan = async () => {
if (!repoUrl) return

setIsScanning(true)
setScanComplete(false)
setCurrentLog(0)
setResults([])

try {
const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:8000"
const response = await fetch(`${API_URL}/scan`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
repo_url: repoUrl,
}),
})

const data = await response.json()

const formattedResults: ScanResult[] = [
...data.custom_results.map((item: any, index: number) => ({
type: "vulnerability",
severity: item.severity.toLowerCase(),
file: item.file || "Unknown File",
line: index + 1,
message: item.type,
code: item.ai_explanation || "Security vulnerability detected",
})),

...data.secret_results.map((item: any, index: number) => ({
type: "secret",
severity: item.severity.toLowerCase(),
file: item.file || "Unknown File",
line: index + 1,
message: item.type,
code: item.ai_explanation || "Secret detected",
})),
]

setResults(formattedResults)
setScanComplete(true)
} catch (error) {
console.error("Repository scan failed:", error)
} finally {
setIsScanning(false)
}
}

useEffect(() => {
if (isScanning && currentLog < terminalLogs.length) {
const timer = setTimeout(() => {
setCurrentLog((prev) => prev + 1)
}, 500)
return () => clearTimeout(timer)
} else if (isScanning && currentLog >= terminalLogs.length) {
setIsScanning(false)
setScanComplete(true)
setResults(mockScanResults)
}
}, [isScanning, currentLog])
useEffect(() => {
if (isScanning && currentLog < terminalLogs.length) {
const timer = setTimeout(() => {
setCurrentLog((prev) => prev + 1)
}, 500)

return () => clearTimeout(timer)
}
}, [isScanning, currentLog])
const getSeverityColor = (severity: string) => {
switch (severity) {
case "critical":
Expand Down
Loading