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

Parsing comma separated CSPs + cleanup #64

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

MaxNad
Copy link

@MaxNad MaxNad commented Jan 8, 2024

This PR implements parsing of comma separated CSPs. It is meant to be a conversation starter and I do not mind reworking the code or the PR itself to make it simpler to merge.

Users can provide an array of CSPs (To interact with HTTP libraries that do not concatenate headers) or a comma separated string (as provided by the http lib in nodejs). This should fix #10 and #25.

While working on the implementation, I had to change some of the rules to take into account the "AND" behaviour of multi-CSPs. I took the opportunity to add check (Ex. #54 and other checks commonly found during review of CSPs)

Since the library now has to handle a list of directive maps instead of a single map, the inner-working have changed and I took the liberty of moving the version number to 2.0.0 to indicate potential breaking changes. The upper-level interactions (Creating a parser, recovering the CSP object, passing the CSP object to the evaluator and obtaining the results, etc.) should remain the same.

To sum up, here is the list of changes:

Copy link

google-cla bot commented Jan 8, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

CSP with commas are parsed in a confusing way
1 participant