# hotchand/magento-2-content-security-policy-csp-whitelist-manager architecture

> Architecture diagram of the GitHub repository hotchand/magento-2-content-security-policy-csp-whitelist-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager
- Repository: https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager

## Overview

Hotchand_CspManager is a Magento 2 admin-configurable CSP whitelist module. Administrators configure per-store directive domains, inline-script hashes, and an optional image domain; Magento’s CSP collector pipeline reads these settings, merges and sanitizes policies, and returns them for header rendering. The README documents the admin UI and DI registration; the sampled collector excerpt shows scoped configuration reads and policy processing. Other configuration files are present in the tree but were not sampled, so their detailed wiring is not inferred.

Main entry points: [`Model/CspPolicyCollector.php`](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php) (CSP Collector), [`etc/adminhtml/system.xml`](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/adminhtml/system.xml) (CSP Settings UI), [`etc/config.xml`](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/config.xml) (Default Whitelists), [`etc/di.xml`](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/di.xml) (Collector Registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_admin["Admin Configuration"]
  node_config_ui["CSP Settings UI<br/>[system.xml]"]
  node_admin_access["Admin Permissions<br/>[acl.xml]"]
  node_default_values["Default Whitelists<br/>[config.xml]"]
end

subgraph group_policy["Policy Collection"]
  node_enabled_check["Enable Check"]
  node_domain_lists["Directive Domains"]
  node_inline_hashes["Inline Hashes"]
  node_image_domain["Image Domain"]
  node_policy_merge["Policy Merge"]
  node_policy_sanitize["Policy Sanitization"]
  node_collector["CSP Collector"]
end

subgraph group_magento["Magento CSP Runtime"]
  node_di_registration["Collector Registration<br/>[di.xml]"]
  node_collector_pipeline["Magento Collector Pipeline"]
  node_csp_header["CSP Header"]
end

node_administrator(("Administrator"))
node_store_config[("Store Configuration")]

node_administrator -->|"edits"| node_config_ui
node_config_ui -->|"saves settings"| node_store_config
node_default_values -.->|"provides defaults"| node_store_config
node_di_registration -->|"registers collector"| node_collector_pipeline
node_collector_pipeline -->|"invokes collection"| node_collector
node_collector -->|"checks setting"| node_enabled_check
node_collector -->|"reads domains"| node_domain_lists
node_collector -->|"parses hashes"| node_inline_hashes
node_collector -->|"reads domain"| node_image_domain
node_collector -->|"merges policies"| node_policy_merge
node_collector -->|"sanitizes policies"| node_policy_sanitize
node_store_config -->|"supplies scoped values"| node_collector
node_collector -->|"returns policies"| node_collector_pipeline
node_collector_pipeline -->|"renders policies"| node_csp_header

click node_config_ui "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/adminhtml/system.xml"
click node_admin_access "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/acl.xml"
click node_default_values "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/config.xml"
click node_enabled_check "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php"
click node_domain_lists "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php"
click node_inline_hashes "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php"
click node_image_domain "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php"
click node_policy_merge "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php"
click node_policy_sanitize "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php"
click node_collector "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php"
click node_di_registration "https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/di.xml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config_ui,node_admin_access,node_default_values toneBlue
class node_enabled_check,node_domain_lists,node_inline_hashes,node_image_domain,node_policy_merge,node_policy_sanitize,node_collector,node_store_config toneAmber
class node_di_registration,node_collector_pipeline,node_csp_header toneMint
class node_administrator toneIndigo
```

## Components

### Admin Configuration

- [CSP Settings UI](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/adminhtml/system.xml): `etc/adminhtml/system.xml`
- [Admin Permissions](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/acl.xml): `etc/acl.xml`
- [Default Whitelists](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/config.xml): `etc/config.xml`

### Policy Collection

- [Enable Check](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php): `Model/CspPolicyCollector.php`
- [Directive Domains](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php): `Model/CspPolicyCollector.php`
- [Inline Hashes](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php): `Model/CspPolicyCollector.php`
- [Image Domain](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php): `Model/CspPolicyCollector.php`
- [Policy Merge](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php): `Model/CspPolicyCollector.php`
- [Policy Sanitization](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php): `Model/CspPolicyCollector.php`
- [CSP Collector](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/Model/CspPolicyCollector.php): `Model/CspPolicyCollector.php`

### Magento CSP Runtime

- [Collector Registration](https://github.com/hotchand/magento-2-content-security-policy-csp-whitelist-manager/blob/main/etc/di.xml): `etc/di.xml`
- **Magento Collector Pipeline**
- **CSP Header**

### Other components

- **Administrator**
- **Store Configuration**

## Connections

- Administrator → CSP Settings UI: edits (evidence: `README.md`)
- CSP Settings UI → Store Configuration: saves settings (evidence: `README.md`)
- Default Whitelists → Store Configuration: provides defaults
- Collector Registration → Magento Collector Pipeline: registers collector (evidence: `README.md`)
- Magento Collector Pipeline → CSP Collector: invokes collection (evidence: `README.md`)
- CSP Collector → Enable Check: checks setting (evidence: `Model/CspPolicyCollector.php`)
- CSP Collector → Directive Domains: reads domains (evidence: `Model/CspPolicyCollector.php`)
- CSP Collector → Inline Hashes: parses hashes (evidence: `Model/CspPolicyCollector.php`)
- CSP Collector → Image Domain: reads domain (evidence: `Model/CspPolicyCollector.php`)
- CSP Collector → Policy Merge: merges policies (evidence: `Model/CspPolicyCollector.php`)
- CSP Collector → Policy Sanitization: sanitizes policies (evidence: `Model/CspPolicyCollector.php`)
- Store Configuration → CSP Collector: supplies scoped values (evidence: `Model/CspPolicyCollector.php`)
- CSP Collector → Magento Collector Pipeline: returns policies (evidence: `README.md`)
- Magento Collector Pipeline → CSP Header: renders policies (evidence: `README.md`)
