Last active
November 10, 2021 22:15
-
-
Save oreoshake/f27e3678ddca4d4a8fa9 to your computer and use it in GitHub Desktop.
Splunk query for mixed content in CSP reports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A csp report looks like | |
{ | |
"csp-report": { | |
"document-uri": "http://example.org/page.html", | |
"referrer": "http://evil.example.com/haxor.html", | |
"blocked-uri": "http://evil.example.com/image.png", | |
"violated-directive": "default-src 'self'", | |
"original-policy": "default-src 'self'; report-uri http://example.org/csp-report.cgi" | |
} | |
} | |
Throw away the outer "csp-report". Setup a splunk input, set type to json. Run query. | |
"document-uri"=https* "blocked-uri"=http://* | rex field="blocked-uri" "https?://(?<blocked_host>.*)" | top blocked_host | |
Fix mixed content. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I figured out how to parse the payload into JSON. This queries csp-report POSTs, uses
rex
to isolate the JSON, usesspath
to access some interesting JSON values, and puts it in a table...