Skip to content

Security hardening, repo hygiene, and documentation for DeepGuard#1

Open
Copilot wants to merge 5 commits intomainfrom
copilot/fix-empty-gitignore-and-secrets
Open

Security hardening, repo hygiene, and documentation for DeepGuard#1
Copilot wants to merge 5 commits intomainfrom
copilot/fix-empty-gitignore-and-secrets

Conversation

Copy link

Copilot AI commented Mar 4, 2026

The repository had an empty .gitignore, committed secrets (kaggle.json, .env), an empty README.md, a hardcoded API URL in the frontend, and a stale root requirements.txt. This PR addresses all of these.

Security

  • Deleted kaggle.json — contained a live Kaggle API key; owner should revoke 576fb3d... at https://www.kaggle.com/settings
  • Deleted .env — secrets must not be committed
  • .gitignore — replaced empty file with comprehensive rules covering secrets, Python, Node, ML artifacts (.pt/.pth, rag_index/, datasets/), Jupyter, IDE, OS, and Docker

Configuration

  • .env.example (new) — documents all expected env vars with safe placeholders; includes Kaggle, DB, and Redis stubs
  • requirements.txt — replaced outdated subset with a redirect to backend/requirements.txt (was missing pydantic-settings, chromadb, sentence-transformers, scipy)

Frontend

  • backendService.ts — replaced hardcoded base URL with the Vite env var already wired in docker-compose.yml:
    // before
    const API_BASE_URL = "http://localhost:8000";
    // after
    const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:8000";

Docker

  • docker-compose.yml — removed deprecated version: '3.8'; fixed frontend volume from ./frontend/src:/app/src./frontend:/app (no src/ subdirectory exists); added restart: unless-stopped and health checks for both services using in-image runtimes (Python urllib.request for backend, Node http for frontend — no curl dependency)

Documentation

  • README.md — replaced empty file with full project docs: architecture diagram reference, feature list, tech stack table, project structure, Docker and local dev setup, API reference for v1 (/upload) and v2 (/api/v2/detect, /api/v2/index/stats)

CI

  • .github/workflows/ci.yml (new) — three jobs on push to main and PRs:
    • Backend: flake8 lint of backend/app
    • Frontend: npm ci && npm run build (type-check + bundle)
    • Docker: docker compose config syntax validation
    • All jobs scoped to permissions: contents: read
Original prompt

Overview

This PR addresses critical security issues, missing documentation, and general repository hygiene improvements for the DeepGuard project.

1. 🔴 Critical: Fix empty root .gitignore

The root .gitignore (sha: e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) is completely empty (0 bytes). This has already caused sensitive files to be committed. Replace it with a comprehensive .gitignore that covers:

  • Secrets: .env, kaggle.json, *.pem, *.key
  • Python: __pycache__/, *.pyc, .venv/, venv/, *.egg-info/
  • Node: node_modules/, dist/, *.local
  • ML artifacts: ml/checkpoints/*.pt, ml/checkpoints/*.pth, ml/rag_index/, ml/datasets/
  • IDE: .vscode/, .idea/, *.swp
  • OS: .DS_Store, Thumbs.db
  • Jupyter: .ipynb_checkpoints/
  • Docker: Unnecessary Docker build context files

2. 🔴 Critical: Remove committed secrets

The following files contain secrets or should never have been committed:

  • kaggle.json — contains a Kaggle API key ("key":"576fb3d57e703f4f744ba3985d6e6b44"). This file must be deleted from the repo. The user should revoke this key separately.
  • .env (sha: 3f59a23288a8eaae5b0b405829b8fb5e18e61e06) — currently contains APP_NAME=DeepGuard, ENV=development, DEBUG=true. Delete this file (it will be covered by .env.example).

3. 🟡 Add .env.example

Create a new .env.example file at the root that documents all expected environment variables:

# DeepGuard Environment Configuration
APP_NAME=DeepGuard
ENV=development
DEBUG=true

# Kaggle (for dataset downloads) — get yours at https://www.kaggle.com/settings
# KAGGLE_USERNAME=your_username
# KAGGLE_KEY=your_key

# Database (optional, for future use)
# DATABASE_URL=postgresql://user:password@localhost:5432/deepguard

# Redis (optional, for Celery task queue)
# REDIS_URL=redis://localhost:6379/0

4. 🟡 Add comprehensive README.md

The README.md (sha: e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) is completely empty (0 bytes). Write a comprehensive README that includes:

  • Project title, badges, and description
  • Architecture overview (how the system works — FastAPI backend, React frontend, RAG pipeline, forensic analysis)
  • Key features: RAG-enhanced detection, forensic signal extraction (FFT, color, noise, compression), explainability engine, Grad-CAM visualizations
  • Tech stack (Python/FastAPI, React/TypeScript/Vite, PyTorch, ChromaDB, Docker)
  • Project structure overview
  • Prerequisites and setup instructions (both Docker and local development)
  • API endpoint documentation (v1 /upload, v2 /api/v2/detect, /api/v2/index/stats)
  • Screenshots placeholder
  • Contributing guidelines
  • License placeholder

The architecture overview should reference the existing image file System-architecture-for-audio-deepfake-detection.png.

5. 🟡 Fix hardcoded API URL in frontend

In frontend/services/backendService.ts (sha: 4e99a780411f017bff5b77a4f4c44093d8b1b3de), line 3 has:

const API_BASE_URL = "http://localhost:8000";

This should use the Vite environment variable that's already being passed in docker-compose.yml (VITE_API_URL=http://localhost:8000):

const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:8000";

6. 🟡 Clean up duplicate/outdated root requirements.txt

The root requirements.txt (sha: 31545baef0a97ccd8c20ffcdd5cc6e853294db3e) is an outdated subset of backend/requirements.txt (sha: bda27a7ad2c54df4a0fe5852331c124f58a99f72) — it's missing pydantic-settings, chromadb, sentence-transformers, and scipy.

Replace the root requirements.txt content with a comment pointing to backend/requirements.txt, so there's no confusion:

# Backend dependencies are managed in backend/requirements.txt
# This file exists for convenience (e.g., pip install -r requirements.txt)
-r backend/requirements.txt

7. 🟡 Fix docker-compose.yml

Current file (sha: 481e85cc3c9053dc7232139394fe1ebed991f35c):

  • Remove deprecated version: '3.8' field
  • Fix frontend volume mount ./frontend/src:/app/src — the frontend source files are at the root of frontend/, not in a src/ subfolder. Update volumes to mount the correct paths.
  • Add health checks for both services
  • Add restart: unless-stopped for reliability

8. 🟢 Add GitHub Actions CI workflow

Create .github/workflows/ci.yml with:

  • Trigger on push to main and pull requests
  • Python backend linting (flake8 or ruff) and basic import checks
  • Frontend lint + type check (npm run build to verify TypeScript compiles)
  • Docker compose build validation

Files to create:

  • .gitignore (overwrite empty file)
  • .env.example (new)
  • README.md (overwrite empty file)
  • .github/workflows/ci.yml (new)

Files to modify:

  • frontend/services/backendService.ts — fix hardcoded API URL on line 3
  • requirements.txt — replace with redirect to backend/requirements.txt
  • docker-compose.yml ...

This pull request was created from Copilot chat.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: prathamc00 <128209604+prathamc00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix critical security issues and improve repository hygiene Security hardening, repo hygiene, and documentation for DeepGuard Mar 4, 2026
@prathamc00 prathamc00 marked this pull request as ready for review March 5, 2026 10:52
Copilot AI review requested due to automatic review settings March 5, 2026 10:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses multiple security, hygiene, configuration, and documentation issues in the DeepGuard repository. It removes committed secrets (kaggle.json, .env), adds a comprehensive .gitignore, documents environment variables in .env.example, replaces the empty README.md with full project documentation, fixes a hardcoded API URL in the frontend, cleans up the root requirements.txt, improves docker-compose.yml with health checks and volume fixes, and adds a GitHub Actions CI workflow.

Changes:

  • Security/Hygiene: Deleted kaggle.json (leaked API key) and .env; replaced the empty .gitignore with comprehensive rules.
  • Configuration & Documentation: Added .env.example, replaced empty README.md with full docs, updated root requirements.txt to delegate to backend/requirements.txt.
  • Infrastructure: Updated docker-compose.yml (removed deprecated version, fixed volumes, added health checks, restart: unless-stopped); added .github/workflows/ci.yml for lint + build + compose validation; fixed hardcoded API URL in frontend/services/backendService.ts.

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
kaggle.json Deleted — removed committed Kaggle API key
.env Deleted — removed committed env file
.gitignore Replaced empty file with comprehensive ignore rules
.env.example New — documents expected environment variables with safe placeholders
requirements.txt Replaced outdated package list with a redirect to backend/requirements.txt
frontend/services/backendService.ts Fixed hardcoded API_BASE_URL to use VITE_API_URL env var with fallback
docker-compose.yml Removed deprecated version, fixed frontend volume mount, added health checks and restart policy
README.md Replaced empty file with full project documentation
.github/workflows/ci.yml New — CI with backend lint, frontend build, and Docker Compose validation jobs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +103 to +104
- **Docker & Docker Compose** ≥ v2 — recommended for the fastest start.
- **Python 3.10+** — for local backend development.
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README states "Python 3.10+" as a prerequisite and the CI workflow installs Python 3.10, but backend/Dockerfile uses FROM python:3.9-slim. This means contributors following the README will use a different Python version than what's used in the Docker container. The Dockerfile's base image should be updated to python:3.10-slim to match the documented prerequisites.

Copilot uses AI. Check for mistakes.
environment:
- VITE_API_URL=http://localhost:8000
depends_on:
- backend
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The depends_on for the frontend uses the simple list form, which only ensures the backend container is started, not that it is actually healthy. Since a health check is now defined for the backend, consider using the condition form to make the frontend wait for the backend to pass its health check before starting: use depends_on: backend: condition: service_healthy. This prevents race conditions where the frontend starts before the backend API is ready.

Suggested change
- backend
backend:
condition: service_healthy

Copilot uses AI. Check for mistakes.
Comment on lines +51 to +53
- name: Build (type-check + bundle)
working-directory: frontend
run: npm run build
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step is named "Build (type-check + bundle)" and the CI job is named "Frontend — Type Check & Build", but npm run build runs vite build which uses esbuild for transpilation and does not perform TypeScript type checking. No tsc script is defined in frontend/package.json. As a result, TypeScript type errors will not be caught by this CI step. To enable proper type checking, add a "type-check": "tsc --noEmit" script to package.json and add a separate step that runs npm run type-check, or update the CI job name to reflect that it only validates the bundle compiles without runtime errors.

Copilot uses AI. Check for mistakes.
| ML / Vision | PyTorch, TorchVision, facenet-pytorch, grad-cam |
| RAG | ChromaDB, sentence-transformers |
| Forensics | OpenCV, NumPy, SciPy, librosa |
| Frontend | React 18, TypeScript, Vite |
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Tech Stack table lists "React 18" in the Frontend row, but the project uses React 19 (react@^19.2.4 per frontend/package.json). This should be updated to "React 19".

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +14
# DeepGuard Environment Configuration
APP_NAME=DeepGuard
ENV=development
DEBUG=true

# Kaggle (for dataset downloads) — get yours at https://www.kaggle.com/settings
# KAGGLE_USERNAME=your_username
# KAGGLE_KEY=your_key

# Database (optional, for future use)
# DATABASE_URL=postgresql://user:password@localhost:5432/deepguard

# Redis (optional, for Celery task queue)
# REDIS_URL=redis://localhost:6379/0
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .env.example is missing the GEMINI_API_KEY variable. The frontend/vite.config.ts (lines 14–15) injects GEMINI_API_KEY into the frontend bundle as both process.env.API_KEY and process.env.GEMINI_API_KEY. Without documenting this variable in .env.example, developers who copy the file and follow the setup instructions will end up with a frontend that has an undefined Gemini API key. Add an entry like # GEMINI_API_KEY=your_key_here to the example file.

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +30
- name: Install flake8
run: pip install flake8

- name: Lint with flake8
run: |
flake8 backend/app \
--max-line-length=120 \
--exclude=__pycache__ \
--count --statistics
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend CI job only runs flake8 linting but the repository has existing test files in backend/tests/ (e.g., test_api.py, test_forensics.py, test_rag.py). Consider adding a step to install dependencies (at least the core ones needed for tests) and run pytest to ensure tests pass on every push. Without this, test regressions won't be caught by CI.

Copilot uses AI. Check for mistakes.
prathamc00 and others added 3 commits March 5, 2026 17:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants