MediaWiki
master
|
Handle sending Content-Security-Policy headers. More...
Public Member Functions | |
__construct (WebResponse $response, Config $mwConfig, HookContainer $hookContainer) | |
addDefaultSrc ( $source) | |
If possible you should use a more specific source type then default. More... | |
addScriptSrc ( $source) | |
So for example, if an extension added a special page that loaded something it might call $this->getOutput()->getCSP()->addScriptSrc( '*.example.com' );. More... | |
addStyleSrc ( $source) | |
So for example, if an extension added a special page that loaded external CSS it might call $this->getOutput()->getCSP()->addStyleSrc( '*.example.com' );. More... | |
getNonce () | |
Get the nonce if nonce is in use. More... | |
sendCSPHeader ( $csp, $reportOnly) | |
Send a single CSP header based on a given policy config. More... | |
sendHeaders () | |
Send CSP headers based on wiki config. More... | |
Static Public Member Functions | |
static | falsePositiveBrowser ( $ua) |
Does this browser give false positive reports? More... | |
static | isNonceRequired (Config $config) |
Should we set nonce attribute. More... | |
Public Attributes | |
const | FULL_MODE = 2 |
const | REPORT_ONLY_MODE = 1 |
Handle sending Content-Security-Policy headers.
Definition at line 37 of file ContentSecurityPolicy.php.
GuzzleHttp\Psr7\Request\ContentSecurityPolicy::__construct | ( | WebResponse | $response, |
Config | $mwConfig, | ||
HookContainer | $hookContainer | ||
) |
WebResponse | $response | |
Config | $mwConfig | |
HookContainer | $hookContainer |
Definition at line 65 of file ContentSecurityPolicy.php.
GuzzleHttp\Psr7\Request\ContentSecurityPolicy::addDefaultSrc | ( | $source | ) |
If possible you should use a more specific source type then default.
So for example, if an extension added a special page that loaded something it might call $this->getOutput()->getCSP()->addDefaultSrc( '*.example.com' );
string | $source | Source to add. e.g. blob:, *.example.com, https://example.com, example.com/foo |
Definition at line 562 of file ContentSecurityPolicy.php.
References $source.
GuzzleHttp\Psr7\Request\ContentSecurityPolicy::addScriptSrc | ( | $source | ) |
So for example, if an extension added a special page that loaded something it might call $this->getOutput()->getCSP()->addScriptSrc( '*.example.com' );.
string | $source | Source to add. e.g. blob:, *.example.com, https://example.com, example.com/foo |
Definition at line 587 of file ContentSecurityPolicy.php.
References $source.
GuzzleHttp\Psr7\Request\ContentSecurityPolicy::addStyleSrc | ( | $source | ) |
So for example, if an extension added a special page that loaded external CSS it might call $this->getOutput()->getCSP()->addStyleSrc( '*.example.com' );.
string | $source | Source to add. e.g. blob:, *.example.com, https://example.com, example.com/foo |
Definition at line 574 of file ContentSecurityPolicy.php.
References $source.
|
static |
Does this browser give false positive reports?
Some versions of firefox (40-42) incorrectly report a CSP violation for nonce sources, despite allowing them.
string | $ua | User-agent header |
Definition at line 503 of file ContentSecurityPolicy.php.
GuzzleHttp\Psr7\Request\ContentSecurityPolicy::getNonce | ( | ) |
Get the nonce if nonce is in use.
Not currently supported or implemented.
Definition at line 548 of file ContentSecurityPolicy.php.
|
static |
Should we set nonce attribute.
Config | $config |
Definition at line 513 of file ContentSecurityPolicy.php.
References MediaWiki\MainConfigNames\CSPHeader, and MediaWiki\MainConfigNames\CSPReportOnlyHeader.
Referenced by MediaWiki\Html\Html\linkedScript().
GuzzleHttp\Psr7\Request\ContentSecurityPolicy::sendCSPHeader | ( | $csp, | |
$reportOnly | |||
) |
Send a single CSP header based on a given policy config.
array | bool | $csp | ContentSecurityPolicy configuration |
int | $reportOnly | self::*_MODE constant |
Definition at line 83 of file ContentSecurityPolicy.php.
Referenced by GuzzleHttp\Psr7\Request\ContentSecurityPolicy\sendHeaders().
GuzzleHttp\Psr7\Request\ContentSecurityPolicy::sendHeaders | ( | ) |
Send CSP headers based on wiki config.
Main method that callers (OutputPage) are expected to use. As a general rule, you would never call this in an extension unless you have disabled OutputPage and are fully controlling the output.
Definition at line 102 of file ContentSecurityPolicy.php.
References MediaWiki\MainConfigNames\CSPHeader, MediaWiki\MainConfigNames\CSPReportOnlyHeader, and GuzzleHttp\Psr7\Request\ContentSecurityPolicy\sendCSPHeader().
const GuzzleHttp\Psr7\Request\ContentSecurityPolicy::FULL_MODE = 2 |
Definition at line 39 of file ContentSecurityPolicy.php.
const GuzzleHttp\Psr7\Request\ContentSecurityPolicy::REPORT_ONLY_MODE = 1 |
Definition at line 38 of file ContentSecurityPolicy.php.