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

Allow an array of reports #67

Closed
landorg opened this issue Aug 24, 2022 · 3 comments · Fixed by #102
Closed

Allow an array of reports #67

landorg opened this issue Aug 24, 2022 · 3 comments · Fixed by #102

Comments

@landorg
Copy link

landorg commented Aug 24, 2022

I'm getting this when reports are sent from chrome:

{"level":"debug","message":"Unable to decode invalid JSON payload: json: cannot unmarshal array into Go value of type main.CSPReport","timestamp":"2022-08-24T11:31:19Z"}

I think that chrome is sending multiple reports in an array.
I couldn't find it in the spec but this says:

As you can see, the report is part of an array of reports, since there can be multiple types of reports in a single Reporting API call.

@jacobbednarz
Copy link
Owner

thanks for the issue. I'll have to take a look at how we handle this as collection vs single in typed languages isn't an easy process 😅

@jacobbednarz
Copy link
Owner

i have a way forward with this using a custom Marshal and Unmarshal methods; it's not pretty but it does work.

@jacobbednarz
Copy link
Owner

also, i sat down and looked into this more and these are actually two different (yet similar) things. the first one is a CSP report whereas the second (array of reports) is from the Reporting API for a CSP violation. the latter is the newer, all encompassing collection mechanism so i think i'll keep these separate. i.e. /csp can be for the older style reports and report (or similar) can be for the reporting API if it is supported by the browser.

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 a pull request may close this issue.

2 participants