Skip to content

Commit

Permalink
security: use Twig in Sandbox mode
Browse files Browse the repository at this point in the history
* revert disabling of Twig functions

not enough, not the right approach

* proof of concept: twig sandboxing

* allow all twig tags, filters, functions

* allow all template accessors

* refactor: extract TwigSandbox class

* fix: add missing accessors
  • Loading branch information
eteubert committed Oct 26, 2024
1 parent e2dcc5d commit dbe8fcd
Show file tree
Hide file tree
Showing 10 changed files with 346 additions and 226 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"monolog/monolog": "2.9.*",
"symfony/yaml": "6.0.*",
"symfony/polyfill-mbstring": "1.27.*",
"twig/twig": "3.6.1",
"twig/twig": "3.14.0",
"geoip2/geoip2": "~2.0",
"matomo/device-detector": "6.1.*",
"phpunit/php-timer": "5.0.*",
Expand All @@ -17,7 +17,8 @@
"dariuszp/cli-progress-bar": "^1.0",
"league/csv": "9.8.0",
"gajus/dindent": "^2.0",
"ramsey/uuid": "^4.7"
"ramsey/uuid": "^4.7",
"symfony/deprecation-contracts": "^3.0"
},
"require-dev": {
"pear/pear_exception": "1.0.*@dev",
Expand Down
256 changes: 47 additions & 209 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/modules/contributors/template/avatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Requires the "Contributor" module.
*
* @deprecated since 2.2.0
*
* @templatetag avatar
*/
class Avatar extends Wrapper
Expand Down
4 changes: 3 additions & 1 deletion lib/template/date_time.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public function __construct($timestamp)
// /////////

/**
* $format parameter is @deprecated, use DateTime.format instead.
* Get date and time in default format.
*
* @accessor
*/
public function __toString()
{
Expand Down
5 changes: 5 additions & 0 deletions lib/template/duration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public function __construct(\Podlove\Model\Episode $episode)
// Accessors
// /////////

/**
* Get default duration display.
*
* @accessor
*/
public function __toString()
{
if (!$this->totalMilliseconds()) {
Expand Down
Loading

0 comments on commit dbe8fcd

Please sign in to comment.