-
Notifications
You must be signed in to change notification settings - Fork 0
🛡️ Sentinel: [CRITICAL] Remove hardcoded secrets and fix authentication tests #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Divineo Bunker Environment Variables | ||
| LVT_SECRET_KEY=your_secret_key_here | ||
| GEMINI_API_KEY=your_gemini_api_key_here | ||
| LVT_ALLOWED_ORIGINS=* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ## 2025-03-05 - Hardcoded Secrets in Authentication Handshake | ||
| **Vulnerability:** Critical authentication secrets were hardcoded in multiple backend files (`main.py`, `DivineoBunker.py`), exposing the system to credential theft if the source code were compromised. | ||
| **Learning:** Hardcoding secrets often occurs during "rapid prototyping" phases and persists into production if not audited. Centralized environment variable management is essential for multi-component systems. | ||
| **Prevention:** Use `python-dotenv` and `os.getenv` for all sensitive keys. Implement mandatory pre-commit hooks or CI scans to detect plaintext secrets (e.g., `git-secrets`). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,15 @@ | |
| import hashlib | ||
| import time | ||
| import json | ||
| import os | ||
| from dotenv import load_dotenv | ||
|
|
||
| load_dotenv() | ||
|
Comment on lines
+6
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling |
||
|
|
||
| class DivineoBunker: | ||
| def __init__(self): | ||
| # 🛡️ Configuración Maestra (abvetos.com) | ||
| self.secret_key = "LVT_SECRET_PROD_091228222" | ||
| self.secret_key = os.getenv("LVT_SECRET_KEY") | ||
| self.patent = "PCT/EP2025/067317" | ||
| self.algorithm_v = "V10_Divineo_Shopify_Final" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,24 +2,30 @@ | |||||||||
| import hashlib | ||||||||||
| import time | ||||||||||
| import json | ||||||||||
| import os | ||||||||||
| from dotenv import load_dotenv | ||||||||||
| from fastapi import FastAPI, HTTPException | ||||||||||
|
|
||||||||||
| load_dotenv() | ||||||||||
| from fastapi.responses import JSONResponse | ||||||||||
| from fastapi.middleware.cors import CORSMiddleware | ||||||||||
| from models import UserScan, SHOPIFY_INVENTORY | ||||||||||
| from jules_engine import get_jules_advice | ||||||||||
|
|
||||||||||
| app = FastAPI(title="Divineo Bunker Backend") | ||||||||||
|
|
||||||||||
| allowed_origins = os.getenv("LVT_ALLOWED_ORIGINS", "*").split(",") | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defaulting to
Suggested change
|
||||||||||
|
|
||||||||||
| app.add_middleware( | ||||||||||
| CORSMiddleware, | ||||||||||
| allow_origins=["*"], | ||||||||||
| allow_origins=allowed_origins, | ||||||||||
| allow_credentials=True, | ||||||||||
| allow_methods=["*"], | ||||||||||
| allow_headers=["*"], | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| # 🛡️ Configuración Maestra (abvetos.com) | ||||||||||
| SECRET_KEY = "LVT_SECRET_PROD_091228222" | ||||||||||
| SECRET_KEY = os.getenv("LVT_SECRET_KEY") | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The application relies on
Suggested change
|
||||||||||
| PATENT = "PCT/EP2025/067317" | ||||||||||
|
|
||||||||||
| def verify_auth(user_id: str, token: str) -> bool: | ||||||||||
|
|
@@ -68,7 +74,14 @@ async def recommend_garment(scan: UserScan, garment_id: str = "BALMAIN_SS26_SLIM | |||||||||
| # Usamos Jules para el toque de estilo | ||||||||||
| styling_advice = get_jules_advice(scan, item) | ||||||||||
| except Exception as e: | ||||||||||
| styling_advice = f"Divineo confirmado con {item['name']}." | ||||||||||
| raise HTTPException( | ||||||||||
| status_code=503, | ||||||||||
| detail={ | ||||||||||
| "status": "error", | ||||||||||
| "code": 503, | ||||||||||
| "message": "Jules AI Engine is currently recalibrating or unavailable. Please try again." | ||||||||||
| } | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| if is_divineo and item['stock'] > 0: | ||||||||||
| return { | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
*forLVT_ALLOWED_ORIGINSis overly permissive, even in an example file, as it encourages insecure configurations during development. It's better to provide a more realistic and secure example that developers can adapt, such as specifying local development origins.