小编Jan*_*sky的帖子

为什么Chrome不尊重我的内容安全策略哈希值?

我不得不将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=' …

google-chrome content-security-policy

10
推荐指数
1
解决办法
2568
查看次数

Gatsby 在 GitHub Actions CI 中运行时抛出 SIGSEV 错误

gatsby buildGatsby 站点上运行时遇到问题,该问题仅在 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)

javascript gatsby github-actions gatsby-image

6
推荐指数
1
解决办法
889
查看次数

将 AWS Device Farm 与 JUnit 5 结合使用

我发现当我将 JUnit 5 测试上传到 AWS 时失败,因为它希望找到格式为junit-<ver>.jar. 但是,JUnit 5 已将包名称更改org.junit.jupiter.aporg.junit.platform.commons

这是否意味着 AWS Device Farm 不支持 JUnit 5?有没有计划很快支持它?

junit amazon-web-services aws-device-farm

5
推荐指数
1
解决办法
219
查看次数

为什么在字典中使用隐式集合初始化程序会导致C#中的运行时错误?

我有一个具有以下签名的异步方法:

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

c#

2
推荐指数
1
解决办法
90
查看次数

为什么Java给我带来双倍基本算术的不寻常结果?

我正在为在火星上驾驶的虚拟漫游车提供一些情报,以获取资源.我有以下代码:

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)

java double

1
推荐指数
1
解决办法
70
查看次数