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
1 change: 1 addition & 0 deletions libs/entitlement/asm-provider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ apply plugin: 'elasticsearch.build'
dependencies {
compileOnly project(':libs:entitlement')
compileOnly project(':libs:core')
compileOnly project(':libs:logging')
implementation 'org.ow2.asm:asm:9.7.1'
testImplementation project(":test:framework")
testImplementation project(":libs:entitlement:bridge")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
requires org.elasticsearch.entitlement;

requires static org.elasticsearch.base; // for SuppressForbidden
requires org.elasticsearch.logging;

provides InstrumentationService with InstrumentationServiceImpl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.elasticsearch.entitlement.instrumentation.CheckMethod;
import org.elasticsearch.entitlement.instrumentation.Instrumenter;
import org.elasticsearch.entitlement.instrumentation.MethodKey;
import org.elasticsearch.logging.LogManager;
import org.elasticsearch.logging.Logger;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
Expand All @@ -36,6 +38,7 @@
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;

public class InstrumenterImpl implements Instrumenter {
private static final Logger logger = LogManager.getLogger(InstrumenterImpl.class);

private final String getCheckerClassMethodDescriptor;
private final String handleClass;
Expand Down Expand Up @@ -155,10 +158,10 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str
var key = new MethodKey(className, name, Stream.of(Type.getArgumentTypes(descriptor)).map(Type::getInternalName).toList());
var instrumentationMethod = checkMethods.get(key);
if (instrumentationMethod != null) {
// System.out.println("Will instrument method " + key);
logger.debug("Will instrument {}", key);
return new EntitlementMethodVisitor(Opcodes.ASM9, mv, isStatic, isCtor, descriptor, instrumentationMethod);
} else {
// System.out.println("Will not instrument method " + key);
logger.trace("Will not instrument {}", key);
}
}
return mv;
Expand Down