系列
- 1 分鍾快速使用 Docker 上手最新版 Sentry-CLI - 創建版本
- 快速使用 Docker 上手 Sentry-CLI - 30 秒上手 Source Maps
- Sentry For React 完整接入詳解
- Sentry For Vue 完整接入詳解
- Sentry-CLI 使用詳解
- Sentry Web 性能監控 - Web Vitals
- Sentry Web 性能監控 - Metrics
- Sentry Web 性能監控 - Trends
- Sentry Web 前端監控 - 最佳實踐(官方教程)
- Sentry 后端監控 - 最佳實踐(官方教程)
- Sentry 監控 - Discover 大數據查詢分析引擎
- Sentry 監控 - Dashboards 數據可視化大屏
- Sentry 監控 - Environments 區分不同部署環境的事件數據
目錄
Content-Security-Policy
Expect-CT
HTTP Public Key Pinning
- 附加配置
Sentry 21.8.0
開源版生產截圖
Sentry
能夠通過設置適當的 HTTP header
來收集有關 Content-Security-Policy (CSP)
違規行為以及 Expect-CT
和 HTTP Public Key Pinning (HPKP)
失敗(failures
)的信息,這會讓違規/失敗(violation/failure)
發送到 report-uri
中指定的 Sentry
端點。
Content-Security-Policy (CSP)
:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-PolicyExpect-CT
:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CTHTTP Public Key Pinning (HPKP)
:https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning
Content-Security-Policy
Content-Security-Policy (CSP)
是一種安全標准,有助於防止跨站點腳本 (XSS)
、點擊劫持(clickjacking)
和其他由於在受信任的網頁上下文中執行惡意內容而導致的代碼注入攻擊。它由瀏覽器廠商強制執行,Sentry
支持使用標准報告 Hook
捕獲 CSP
違規。
要在 Sentry
中配置 CSP
報告,您需要從服務器發送一個 header
來描述您的策略,並指定經過身份驗證的 Sentry
端點:
Content-Security-Policy: ...; report-uri https://o0.ingest.sentry.io/api/0/security/?sentry_key=examplePublicKey
或者,您可以設置 CSP
報告以簡單地發送報告而不是實際執行策略:
Content-Security-Policy-Report-Only: ...; report-uri https://o0.ingest.sentry.io/api/0/security/?sentry_key=examplePublicKey
在定義您的策略時,確保 sentry.io
或您的自托管 sentry 域
在您的 default-src
或 connect-src
策略中很重要,否則瀏覽器將阻止提交違反策略的請求。
有關更多信息,請參閱 MDN
上的文章。
Expect-CT
Certificate Transparency (CT)
是一種安全標准,可幫助跟蹤和識別有效證書,允許識別惡意頒發的證書。
要在 Sentry
中配置報告,您需要從服務器配置 Expect-CT
header:
Expect-CT: ..., report-uri="https://o0.ingest.sentry.io/api/0/security/?sentry_key=examplePublicKey"
有關更多信息,請參閱 MDN
上的文章。
HTTP Public Key Pinning
HTTP Public Key Pinning (HPKP)
是一種安全功能,它告訴 Web 客戶端
將特定的加密公鑰(public key
)與某個 Web 服務器
相關聯,以降低使用偽造證書進行 MITM
攻擊的風險。 它由瀏覽器廠商強制執行,Sentry
支持使用標准報告 Hook
捕獲違規行為。
要在 Sentry
中配置 HPKP
報告,您需要從服務器發送一個 header
來描述您的策略,並指定經過身份驗證的 Sentry 端點:
Public-Key-Pins: ...; report-uri="https://o0.ingest.sentry.io/api/0/security/?sentry_key=examplePublicKey"
有關更多信息,請參閱 MDN
上的文章。
附加配置
除了 sentry_key
參數,您還可以在 report URI
的查詢字符串中傳遞以下內容:
sentry_environment
- 環境名稱(例如
production
)。
sentry_release
- 應用程序的版本。