Skip to content

Bugfix: Accept the $tests argument in SecurityPolicy::checkSecurity() - #1591

Merged
LukeTowers merged 1 commit into
wintercms:developfrom
austinderrick:wip/twig-security-policy-tests
Nov 8, 2026
Merged

LukeTowers merged 1 commit into
wintercms:developfrom
austinderrick:wip/twig-security-policy-tests

Conversation

@austinderrick

@austinderrick austinderrick commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Twig 3.28 added a 4th array $tests argument to SecurityPolicyInterface::checkSecurity() in twigphp/Twig#4819. When a policy does not declare it, SandboxExtension triggers a deprecation on every sandboxed render, and with deprecation logging enabled that adds a log write to each page load.

This adds the argument to System\Twig\SecurityPolicy::checkSecurity() with a default value, so the method still works with Twig versions before 3.28.

Testing

Rendering a sandboxed template with Twig 3.30 raised 1 deprecation before this change and 0 after.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

SecurityPolicy::checkSecurity now accepts an optional array $tests = [] argument. Its documentation lists the parameter. The method body is unchanged.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • wintercms/winter#1590: Adds System\Twig\SandboxPolicy with a checkSecurity signature that also includes the optional $tests argument.
Merge Risk: Minimal · up to 10920

No actionable merge-blocking risk remains.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the core change: SecurityPolicy::checkSecurity() now accepts the $tests argument. The raw summary confirms the signature gained an optional array $tests = [] parameter, so the title ma…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the core change: SecurityPolicy::checkSecurity() now accepts the $tests argument. The raw summary confirms the signature gained an optional array $tests = [] parameter, so the title matches the changeset. The title begins with the 'Bugfix:' prefix, which is acceptable and does not make it vague.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 684d39d8-b5c3-4d9d-af7b-180c4958155d
Commits

Reviewing files that changed from the base of the PR and between 901d825 and 1092085.

Files selected for processing: 1

  • modules/system/twig/SecurityPolicy.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@austinderrick austinderrick changed the title Accept the $tests argument in SecurityPolicy::checkSecurity() Bugfix: Accept the $tests argument in SecurityPolicy::checkSecurity() Nov 5, 2026
Twig 3.28 deprecates security policies whose checkSecurity() does not declare
the 4th "array $tests" argument, and triggers the deprecation on every
sandboxed render.
@austinderrick
austinderrick force-pushed the wip/twig-security-policy-tests branch from 7e4a0a5 to 1092085 Compare November 5, 2026 03:03
@austinderrick
austinderrick changed the base branch from wip/1.3 to develop November 5, 2026 03:03
@LukeTowers
LukeTowers merged commit 3d73fb0 into wintercms:develop Nov 8, 2026
13 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants