<?php
//$payload = file_get_contents('./csp-log.log');
$payload = "{\"csp-report\":{\"document-uri\":\"http://athleticssite.com/\",
\"referrer\":\"\",
\"violated-directive\":\"img-src\",
\"effective-directive\":\"img-src\",
\"original-policy\":\"default-src 'self' https://someurl.com; script-src 'self' 'unsafe-inline' https://use.typekit.com https://google-analytics.com https://ajax.googleapis.com https://js.hsforms.net https://ssl.google-analytics.com; img-src 'self' https://p.typekit.net https://ssl.google-analytics.com ; font-src https://use.typekit.com; report-uri /csp-violations-report-endpoint/;\",
\"disposition\":\"report\",
\"blocked-uri\":\"https://someurl.com/path/to/file/516.large.jpg?1530632190456\",
\"status-code\":200,
\"script-sample\":\"\"}}
{\"csp-report\":{\"document-uri\":\"http://athleticssite.com/\",
\"referrer\":\"\",
\"violated-directive\":\"img-src\",
\"effective-directive\":\"img-src\",
\"original-policy\":\"default-src 'self' https://someurl.com; script-src 'self' 'unsafe-inline' https://use.typekit.com https://google-analytics.com https://ajax.googleapis.com https://js.hsforms.net https://ssl.google-analytics.com; img-src 'self' https://p.typekit.net https://ssl.google-analytics.com ; font-src https://use.typekit.com; report-uri /csp-violations-report-endpoint/;\",
\"disposition\":\"report\",
\"blocked-uri\":\"https://someurl.com/path/to/file/516.large.jpg?1530632190456\",
\"status-code\":200,
\"script-sample\":\"\"}}";
$matches = [];
preg_match_all('/"blocked-uri":"(.*?)",/m', $payload, $matches);
/*
for($i = 0; $i < count($matches[1]); $i++) {
echo $matches[1][$i] . "\n";
}
*/
foreach($matches as $match => $uri) {
echo $uri[0] . "\n";
}
preferences:
24.76 ms | 402 KiB | 5 Q