paragonie / csp-builder

Build Content-Security-Policy headers from a JSON file (or build them programmatically)
https://paragonie.com/projects
MIT License
544 stars 39 forks source link

Prevent duplicated entries in policies #77

Closed rmpel closed 4 months ago

rmpel commented 5 months ago

When building from aggregated violations, the list of allowed domains will contain many duplicate entries. This PR is the most simple fix to remove the duplication.

Preferably, a public function hasSource(string $directive, string $path): bool would be available to prevent adding in the first place, but array_unique will do the trick for now.