Welcome Guest, Not a member yet? Register   Sign In
Catch data from CSP: report-uri
#1

Hi guys how can I catch the data from CSP: report-uri? I already active it in the config App and set the report URL in ContentSecurityPolicy.php like this:
 
Code:
public $reportURI = '/csp-violation-report-endpoint';
at my Route.php I already define it like this:
Code:
$routes->add('csp-violation-report-endpoint', 'Home::csp');

And my controller like this:

    public function csp()
    {
        log_message('info', 'CSP violation trigerred');
        $json_data = file_get_contents('php://input');

        $json_data = json_encode($json_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        $current_domain = preg_replace('/www\./i', '', $_SERVER['SERVER_NAME']);
        $message = "The following Content-Security-Policy violation occurred on " .
            $current_domain . ":\n\n" .
            $json_data .
            "\n\nFurther CPS violations will be logged to the following log file, but no further email notifications will be sent until this log file is deleted:\n\n";

        log_message('error', $message);
    }
But I don't get anything? is it something wrong or did I miss here? Thanks.
Reply


Messages In This Thread
Catch data from CSP: report-uri - by Eko - 06-16-2022, 12:49 AM
RE: Catch data from CSP: report-uri - by iRedds - 06-16-2022, 08:12 AM
RE: Catch data from CSP: report-uri - by Eko - 06-16-2022, 08:37 PM
RE: Catch data from CSP: report-uri - by kenjis - 06-29-2022, 12:03 AM
RE: Catch data from CSP: report-uri - by Eko - 07-02-2022, 11:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB