Skip to content

Commit

Permalink
Minimize granted and denied fields in FLS (elastic#119453)
Browse files Browse the repository at this point in the history
Instead of only determinizing, we can minimize the intermediate automata
during FLS automaton construction. This brings the codebase back to its
original form, before the Lucene 10 upgrade. 

Follow up to: elastic#119309
  • Loading branch information
n1v0lg authored Jan 14, 2025
1 parent 3534133 commit 2fe55db
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.lucene.util.automaton.MinimizationOperations;
import org.elasticsearch.plugins.FieldPredicate;
import org.elasticsearch.xpack.core.security.authz.accesscontrol.FieldSubsetReader;
import org.elasticsearch.xpack.core.security.authz.permission.FieldPermissionsDefinition.FieldGrantExcludeGroup;
Expand Down Expand Up @@ -172,12 +173,8 @@ public static Automaton buildPermittedFieldsAutomaton(final String[] grantedFiel
deniedFieldsAutomaton = Automatons.patterns(deniedFields);
}

grantedFieldsAutomaton = Operations.removeDeadStates(
Operations.determinize(grantedFieldsAutomaton, Operations.DEFAULT_DETERMINIZE_WORK_LIMIT)
);
deniedFieldsAutomaton = Operations.removeDeadStates(
Operations.determinize(deniedFieldsAutomaton, Operations.DEFAULT_DETERMINIZE_WORK_LIMIT)
);
grantedFieldsAutomaton = MinimizationOperations.minimize(grantedFieldsAutomaton, Operations.DEFAULT_DETERMINIZE_WORK_LIMIT);
deniedFieldsAutomaton = MinimizationOperations.minimize(deniedFieldsAutomaton, Operations.DEFAULT_DETERMINIZE_WORK_LIMIT);

if (Automatons.subsetOf(deniedFieldsAutomaton, grantedFieldsAutomaton) == false) {
throw new ElasticsearchSecurityException(
Expand Down

0 comments on commit 2fe55db

Please sign in to comment.