Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public record BootstrapArgs(
Function<Class<?>, PolicyManager.PolicyScope> scopeResolver,
PathLookup pathLookup,
Map<String, Path> sourcePaths,
Set<Class<?>> suppressFailureLogClasses
Set<Package> suppressFailureLogPackages
) {
public BootstrapArgs {
requireNonNull(pluginPolicies);
requireNonNull(scopeResolver);
requireNonNull(pathLookup);
requireNonNull(sourcePaths);
requireNonNull(suppressFailureLogClasses);
requireNonNull(suppressFailureLogPackages);
}
}

Expand Down Expand Up @@ -78,7 +78,7 @@ public static BootstrapArgs bootstrapArgs() {
* @param tempDir the temp directory for Elasticsearch
* @param logsDir the log directory for Elasticsearch
* @param pidFile path to a pid file for Elasticsearch, or {@code null} if one was not specified
* @param suppressFailureLogClasses classes for which we do not need or want to log Entitlements failures
* @param suppressFailureLogPackages packages for which we do not need or want to log Entitlements failures
*/
public static void bootstrap(
Policy serverPolicyPatch,
Expand All @@ -95,7 +95,7 @@ public static void bootstrap(
Path logsDir,
Path tempDir,
Path pidFile,
Set<Class<?>> suppressFailureLogClasses
Set<Package> suppressFailureLogPackages
) {
logger.debug("Loading entitlement agent");
if (EntitlementBootstrap.bootstrapArgs != null) {
Expand All @@ -119,7 +119,7 @@ public static void bootstrap(
settingResolver
),
sourcePaths,
suppressFailureLogClasses
suppressFailureLogPackages
);
exportInitializationToAgent();
loadAgent(findAgentJar());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static PolicyManager createPolicyManager() {
EntitlementBootstrap.bootstrapArgs().sourcePaths(),
ENTITLEMENTS_MODULE,
pathLookup,
bootstrapArgs.suppressFailureLogClasses()
bootstrapArgs.suppressFailureLogPackages()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ ModuleEntitlements policyEntitlements(String componentName, Path componentPath,
private final Map<String, Map<String, List<Entitlement>>> pluginsEntitlements;
private final Function<Class<?>, PolicyScope> scopeResolver;
private final PathLookup pathLookup;
private final Set<Class<?>> mutedClasses;
private final Set<Package> suppressFailureLogPackages;

public static final String ALL_UNNAMED = "ALL-UNNAMED";

Expand Down Expand Up @@ -311,7 +311,7 @@ public PolicyManager(
Map<String, Path> sourcePaths,
Module entitlementsModule,
PathLookup pathLookup,
Set<Class<?>> suppressFailureLogClasses
Set<Package> suppressFailureLogPackages
) {
this.serverEntitlements = buildScopeEntitlementsMap(requireNonNull(serverPolicy));
this.apmAgentEntitlements = apmAgentEntitlements;
Expand All @@ -322,7 +322,7 @@ public PolicyManager(
this.sourcePaths = sourcePaths;
this.entitlementsModule = entitlementsModule;
this.pathLookup = requireNonNull(pathLookup);
this.mutedClasses = suppressFailureLogClasses;
this.suppressFailureLogPackages = suppressFailureLogPackages;

List<ExclusiveFileEntitlement> exclusiveFileEntitlements = new ArrayList<>();
for (var e : serverEntitlements.entrySet()) {
Expand Down Expand Up @@ -688,8 +688,8 @@ public void checkWriteProperty(Class<?> callerClass, String property) {

private void notEntitled(String message, Class<?> callerClass, ModuleEntitlements entitlements) {
var exception = new NotEntitledException(message);
// Don't emit a log for muted classes, e.g. classes containing self tests
if (mutedClasses.contains(callerClass) == false) {
// Don't emit a log for suppressed packages, e.g. packages containing self tests
if (suppressFailureLogPackages.contains(callerClass.getPackage()) == false) {
entitlements.logger().warn("Not entitled: {}", message, exception);
}
throw exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private static void initPhase2(Bootstrap bootstrap) throws IOException {
nodeEnv.logsDir(),
nodeEnv.tmpDir(),
args.pidFile(),
Set.of(EntitlementSelfTester.class)
Set.of(EntitlementSelfTester.class.getPackage())
);
EntitlementSelfTester.entitlementSelfTest();
} else {
Expand Down