deployecommerce/magento2-csp-writer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

deployecommerce/magento2-csp-writer

最新稳定版本:0.0.8

Composer 安装命令:

composer require deployecommerce/magento2-csp-writer

包简介

A PHP library to write a Magento 2/Adobe Commerce whitelist.xml file from a structured array.

README 文档

README

This library is a simple CSP writer for Magento 2.

It can be used to write a csp_whitelist.xml file given a structured array.

The policies array should be in the format:

$policies = [
    'default-src' => [
        [
            'type' => 'host',
            'name' => 'example.com',
            'value' => 'https://example.com',
            'directive' => 'default-src',
        ],
        [
            'type' => 'host',
            'name' => '*.example.com',
            'value' => '*.example.com',
            'directive' => 'default-src',
        ],
    ],
];

Create a writer instance and call the generate method with the structured array:

$writer = new DeployEcommerce\Csp\Writer\Magento2CspWriter();
$xml = $writer->generate($policies);

You'll then be returned the following XML to write to your csp_whitelist.xml file:

<?xml version="1.0" encoding="utf-8"?>
<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="default-src">
            <values>
                <value id="example.com" type="host">https://example.com</value>
                <value id="*.example.com" type="host">*.example.com</value>
            </values>
        </policy>
    </policies>
</csp_whitelist>

This can be used in conjunction with the DeployEcommerce/magento2-csp-parser package to parse an existing csp_whitelist.xml file and return you a structured array.

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2025-04-02