我不得不将CSP添加到具有内联样式的页面,并避免使用unsafe-inline我正在使用哈希.我添加哈希的技巧只是在Chrome中加载页面,查看错误消息并复制所有建议的哈希值(例如从中<suggested hash>获取Refused to apply inline style because it violates the following Content Security Policy directive: "style-src ...". Either the 'unsafe-inline' keyword, a hash ('<suggested hash>'), or... is required to enable inline execution.).
这解决了Firefox中的问题,但在Chrome中没有.奇怪的是,Chrome似乎并不尊重它本身产生的哈希值.这导致了一个有趣的情况,即Chrome列出包含哈希的策略,表示它不符合,然后建议我添加一个哈希,它在之前打印的策略中.
我的政策:
default-src 'none'; font-src 'self' data:; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' 'sha256-/3kWSXHts8LrwfemLzY9W0tOv5I4eLIhrf0pT8cU0WI=' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' 'sha256-OTeu7NEHDo6qutIWo0F2TmYrDhsKWCzrUgGoxxHGJ8o=' 'sha256-fviu5RwuBYFcCd5CDanhy6NCLufcwvCAbm061aSqhoQ=' 'sha256-wS7xf+bhXBr5EM064hQkAW0vX3ks5VoxbGn+KQC/Vhk=' 'sha256-cxL35Ug49Sl1zHMOdz/r0xinQ6BYGgClHdDCk2XPTzE='; object-src 'self'; connect-src 'self'
这会导致许多错误,例如:
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'sha256-/3kWSXHts8LrwfemLzY9W0tOv5I4eLIhrf0pT8cU0WI=' …
我gatsby build在Gatsby 站点上运行时遇到问题,该问题仅在 Github Actions 容器中运行时发生。它也不总是发生。作为一个很好的例子,今天 Dependabot 启动了 12 个 PR,其中两个因此错误而失败。错误显示如下:
$ gatsby build
??????????????????????????????????????????????????????????????????????????
? ?
? Gatsby collects anonymous usage analytics ?
? to help improve Gatsby for all users. ?
? ?
? If you'd like to opt-out, you can use `gatsby telemetry --disable` ?
? To learn more, checkout https://gatsby.dev/telemetry ?
? ?
??????????????????????????????????????????????????????????????????????????
success open and validate gatsby-configs - 0.035s
success load plugins - 0.892s
success onPreInit - 0.010s
success delete …Run Code Online (Sandbox Code Playgroud) 我发现当我将 JUnit 5 测试上传到 AWS 时失败,因为它希望找到格式为junit-<ver>.jar. 但是,JUnit 5 已将包名称更改为org.junit.jupiter.ap和org.junit.platform.commons。
这是否意味着 AWS Device Farm 不支持 JUnit 5?有没有计划很快支持它?
我有一个具有以下签名的异步方法:
public async Task UpdateMerchantAttributes(UpdateMerchantRequestModel model).
Run Code Online (Sandbox Code Playgroud)
该模型只有一个属性:
public Dictionary<string, string> Attributes { get; set; }
Run Code Online (Sandbox Code Playgroud)
有一段时间我用以下方式在测试中调用它:
await client.UpdateMerchantAttributes(new UpdateMerchantRequestModel { Attributes =
{
{"businessType", "0"}
}
});
Run Code Online (Sandbox Code Playgroud)
编译得很好,但NullReferenceException在该行上运行时引起了.我对此感到困惑,因为client它不是null,并且该行中没有引用任何其他内容(或者看起来一目了然).然后我尝试添加一个显式的Dictionary声明,如下所示:
await client.UpdateMerchantAttributes(new UpdateMerchantRequestModel { Attributes =
new Dictionary<string, string>
{
{"businessType", "0"}
}
});
Run Code Online (Sandbox Code Playgroud)
现在它传递得很好.这是我的错误,但如果这是一个编译错误而不是运行时空引用异常,那么这个错误将花费我更少的时间.所以我很好奇,为什么会这样呢?编译器是否认为我正在尝试定义一个dynamic并以某种方式解析为null?
我正在为在火星上驾驶的虚拟漫游车提供一些情报,以获取资源.我有以下代码:
public Point getPointFromRoverOffset(double offsetX, double offsetY) {
double x = offsetX + currentLocation.x;
double y = offsetY + currentLocation.y;
if(x > getWorldWidth()) {
x = x - getWorldWidth();
}
else if (x < 0) {
x = getWorldWidth() + x;
}
if(y > getWorldHeight()) {
y = y - getWorldHeight();
}
else if(y < 0) {
y = getWorldHeight() + y;
}
getLog().info("Based on location " + currentLocation.toString());
getLog().info("Decided that offset (" + offsetX + "," + offsetY + …Run Code Online (Sandbox Code Playgroud)