Skip to content

Support param conditions in allowExceptIn and allowExceptInMethods#414

Merged
spaze merged 2 commits into
mainfrom
spaze/allowexcept-params-in-allowed
Apr 26, 2026
Merged

Support param conditions in allowExceptIn and allowExceptInMethods#414
spaze merged 2 commits into
mainfrom
spaze/allowexcept-params-in-allowed

Conversation

@spaze
Copy link
Copy Markdown
Owner

@spaze spaze commented Apr 26, 2026

When allowParamsInAllowed or allowExceptParamsInAllowed was combined with allowExceptIn or allowExceptInMethods, the param condition was silently ignored - the config looked valid, produced no error, and had no effect. allowExceptInInstanceOf already supported param conditions; this extends the same behaviour to the path-based (allowExceptIn) and call-based (allowExceptInMethods, allowExceptInFunctions) directives. In the matched (disallowed) location, allowParamsInAllowed can allow a call when params match, and allowExceptParamsInAllowed can allow a call when params don't match the forbidden values.

The documentation in allow-with-parameters.md is updated to explain the difference between allowIn-style and allowExceptIn-style semantics and includes a concrete config example. allow-in-paths.md gains a cross-reference to the params documentation.

Close #406

@spaze spaze self-assigned this Apr 26, 2026
Copilot AI review requested due to automatic review settings April 26, 2026 17:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends parameter-condition handling so allowParamsInAllowed / allowExceptParamsInAllowed are honored when combined with the “except” allow directives (allowExceptIn*), preventing silently-ignored configuration and aligning behavior across path-, call-, and instanceOf-based scopes.

Changes:

  • Update Allowed::isAllowed() to apply parameter conditions when the current scope matches allowExceptInCalls / allowExceptIn (paths), with “disallowed-by-default in this scope” semantics.
  • Add PHPUnit coverage for allowExceptIn + params (paths) and allowExceptInMethods + params (calls).
  • Update docs to explain allowIn-style vs allowExceptIn-style parameter-condition semantics and cross-reference parameter docs from path docs.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Allowed/Allowed.php Applies param-condition overrides within allowExceptInCalls and allowExceptIn matched scopes.
tests/Calls/FunctionCallsTest.php Adds config + a test case covering allowExceptIn (paths) with both param-condition variants.
tests/Calls/FunctionCallsAllowExceptInMethodsWithParamsTest.php New test covering allowExceptInMethods with both param-condition variants.
tests/src/disallowed-allow/functionCallsExceptWithParams.php New fixture for path-based except-scope param behavior.
tests/src/RoyaleExceptWithParams.php New fixture for method-based except-scope param behavior.
docs/allow-with-parameters.md Documents semantics and provides an example configuration.
docs/allow-in-paths.md Adds a cross-reference to parameter-condition documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/allow-in-paths.md Outdated
Comment thread docs/allow-with-parameters.md Outdated
Comment thread docs/allow-with-parameters.md Outdated
@spaze spaze force-pushed the spaze/allowexcept-params-in-allowed branch from 70807e2 to 18f006c Compare April 26, 2026 19:38
@spaze spaze requested a review from Copilot April 26, 2026 19:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

spaze added 2 commits April 26, 2026 22:02
…rectives

`allow-in-paths.md` and `allow-in-methods.md` covered their their respective directives without mentioning that they can be further narrowed by parameter conditions via `allowParamsInAllowed` or `allowExceptParamsInAllowed` (also known as `disallowParamsInAllowed`).
`allowParamsInAllowed` and `allowExceptParamsInAllowed` were silently ignored when combined with `allowExceptIn` or `allowExceptInMethods`. The config looked valid, produced no schema error, and had no effect. `allowExceptInInstanceOf` already supported param conditions; this extends the same behaviour to the path-based (`allowExceptIn`) and call-based (`allowExceptInMethods`, `allowExceptInFunctions`) directives. In the matched location, `allowParamsInAllowed` can allow a call when params match, and `allowExceptParamsInAllowed` can allow a call when params don't match the forbidden values.
@spaze spaze force-pushed the spaze/allowexcept-params-in-allowed branch from 18f006c to d9ad222 Compare April 26, 2026 20:03
@spaze spaze requested a review from Copilot April 26, 2026 20:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Allowed/Allowed.php
Comment thread src/Allowed/Allowed.php
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@spaze spaze merged commit 785481b into main Apr 26, 2026
158 checks passed
@spaze spaze deleted the spaze/allowexcept-params-in-allowed branch April 26, 2026 21:06
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.

allowExceptIn and allowExceptInMethods silently ignore allowParamsInAllowed and allowExceptParamsInAllowed

2 participants