定制 experius/module-csp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

experius/module-csp

Composer 安装命令:

composer require experius/module-csp

包简介

Provide a basic Content Security Policy Allowed List and report blocked resources.

README 文档

README

experius/module-csp

Installation

In production please use the --keep-generated option

  • Install the module composer by running composer require experius/module-csp
  • enable the module by running php bin/magento module:enable Experius_Csp
  • apply database updates by running php bin/magento setup:upgrade
  • Flush the cache by running php bin/magento cache:flush

Main Functionalities

Provide a basic Content Security Policy allowed-list (whitelist) and when the Resource should be blocked it will automatically be reported within the Experius CSP Report Table (experius_csp_report).

When there is a report of a blocked directive is found, an error message will be show in the admin to notify the developer/client.

These reports can be whitelisted for directive which allow this. See "Content Security Policy Reporting & whitelisting" below for an example and more details.

IMPORTANT: Content Security Policy Report Only Mode

In the upcoming Magento 2.4 Release then the Content Security Policy Report Only Mode then will be disabled and it will validate strict.

The report-to has been disabled in this version because it is not working properly. See: \Experius\Csp\Plugin\Magento\Framework\App\Response\HttpInterface::beforeSetHeader

Basic allowed list

Currently this module contains a basic whitelist of considerd "safe" sources.

A few examples:

  • Google Fonts
  • Google Maps
  • Dotdigital / Dotmailer Chat
  • Buckaroo
  • etc.

For a full list for each directive, please check the following file:

etc/csp_whitelist.xml

Content Security Policy Reporting & whitelisting

In the Magento Admin you can view the reports which are created.

System > Tools > CSP reporting & whitelist

Scheme

To avoid clutter a counter is introduced, which prevents the table from growing in size excessively with many pageviews. This is grouped by "violated_directive", "blocked_uri" and "document_uri".

@TODO: [Nice to have] consider letting louse "document_uri", since whitelist is applied across the entire Magento installation (globally).

Add a resource to the allowed list permanently

Based on the reports you can easily add a csp_whitelist.xml file within your own modules and when you are done just delete the record because it no longer is relevant. More information about how this xml file works you can find here:

https://devdocs.magento.com/guides/v2.3/extension-dev-guide/security/content-security-policies.html

For example Report:

Fix:

# app/code/Custom/Csp/etc/csp_whitelist
<?xml version="1.0"?>
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
    <policies>
        <policy id="img-src">
            <values>
                <value id="gstatic" type="host">*.gstatic.com</value>
            </values>
        </policy>
    </policies>
</csp_whitelist>

experius/module-csp 适用场景与选型建议

experius/module-csp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 87.34k 次下载、GitHub Stars 达 35, 最近一次更新时间为 2020 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 experius/module-csp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 experius/module-csp 我们能提供哪些服务?
定制开发 / 二次开发

基于 experius/module-csp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 87.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 35
  • 点击次数: 37
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 35
  • Watchers: 5
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2020-06-15