Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a CSP header parser (CSPBuilder::fromHeader) #74

Merged
merged 7 commits into from
Jul 18, 2023

Conversation

fritzmg
Copy link
Contributor

@fritzmg fritzmg commented Jun 26, 2023

This introduces an additional fromHeader factory method to the CSPBuilder with which you can parse and then modify an existing Content-Security-Policy response header.

$csp = CSPBuilder::fromHeader("script-src 'self'");
$csp->addSource('style-src', 'self');

echo $csp->compile(); // script-src 'self'; style-src 'self'

This can be useful if the CSP header is defined elsewhere in the system and you want to additionally analyse or modify said header.

@paragonie-security paragonie-security merged commit 34b2d80 into paragonie:master Jul 18, 2023
@paragonie-security
Copy link
Contributor

Thanks! This is a wonderful addition to this library.

@fritzmg
Copy link
Contributor Author

fritzmg commented Sep 17, 2023

Nice :). @paragonie-security will you tag this as 2.10.0?

@fritzmg fritzmg deleted the csp-header-parser branch September 17, 2023 16:20
@fritzmg
Copy link
Contributor Author

fritzmg commented Dec 16, 2023

@paragonie-security any chance of this getting tagged as a new release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants