Skip to content

Commit 3fa1174

Browse files
committed
Content filtering: Updated config and readme attribution
1 parent 50e8501 commit 3fa1174

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

.env.example.complete

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,25 @@ EXPORT_PDF_COMMAND_TIMEOUT=15
351351
# Only used if 'ALLOW_UNTRUSTED_SERVER_FETCHING=true' which disables security protections.
352352
WKHTMLTOPDF=false
353353

354-
# Allow <script> tags in page content
354+
# Allow JavaScript, and other potentiall dangerous content in page content.
355+
# This also removes CSP-level JavaScript control.
355356
# Note, if set to 'true' the page editor may still escape scripts.
357+
# DEPRECATED: Use 'APP_CONTENT_FILTERING' instead as detailed below. Activiting this option
358+
# effectively sets APP_CONTENT_FILTERING='' (No filtering)
356359
ALLOW_CONTENT_SCRIPTS=false
357360

361+
# Control the behaviour of content filtering, primarily used for page content.
362+
# This setting is a string of characters which represent different available filters:
363+
# - j - Filter out JavaScript and unknown binary data based content
364+
# - h - Filter out unexpected, and potentially dangerous, HTML elements
365+
# - f - Filter out unexpected form elements
366+
# - a - Run content through a more complex allowlist filter
367+
# This defaults to using all filters, unless ALLOW_CONTENT_SCRIPTS is set to true in which case no filters are used.
368+
# Note: These filters are a best-attempt and may not be 100% effective. They are typically a layer used in addition to other security measures.
369+
# Note: The default value will always be the most-strict, so it's advised to leave this unset in your own configuration
370+
# to ensure you are always using the full range of filters.
371+
APP_CONTENT_FILTERING="jfha"
372+
358373
# Indicate if robots/crawlers should crawl your instance.
359374
# Can be 'true', 'false' or 'null'.
360375
# The behaviour of the default 'null' option will depend on the 'app-public' admin setting.

app/Config/app.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,14 @@
3737
// The limit for all uploaded files, including images and attachments in MB.
3838
'upload_limit' => env('FILE_UPLOAD_SIZE_LIMIT', 50),
3939

40-
// Allow <script> tags to entered within page content.
41-
// <script> tags are escaped by default.
42-
// Even when overridden the WYSIWYG editor may still escape script content.
43-
'allow_content_scripts' => env('ALLOW_CONTENT_SCRIPTS', false),
44-
4540
// Control the behaviour of content filtering, primarily used for page content.
46-
// This setting is a collection of characters which represent different available filters:
41+
// This setting is a string of characters which represent different available filters:
4742
// - j - Filter out JavaScript and unknown binary data based content
4843
// - h - Filter out unexpected, and potentially dangerous, HTML elements
4944
// - f - Filter out unexpected form elements
50-
// - a - Run content through a more complex allow-list filter
45+
// - a - Run content through a more complex allowlist filter
5146
// This defaults to using all filters, unless ALLOW_CONTENT_SCRIPTS is set to true in which case no filters are used.
52-
// Note: These filters are a best attempt, and may not be 100% effective. They are typically a layer used in addition to other security measures.
53-
// TODO - Add to example env
54-
// TODO - Remove allow_content_scripts option above
47+
// Note: These filters are a best-attempt and may not be 100% effective. They are typically a layer used in addition to other security measures.
5548
'content_filtering' => env('APP_CONTENT_FILTERING', env('ALLOW_CONTENT_SCRIPTS', false) === true ? '' : 'jhfa'),
5649

5750
// Allow server-side fetches to be performed to potentially unknown

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ The website which contains the project docs & blog can be found in the [BookStac
155155
The BookStack source is provided under the [MIT License](https://github.com/BookStackApp/BookStack/blob/development/LICENSE).
156156

157157
The libraries used by, and included with, BookStack are provided under their own licenses and copyright.
158-
The licenses for many of our core dependencies can be found in the attribution list below but this is not an exhaustive list of all projects used within BookStack.
158+
The licenses for many of our core dependencies can be found in the attribution list below, but this is not an exhaustive list of all projects used within BookStack.
159159

160160
## 👪 Attribution
161161

@@ -187,5 +187,6 @@ Note: This is not an exhaustive list of all libraries and projects that would be
187187
* [PHPStan](https://phpstan.org/) & [Larastan](https://github.com/nunomaduro/larastan) - _[MIT](https://github.com/phpstan/phpstan/blob/master/LICENSE) and [MIT](https://github.com/nunomaduro/larastan/blob/master/LICENSE.md)_
188188
* [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) - _[BSD 3-Clause](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt)_
189189
* [JakeArchibald/IDB-Keyval](https://github.com/jakearchibald/idb-keyval) - _[Apache-2.0](https://github.com/jakearchibald/idb-keyval/blob/main/LICENCE)_
190+
* [HTML Purifier](https://github.com/ezyang/htmlpurifier) and [htmlpurifier-html5](https://github.com/xemlock/htmlpurifier-html5) - _[LGPL-2.1](https://github.com/ezyang/htmlpurifier/blob/master/LICENSE) and [MIT](https://github.com/xemlock/htmlpurifier-html5/blob/master/LICENSE)_
190191

191-
For a detailed breakdown of the JavaScript & PHP projects imported & used via NPM & composer package managers, along with their licenses, please see the [dev/licensing/js-library-licenses.txt](dev/licensing/js-library-licenses.txt) and [dev/licensing/php-library-licenses.txt](dev/licensing/php-library-licenses.txt) files.
192+
For a detailed breakdown of the JavaScript & PHP projects imported and used via NPM & composer package managers, along with their licenses, please see the [dev/licensing/js-library-licenses.txt](dev/licensing/js-library-licenses.txt) and [dev/licensing/php-library-licenses.txt](dev/licensing/php-library-licenses.txt) files.

tests/Unit/ConfigTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ public function test_content_filtering_defaults_to_enabled()
177177
});
178178
}
179179

180+
public function test_content_filtering_can_be_disabled()
181+
{
182+
$this->runWithEnv(['APP_CONTENT_FILTERING' => "", 'ALLOW_CONTENT_SCRIPTS' => null], function () {
183+
$this->assertEquals('', config('app.content_filtering'));
184+
});
185+
}
186+
180187
public function test_allow_content_scripts_disables_content_filtering()
181188
{
182189
$this->runWithEnv(['APP_CONTENT_FILTERING' => null, 'ALLOW_CONTENT_SCRIPTS' => 'true'], function () {

0 commit comments

Comments
 (0)