mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Updated CSP with frame-src rules
- Configurable via 'ALLOWED_IFRAME_SOURCES' .env option. - Also updated how CSP rules are set, with a single header being used instead of many. - Also applied CSP rules to HTML export outputs. - Updated tests to cover. For #3314
This commit is contained in:
@ -268,7 +268,7 @@ class ExportTest extends TestCase
|
||||
foreach ($entities as $entity) {
|
||||
$resp = $this->asEditor()->get($entity->getUrl('/export/html'));
|
||||
$resp->assertDontSee('window.donkey');
|
||||
$resp->assertDontSee('script');
|
||||
$resp->assertDontSee('<script', false);
|
||||
$resp->assertSee('.my-test-class { color: red; }');
|
||||
}
|
||||
}
|
||||
@ -448,4 +448,18 @@ class ExportTest extends TestCase
|
||||
$resp = $this->get($page->getUrl('/export/pdf'));
|
||||
$resp->assertStatus(500); // Bad response indicates wkhtml usage
|
||||
}
|
||||
|
||||
public function test_html_exports_contain_csp_meta_tag()
|
||||
{
|
||||
$entities = [
|
||||
Page::query()->first(),
|
||||
Book::query()->first(),
|
||||
Chapter::query()->first(),
|
||||
];
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
$resp = $this->asEditor()->get($entity->getUrl('/export/html'));
|
||||
$resp->assertElementExists('head meta[http-equiv="Content-Security-Policy"][content*="script-src "]');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user