fix(acl): correctly evaluate multi-match JSONPath labels#13527
Open
shreemaan-abhishek wants to merge 1 commit into
Open
fix(acl): correctly evaluate multi-match JSONPath labels#13527shreemaan-abhishek wants to merge 1 commit into
shreemaan-abhishek wants to merge 1 commit into
Conversation
The ACL plugin read the external_user label field with single-value jp.value(), which returns only the FIRST JSONPath match. For external users that belong to multiple orgs/teams, the allow/deny matching then ran against an incomplete label set: a denied label packed into a later match could be missed (ACL bypass), and a matched value that is a table could be handed to the string parser and crash re_split. Use jp.query() to collect ALL matches. With 0 or 1 match the original jp.value() semantics are preserved. With 2 or more matches, the configured parser is applied to each matched value individually and the parsed sub-values are merged before allow/deny matching, with a type guard so a table sub-value is not passed to the string parser.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
aclplugin extracts the external-user label value fromctx.external_userusing a JSONPath expression (external_user_label_field). It did so with single-valuejp.value(), which returns only the first match of the JSONPath query.For external users that belong to multiple organizations/teams, a JSONPath such as
$.orgs..teamor$..namematches several values, but only the first one was evaluated. This caused two problems:segmented_textstring parser, wherere_splitcannot operate on a table value.This change reads all matches with
jp.query():jp.value()semantics are preserved, including letting the json/segmented_text parser reject a single table value).This is an internal correctness fix. There is no schema or option change and no change to documented behavior, so the plugin docs are unchanged.
Tests
t/plugin/acl.tTEST 32: a multi-match JSONPath whose values include a packed allowed label ("cloud|infra") is now correctly honored (200 instead of 403).segmented_textparser where a denied label (infra) is packed inside a parsed value ("infra,qa"), confirming the denied label is now caught (403).Checklist