diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2021-07-16 16:27:00 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-17 04:27:00 +0800 |
| commit | b9afb23d12dcae1e09f8d04c72143c5ddaa34aea (patch) | |
| tree | f6c20844119bcaf0131ad4a037e0245577927f2c /files/zh-cn/conflicting/web/http | |
| parent | 1aa671566c3a990ec2df9a46137471d624b6f7ff (diff) | |
| download | translated-content-b9afb23d12dcae1e09f8d04c72143c5ddaa34aea.tar.gz translated-content-b9afb23d12dcae1e09f8d04c72143c5ddaa34aea.tar.bz2 translated-content-b9afb23d12dcae1e09f8d04c72143c5ddaa34aea.zip | |
delete conflicting/orphaned docs (zh-CN) (#1412)
* delete conflicting docs (zh-CN)
* and redirects
* do orphaned as well
* fix
* remove more orphans
* revert orphaned docs that can identify origin
* move orphaned docs to current loc
* adjust slug path
* fix redirect change from rebase
Co-authored-by: Irvin <irvinfly@gmail.com>
Diffstat (limited to 'files/zh-cn/conflicting/web/http')
5 files changed, 0 insertions, 456 deletions
diff --git a/files/zh-cn/conflicting/web/http/cors/index.html b/files/zh-cn/conflicting/web/http/cors/index.html deleted file mode 100644 index eb37a40e1d..0000000000 --- a/files/zh-cn/conflicting/web/http/cors/index.html +++ /dev/null @@ -1,250 +0,0 @@ ---- -title: Server-Side Access Control -slug: conflicting/Web/HTTP/CORS -tags: - - AJAX - - CORS - - HTTP - - PHP -translation_of: Web/HTTP/CORS -translation_of_original: Web/HTTP/Server-Side_Access_Control -original_slug: Web/HTTP/Server-Side_Access_Control ---- -<p>{{HTTPSidebar}}</p> - -<p>浏览器会针对从 {{domxref("XMLHttpRequest")}} 或<a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API">Fetch API</a>中发起的跨网站请求发送特定的<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers">HTTP标头</a>。它还希望看到使用跨站点响应发送回的特定HTTP标头。这些标头的概述,包括启动请求和处理来自服务器的响应的示例JavaScript代码, 以及每个头的讨论,可以在HTTP访问控制(<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS">CORS</a>)文章中找到,应该作为本文的配套文章阅读。</p> - -<p>HTTP访问控制文章是很好的使用指南。本文介绍利用PHP处理访问控制请求和制定访问控制响应。本文的目标读者是服务器程序员或管理员。虽然在PHP代码示例所示,类似的概念适用于ASP.net,Perl、Python、Java等;一般来说,这些概念可以应用于任何服务器端编程环境处理HTTP请求和动态制定的HTTP响应。</p> - -<h3 id="讨论HTTP标头"><strong>讨论HTTP标头</strong></h3> - -<p>了解HTTP 头部信息, 建议先阅读这篇文章 <a href="https://developer.mozilla.org/En/HTTP_access_control">covering the HTTP headers used by both clients (such as Firefox 3.5 and beyond) and servers</a></p> - -<div> </div> - -<h3 id="工作代码示例"><strong>工作代码示例</strong></h3> - -<p>随后的章节中PHP代码(和JavaScript调用服务器)可查看<a href="http://arunranga.com/examples/access-control/">相关代码</a>,这些代码在实现了XMLHttpRequest的浏览器上都可运行,像Firefox 3.5及以上。</p> - -<div> </div> - -<h3 id="简单的跨站请求"><strong>简单的跨站请求</strong></h3> - -<p><a class="internal" href="/En/HTTP_access_control#Simple_requests" title="En/HTTP access control#Simple requests">简单的访问控制请求</a> 在下列情况下会被发起:</p> - -<ul> - <li>请求方式为 HTTP/1.1 <code style="font-style: normal;">GET </code>或者<code style="font-style: normal;"> POST</code>,如果是<code style="font-style: normal;">POST</code>,则请求的Content-Type为以下之一: <code style="font-style: normal;">application/x-www-form-urlencoded</code>, <code style="font-style: normal;">multipart/form-data</code>, 或<code style="font-style: normal;">text/plain</code></li> - <li>在请求中,不会发送自定义的头部(如X-Modified)</li> -</ul> - -<p>以下情况,请求会返回相关响应信息</p> - -<ul> - <li>如果资源是允许公开访问的(就像任何允许GET访问的 HTTP资源),返回Access-Control-Allow-Origin:*头信息就足够了,除非是一些需要Cookies和HTTP身份验证信息的请求。</li> - <li> - <div class="tran-result">如果资源访问被限制基于相同的域名,或者如果要访问的资源需要凭证(或设置凭证),那么就有必要对请求头信息中的ORIGIN进行过滤,或者至少响应请求的来源(例如Access-Control-Allow-Origin:http://arunranga.com)。另外,将发送Access-Control-Allow-Credentials:TRUE头信息,这在后续部分将进行讨论。</div> - </li> -</ul> - -<p> <a class="internal" href="/En/HTTP_access_control#Simple_requests" title="En/HTTP access control#Simple requests">简单的访问控制请求</a> 介绍了在客户端和服务端进行信息交换的HEADER. 下面是一段用来处理简单请求的PHP代码。</p> - -<pre class="brush: php"><?php - -// 我们将只授予 arunranga.com 域的访问权限,因为我们认为它通过 application/xml 方式来访问这些资源是安全的。 - -if($_SERVER['HTTP_ORIGIN'] == "http://arunranga.com") -{ - - header('Access-Control-Allow-Origin: http://arunranga.com'); - header('Content-type: application/xml'); - readfile('arunerDotNetResource.xml'); -} -else -{ -header('Content-Type: text/html'); -echo "<html>"; -echo "<head>"; -echo " <title>Another Resource</title>"; -echo "</head>"; -echo "<body>", - "<p>This resource behaves two-fold:"; -echo "<ul>", - "<li>If accessed from <code>http://arunranga.com</code> it returns an XML document</li>"; -echo " <li>If accessed from any other origin including from simply typing in the URL into the browser's address bar,"; -echo "you get this HTML document</li>", - "</ul>", -"</body>", -"</html>"; -} -?> -</pre> - -<p>上面的代码通过检查浏览器发送的 <code>ORIGIN</code> 头部信息(通过<code> $_SERVER['HTTP_ORIGIN']</code> ) 是否匹配 '<a class="external" href="http://arunranga.com" rel="freelink" style="font-size: 14px; line-height: 1.5;">http://arunranga.com</a>' 得知,如果是,返回 Access-Control-Allow-Origin: <a class="external" href="http://arunranga.com" rel="freelink" style='font-size: 14px; line-height: 1.5; font-family: "Courier New","Andale Mono",monospace;'>http://arunranga.com</a> 。如果你的浏览器支持访问控制<span style="font-size: 14px; line-height: 1.5;">,你可以访问 <a class="external" href="http://arunranga.com/examples/access-control/" style="font-size: 14px; line-height: 1.5;" title="http://arunranga.com/examples/access-control/">这里 .</a></span></p> - -<h3 id="预请求"><strong>预请求</strong></h3> - -<p><a class="internal" href="/En/HTTP_access_control#Preflighted_requests" title="En/HTTP access control#Preflighted requests">预请求</a> 发生在下列情况中:</p> - -<ul> - <li>使用GET或POST以外的方法;利用POST发送<code style="font-style: normal;">application/x-www-form-urlencoded</code>, <code style="font-style: normal;">multipart/form-data</code>, or <code style="font-style: normal;">text/plain</code>之外的Content-Type;例如,post body的Content-type为<code style="font-style: normal;">application/xml</code></li> - <li>发送自定义的头信息,如x-pingaruner</li> -</ul> - -<p><a class="internal" href="/En/HTTP_access_control#Preflighted_requests" title="En/HTTP access control#Preflighted requests">预请求访问控制</a> 这篇文章介绍了在客户端和服务器间进行交换的<span style="font-size: 14px; line-height: 1.5;">头信息,响应preflight requests请求的服务器资源会有这些动作:</span></p> - -<ul> - <li> 基于 <code>ORIGIN </code>进行过滤</li> - <li> preflight请求的响应内容,包括必要的 <code>Access-Control-Allow-Methods</code>, <code>Access-Control-Allow-Headers</code> (保证系统正常运行),如果需要凭据的话,也会包括 <code>Access-Control-Allow-Credentials </code>头信息</li> - <li>响应实际请求,包括处理 POST数据等。</li> -</ul> - -<p>下面是相关的PHP内容, <a class="internal" href="/En/HTTP_access_control#Preflighted_requests" title="En/HTTP access control#Preflighted requests">preflighted request</a>:</p> - -<pre class="brush: php"><?php -if($_SERVER['REQUEST_METHOD'] == "GET") -{ - header('Content-Type: text/plain'); - echo "This HTTP resource is designed to handle POSTed XML input from arunranga.com and not be retrieved with GET"; - -} -elseif($_SERVER['REQUEST_METHOD'] == "OPTIONS") -{ - // 告诉客户端我们支持来自 arunranga.com 的请求并且预请求有效期将仅有20天 - if($_SERVER['HTTP_ORIGIN'] == "http://arunranga.com") - { - header('Access-Control-Allow-Origin: http://arunranga.com'); - header('Access-Control-Allow-Methods: POST, GET, OPTIONS'); - header('Access-Control-Allow-Headers: X-PINGARUNER'); - header('Access-Control-Max-Age: 1728000'); - header("Content-Length: 0"); - header("Content-Type: text/plain"); - //exit(0); - } - else - { - header("HTTP/1.1 403 Access Forbidden"); - header("Content-Type: text/plain"); - echo "You cannot repeat this request"; - - } -} -elseif($_SERVER['REQUEST_METHOD'] == "POST") -{ - /* 通过首先获得XML传送过来的blob来处理POST请求,然后做一些处理, 最后将结果返回客户端 - */ - if($_SERVER['HTTP_ORIGIN'] == "http://arunranga.com") - { - $postData = file_get_contents('php://input'); - $document = simplexml_load_string($postData); - - // 对POST过来的数据进行一些处理 - - $ping = $_SERVER['HTTP_X_PINGARUNER']; - - - header('Access-Control-Allow-Origin: http://arunranga.com'); - header('Content-Type: text/plain'); - echo // 处理之后的一些响应 - } - else - die("POSTing Only Allowed from arunranga.com"); -} -else - die("No Other Methods Allowed"); - -?> -</pre> - -<p>可以看到,就像POST一样,针对OPTIONS preflight请求,同样返回对应的头信息。这样 以来,处理preflight就像处理普通的request请求一样,在针对OPTIONS请求的响应信息中,服务器通过客户端,实际的请求可以用POST的形式发送,同时可附加X-PINGARUNERP这样的头信息。如果浏览器支持的话,可访问<a class="external" href="http://arunranga.com/examples/access-control/" style="line-height: 1.5;" title="http://arunranga.com/examples/access-control/"> 这里</a></p> - -<h3 id="凭证请求"><strong>凭证请求</strong></h3> - -<p>带凭据的请求,将Cookies和HTTP认证信息一起发送出去的跨域请求,根据请求方式,可以是<span style="line-height: 1.5;"> </span><a class="internal" href="/En/HTTP_access_control#Simple_requests" style="line-height: 1.5;" title="En/HTTP access control#Simple requests">Simple</a><span style="line-height: 1.5;"> 或 </span><a class="internal" href="/En/HTTP_access_control#Preflighted_requests" style="line-height: 1.5;" title="En/HTTP access control#Preflighted requests">Preflighted</a><span style="line-height: 1.5;">,</span></p> - -<p>发送 <a class="internal" href="/En/HTTP_access_control#Simple%20requests" title="En/HTTP access control#Simple requests">简单请求</a> 时, Firefox 3.5 (或以上)会发送带Cookies信息的请求, (如果<code>withCredentials</code> 设以true). 如果服务器响应真的是可信任的, 客户端接受并进行输出。 在 <a class="internal" href="/En/HTTP_access_control#Preflighted%20requests" title="En/HTTP access control#Preflighted requests">预请求</a> 中,服务器可以<span style="line-height: 1.5;">针对</span><span style="line-height: 1.5;"> </span><code style="font-style: normal; line-height: 1.5;">OPTIONS</code><span style="line-height: 1.5;"> 请求,返回</span><span style="line-height: 1.5;"> </span><code style="font-style: normal; line-height: 1.5;">Access-Control-Allow-Credentials: true</code><span style="line-height: 1.5;"> 信息</span></p> - -<p>下面是处理请求的PHP内容:</p> - -<pre class="brush: php"><?php - -if($_SERVER['REQUEST_METHOD'] == "GET") -{ - - // First See if There Is a Cookie - //$pageAccess = $_COOKIE['pageAccess']; - if (!isset($_COOKIE["pageAccess"])) { - - setcookie("pageAccess", 1, time()+2592000); - header('Access-Control-Allow-Origin: http://arunranga.com'); - header('Cache-Control: no-cache'); - header('Pragma: no-cache'); - header('Access-Control-Allow-Credentials: true'); - header('Content-Type: text/plain'); - echo 'I do not know you or anyone like you so I am going to mark you with a Cookie :-)'; - - } - else - { - - $accesses = $_COOKIE['pageAccess']; - setcookie('pageAccess', ++$accesses, time()+2592000); - header('Access-Control-Allow-Origin: http://arunranga.com'); - header('Access-Control-Allow-Credentials: true'); - header('Cache-Control: no-cache'); - header('Pragma: no-cache'); - header('Content-Type: text/plain'); - echo 'Hello -- I know you or something a lot like you! You have been to ', $_SERVER['SERVER_NAME'], ' at least ', $accesses-1, ' time(s) before!'; - } - -} -elseif($_SERVER['REQUEST_METHOD'] == "OPTIONS") -{ - // Tell the Client this preflight holds good for only 20 days - if($_SERVER['HTTP_ORIGIN'] == "http://arunranga.com") - { - header('Access-Control-Allow-Origin: http://arunranga.com'); - header('Access-Control-Allow-Methods: GET, OPTIONS'); - header('Access-Control-Allow-Credentials: true'); - header('Access-Control-Max-Age: 1728000'); - header("Content-Length: 0"); - header("Content-Type: text/plain"); - //exit(0); - } - else - { - header("HTTP/1.1 403 Access Forbidden"); - header("Content-Type: text/plain"); - echo "You cannot repeat this request"; - - } -} -else - die("This HTTP Resource can ONLY be accessed with GET or OPTIONS"); - - - -?> -</pre> - -<p>需要注意的是,在带凭据请求中, <code>Access-Control-Allow-Origin:</code> 头不能是通配符 "*",必须是一个有效的域名。 可参考这里 <a class="external" href="http://arunranga.com/examples/access-control/" title="http://arunranga.com/examples/access-control/">running here</a></p> - -<h3 id="Apache示例"><strong>Apache示例</strong></h3> - -<h4 id="限制对某些URI的访问"><strong>限制对某些URI的访问</strong></h4> - -<p>最有效的方法之一,利用Apache rewrite, 环境变量,还有headers使<code style="font-style: normal; line-height: 1.5;">Access-Control-Allow-*</code><span style="line-height: 1.5;"> 对某些特定的URI生效,比如,以无认证信息形式利用GET跨域请求api(.*).json。</span></p> - -<pre>RewriteRule ^/api(.*)\.json$ /api$1.json [CORS=True] -Header set Access-Control-Allow-Origin "*" env=CORS -Header set Access-Control-Allow-Methods "GET" env=CORS -Header set Access-Control-Allow-Credentials "false" env=CORS -</pre> - -<h3 id="参见"><strong>参见</strong></h3> - -<ul> - <li><a class="external" href="http://arunranga.com/examples/access-control/" title="http://arunranga.com/examples/access-control/">Examples of Access Control in Action</a></li> - <li><a class="internal" href="/En/HTTP_access_control" title="En/HTTP Access Control">HTTP Access Control covering the HTTP Headers</a></li> - <li><a class="internal" href="/en/DOM/XMLHttpRequest" title="En/XMLHttpRequest">XMLHttpRequest</a></li> - <li><a class="external" href="http://www.webfonts.info/wiki/index.php?title=%40font-face_support_in_Firefox" title="http://www.webfonts.info/wiki/index.php?title=@font-face_support_in_Firefox">Web Fonts</a></li> -</ul> diff --git a/files/zh-cn/conflicting/web/http/csp/index.html b/files/zh-cn/conflicting/web/http/csp/index.html deleted file mode 100644 index c9e88056a9..0000000000 --- a/files/zh-cn/conflicting/web/http/csp/index.html +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: 内容安全策略 (CSP) -slug: conflicting/Web/HTTP/CSP -translation_of: Web/HTTP/CSP -translation_of_original: Web/Security/CSP -original_slug: Web/Security/CSP ---- -<div>{{gecko_minversion_header("2.0")}}</div> - -<p><b>内容安全策略</b> (CSP, Content Security Policy) 是一个附加的安全层,用于帮助检测和缓解某些类型的攻击,包括跨站脚本 (XSS) 和数据注入等攻击。 这些攻击可用于实现从数据窃取到网站破坏或作为恶意软件分发版本等用途。</p> - -<p>尽管内容安全策略在 Firefox 4 中已经包含,使用 <code>X-Content-Security-Policy</code> 头部来实现,但它使用的是过时的 CSP 标准。Firefox 23 包含了更新的 CSP 实现,使用的是 W3C CSP 1.0 标准中描述的没有前缀的 <code>Content-Security-Policy</code> 头部和指令。</p> - -<h2 id="内容安全策略主题">内容安全策略主题</h2> - -<dl> - <dt><a href="/zh-CN/docs/Security/CSP/Introducing_Content_Security_Policy">介绍内容安全策略</a></dt> - <dd>概述什么是 CSP,以及它如何让你的网站变得更安全。</dd> - <dt><a href="/zh-CN/docs/Security/CSP/CSP_policy_directives">CSP 策略指令</a></dt> - <dd>CSP 策略指令参考。</dd> - <dt><a href="/zh-CN/docs/Security/CSP/Using_Content_Security_Policy">使用内容安全策略</a></dt> - <dd>你可以通过配置策略集调整 CSP 的行为。这让你可以按需对个别类型的资源使用宽松或严格的安全策略。这篇文章讲述了如何建立 CSP 和如何激活你网站的 CSP。</dd> - <dt><a href="/zh-CN/docs/Security/CSP/Using_CSP_violation_reports">使用 CSP 违规报告</a></dt> - <dd>如何使用 CSP 违规报告来监视攻击你网站的尝试和攻击者。</dd> - <dt><a href="/zh-CN/docs/Security/CSP/Default_CSP_restrictions">默认 CSP 限制 </a>{{obsolete_inline("15.0")}}</dt> - <dd>CSP 强制实施的默认限制的细节</dd> -</dl> - -<h2 id="另请参阅">另请参阅</h2> - -<ul> - <li><a href="/zh-CN/docs/Security">Security</a></li> - <li><a href="/zh-CN/docs/HTTP_access_control">HTTP access control</a></li> - <li><a class="link-https" href="http://www.w3.org/TR/CSP/">CSP 1.0 specification</a></li> - <li><a class="link-https" href="https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html">CSP 1.1 specification</a></li> - <li><a href="/docs/Apps/CSP">CSP restrictions for Open Web Apps</a></li> -</ul> diff --git a/files/zh-cn/conflicting/web/http/csp_9583294484b49ac391995b392c2b1ae1/index.html b/files/zh-cn/conflicting/web/http/csp_9583294484b49ac391995b392c2b1ae1/index.html deleted file mode 100644 index aad26533cd..0000000000 --- a/files/zh-cn/conflicting/web/http/csp_9583294484b49ac391995b392c2b1ae1/index.html +++ /dev/null @@ -1,98 +0,0 @@ ---- -title: Using CSP violation reports -slug: conflicting/Web/HTTP/CSP_9583294484b49ac391995b392c2b1ae1 -translation_of: Web/HTTP/CSP -translation_of_original: Web/Security/CSP/Using_CSP_violation_reports -original_slug: Web/Security/CSP/Using_CSP_violation_reports ---- -<p>{{ gecko_minversion_header("2.0") }}{{ draft() }}</p> - -<p>CSP其中的一个强大的特性是它为web站点管理员提供了生成和报告详细的站点攻击的描述信息。这些报告通过HTTP的POST请求发送到预先你指定的一个或多个服务器上,这些服务器可以通过 <a href="/en/Security/CSP/CSP_policy_directives#report-uri" title="en/Security/CSP/CSP policy directives#report-uri"><code>report-uri</code></a> 策略来制定。发送的报告是JSON格式的,对于非ASCII字符,其使用了默认的JSON UTF-8编码。本文将向你展示如何在你的站点上配置报告,以及报告的格式。</p> - -<p>对于支持CSP的浏览器,只要你制定了合法的 <a href="/en/Security/CSP/CSP_policy_directives#report-uri" style="text-decoration: underline;" title="en/Security/CSP/CSP policy directives#report-uri"><code>report-uri</code></a> 指令,任何违背该策略的攻击操作都会被浏览器所报告。</p> - -<h2 id="开启报告">开启报告</h2> - -<p>默认情况下,攻击是不会被报告的。要开启报告模式,你要指定 <a href="/en/Security/CSP/CSP_policy_directives#report-uri" title="en/Security/CSP/CSP policy directives#report-uri"><code>report-uri</code></a> 指令,这个指令包含了至少一个用于接收报告的URI:</p> - -<pre>Content-Security-Policy: default-src self; report-uri http://reportcollector.example.com/collector.cgi -</pre> - -<p>然后,你要搭建接受报告的服务器;它可以对报告进行存储和并进行适时的处理。</p> - -<p>注意:Firefox 23以前的版本所使用的报告头为 X-Content-Security-Policy。这个头在将来将被废弃。</p> - -<h2 id="攻击报告的语法">攻击报告的语法</h2> - -<p>报告的JSON对象包含了以下的数据:</p> - -<dl> - <dt><code>document-uri</code></dt> - <dd>当前攻击所发生的文档的URI。</dd> - <dt><code>referrer</code></dt> - <dd>当前攻击所发生的文档的来源页面的URI。</dd> - <dt><code>blocked-uri</code></dt> - <dd>被CSP策略所拦截的资源的URI。如果被拦截资源的URI属于与当前文档不同的来源,则所拦截的资源URI会被削减至只剩scheme,host和port三部分。</dd> - <dt><code>violated-directive</code></dt> - <dd>攻击所针对的策略部分的名称</dd> - <dt><code>original-policy</code></dt> - <dd>由X-Content-Security-Policy头指定的原始策略。</dd> -</dl> - -<h2 id="Sample_violation_report">Sample violation report</h2> - -<h2 id="攻击报告的样例">攻击报告的样例</h2> - -<div>在CSP规范中,已经有一个样例展示攻击报告。这里我们来看另一个例子。</div> - -<div> </div> - -<div>假设有一个页面叫做<a class="external" href="http://example.com/signup.html" rel="freelink" style="font-family: Consolas, Monaco, 'Andale Mono', monospace;">http://example.com/signup.html</a>. 它使用了一下的策略,它禁止从除cdn.example.com以外的域加载样式表。</div> - -<div> -<pre>Content-Security-Policy: default-src 'none'; style-src cdn.example.com; report-uri /_/csp-reports -</pre> -</div> - -<div>signup.html的HTML则像下面这样:</div> - -<pre class="brush: html"><!DOCTYPE html> -<html> - <head> - <title>Sign Up</title> - <link rel="stylesheet" href="css/style.css"> - </head> - <body> - ... Content ... - </body> -</html> -</pre> - -<div><span style="line-height: 22.0080013275147px;">看到问题了么?在策略中指明样式表只能从cdn.example.com加载,而这个页面则试图从它本域(http://example.com)下载样式表. 浏览器基于强制CSP的开启,在这个页面被访问时,将以下的报告通过POST请求发送到 </span><a href="http://example.com/_/csp-reports" rel="freelink" style="font-family: Consolas, Monaco, 'Andale Mono', monospace;">http://example.com/_/csp-reports</a><span style="line-height: 22.0080013275147px;"> 下</span></div> - -<pre>{ - "csp-report": { - "document-uri": "http://example.com/signup.html", - "referrer": "", - "blocked-uri": "http://example.com/css/style.css", - "violated-directive": "style-src cdn.example.com", - "original-policy": "default-src 'none'; style-src cdn.example.com; report-uri /_/csp-reports" - } -} -</pre> - -<p><span style="line-height: 22.0080013275147px;">我们可以看到,这个报告在blocked-uri中包含了错误资源的整个路径。而这并非总是这样。例如,当signup.html试图从</span><a href="http://anothercdn.example.com/stylesheet.css" style="text-decoration: underline;"><code>http://anothercdn.example.com/stylesheet.css</code></a><span style="line-height: 22.0080013275147px;">加载css的时候,浏览器只会记录来源(http://anothercdn.example.com)而不会记录完整的路径。CSP规范中对这一行为进行了</span><a href="http://www.w3.org/TR/CSP/#violation-reports">解释</a>。总结一下<span style="line-height: 22.0080013275147px;">,CSP的作用是放置跨域信息的泄露。值得注意的是,规范中的</span> <a href="http://www.w3.org/TR/CSP/#sample-violation-report">攻击报告范例</a> 有一处错误(其中blocked-uri应该是"http://evil.example.com")。</p> - -<h2 id="更多参考">更多参考</h2> - -<ul> - <li><a href="/en/Security/CSP/Introducing_Content_Security_Policy" title="en/Security/CSP/Introducing Content Security Policy">Introducing Content Security Policy</a></li> - <li><a href="/en/Security/CSP/Using_Content_Security_Policy" title="en/Security/CSP/Using Content Security Policy">Using Content Security Policy</a></li> - <li><a href="/en/Security/CSP/CSP_policy_directives" title="en/Security/CSP/CSP policy directives">CSP policy directives</a></li> -</ul> - -<div class="noinclude"> -<p>{{ languages( { "ja": "ja/Security/CSP/Using_CSP_violation_reports" } ) }}</p> -</div> - -<p> </p> diff --git a/files/zh-cn/conflicting/web/http/csp_aeae68a149c6fbe64e541cbdcd6ed5c5/index.html b/files/zh-cn/conflicting/web/http/csp_aeae68a149c6fbe64e541cbdcd6ed5c5/index.html deleted file mode 100644 index 8b035b39df..0000000000 --- a/files/zh-cn/conflicting/web/http/csp_aeae68a149c6fbe64e541cbdcd6ed5c5/index.html +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: 内容安全策略介绍 -slug: conflicting/Web/HTTP/CSP_aeae68a149c6fbe64e541cbdcd6ed5c5 -tags: - - 介绍 - - 内容安全策略 - - 安全 -translation_of: Web/HTTP/CSP -translation_of_original: Web/Security/CSP/Introducing_Content_Security_Policy -original_slug: Web/Security/CSP/Introducing_Content_Security_Policy ---- -<p>{{ gecko_minversion_header("2") }}</p> - -<p><strong>内容安全策略</strong> (CSP) 是一个附加的安全层,用于帮助检测和缓解某些类型的攻击,包括跨站脚本 (XSS) 和数据注入等攻击。 这些攻击可用于实现从数据窃取到网站破坏或作为恶意软件分发版本等用途。</p> - -<p>CSP被设计成向后兼容;不支持的浏览器依然可以运行使用了它的服务器页面,反之亦然。不支持CSP的浏览器会忽略它,像平常一样运行,默认对网页内容使用标准的同源策略。如果网站不提供CSP头部,浏览器同样会使用标准的<a href="/zh-CN/docs/Same_origin_policy_for_JavaScript">同源策略</a>。</p> - -<p>开启CSP就如配置您的页面服务来返回<code>Content-Security-Policy</code> HTTP 头部一样简单. (Firefox 23之前的版本使用的是<code>X-Content-Security-Policy</code> ). 查看 <a href="/en/Security/CSP/Using_Content_Security_Policy" title="en/Security/CSP/Using Content Security Policy">Using Content Security Policy</a> 获取如何配置和开启CSP的细节</p> - -<div class="note"><strong>提示:</strong> 内容安全策略<a class="link-https" href="https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#meta-http-equiv--x-content-security-policy---html-element" title="https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#meta-http-equiv--x-content-security-policy---html-element">标准特点</a> 是一种能被 {{ HTMLElement("meta") }}元素来配置的一种协议,但这种做法仍未被Firefox支持, 支持这种做法是被添加在<a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=663570" title="https://bugzilla.mozilla.org/show_bug.cgi?id=663570">bug 663570</a>.</div> - -<h2 id="减少跨域脚本">减少跨域脚本</h2> - -<p>CSP的主要目标是减少和报告XSS攻击. XSS攻击利用浏览器对从服务器接受的内容的信任。恶意的脚本在受害的浏览器被执行, 因为浏览器相信内容源,甚至当内容源并不是从它应该来的地方过来的。</p> - -<p>CSP使服务器管理员能够通过制定浏览器能够执行的可信赖脚本的域名来减少或者消除由XSS可能出现的矢量。 一个兼容CSP的浏览器将只会执行加载与白名单域名的源文件的脚本,忽略那些其他的脚本(包括内联脚本和事件操控HTML属性)</p> - -<p>作为一种最终的保护,想要禁止脚本的站点可以选择全局禁止脚本执行</p> - -<h2 id="减少数据包监听攻击">减少数据包监听攻击</h2> - -<p>为了重新约束内容被下载的域名, 服务端能够制定那种协议能够被使用;例如(理论上,从安全的立足点来看),一个服务制定所有的内容都通过HTTPS协议来加载</p> - -<div class="note"><strong>提示:</strong>一个完整地数据传输安全策略不单单包括通HTTPS加强数据的传输,还可以使所有cookie带上安全标志并且提供从HTTP页面到对应HTTPS页面的自动重定向。</div> - -<div class="note"><strong>提示:</strong>站点可能也会使用 <a href="/en/Security/HTTP_Strict_Transport_Security" title="/en/Security/HTTP_Strict_Transport_Security">Strict-Transport-Security</a> HTTP头部来确保浏览器只通过一个加密渠道来连接他们</div> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en/Security/CSP/Using_Content_Security_Policy" title="en/Security/CSP/Using Content Security Policy">Using Content Security Policy</a></li> - <li><a href="/en/Security/CSP/CSP_policy_directives" title="en/Security/CSP/CSP policy directives">CSP policy directives</a></li> - <li><a href="/en/Security/CSP/Using_CSP_violation_reports" title="en/Security/CSP/Using CSP violation reports">Using CSP violation reports</a></li> -</ul> - -<h2 id="Specification">Specification</h2> - -<ul> - <li>{{ spec("https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/latest.html", "Content Security Policy 1.1 (Editor's Draft)") }}</li> - <li>{{ spec("http://www.w3.org/TR/CSP/", "Content Security Policy 1.0 (Candidate Recommendation)") }}</li> -</ul> - -<div class="noinclude"> -<p>{{ languages( { "ja": "ja/Introducing_Content_Security_Policy" } ) }}</p> -</div> - -<p> </p> diff --git a/files/zh-cn/conflicting/web/http/status/index.html b/files/zh-cn/conflicting/web/http/status/index.html deleted file mode 100644 index cb0c385f77..0000000000 --- a/files/zh-cn/conflicting/web/http/status/index.html +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: HTTP response codes -slug: conflicting/Web/HTTP/Status -translation_of: Web/HTTP/Status -translation_of_original: Web/HTTP/HTTP_response_codes -original_slug: Web/HTTP/HTTP_response_codes ---- -<p>HTTP状态码(响应码)用来表明这个<a href="/zh-cn/HTTP" title="zh-cn/HTTP">HTTP</a> 请求是否已经成功完成.HTTP响应类型一共分五大类:消息响应,成功响应,重定向,客户端错误,服务器端错误.</p> -<p> </p> -<p><span class="long_text short_text" id="result_box" lang="zh-CN"><span>下表列出了</span><span>所有HTTP</span></span><span class="long_text short_text" lang="zh-CN"><span>状态码</span><span>,以及他们</span><span>各自所代表的含义</span><span>:</span></span></p> -<table class="standard-table" style="width: 100%;"> <thead> <tr> <th scope="col">状态码 </th> <th scope="col">原因短语</th> <th scope="col">代表含义</th> <th scope="col">HTTP 版本 </th> </tr> </thead> <tbody> <tr> <th colspan="4">消息响应</th> </tr> <tr> <td id="100">100 </td> <td>Continue<br> (继续)</td> <td>客户端应当继续发送请求.这个临时响应是用来通知客户端它的部分请求已经被服务器接收,且仍未被拒绝.客户端应当继续发送请求的剩余部分,或者如果请求已经完成,忽略这个响应.服务器必须在请求完成后向客户端发送一个最终响应.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="101">101</td> <td>Switching Protocol<br> (切换协议)</td> <td>服务器已经理解了客户端的请求,并将通过Upgrade消息头通知客户端采用不同的协议来完成这个请求。在发送完这个响应最后的空行后,服务器将会切换到 在Upgrade消息头中定义的那些协议。: 只有在切换新的协议更有好处的时候才应该采取类似措施。例如,切换到新的HTTP版本比旧版本更有优势,或者切换到一个实时且同步的协议以传送利用此类特 性的资源。</td> <td>HTTP/1.1 可用</td> </tr> <tr> <th colspan="4">成功响应</th> </tr> <tr> <td id="200">200</td> <td>OK<br> (成功)</td> <td>请求成功.成功的意义根据请求所使用的方法不同而不同. <ul> <li>GET: 资源已被提取,并作为响应体传回客户端.</li> <li>HEAD: <span class="long_text short_text" id="result_box" lang="zh-CN"><span>实体</span><span>头</span><span>已作为响应头传回客户端</span></span></li> <li>POST: 经过服务器处理客户端传来的数据,适合的资源作为响应体传回客户端.</li> <li>TRACE: <span class="long_text short_text" id="result_box" lang="zh-CN"><span>服务器</span><span>收到</span><span>请求消息</span></span>作为响应体传回客户端.</li> </ul> PUT, DELETE, 和 OPTIONS 方法永远不会返回 200 状态码.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="201">201</td> <td>Created<br> (已创建)</td> <td>请求成功,而且有一个新的资源已经依据请求的需要而建立,通常这是 PUT 方法得到的响应码.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="202">202</td> <td>Accepted<br> (已创建)</td> <td>服务器已接受请求,但尚未处理。正如它可能被拒绝一样,最终该请求可能会也可能不会被执行。在异步操作的场合下,没有比发送这个状态码更方便的做法了。:返回202状态码的响应的目的是允许服务器接受其他过程的请求(例如某个每天只执行一次的基于批处理的操作),而不必让客户端一直保持与服务器的连接直到批处理操作全部完成。在接受请求处理并返回202状态码的响应应当在返回的实体中包含一些指示处理当前状态的信息,以及指向处理状态监视器或状态预测的指针,以便用户能够估计操作是否已经完成。</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="203">203</td> <td>Non-Authoritative Information<br> (未授权信息)</td> <td> <p>服务器已成功处理了请求,但返回的实体头部元信息不是在原始服务器上有效的确定集合,而是来自本地或者第三方的拷贝,如果不是上述情况,使用200状态码才是最合适的.</p> </td> <td>HTTP/0.9 and 1.1</td> </tr> <tr> <td id="204">204</td> <td>No Content<br> (无内容)</td> <td>该响应没有响应内容,只有响应头,响应头也可能是有用的.用户代理可以根据新的响应头来更新对应资源的缓存信息.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="205">205</td> <td>Reset Content<br> (重置内容)</td> <td>告诉用户代理去重置发送该请求的窗口的文档视图.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="206">206</td> <td>Partial Content<br> (部分内容)</td> <td>当客户端通过使用range头字段进行文件分段下载时使用该状态码</td> <td>HTTP/1.1 可用</td> </tr> <tr> <th colspan="4">重定向</th> </tr> <tr> <td id="300">300</td> <td>Multiple Choice<br> (多种选择)</td> <td>该请求有多种可能的响应,用户代理或者用户必须选择它们其中的一个.服务器没有任何标准可以遵循去代替用户来进行选择.</td> <td>HTTP/1.0 and later</td> </tr> <tr> <td id="301">301</td> <td>Moved Permanently<br> (永久移动)</td> <td>该状态码表示所请求的URI资源路径已经改变,新的URL会在响应的<code>Location</code>:头字段里找到.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="302">302</td> <td>Found<br> (临时移动)</td> <td>该状态码表示所请求的URI资源路径临时改变,并且还可能继续改变.因此客户端在以后访问时还得继续使用该URI.新的URL会在响应的<code>Location:</code>头字段里找到.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="303">303</td> <td>See Other<br> (查看其他位置)</td> <td>服务器发送该响应用来引导客户端使用GET方法访问另外一个URI.</td> <td>HTTP/0.9 and 1.1</td> </tr> <tr> <td id="304">304</td> <td>Not Modified<br> (未修改)</td> <td>告诉客户端,所请求的内容距离上次访问并没有变化. 客户端可以直接从浏览器缓存里获取该资源.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="305">305</td> <td>Use Proxy<br> (使用代理)</td> <td>所请求的资源必须统过代理才能访问到.由于安全原因,该状态码并未受到广泛支持.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="306">306</td> <td><em>unused</em><br> (未使用)</td> <td><span class="long_text short_text" id="result_box" lang="zh-CN"><span>这个</span><span>状态码</span><span>已经不再被使用</span><span>,</span><span>当初它被用</span><span>在</span><span>HTTP 1.1规范</span><span>的</span><span>旧版本</span><span>中.</span></span></td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="307">307</td> <td>Temporary Redirect<br> (临时重定向)</td> <td> <p>服务器发送该响应用来引导客户端使用相同的方法访问另外一个URI来获取想要获取的资源.新的URL会在响应的<code>Location:</code>头字段里找到.与302状态码有相同的语义,且前后两次访问必须使用相同的方法(GET POST).</p> </td> <td>HTTP/1.1 可用</td> </tr> <tr> <td>308</td> <td>Permanent Redirect<br> (永久重定向)</td> <td> <p>所请求的资源将永久的位于另外一个URI上.新的URL会在响应的<code>Location:</code>头字段里找到.与301状态码有相同的语义,且前后两次访问必须使用相同的方法(GET POST).</p> <div class="note"><strong>注意:</strong> 这是个试验性的状态码,这里是<a class="external" href="http://greenbytes.de/tech/webdav/#draft-reschke-http-status-308" title="http://greenbytes.de/tech/webdav/#draft-reschke-http-status-308">规范草案</a>. <a href="/en/Firefox_14_for_developers" title="en/Firefox_14_for_developers">Firefox14</a>已经实现对该状态码的支持.</div> </td> <td> <p>HTTPbis <a class="external" href="http://greenbytes.de/tech/webdav/draft-reschke-http-status-308-05.html" title="http://greenbytes.de/tech/webdav/draft-reschke-http-status-308-05.html"></a><br> (试验草案)</p> </td> </tr> <tr> <th colspan="4">客户端错误</th> </tr> <tr> <td id="400">400</td> <td>Bad Request<br> (错误请求)</td> <td>因发送的请求语法错误,服务器无法正常读取.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="401">401</td> <td>Unauthorized<br> (未授权)</td> <td>需要身份验证后才能获取所请求的内容,类似于403错误.不同点是.401错误后,只要正确输入帐号密码,验证即可通过.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="402">402</td> <td>Payment Required<br> (需要付款)</td> <td><span class="long_text" id="result_box" lang="zh-CN"><span>该状态</span><span>码</span><span>被保留以</span><span>供将来使用.</span><span>创建此代码</span><span>最初的目的是</span><span>为</span><span>数字</span><span>支付系统而用</span><span>,</span><span>然而,到现在也没投入使用</span><span>.</span></span></td> <td>HTTP/0.9 and 1.1</td> </tr> <tr> <td id="403">403</td> <td>Forbidden<br> (禁止访问)</td> <td>客户端没有权利访问所请求内容,服务器拒绝本次请求.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="404">404</td> <td>Not Found<br> (未找到)</td> <td>服务器找不到所请求的资源.由于经常发生此种情况,所以该状态码在上网时是非常常见的.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="405">405</td> <td>Method Not Allowed<br> (不允许使用该方法)</td> <td>该请求使用的方法被服务器端禁止使用,RFC2616中规定, <code>GET</code> 和 <code>HEAD</code> 方法不能被禁止.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="406">406</td> <td>Not Acceptable<br> (无法接受)</td> <td>在进行<a href="/zh-cn/HTTP/Content_negotiation#Server-driven_negotiation" title="https://developer.mozilla.org/zh-cn/HTTP/Content_negotiation#Server-driven_negotiation"><span class="st">服务器驱动内容协商</span></a>后,没有发现合适的内容传回给客户端.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="407">407</td> <td>Proxy Authentication Required<br> (要求代理身份验证)</td> <td> <p>类似于状态码 401,不过需要通过代理才能进行验证.</p> </td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="408">408</td> <td>Request Timeout<br> (请求超时)</td> <td>客户端没有在服务器预备等待的时间内完成一个请求的发送.这意味着服务器将会切断和客户端的连接. 在其他浏览器中,这种响应更常见一些, 例如Chrome 和 IE9, 目的是为了使用 <a class="external" href="http://www.belshe.com/2011/02/10/the-era-of-browser-preconnect/" title="http://www.belshe.com/2011/02/10/the-era-of-browser-preconnect/">HTTP 预连机制</a> <span class="long_text short_text" id="result_box" lang="zh-CN"><span>加快浏览速度</span></span> (查看{{ bug("634278") }}, Firefox在未来版本中会实现这种机制). 同时注意,一些服务器不发送此种响应就直接切断连接.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="409">409</td> <td>Conflict<br> (冲突)</td> <td>该请求与服务器的当前状态所冲突.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="410">410</td> <td>Gone<br> (已失效)</td> <td>所请求的资源已经被删除.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="411">411</td> <td>Length Required<br> (需要内容长度头)</td> <td>因服务器在本次请求中需要 <code>Content-Length</code> 头字段,而客户端没有发送.所以,服务器拒绝了该请求.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="412">412</td> <td>Precondition Failed<br> (预处理失败)</td> <td>服务器没能满足客户端在获取资源时在请求头字段中设置的先决条件.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="413">413</td> <td>Request Entity Too Large<br> (请求实体过长)</td> <td>请求实体大小超过服务器的设置的最大限制,服务器可能会关闭HTTP链接并返回<code>Retry-After</code> 头字段.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="414">414</td> <td>Request-URI Too Long<br> (请求网址过长)</td> <td>客户端请求所包含的URI地址太长,以至于服务器无法处理.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="415">415</td> <td>Unsupported Media Type<br> (媒体类型不支持)</td> <td>服务器不支持客户端所请求的媒体类型,因此拒绝该请求.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="416">416</td> <td>Requested Range Not Satisfiable<br> (请求范围不合要求)</td> <td>请求中包含的<code>Range</code>头字段无法被满足,通常是因为<code>Range</code>中的数字范围超出所请求资源的大小.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="417">417</td> <td>Expectation Failed<br> (预期结果失败)</td> <td>在请求头<code> Expect</code> 中指定的预期内容无法被服务器满足.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <th colspan="4">服务器端错误</th> </tr> <tr> <td id="500">500</td> <td>Internal Server Error<br> (内部服务器错误)</td> <td>服务器遇到未知的无法解决的问题.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="501">501</td> <td>Implemented<br> (未实现)</td> <td>服务器不支持该请求中使用的方法,比如<code>POST</code> 和 <code>PUT.只有</code><code>GET</code> 和 <code>HEAD</code> 是RFC2616规范中规定服务器必须实现的方法.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="502">502</td> <td>Bad Gateway<br> (网关错误)</td> <td>服务器作为网关且从上游<span class="st">服务器获取到了一个无效的HTTP响应</span>.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="503">503</td> <td>Service Unavailable<br> (服务不可用)</td> <td>由于临时的服务器维护或者过载,服务器当前无法处理请求.这个状况是临时的,并且将在一段时间以后恢复.如果能够预计延迟时间,那么响应中可以包含一个<code>Retry-After:</code>头用以标明这个延迟时间.如果没有给出这个<code>Retry-After:</code>信息,那么客户端应当以处理500响应的方式处理它.同时,这种情况下,一个友好的用于解释服务器出现问题的页面应当被返回,并且,缓存相关的HTTP头信息也应该包含,因为通常这种错误提示网页不应当被客户端缓存.</td> <td>HTTP/0.9 可用</td> </tr> <tr> <td id="504">504</td> <td>Gateway Timeout <br> (网关超时)</td> <td>服务器作为网关且不能从上游<span class="st">服务器</span>及时的得到响应返回给客户端.</td> <td>HTTP/1.1 可用</td> </tr> <tr> <td id="505">505</td> <td>HTTP Version Not Supported<br> (HTTP版本不受支持)</td> <td>服务器不支持客户端发送的HTTP请求中所使用的HTTP协议版本.</td> <td>HTTP/1.1 可用 </td> </tr> </tbody> -</table> -<p> </p> -<p>{{ languages( { "en": "en/HTTP/HTTP_response_codes"} ) }}</p> |
