[#719] Fix NullPointerException decoding an ACI bind rule with a missing and/or operand#720
Conversation
de308dd to
76a6bfd
Compare
Review summaryApprove with changes. No blocking correctness defect. One incorrect code comment, Suggested changes1. Merge guards 1 and 2 into one, hoisted in
|
…/or operand (OpenIdentityPlatform#719) An empty group such as "()" decodes to a null bind rule. BindRule.decode dereferenced that null when it appeared as the left or right operand of an "and"/"or" bind rule (e.g. "(()or)"), throwing a NullPointerException instead of an AciException. Reject the missing operand - and a bare "()" group - with an AciException.
… fix
- Hoist the null left-operand guard into BindRule.decode, above the
remaining-chars test, so one check rejects both a bare empty group ("()")
and a missing left operand ("()or userdn=..."), and the message names the
full offending input. Remove the now-redundant null guard in
createBindRule (its only null-capable caller is guarded upstream).
- Correct the bindrule_2 comment: "(()or)" is caught by the left guard, so
use the input that actually reaches it ('userdn="ldap:///self" or').
- Document decode's null base case in the javadoc and fix the stale
blank-bind-rule comment.
- Add tests: malformed "(())", "( )", '... or ()', "not ()"; positive
controls for valid nested/complex rules; and an ACI-level missing-left
regression case.
76a6bfd to
6d47862
Compare
|
Thanks for the thorough review, @maximthomas — addressed all four points in First, I rebased onto
Verification ( |
Fixes #719.
Problem
Aci.decodethrows aNullPointerExceptioninstead of anAciExceptionwhen a bind rule contains anand/orboolean whose operand is missing. Reported via ACI:Root cause
An empty group such as
()decodes to anullbind rule (the base case ofBindRule.decode). Thatnullwas then dereferenced without a check — as the right operand of anand/or(the exact NPE from the issue), as the left operand (a complexBindRulewithleft == null, which NPEs later during evaluation), or returned bare up toPermBindRulePair.Fix
BindRule.decodenow rejects an empty group instead of letting anullpropagate:bindrule_1 == nullguard indecode(hoisted above the remaining-chars test) rejects both a bare empty group (()) and an empty left operand (()or userdn=...), reporting the full offending input.bindrule_2 == nullguard increateBindRulerejects an empty right operand (... or,... and).Both throw
WARN_ACI_SYNTAX_INVALID_BIND_RULE_SYNTAX(AciException). Same class of malformed-input defect as #716. Rebased on #715, whose blank-bind-rule fix (decode(" ")→null) this change relies on.Tests
New
BindRuleOperandTest:AciException):(()or),(... or),(... and),()or ...,(),(()),( ),(... or ()),not ().((userdn=...)),(userdn=... or userdn=...).Aci.decode: the full ACI from the issue, plus the missing-left case()or userdn=....Regression:
AciTests515,AciBodyTest8,BindRuleParenTest8 — all pass.