[WordPress] 外掛分享: CSP Pilot

首頁 › 外掛目錄 › CSP Pilot
WordPress 外掛 CSP Pilot 的封面圖片
全新外掛
安裝啟用
—
尚無評分
剛更新
最後更新
—
問題解決
WordPress 6.0+ PHP 7.4+ v1.0.0 上架:2026-11-28

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「CSP Pilot」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

A Content Security Policy (CSP) is a rule set that your website sends to the browser. It states which sources a page may load scripts, images and other content from, and where it may send data to. Used carefully, it can limit the damage when a third-party script on your site is compromised, mainly by restricting where data can be sent (connect-src), and it makes violations visible.
CSP Pilot helps you introduce a policy without breaking your site, also on shared hosting without server access:

Guided rollout in five steps. Scan your site, observe in Report-Only mode, evaluate the reports, check that the header really arrives, then enforce. Every step explains why it exists and what can go wrong. The status of each step is calculated from real data (settings, site scan, reports, self-test), not ticked off by hand.
Presets for common services (Google Analytics 4, Tag Manager, reCAPTCHA, Cloudflare Web Analytics, Google Fonts, YouTube, Vimeo). Every entry comes from the service’s own documentation and shows its source and check date. You see a preview and confirm; nothing is removed.
Safe by default. The plugin starts in Report-Only mode: nothing is blocked. It never switches to Enforce by itself, and switching needs an explicit confirmation. An emergency switch in wp-config.php stops the header at once.
Built-in report endpoint. Browsers send violation reports to your own site (Reporting API and the older report-uri). They are summarised in the admin area, so you do not need an external reporting service.
Adopt source. A report for a host can be turned into a rule: you see a before/after preview of the directive and confirm. Inline code, eval, data:, blob: and browser extensions get an explanation instead of a button.
Site scan. On a button, the plugin reads pages of your own site (the home page, a page you pick, the login page or the 20 latest pages) like a visitor and shows which sources they use that your policy does not cover. Strict limits apply: only your own site, no cookies, no automatic redirects to other sites, time and size limits, one scan at a time. It sees only the delivered page and your own style sheets, not what scripts load later.
Draft for a stricter policy. In Enforce mode, a change that could block something is saved as a draft and sent as Report-Only next to the enforced policy, so real browsers test it first.
Guard rails. Values that practically switch a policy off in script-src and similar directives (https:, data:, whole top-level domains, public CDNs) are refused unless you confirm.
Take over rules of another policy (from a header found by the scan, or pasted): every rule is checked, safe ones are ticked, unsafe ones refused.
Self-test. Checks that exactly one policy arrives (a cache, a CDN or a second plugin can remove or double the header), that the report address is sent, and that a test report is stored.
Explanations for every setting. The plugin is fully translatable; translations are delivered through translate.wordpress.org.
Privacy-friendly. Only reduced data is stored: directive, blocked host or keyword, page path without query string and fragment, mode, time and a counter. No IP addresses, no user agents, no cookies, no full URLs. Reports are deleted automatically (7 to 90 days, default 30). A suggestion for your privacy statement is included (it is not legal advice).
No external services. No telemetry, no calls to other sites. The self-test and the site scan only request pages of your own site. See “External services” below.

What it does not do

There is no guarantee. A CSP is one layer of protection, not a complete defence, and a wrongly configured policy can break parts of your site. Always start in Report-Only mode and test your important pages.
The included “Basis” template allows inline scripts and styles ('unsafe-inline'), which is the usual WordPress compromise. This reduces the protection against injected code. It does not weaken the limit on where data can be sent.
No nonce or hash mode ('strict-dynamic' with nonces). Nonces do not work together with page caching, because all visitors would get the same value.
No crawler and no scan in the background. The site scan runs only when you press the button, and you decide which sources to allow.
It does not manage other security headers (HSTS, X-Content-Type-Options and so on).
It cannot guarantee compatibility with every plugin, theme or page builder. Front-end editors such as Elementor are excluded for logged-in administrators by default, and the header is not sent inside the Customizer preview and common page builders (checked with test doubles, not with every builder).

Requirements
PHP 7.4 or newer, WordPress 6.0 or newer. For the Reporting API (report-to) the site must be served over https; browsers fall back to report-uri otherwise.
External services
CSP Pilot does not connect to any external or third-party service. It sends no telemetry and loads no scripts, styles, fonts or images from other sites.
The only HTTP requests the plugin makes go to your own site, and only when you start them in the admin area:

Self-test (Settings → CSP Pilot → Self-test, on a button): requests your own home page to check which policy header arrives, and sends one test report to the report endpoint of your own site.
Site scan (on a button): requests pages of your own site (and its own style sheets) like a visitor. Addresses on other hosts are never requested; redirects to other sites are not followed.

No personal data is sent anywhere by these requests.
Service presets. The configuration offers presets for Google Analytics 4, Google Tag Manager, Google reCAPTCHA, Cloudflare Web Analytics, Google Fonts, YouTube and Vimeo. A preset only adds the host names of that service (for example https://www.googletagmanager.com) as text to your Content Security Policy header, after you preview and confirm it. CSP Pilot never contacts these services and does not embed them: the header only tells the visitor’s browser that your site may load content from them, which matters only if your site already uses the service (for example through another plugin or your theme). Using such a service is subject to its own terms and privacy policy, for example:

Google (Analytics, Tag Manager, reCAPTCHA, Fonts, YouTube): Terms of Service, Privacy Policy
Cloudflare Web Analytics: Website and Online Services Terms of Use, Privacy Policy
Vimeo: Terms of Service, Privacy Policy

The code also names a few public CDN hosts (for example cdn.jsdelivr.net), only to warn when you try to allow all of them for scripts, and the documentation pages each preset was taken from, which are shown as text in the admin area. None of these addresses is contacted by the plugin.

文章
Filter
Mastodon