【发布时间】:2021-06-14 18:07:41
【问题描述】:
每次对我们的网站进行 PCI 扫描后,我都必须进入扫描结果并为 Google 翻译 cookie 的“Cookie 不使用安全属性”问题(PCI 失败条件)添加争议。有没有办法为谷歌翻译 cookie 设置这个属性?我在网上搜索过,但到目前为止什么也没找到,除了 Chrome 78 的一个旧 GitHub 问题,其中一张海报提到谷歌翻译,但只是说它遇到了与其他海报相同的问题。
服务器是 Windows Server 2016 上的 IIS 10。
这是我尝试过的。我将以下内容放入web.config,但传出的cookie仍然没有Secure属性。
<outboundRules rewriteBeforeCache="true">
<rule name="Add Secure" preCondition="No Secure" patternSyntax="Wildcard">
<match serverVariable="RESPONSE_Set_Cookie" pattern="*" negate="false" />
<action type="Rewrite" value="{R:0}; secure" />
<conditions />
</rule>
<rule name="Add HttpOnly" preCondition="No HttpOnly" patternSyntax="Wildcard">
<match serverVariable="RESPONSE_Set_Cookie" pattern="*" negate="false" />
<action type="Rewrite" value="{R:0}; HttpOnly" />
<conditions />
</rule>
<rule name="Add SameSite" preCondition="No SameSite" patternSyntax="Wildcard">
<match serverVariable="RESPONSE_Set_Cookie" pattern="*" negate="false" />
<action type="Rewrite" value="{R:0}; SameSite=None" />
<conditions />
</rule>
<preConditions>
<preCondition name="No Secure">
<add input="{RESPONSE_Set_Cookie}" pattern="." />
<add input="{RESPONSE_Set_Cookie}" pattern="; secure" negate="true" />
</preCondition>
<preCondition name="No HttpOnly">
<add input="{RESPONSE_Set_Cookie}" pattern="." />
<add input="{RESPONSE_Set_Cookie}" pattern="; HttpOnly" negate="true" />
</preCondition>
<preCondition name="No SameSite">
<add input="{RESPONSE_Set_Cookie}" pattern="." />
<add input="{RESPONSE_Set_Cookie}" pattern="; SameSite" negate="true" />
</preCondition>
</preConditions>
</outboundRules>
【问题讨论】:
-
使用上述规则,我现在正确地将
HttpOnly和SameSite=None属性设置为googtranscookie。但由于某种原因,它仍然没有应用secure属性。