X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fapi%2FApiCSPReport.php;h=82a7cce44bb5736b90c874715485712fd37bc94b;hb=bfb5cd8bb3d59185bfd313940fe4e9c7b60489b8;hp=af040d153a0820c8252f42ce2c183f78e1d1e9f8;hpb=38907a449e21c4db8f97d14963ceb6c9c022a333;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiCSPReport.php b/includes/api/ApiCSPReport.php index af040d153a..82a7cce44b 100644 --- a/includes/api/ApiCSPReport.php +++ b/includes/api/ApiCSPReport.php @@ -47,7 +47,7 @@ class ApiCSPReport extends ApiBase { $this->verifyPostBodyOk(); $report = $this->getReport(); - $flags = $this->getFlags( $report ); + $flags = $this->getFlags( $report, $userAgent ); $warningText = $this->generateLogLine( $flags, $report ); $this->logReport( $flags, $warningText, [ @@ -81,9 +81,10 @@ class ApiCSPReport extends ApiBase { * Get extra notes about the report. * * @param array $report The CSP report + * @param string $userAgent * @return array */ - private function getFlags( $report ) { + private function getFlags( $report, $userAgent ) { $reportOnly = $this->getParameter( 'reportonly' ); $source = $this->getParameter( 'source' ); $falsePositives = $this->getConfig()->get( 'CSPFalsePositiveUrls' ); @@ -97,12 +98,22 @@ class ApiCSPReport extends ApiBase { } if ( - ( isset( $report['blocked-uri'] ) && - isset( $falsePositives[$report['blocked-uri']] ) ) - || ( isset( $report['source-file'] ) && - isset( $falsePositives[$report['source-file']] ) ) + ( + ContentSecurityPolicy::falsePositiveBrowser( $userAgent ) && + $report['blocked-uri'] === "self" + ) || + ( + isset( $report['blocked-uri'] ) && + isset( $falsePositives[$report['blocked-uri']] ) + ) || + ( + isset( $report['source-file'] ) && + isset( $falsePositives[$report['source-file']] ) + ) ) { - // Report caused by Ad-Ware + // False positive due to: + // https://bugzilla.mozilla.org/show_bug.cgi?id=1026520 + $flags[] = 'false-positive'; } return $flags; @@ -127,7 +138,7 @@ class ApiCSPReport extends ApiBase { /** * Get the report from post body and turn into associative array. * - * @return Array + * @return array */ private function getReport() { $postBody = $this->getRequest()->getRawInput();