BUG:[Security & Tech Debt] Comprehensive SAST Scan Findings & Remediation Plan

Aperta
#295 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@Muneerali199 ci sta già lavorando.

Dal 8/3/2026.

  • #296 di @Muneerali199 — aperta
  • #297 di @Muneerali199 — aperta
  • #298 di @Muneerali199 — aperta

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
python, react, sql, typescript

Direzione di ricerca

Inizia esaminando i file elencati, cominciando da backend/app/database/supabase/scripts/populate_db.sql e backend/app/database/falkor/code-graph-backend/static/index.html, quindi esamina tests/test_c_analyzer.py e tests/test_graph_ops.py per verificare la copertura pertinente. Conferma ogni rilevazione SAST rispetto al codice sorgente, concorda ambiti circoscritti e considera il lavoro completato quando ogni elemento accettato della checklist è stato affrontato e verificato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Is there an existing issue for this?
  • I have searched the existing issues
What happened?

📌 Context & Executive Summary

As part of an initiative to improve the security posture and code maintainability of Devr.AI, I ran a comprehensive Static Application Security Testing (SAST) scan on the codebase using Code Guardian.

The scan analyzed 243 files (20,770 lines) and identified several high-priority security vulnerabilities, reliability concerns, and areas with high cognitive complexity. I have manually reviewed the automated findings to filter out false positives and categorize the legitimate issues below.


🔒 1. Security: Potential Hardcoded Secrets (API Keys)

Severity: High | Confidence: Medium (60%)

Description:
The scanner detected Heroku API keys within the database population scripts. While these are highly likely to be "dummy" or mock keys used for local testing, hardcoded secrets (even fake ones) trigger automated security alerts and create alert fatigue. If these are active keys, this is a critical security risk.

Locations:

  • backend/app/database/supabase/scripts/populate_db.sql (Lines: 13, 23, 33)

Recommended Fix:

  • Replace the hardcoded strings with obvious placeholder text (e.g., <YOUR_MOCK_HEROKU_KEY>) or migrate these values to an .env.example file so they can be loaded via environment variables during local setup.

⚡ 2. Security: Dynamic Code Execution Risks

Severity: High | Confidence: High (80%)

Description:
The scan flagged several instances where dynamic code is being executed (likely via eval(), exec(), or unsafe innerHTML injections). If any of these execution paths process unsanitized user or third-party input, it exposes the application to Cross-Site Scripting (XSS) or Arbitrary Code Execution vulnerabilities.

Locations:

  • backend/app/database/falkor/code-graph-backend/static/index.html (Lines: 79, 108, 113)
  • backend/app/database/falkor/code-graph-backend/tests/test_c_analyzer.py (Lines: 38, 46)
  • backend/app/database/falkor/code-graph-backend/tests/test_graph_ops.py (Line: 15)

Recommended Fix:

  • Review the flagged lines to ensure no user-controlled data is passed to dynamic execution functions. Replace eval() with safer alternatives like JSON.parse() (if parsing data) or use safe DOM manipulation APIs.

🐛 3. Reliability: Unhandled Promises (Silent Failures)

Severity: High | Confidence: Very High (90%)

Description:
Asynchronous Promises are being executed without proper error handling. If the underlying API request or operation fails, the application will fail silently. This leads to a degraded user experience where the UI does not reflect the error state, making debugging incredibly difficult.

Locations:

  • backend/app/database/falkor/code-graph-backend/static/index.html (Lines: 117, 130)

Recommended Fix:

  • Wrap the asynchronous logic in try/catch blocks (if using async/await) or append .catch(err => ...) chains to handle and properly log the UI errors.

🧹 4. Code Quality: High Cognitive Complexity & Tech Debt

Severity: Medium | Impact: Developer Experience / Maintainability

Description:
Several core React components and backend Python scripts have grown too long and possess high cognitive complexity. In an open-source environment, highly complex files create friction for new contributors trying to understand the codebase.

Locations:
Frontend:

  • frontend/src/components/pages/LoginPage.tsx (Line 50)
  • frontend/src/components/pages/ResetPasswordPage.tsx (Line 49)
  • frontend/src/components/pages/SettingsPage.tsx (Line 12)
  • frontend/src/components/pages/SignUpPage.tsx (Line 51)
  • frontend/src/components/pages/SupportPage.tsx (Line 54)

Backend:

  • backend/app/database/falkor/code-graph-backend/api/prompts.py (Line 24)

Recommended Fix:

  • Refactor these large pages by abstracting reusable logic into Custom React Hooks (useAuth, etc.) and breaking down the UI into smaller, modular components.

🚫 False Positives Identified (No Action Required)

During my manual review of the scan, the tool flagged multiple GitHub Issue Templates (.github/ISSUE_TEMPLATE/*.yml) for "Use of 'any' type reduces type safety".
This is a scanner bug caused by a TypeScript linting rule being incorrectly applied to plain English text inside YAML files. I have filtered these out, and the .github directory requires no changes.


✅ Proposed Action Plan (Checklist)

I would love to help resolve these issues to improve the project! If the maintainers agree with these findings, we can break this down into the following PRs:

  • PR 1: Sanitize populate_db.sql and remove hardcoded mock keys.
  • PR 2: Add error handling/catch blocks to Promises in index.html.
  • PR 3: Audit and refactor dynamic code execution in the falkor submodule.
  • PR 4: Refactor and modularize the flagged frontend components to reduce tech debt.

@Maintainers: Please let me know which of these you consider the highest priority, and I would be happy to be assigned to work on it! 🚀

Record
  • I agree to follow this project's Code of Conduct
  • I want to work on this issue
Lingua principale
Python
Stelle
103
Fork
143
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/Devr.AI

Tutte le issue di AOSSIE-Org/Devr.AI

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.