Skip to content

Commit 69a0b4e

Browse files
committed
merge
2 parents 8ca12bc + b5d5229 commit 69a0b4e

File tree

49 files changed

+1326
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1326
-473
lines changed

docs/changelog/128925.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128925
2+
summary: ES|QL - Add `match_phrase` full text function (tech preview)
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/reference/query-languages/esql/_snippets/functions/description/match_phrase.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/_snippets/functions/parameters/match_phrase.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
* [preview] [`KQL`](../../functions-operators/search-functions.md#esql-kql)
22
* [preview] [`MATCH`](../../functions-operators/search-functions.md#esql-match)
3-
% * [preview] [
4-
`MATCH_PHRASE`](../../functions-operators/search-functions.md#esql-match-phrase)
3+
* [preview] [`MATCH_PHRASE`](../../functions-operators/search-functions.md#esql-match_phrase)
54
* [preview] [`QSTR`](../../functions-operators/search-functions.md#esql-qstr)
65
% * [preview] [
76
`TERM`](../../functions-operators/search-functions.md#esql-term)

docs/reference/query-languages/esql/functions-operators/search-functions.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ for information on the limitations of full text search.
3636
:::{include} ../_snippets/functions/layout/match.md
3737
:::
3838

39-
% MATCH_PHRASE is currently hidden
40-
% :::{include} ../_snippets/functions/layout/match_phrase.md
41-
% :::
39+
:::{include} ../_snippets/functions/layout/match_phrase.md
40+
:::
4241

4342
:::{include} ../_snippets/functions/layout/qstr.md
4443
:::

docs/reference/query-languages/esql/kibana/definition/functions/match_phrase.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/docs/functions/match_phrase.md

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@
3737
import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES;
3838
import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS;
3939
import static org.objectweb.asm.Opcodes.ACC_STATIC;
40+
import static org.objectweb.asm.Opcodes.CHECKCAST;
4041
import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
4142
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
4243

43-
public class InstrumenterImpl implements Instrumenter {
44+
public final class InstrumenterImpl implements Instrumenter {
4445
private static final Logger logger = LogManager.getLogger(InstrumenterImpl.class);
4546

4647
private final String getCheckerClassMethodDescriptor;
@@ -271,7 +272,8 @@ public void visitCode() {
271272
}
272273

273274
private void pushEntitlementChecker() {
274-
InstrumenterImpl.this.pushEntitlementChecker(mv);
275+
mv.visitMethodInsn(INVOKESTATIC, handleClass, "instance", getCheckerClassMethodDescriptor, false);
276+
mv.visitTypeInsn(CHECKCAST, checkMethod.className());
275277
}
276278

277279
private void pushCallerClass() {
@@ -319,10 +321,7 @@ private void invokeInstrumentationMethod() {
319321
true
320322
);
321323
}
322-
}
323324

324-
protected void pushEntitlementChecker(MethodVisitor mv) {
325-
mv.visitMethodInsn(INVOKESTATIC, handleClass, "instance", getCheckerClassMethodDescriptor, false);
326325
}
327326

328327
record ClassFileInfo(String fileName, byte[] bytecodes) {}

libs/entitlement/src/main/java/org/elasticsearch/entitlement/bootstrap/EntitlementBootstrap.java

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
import com.sun.tools.attach.AttachNotSupportedException;
1515
import com.sun.tools.attach.VirtualMachine;
1616

17+
import org.elasticsearch.core.Nullable;
1718
import org.elasticsearch.core.PathUtils;
1819
import org.elasticsearch.core.SuppressForbidden;
1920
import org.elasticsearch.entitlement.initialization.EntitlementInitialization;
21+
import org.elasticsearch.entitlement.runtime.policy.PathLookup;
2022
import org.elasticsearch.entitlement.runtime.policy.PathLookupImpl;
2123
import org.elasticsearch.entitlement.runtime.policy.Policy;
2224
import org.elasticsearch.entitlement.runtime.policy.PolicyManager;
@@ -26,6 +28,7 @@
2628
import java.io.IOException;
2729
import java.nio.file.Files;
2830
import java.nio.file.Path;
31+
import java.util.Collection;
2932
import java.util.Map;
3033
import java.util.Set;
3134
import java.util.function.Function;
@@ -38,20 +41,20 @@ public class EntitlementBootstrap {
3841
* calls to methods protected by entitlements from classes without a valid
3942
* policy will throw {@link org.elasticsearch.entitlement.runtime.api.NotEntitledException}.
4043
*
41-
* @param serverPolicyPatch a policy with additional entitlements to patch the embedded server layer policy
42-
* @param pluginPolicies a map holding policies for plugins (and modules), by plugin (or module) name.
43-
* @param scopeResolver a functor to map a Java Class to the component and module it belongs to.
44-
* @param settingResolver a functor to resolve a setting name pattern for one or more Elasticsearch settings.
45-
* @param dataDirs data directories for Elasticsearch
46-
* @param sharedRepoDirs shared repository directories for Elasticsearch
47-
* @param configDir the config directory for Elasticsearch
48-
* @param libDir the lib directory for Elasticsearch
49-
* @param modulesDir the directory where Elasticsearch modules are
50-
* @param pluginsDir the directory where plugins are installed for Elasticsearch
51-
* @param sourcePaths a map holding the path to each plugin or module jars, by plugin (or module) name.
52-
* @param tempDir the temp directory for Elasticsearch
53-
* @param logsDir the log directory for Elasticsearch
54-
* @param pidFile path to a pid file for Elasticsearch, or {@code null} if one was not specified
44+
* @param serverPolicyPatch additional entitlements to patch the embedded server layer policy
45+
* @param pluginPolicies maps each plugin name to the corresponding {@link Policy}
46+
* @param scopeResolver a functor to map a Java Class to the component and module it belongs to.
47+
* @param settingResolver a functor to resolve a setting name pattern for one or more Elasticsearch settings.
48+
* @param dataDirs data directories for Elasticsearch
49+
* @param sharedRepoDirs shared repository directories for Elasticsearch
50+
* @param configDir the config directory for Elasticsearch
51+
* @param libDir the lib directory for Elasticsearch
52+
* @param modulesDir the directory where Elasticsearch modules are
53+
* @param pluginsDir the directory where plugins are installed for Elasticsearch
54+
* @param pluginSourcePaths maps each plugin name to the location of that plugin's code
55+
* @param tempDir the temp directory for Elasticsearch
56+
* @param logsDir the log directory for Elasticsearch
57+
* @param pidFile path to a pid file for Elasticsearch, or {@code null} if one was not specified
5558
* @param suppressFailureLogPackages packages for which we do not need or want to log Entitlements failures
5659
*/
5760
public static void bootstrap(
@@ -65,35 +68,33 @@ public static void bootstrap(
6568
Path libDir,
6669
Path modulesDir,
6770
Path pluginsDir,
68-
Map<String, Path> sourcePaths,
71+
Map<String, Collection<Path>> pluginSourcePaths,
6972
Path logsDir,
7073
Path tempDir,
71-
Path pidFile,
74+
@Nullable Path pidFile,
7275
Set<Package> suppressFailureLogPackages
7376
) {
7477
logger.debug("Loading entitlement agent");
7578
if (EntitlementInitialization.initializeArgs != null) {
7679
throw new IllegalStateException("initialization data is already set");
7780
}
81+
PathLookupImpl pathLookup = new PathLookupImpl(
82+
getUserHome(),
83+
configDir,
84+
dataDirs,
85+
sharedRepoDirs,
86+
libDir,
87+
modulesDir,
88+
pluginsDir,
89+
logsDir,
90+
tempDir,
91+
pidFile,
92+
settingResolver
93+
);
7894
EntitlementInitialization.initializeArgs = new EntitlementInitialization.InitializeArgs(
79-
serverPolicyPatch,
80-
pluginPolicies,
81-
scopeResolver,
82-
new PathLookupImpl(
83-
getUserHome(),
84-
configDir,
85-
dataDirs,
86-
sharedRepoDirs,
87-
libDir,
88-
modulesDir,
89-
pluginsDir,
90-
logsDir,
91-
tempDir,
92-
pidFile,
93-
settingResolver
94-
),
95-
sourcePaths,
96-
suppressFailureLogPackages
95+
pathLookup,
96+
suppressFailureLogPackages,
97+
createPolicyManager(pluginPolicies, pathLookup, serverPolicyPatch, scopeResolver, pluginSourcePaths)
9798
);
9899
exportInitializationToAgent();
99100
loadAgent(findAgentJar(), EntitlementInitialization.class.getName());
@@ -151,5 +152,24 @@ static String findAgentJar() {
151152
}
152153
}
153154

155+
private static PolicyManager createPolicyManager(
156+
Map<String, Policy> pluginPolicies,
157+
PathLookup pathLookup,
158+
Policy serverPolicyPatch,
159+
Function<Class<?>, PolicyManager.PolicyScope> scopeResolver,
160+
Map<String, Collection<Path>> pluginSourcePaths
161+
) {
162+
FilesEntitlementsValidation.validate(pluginPolicies, pathLookup);
163+
164+
return new PolicyManager(
165+
HardcodedEntitlements.serverPolicy(pathLookup.pidFile(), serverPolicyPatch),
166+
HardcodedEntitlements.agentEntitlements(),
167+
pluginPolicies,
168+
scopeResolver,
169+
pluginSourcePaths,
170+
pathLookup
171+
);
172+
}
173+
154174
private static final Logger logger = LogManager.getLogger(EntitlementBootstrap.class);
155175
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
package org.elasticsearch.entitlement.initialization;
10+
package org.elasticsearch.entitlement.bootstrap;
1111

1212
import org.elasticsearch.core.Strings;
1313
import org.elasticsearch.entitlement.runtime.policy.FileAccessTree;
@@ -17,6 +17,7 @@
1717

1818
import java.nio.file.Path;
1919
import java.util.HashSet;
20+
import java.util.List;
2021
import java.util.Map;
2122
import java.util.Set;
2223

@@ -44,7 +45,7 @@ static void validate(Map<String, Policy> pluginPolicies, PathLookup pathLookup)
4445
.map(x -> ((FilesEntitlement) x))
4546
.findFirst();
4647
if (filesEntitlement.isPresent()) {
47-
var fileAccessTree = FileAccessTree.withoutExclusivePaths(filesEntitlement.get(), pathLookup, null);
48+
var fileAccessTree = FileAccessTree.withoutExclusivePaths(filesEntitlement.get(), pathLookup, List.of());
4849
validateReadFilesEntitlements(pluginPolicy.getKey(), scope.moduleName(), fileAccessTree, readAccessForbidden);
4950
validateWriteFilesEntitlements(pluginPolicy.getKey(), scope.moduleName(), fileAccessTree, writeAccessForbidden);
5051
}

0 commit comments

Comments
 (0)