Security hardening, repo hygiene, and documentation for DeepGuard#1
Security hardening, repo hygiene, and documentation for DeepGuard#1
Conversation
Co-authored-by: prathamc00 <128209604+prathamc00@users.noreply.github.com>
There was a problem hiding this comment.
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.gitignorewith comprehensive rules. - Configuration & Documentation: Added
.env.example, replaced emptyREADME.mdwith full docs, updated rootrequirements.txtto delegate tobackend/requirements.txt. - Infrastructure: Updated
docker-compose.yml(removed deprecatedversion, fixed volumes, added health checks,restart: unless-stopped); added.github/workflows/ci.ymlfor lint + build + compose validation; fixed hardcoded API URL infrontend/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.
| - **Docker & Docker Compose** ≥ v2 — recommended for the fastest start. | ||
| - **Python 3.10+** — for local backend development. |
There was a problem hiding this comment.
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.
| environment: | ||
| - VITE_API_URL=http://localhost:8000 | ||
| depends_on: | ||
| - backend |
There was a problem hiding this comment.
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.
| - backend | |
| backend: | |
| condition: service_healthy |
| - name: Build (type-check + bundle) | ||
| working-directory: frontend | ||
| run: npm run build |
There was a problem hiding this comment.
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.
| | ML / Vision | PyTorch, TorchVision, facenet-pytorch, grad-cam | | ||
| | RAG | ChromaDB, sentence-transformers | | ||
| | Forensics | OpenCV, NumPy, SciPy, librosa | | ||
| | Frontend | React 18, TypeScript, Vite | |
There was a problem hiding this comment.
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".
| # 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 |
There was a problem hiding this comment.
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.
| - name: Install flake8 | ||
| run: pip install flake8 | ||
|
|
||
| - name: Lint with flake8 | ||
| run: | | ||
| flake8 backend/app \ | ||
| --max-line-length=120 \ | ||
| --exclude=__pycache__ \ | ||
| --count --statistics |
There was a problem hiding this comment.
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.
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>
The repository had an empty
.gitignore, committed secrets (kaggle.json,.env), an emptyREADME.md, a hardcoded API URL in the frontend, and a stale rootrequirements.txt. This PR addresses all of these.Security
kaggle.json— contained a live Kaggle API key; owner should revoke576fb3d...at https://www.kaggle.com/settings.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 DockerConfiguration
.env.example(new) — documents all expected env vars with safe placeholders; includes Kaggle, DB, and Redis stubsrequirements.txt— replaced outdated subset with a redirect tobackend/requirements.txt(was missingpydantic-settings,chromadb,sentence-transformers,scipy)Frontend
backendService.ts— replaced hardcoded base URL with the Vite env var already wired indocker-compose.yml:Docker
docker-compose.yml— removed deprecatedversion: '3.8'; fixed frontend volume from./frontend/src:/app/src→./frontend:/app(nosrc/subdirectory exists); addedrestart: unless-stoppedand health checks for both services using in-image runtimes (Pythonurllib.requestfor backend, Nodehttpfor frontend — nocurldependency)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 tomainand PRs:flake8lint ofbackend/appnpm ci && npm run build(type-check + bundle)docker compose configsyntax validationpermissions: contents: readOriginal prompt
Overview
This PR addresses critical security issues, missing documentation, and general repository hygiene improvements for the DeepGuard project.
1. 🔴 Critical: Fix empty root
.gitignoreThe root
.gitignore(sha:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) is completely empty (0 bytes). This has already caused sensitive files to be committed. Replace it with a comprehensive.gitignorethat covers:.env,kaggle.json,*.pem,*.key__pycache__/,*.pyc,.venv/,venv/,*.egg-info/node_modules/,dist/,*.localml/checkpoints/*.pt,ml/checkpoints/*.pth,ml/rag_index/,ml/datasets/.vscode/,.idea/,*.swp.DS_Store,Thumbs.db.ipynb_checkpoints/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 containsAPP_NAME=DeepGuard,ENV=development,DEBUG=true. Delete this file (it will be covered by.env.example).3. 🟡 Add
.env.exampleCreate a new
.env.examplefile at the root that documents all expected environment variables:4. 🟡 Add comprehensive
README.mdThe
README.md(sha:e69de29bb2d1d6434b8b29ae775ad8c2e48c5391) is completely empty (0 bytes). Write a comprehensive README that includes:/upload, v2/api/v2/detect,/api/v2/index/stats)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:This should use the Vite environment variable that's already being passed in
docker-compose.yml(VITE_API_URL=http://localhost:8000):6. 🟡 Clean up duplicate/outdated root
requirements.txtThe root
requirements.txt(sha:31545baef0a97ccd8c20ffcdd5cc6e853294db3e) is an outdated subset ofbackend/requirements.txt(sha:bda27a7ad2c54df4a0fe5852331c124f58a99f72) — it's missingpydantic-settings,chromadb,sentence-transformers, andscipy.Replace the root
requirements.txtcontent with a comment pointing tobackend/requirements.txt, so there's no confusion:7. 🟡 Fix
docker-compose.ymlCurrent file (sha:
481e85cc3c9053dc7232139394fe1ebed991f35c):version: '3.8'field./frontend/src:/app/src— the frontend source files are at the root offrontend/, not in asrc/subfolder. Update volumes to mount the correct paths.restart: unless-stoppedfor reliability8. 🟢 Add GitHub Actions CI workflow
Create
.github/workflows/ci.ymlwith:mainand pull requestsnpm run buildto verify TypeScript compiles)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 3requirements.txt— replace with redirect to backend/requirements.txtdocker-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.