feat: enhance security audit and CSP configuration for admin interface
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
|
||||
### وضعیت رفع (۲۰۲۶-۰۷-۱۹)
|
||||
- **۱ — CSP:** `src/Shared/EventSubscriber/AdminCspSubscriber.php` افزوده شد؛ CSP فقط روی `/admin/*`. تأیید زنده: هدر `content-security-policy` روی `/admin` حاضر است. تست: `tests/Shared/AdminCspSubscriberTest.php` (۲ تست سبز).
|
||||
- **پیگیری (۲۰۲۶-۰۷-۲۳):** دو خطای کنسول CSP رفع شد. (الف) فونت Vazirmatn از CDN گوگل حذف شد (`templates/admin/index.html.twig`)؛ فونت از قبل بهصورت لوکال با `@fontsource` باندل میشود، پس CDN هم مسدود و هم زائد بود. (ب) هاستهای نقشهٔ کلینیک به CSP اضافه شد: `img-src` += `*.tile.openstreetmap.org unpkg.com`، `connect-src` += `nominatim.openstreetmap.org *.tile.openstreetmap.org`. بدون اینها نقشهٔ Leaflet در `ClinicDetailPage` خالی میماند. تست CSP به ۹ assertion رسید.
|
||||
- **مرتبط (غیرامنیتی):** باگ Service Worker در `public/sw.js` رفع شد — هندلر navigate در حالت آفلاین وقتی shell کش نشده بود `undefined` به `respondWith` میداد → خطای `Failed to convert value to 'Response'`؛ حالا fallback واقعی (Response 503) برمیگرداند.
|
||||
- **۳ — APP_SECRET:** مقدار واقعی از `.env.dev` برداشته و placeholder شد (مقدار واقعی باید در `.env.local` خارج از git بماند + rotate).
|
||||
- **۴ — cookie flags:** `config/packages/framework.yaml` → `cookie_secure: true`، `cookie_samesite: lax`، `cookie_httponly: true`. لینت YAML سبز، ۵۶ تست Shared/Smoke سبز.
|
||||
- **۲ — deps:**
|
||||
@@ -97,9 +99,9 @@ final class AdminCspSubscriber implements EventSubscriberInterface
|
||||
"default-src 'self'; "
|
||||
. "script-src 'self'; "
|
||||
. "style-src 'self' 'unsafe-inline'; " // Tailwind/CKEditor inline styles
|
||||
. "img-src 'self' data: blob:; "
|
||||
. "img-src 'self' data: blob: https://*.tile.openstreetmap.org https://unpkg.com; " // OSM tiles + Leaflet markers (clinic map)
|
||||
. "font-src 'self' data:; "
|
||||
. "connect-src 'self'; "
|
||||
. "connect-src 'self' https://nominatim.openstreetmap.org https://*.tile.openstreetmap.org; " // nominatim geocode + OSM tiles
|
||||
. "frame-ancestors 'none'; base-uri 'self'; object-src 'none'"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user