Skip to content

fix: bug fixes, security headers, and resilience improvements - #2

Merged
canblmz1 merged 2 commits into
mainfrom
copilot/new-feature-branch
May 10, 2026
Merged

fix: bug fixes, security headers, and resilience improvements#2
canblmz1 merged 2 commits into
mainfrom
copilot/new-feature-branch

Conversation

Copilot AI commented May 9, 2026

Copy link
Copy Markdown
Contributor

Özet / Summary

Kodun baştan sona incelemesiyle bulunan hatalar düzeltildi, güvenlik iyileştirmeleri yapıldı ve yeni testler eklendi. Merge işlemi sana düşüyor.


Bug Fixes

Dosya Sorun Düzeltme
web_security.py int(raw_limit) geçersiz env var'da crash → sunucu düşüyor try/except + varsayılan 60'a fallback
web.py scan_id 12 karakter (çarpışma riski) 20 hex karaktere genişletildi
web.py CORS localhost:8787'ye hardcoded host:port'a göre dinamik hale getirildi
cli.py --port aralığı doğrulanmıyor (0 veya 99999 kabul ediliyordu) 1–65535 dışında reddediliyor
cli.py --plan kullanıldığında _validate_flags() çağrılmıyordu Plan öncesi flag çakışması kontrol edildi
cache_manager.py Yanıltıcı docstring: "SHA256 of file content" (path+size+mtime kullanıyor) Doğru açıklamayla güncellendi
scanner.py max_files parametresi fonksiyon içinde hiç kullanılmıyor Kasıtlı olduğu dokümante edildi

Security Improvements

  • HTTP güvenlik başlıkları middleware eklendi:
    • X-Content-Type-Options: nosniff
    • X-Frame-Options: DENY
    • Referrer-Policy: strict-origin-when-cross-origin
  • Rate limit env var parse hatası artık sunucuyu çökertmiyor
  • Scan ID entropisinin artırılması (12 → 20 karakter)

New Tests

  • Geçersiz rate-limit env var'ı (non-integer) varsayılana düşüyor
  • /api/health yanıtında güvenlik başlıkları doğrulanıyor
  • CORS'un yapılandırılmış port'u yansıttığı test ediliyor
  • CLI'da geçersiz port aralığı reddediliyor
  • --plan öncesi çakışan flagler yakalanıyor

Test Results

351 passed in 0.87s
ruff check: All checks passed!

Copilot AI and others added 2 commits May 9, 2026 15:25
Bug fixes:
- web_security: guard int() parse of rate-limit env var with try/except, fallback to 60
- web: extend scan_id from 12 to 20 hex chars (less collision-prone)
- web: remove hardcoded CORS origins; make them dynamic from configured host/port
- web: add comment explaining why background task re-validates inputs
- cli: reject --port values outside 1-65535 before starting the web server
- cli: call _validate_flags() before _run_plan to catch conflicting flag pairs
- cache_manager: fix misleading docstring (uses path+size+mtime, not file content)
- scanner: document that max_files is intentionally not enforced in scan_project

Security improvements:
- web: add HTTP security-headers middleware
  (X-Content-Type-Options, X-Frame-Options, X-XSS-Protection, Referrer-Policy)
- web: import Response so middleware type annotation is correct

Tests:
- test_web_rate_limit: add test for non-integer env var falling back to default
- test_security_hardening: add test for security headers on /api/health
- test_security_hardening: add test that CORS reflects configured port
- test_cli_plan: add test for invalid port rejection
- test_cli_plan: add test that _validate_flags is respected before --plan

Agent-Logs-Url: https://github.com/canblmz1/Project-Prompt-Generator/sessions/f1dcb32b-a53f-40c7-9d47-673a5fc64b72

Co-authored-by: canblmz1 <116688414+canblmz1@users.noreply.github.com>
Copilot AI requested a review from canblmz1 May 9, 2026 15:28
@canblmz1
canblmz1 marked this pull request as ready for review May 10, 2026 12:09
@canblmz1
canblmz1 merged commit d58ecc4 into main May 10, 2026
6 checks passed
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.

2 participants