Parsing comma separated CSPs + cleanup #64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: