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

Đang mở
#295 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@Muneerali199 đang làm issue này rồi.

Từ ngày 8/3/2026.

  • #296 của @Muneerali199 — đang mở
  • #297 của @Muneerali199 — đang mở
  • #298 của @Muneerali199 — đang mở

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python, react, sql, typescript

Hướng nghiên cứu

Bắt đầu bằng việc xem xét các tệp được liệt kê, bắt đầu với backend/app/database/supabase/scripts/populate_db.sql và backend/app/database/falkor/code-graph-backend/static/index.html, sau đó kiểm tra tests/test_c_analyzer.py và tests/test_graph_ops.py để tìm phần coverage liên quan. Xác nhận từng phát hiện SAST với mã nguồn, thống nhất các phạm vi tập trung và coi công việc là hoàn tất khi từng mục checklist được chấp nhận đã được xử lý và xác minh.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
103
Fork
143
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AOSSIE-Org/Devr.AI

Tất cả issue của AOSSIE-Org/Devr.AI

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.