Skip to content

allowParamsInAllowed with allowExceptIn* incorrectly allows first-class callables in the disallowed location #415

@spaze

Description

@spaze

When allowExceptIn, allowExceptInMethods, or allowExceptInInstanceOf is combined with allowParamsInAllowed, a first-class callable like crc32(...) inside the disallowed location is incorrectly treated as allowed. The root cause is DisallowedCallsRuleErrors explicitly setting $args = null for first-class callables, and hasAllowedParams() returning true for null $args regardless of whether the calling context is an allowed zone (where that is reasonable) or a disallowed zone (where it is not). Without any allowParamsInAllowed condition the same callable in the same location is correctly disallowed, so adding a param restriction paradoxically makes the rule more permissive for first-class callables. The issue affects allowExceptInInstanceOf as well, which had param support before #414.

The failing test in #416 demonstrates the bug: crc32(...) inside methodA() (the except/disallowed zone) is not reported as an error, but it should be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions