From 60947a2dc90c99a55516565db2d67ea2e5410265 Mon Sep 17 00:00:00 2001 From: katherine-hough <32645020+katherine-hough@users.noreply.github.com> Date: Mon, 27 Nov 2023 09:20:25 -0500 Subject: [PATCH] * Moved static string checking from Instrumenter to Phosphor.java * Moved source/sink/taintThrough files from Instrumenter to BasicSourceSinkManager * Renamed Instrumenter.java to ClassNodeCache --- .../psl/phosphor/BasicSourceSinkManager.java | 13 +- .../cs/psl/phosphor/ClassNodeCache.java | 79 +++++++ .../ClassSupertypeReadingTransformer.java | 2 +- .../cs/psl/phosphor/Instrumenter.java | 193 ------------------ .../cs/psl/phosphor/PCLoggingTransformer.java | 2 +- .../columbia/cs/psl/phosphor/Phosphor.java | 113 +++++++++- .../cs/psl/phosphor/PhosphorOption.java | 6 +- .../cs/psl/phosphor/PhosphorPatcher.java | 39 ++-- .../control/ControlStackInitializingMV.java | 4 +- .../cs/psl/phosphor/control/OpcodesUtil.java | 6 +- .../DefaultTaintCheckingMethodVisitor.java | 8 +- .../instrumenter/ReflectionHidingMV.java | 16 +- .../phosphor/instrumenter/TaintPassingMV.java | 17 +- .../TaintTrackingClassVisitor.java | 12 +- .../instrumenter/UninstrumentedCompatMV.java | 4 +- .../phosphor/runtime/ReflectionMasker.java | 4 +- .../driver/PhosphorInstrumentation.java | 3 +- 17 files changed, 261 insertions(+), 260 deletions(-) create mode 100644 Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/ClassNodeCache.java delete mode 100644 Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/Instrumenter.java diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/BasicSourceSinkManager.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/BasicSourceSinkManager.java index 9c849fb5a..ddc4ba46c 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/BasicSourceSinkManager.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/BasicSourceSinkManager.java @@ -21,6 +21,9 @@ public class BasicSourceSinkManager extends SourceSinkManager { private static final Map> taintThrough = new HashMap<>(); // Maps class names to sets of class instances private static final Map>> classMap = new HashMap<>(); + public static InputStream sourcesFile; + public static InputStream sinksFile; + public static InputStream taintThroughFile; // Maps class names to a set of all methods listed as sources for the class or one of its supertypes or superinterfaces private static Map> inheritedSources = new HashMap<>(); // Maps class names to a set of all methods listed as sinks for the class or one of its supertypes or superinterfaces @@ -109,9 +112,9 @@ public String getBaseSink(String str) { /* Reads source, sink and taintThrough methods from their files into their respective maps. */ public static synchronized void loadTaintMethods() { - readTaintMethods(Instrumenter.sourcesFile, AutoTaint.SOURCE); - readTaintMethods(Instrumenter.sinksFile, AutoTaint.SINK); - readTaintMethods(Instrumenter.taintThroughFile, AutoTaint.TAINT_THROUGH); + readTaintMethods(sourcesFile, AutoTaint.SOURCE); + readTaintMethods(sinksFile, AutoTaint.SINK); + readTaintMethods(taintThroughFile, AutoTaint.TAINT_THROUGH); } /* Provides access to the single instance of BasicSourceSinkManager */ @@ -263,7 +266,7 @@ private static synchronized Set getAutoTaintMethods(String className, Ma // Add any methods from this class that are directly listed as auto taint methods set.addAll(baseMethods.get(className)); } - ClassNode cn = Instrumenter.getClassNode(className); + ClassNode cn = ClassNodeCache.getClassNode(className); if (cn != null) { if (cn.interfaces != null) { // Add all auto taint methods from interfaces implemented by this class @@ -295,7 +298,7 @@ private static synchronized String findSuperTypeAutoTaintProvider(String classNa if (baseMethods.containsKey(curClassName) && baseMethods.get(curClassName).contains(methodName)) { return curClassName; } - ClassNode cn = Instrumenter.getClassNode(curClassName); + ClassNode cn = ClassNodeCache.getClassNode(curClassName); if (cn != null) { if (cn.interfaces != null) { // Enqueue interfaces implemented by the current class diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/ClassNodeCache.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/ClassNodeCache.java new file mode 100644 index 000000000..905c810ec --- /dev/null +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/ClassNodeCache.java @@ -0,0 +1,79 @@ +package edu.columbia.cs.psl.phosphor; + +import edu.columbia.cs.psl.phosphor.struct.harmony.util.Collections; +import edu.columbia.cs.psl.phosphor.struct.harmony.util.HashMap; +import edu.columbia.cs.psl.phosphor.struct.harmony.util.Map; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.MethodNode; + +import java.io.InputStream; + +public final class ClassNodeCache { + public static Map classes = Collections.synchronizedMap(new HashMap<>()); + + static { + classes.putAll(ClassSupertypeReadingTransformer.classNodes); + ClassSupertypeReadingTransformer.classNodes = null; + } + + private ClassNodeCache() { + throw new AssertionError("Tried to instantiate static utility class: " + getClass()); + } + + /* Returns the class node associated with the specified class name or null if none exists and a new one could not + * successfully be created for the class name. */ + public static ClassNode getClassNode(String className) { + ClassNode cn = classes.get(className); + if (cn == null) { + // Class was loaded before ClassSupertypeReadingTransformer was added + return tryToAddClassNode(className); + } else { + return cn; + } + } + + /* Attempts to create a ClassNode populated with supertype information for this class. */ + private static ClassNode tryToAddClassNode(String className) { + try (InputStream is = ClassLoader.getSystemResourceAsStream(className + ".class")) { + if (is == null) { + return null; + } + ClassReader cr = new ClassReader(is); + cr.accept( + new ClassVisitor(Configuration.ASM_VERSION) { + private ClassNode cn; + + @Override + public void visit( + int version, + int access, + String name, + String signature, + String superName, + String[] interfaces) { + super.visit(version, access, name, signature, superName, interfaces); + cn = new ClassNode(); + cn.name = name; + cn.superName = superName; + cn.interfaces = new java.util.ArrayList<>(java.util.Arrays.asList(interfaces)); + cn.methods = new java.util.LinkedList<>(); + classes.put(name, cn); + } + + @Override + public MethodVisitor visitMethod( + int access, String name, String descriptor, String signature, String[] exceptions) { + cn.methods.add(new MethodNode(access, name, descriptor, signature, exceptions)); + return super.visitMethod(access, name, descriptor, signature, exceptions); + } + }, + ClassReader.SKIP_CODE); + return classes.get(className); + } catch (Exception e) { + return null; + } + } +} diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/ClassSupertypeReadingTransformer.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/ClassSupertypeReadingTransformer.java index 822bfd9fd..239519713 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/ClassSupertypeReadingTransformer.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/ClassSupertypeReadingTransformer.java @@ -27,7 +27,7 @@ public void visit(int version, int access, String name, String signature, String cn.superName = superName; cn.interfaces = new ArrayList<>(Arrays.asList(interfaces)); if(classNodes == null) { - Instrumenter.classes.put(name, cn); + ClassNodeCache.classes.put(name, cn); } else { classNodes.put(name, cn); } diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/Instrumenter.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/Instrumenter.java deleted file mode 100644 index 0308f3892..000000000 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/Instrumenter.java +++ /dev/null @@ -1,193 +0,0 @@ -package edu.columbia.cs.psl.phosphor; - -import edu.columbia.cs.psl.phosphor.runtime.StringUtils; -import edu.columbia.cs.psl.phosphor.struct.harmony.util.Collections; -import edu.columbia.cs.psl.phosphor.struct.harmony.util.HashMap; -import edu.columbia.cs.psl.phosphor.struct.harmony.util.Map; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.MethodNode; - -import java.io.InputStream; - -import static edu.columbia.cs.psl.phosphor.Configuration.controlFlowManagerPackage; -import static edu.columbia.cs.psl.phosphor.Configuration.taintTagFactoryPackage; - -public final class Instrumenter { - public static ClassLoader loader; - public static Map classes = Collections.synchronizedMap(new HashMap<>()); - public static InputStream sourcesFile; - public static InputStream sinksFile; - public static InputStream taintThroughFile; - - static { - classes.putAll(ClassSupertypeReadingTransformer.classNodes); - ClassSupertypeReadingTransformer.classNodes = null; - } - - private Instrumenter() { - throw new AssertionError("Tried to instantiate static utility class: " + getClass()); - } - - public static boolean isIgnoredClass(String owner) { - return Configuration.taintTagFactory.isIgnoredClass(owner) - || taintTagFactoryPackage != null && StringUtils.startsWith(owner, taintTagFactoryPackage) - || controlFlowManagerPackage != null && StringUtils.startsWith(owner, controlFlowManagerPackage) - || (Configuration.controlFlowManager != null && Configuration.controlFlowManager.isIgnoredClass(owner)) - || (Configuration.ADDL_IGNORE != null && StringUtils.startsWith(owner, Configuration.ADDL_IGNORE)) - // || !owner.startsWith("edu/columbia/cs/psl") - // For these classes: HotSpot expects fields to be at hardcoded offsets of these classes. - // If we instrument them, it will break those assumptions and segfault. - // Different classes have different assumptions, and there are special cases for these elsewhere in - // Phosphor. - || StringUtils.startsWith(owner, "java/lang/Object") - || StringUtils.startsWith(owner, "java/lang/Boolean") - || StringUtils.startsWith(owner, "java/lang/Character") - || StringUtils.startsWith(owner, "java/lang/Byte") - || StringUtils.startsWith(owner, "java/lang/Short") - || StringUtils.startsWith(owner, "java/lang/Number") - || StringUtils.startsWith(owner, "java/lang/ref/Reference") - || StringUtils.startsWith(owner, "java/lang/ref/FinalReference") - || StringUtils.startsWith(owner, "java/lang/ref/SoftReference") - // Lambdas are hosted by this class, and when generated, will have hard-coded offsets to constant pool - || StringUtils.equals(owner, "java/lang/invoke/LambdaForm") - // Lambdas are hosted by this class, and when generated, will have hard-coded offsets to constant pool - || StringUtils.startsWith(owner, "java/lang/invoke/LambdaForm$") - // Phosphor internal classes - || StringUtils.startsWith(owner, "edu/columbia/cs/psl/phosphor") - || StringUtils.startsWith(owner, "edu/gmu/swe/phosphor/ignored") - // Reflection is handled by: - // DelegatingMethod/ConstructorAccessorImpl calls either NativeMethod/ConstructorAccessorImpl OR - // calls GeneratedMethod/ConstructorAccessorImpl. - // We do the wrapping at the delegating level. - // Generated code won't be instrumented. - // Hence, it's convenient to also not wrap the native version, - // so that passed params/returns line up exactly when we hit the reflected call - || StringUtils.startsWith(owner, "edu/columbia/cs/psl/phosphor/struct/TaintedWith") - // Java 9+ class full of hardcoded offsets - || StringUtils.startsWith(owner, "jdk/internal/misc/UnsafeConstants"); - } - - public static boolean isIgnoredMethod(String owner, String name, String desc) { - return false; // TODO see below from old jdk14 version - // if(name.equals("wait") && desc.equals("(J)V")) { - // return true; - // } - // if(name.equals("wait") && desc.equals("(JI)V")) { - // return true; - // } - // if (owner.equals("jdk/internal/reflect/Reflection") && name.equals("getCallerClass")) { - // return true; - // } - // if (owner.equals("java/lang/invoke/MethodHandle") - // && ((name.equals("invoke") || name.equals("invokeBasic") || name.startsWith("linkTo")))) { - // return true; - // } - // return owner.equals("java/lang/invoke/VarHandle"); //TODO wrap these all - } - - public static boolean isPolymorphicSignatureMethod(String owner, String name) { - if (owner.equals("java/lang/invoke/VarHandle")) { - switch (name) { - case "get": - case "set": - case "getVolatile": - case "setVolatile": - case "getOpaque": - case "setOpaque": - case "getAcquire": - case "setRelease": - case "compareAndSet": - case "compareAndExchange": - case "compareAndExchangeAcquire": - case "compareAndExchangeRelease": - case "weakCompareAndSetPlain": - case "weakCompareAndSet": - case "weakCompareAndSetAcquire": - case "weakCompareAndSetRelease": - case "getAndSet": - case "getAndSetAcquire": - case "getAndSetRelease": - case "getAndAdd": - case "getAndAddAcquire": - case "getAndAddRelease": - case "getAndBitwiseOr": - case "getAndBitwiseOrAcquire": - case "getAndBitwiseOrRelease": - case "getAndBitwiseAnd": - case "getAndBitwiseAndAcquire": - case "getAndBitwiseAndRelease": - case "getAndBitwiseXor": - case "getAndBitwiseXorAcquire": - case "getAndBitwiseXorRelease": - return true; - } - } - return false; - } - - public static boolean isUninstrumentedField(String owner, String name) { - return owner.equals("sun/java2d/cmm/lcms/LCMSImageLayout") && name.equals("dataArray"); - } - - /* Returns the class node associated with the specified class name or null if none exists and a new one could not - * successfully be created for the class name. */ - public static ClassNode getClassNode(String className) { - ClassNode cn = classes.get(className); - if (cn == null) { - // Class was loaded before ClassSupertypeReadingTransformer was added - return tryToAddClassNode(className); - } else { - return cn; - } - } - - /* Attempts to create a ClassNode populated with supertype information for this class. */ - private static ClassNode tryToAddClassNode(String className) { - try (InputStream is = ClassLoader.getSystemResourceAsStream(className + ".class")) { - if (is == null) { - return null; - } - ClassReader cr = new ClassReader(is); - cr.accept( - new ClassVisitor(Configuration.ASM_VERSION) { - private ClassNode cn; - - @Override - public void visit( - int version, - int access, - String name, - String signature, - String superName, - String[] interfaces) { - super.visit(version, access, name, signature, superName, interfaces); - cn = new ClassNode(); - cn.name = name; - cn.superName = superName; - cn.interfaces = new java.util.ArrayList<>(java.util.Arrays.asList(interfaces)); - cn.methods = new java.util.LinkedList<>(); - classes.put(name, cn); - } - - @Override - public MethodVisitor visitMethod( - int access, String name, String descriptor, String signature, String[] exceptions) { - cn.methods.add(new MethodNode(access, name, descriptor, signature, exceptions)); - return super.visitMethod(access, name, descriptor, signature, exceptions); - } - }, - ClassReader.SKIP_CODE); - return classes.get(className); - } catch (Exception e) { - return null; - } - } - - public static boolean isUnsafeClass(String className) { - return (Configuration.IS_JAVA_8 && "sun/misc/Unsafe".equals(className)) - || (!Configuration.IS_JAVA_8 && "jdk/internal/misc/Unsafe".equals(className)); - } -} diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PCLoggingTransformer.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PCLoggingTransformer.java index fdd4d67a2..218385167 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PCLoggingTransformer.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PCLoggingTransformer.java @@ -34,7 +34,7 @@ public byte[] transform(ClassLoader loader, final String className2, Class cl ClassReader cr = (Configuration.READ_AND_SAVE_BCI ? new OffsetPreservingClassReader(classfileBuffer) : new ClassReader(classfileBuffer)); String className = cr.getClassName(); - if (Instrumenter.isIgnoredClass(className)) { + if (Phosphor.isIgnoredClass(className)) { switch (className) { case "java/lang/Boolean": case "java/lang/Byte": diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/Phosphor.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/Phosphor.java index 38c034e6a..ad3719a4d 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/Phosphor.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/Phosphor.java @@ -2,8 +2,12 @@ import edu.columbia.cs.psl.phosphor.instrumenter.InvokedViaInstrumentation; import edu.columbia.cs.psl.phosphor.instrumenter.TaintMethodRecord; +import edu.columbia.cs.psl.phosphor.runtime.StringUtils; import edu.columbia.cs.psl.phosphor.struct.SinglyLinkedList; +import static edu.columbia.cs.psl.phosphor.Configuration.controlFlowManagerPackage; +import static edu.columbia.cs.psl.phosphor.Configuration.taintTagFactoryPackage; + public final class Phosphor { public static boolean DEBUG = System.getProperty("phosphor.debug") != null; public static boolean RUNTIME_INST = false; @@ -25,9 +29,6 @@ public static void initialize(String agentArgs, InstrumentationAdaptor instrumen if (System.getProperty("phosphorCacheDirectory") != null) { Configuration.CACHE = TransformationCache.getInstance(System.getProperty("phosphorCacheDirectory")); } - if (Instrumenter.loader == null) { - Instrumenter.loader = bigLoader; - } // Ensure that BasicSourceSinkManager and anything needed to call isSourceOrSinkOrTaintThrough gets initialized BasicSourceSinkManager.loadTaintMethods(); BasicSourceSinkManager.getInstance().isSourceOrSinkOrTaintThrough(Object.class); @@ -67,4 +68,110 @@ private static String[] parseOptions(String agentArgs) { } return options.toArray(new String[0]); } + + public static boolean isIgnoredClass(String owner) { + return Configuration.taintTagFactory.isIgnoredClass(owner) + || taintTagFactoryPackage != null && StringUtils.startsWith(owner, taintTagFactoryPackage) + || controlFlowManagerPackage != null && StringUtils.startsWith(owner, controlFlowManagerPackage) + || (Configuration.controlFlowManager != null && Configuration.controlFlowManager.isIgnoredClass(owner)) + || (Configuration.ADDL_IGNORE != null && StringUtils.startsWith(owner, Configuration.ADDL_IGNORE)) + // || !owner.startsWith("edu/columbia/cs/psl") + // For these classes: HotSpot expects fields to be at hardcoded offsets of these classes. + // If we instrument them, it will break those assumptions and segfault. + // Different classes have different assumptions, and there are special cases for these elsewhere in + // Phosphor. + || StringUtils.startsWith(owner, "java/lang/Object") + || StringUtils.startsWith(owner, "java/lang/Boolean") + || StringUtils.startsWith(owner, "java/lang/Character") + || StringUtils.startsWith(owner, "java/lang/Byte") + || StringUtils.startsWith(owner, "java/lang/Short") + || StringUtils.startsWith(owner, "java/lang/Number") + || StringUtils.startsWith(owner, "java/lang/ref/Reference") + || StringUtils.startsWith(owner, "java/lang/ref/FinalReference") + || StringUtils.startsWith(owner, "java/lang/ref/SoftReference") + // Lambdas are hosted by this class, and when generated, will have hard-coded offsets to constant pool + || StringUtils.equals(owner, "java/lang/invoke/LambdaForm") + // Lambdas are hosted by this class, and when generated, will have hard-coded offsets to constant pool + || StringUtils.startsWith(owner, "java/lang/invoke/LambdaForm$") + // Phosphor internal classes + || StringUtils.startsWith(owner, "edu/columbia/cs/psl/phosphor") + || StringUtils.startsWith(owner, "edu/gmu/swe/phosphor/ignored") + // Reflection is handled by: + // DelegatingMethod/ConstructorAccessorImpl calls either NativeMethod/ConstructorAccessorImpl OR + // calls GeneratedMethod/ConstructorAccessorImpl. + // We do the wrapping at the delegating level. + // Generated code won't be instrumented. + // Hence, it's convenient to also not wrap the native version, + // so that passed params/returns line up exactly when we hit the reflected call + || StringUtils.startsWith(owner, "edu/columbia/cs/psl/phosphor/struct/TaintedWith") + // Java 9+ class full of hardcoded offsets + || StringUtils.startsWith(owner, "jdk/internal/misc/UnsafeConstants"); + } + + public static boolean isIgnoredMethod(String owner, String name, String desc) { + return false; // TODO see below from old jdk14 version + // if(name.equals("wait") && desc.equals("(J)V")) { + // return true; + // } + // if(name.equals("wait") && desc.equals("(JI)V")) { + // return true; + // } + // if (owner.equals("jdk/internal/reflect/Reflection") && name.equals("getCallerClass")) { + // return true; + // } + // if (owner.equals("java/lang/invoke/MethodHandle") + // && ((name.equals("invoke") || name.equals("invokeBasic") || name.startsWith("linkTo")))) { + // return true; + // } + // return owner.equals("java/lang/invoke/VarHandle"); //TODO wrap these all + } + + public static boolean isPolymorphicSignatureMethod(String owner, String name) { + if (owner.equals("java/lang/invoke/VarHandle")) { + switch (name) { + case "get": + case "set": + case "getVolatile": + case "setVolatile": + case "getOpaque": + case "setOpaque": + case "getAcquire": + case "setRelease": + case "compareAndSet": + case "compareAndExchange": + case "compareAndExchangeAcquire": + case "compareAndExchangeRelease": + case "weakCompareAndSetPlain": + case "weakCompareAndSet": + case "weakCompareAndSetAcquire": + case "weakCompareAndSetRelease": + case "getAndSet": + case "getAndSetAcquire": + case "getAndSetRelease": + case "getAndAdd": + case "getAndAddAcquire": + case "getAndAddRelease": + case "getAndBitwiseOr": + case "getAndBitwiseOrAcquire": + case "getAndBitwiseOrRelease": + case "getAndBitwiseAnd": + case "getAndBitwiseAndAcquire": + case "getAndBitwiseAndRelease": + case "getAndBitwiseXor": + case "getAndBitwiseXorAcquire": + case "getAndBitwiseXorRelease": + return true; + } + } + return false; + } + + public static boolean isUninstrumentedField(String owner, String name) { + return owner.equals("sun/java2d/cmm/lcms/LCMSImageLayout") && name.equals("dataArray"); + } + + public static boolean isUnsafeClass(String className) { + return (Configuration.IS_JAVA_8 && "sun/misc/Unsafe".equals(className)) + || (!Configuration.IS_JAVA_8 && "jdk/internal/misc/Unsafe".equals(className)); + } } diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorOption.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorOption.java index ecbb26116..8af955070 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorOption.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorOption.java @@ -202,7 +202,7 @@ public void configure(boolean forRuntimeInst, boolean isPresent, CommandLine com if(isPresent) { String value = commandLine.getOptionValue(optionName); try { - Instrumenter.sourcesFile = new FileInputStream(value); + BasicSourceSinkManager.sourcesFile = new FileInputStream(value); } catch(FileNotFoundException e) { e.printStackTrace(); } @@ -215,7 +215,7 @@ public void configure(boolean forRuntimeInst, boolean isPresent, CommandLine com if(isPresent) { String value = commandLine.getOptionValue(optionName); try { - Instrumenter.sinksFile = new FileInputStream(value); + BasicSourceSinkManager.sinksFile = new FileInputStream(value); } catch(FileNotFoundException e) { e.printStackTrace(); } @@ -228,7 +228,7 @@ public void configure(boolean forRuntimeInst, boolean isPresent, CommandLine com if(isPresent) { String value = commandLine.getOptionValue(optionName); try { - Instrumenter.taintThroughFile = new FileInputStream(value); + BasicSourceSinkManager.taintThroughFile = new FileInputStream(value); } catch(FileNotFoundException e) { e.printStackTrace(); } diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorPatcher.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorPatcher.java index b21dea36f..5c2328ecb 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorPatcher.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorPatcher.java @@ -15,15 +15,19 @@ public class PhosphorPatcher { private final boolean patchUnsafeNames; public PhosphorPatcher(byte[] unsafeClassFileBuffer) { - this.patchUnsafeNames = shouldPatchUnsafeNames(unsafeClassFileBuffer); + this(shouldPatchUnsafeNames(unsafeClassFileBuffer)); + } + + public PhosphorPatcher(boolean patchUnsafeNames) { + this.patchUnsafeNames = patchUnsafeNames; } public byte[] patch(String name, byte[] content) throws IOException { if (name.equals("edu/columbia/cs/psl/phosphor/Configuration.class")) { return setConfigurationVersion(new ByteArrayInputStream(content)); } else if (name.equals("edu/columbia/cs/psl/phosphor/runtime/RuntimeJDKInternalUnsafePropagator.class")) { - return transformUnsafePropagator(new ByteArrayInputStream(content), - "jdk/internal/misc/Unsafe", patchUnsafeNames); + return transformUnsafePropagator( + new ByteArrayInputStream(content), "jdk/internal/misc/Unsafe", patchUnsafeNames); } else if (AsmPatchingCV.isApplicable(name)) { return AsmPatchingCV.patch(content); } else { @@ -51,8 +55,8 @@ private static byte[] setConfigurationVersion(InputStream is) throws IOException ClassWriter cw = new ClassWriter(cr, 0); ClassVisitor cv = new ClassVisitor(Configuration.ASM_VERSION, cw) { @Override - public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, - String[] exceptions) { + public MethodVisitor visitMethod( + int access, String name, String descriptor, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions); if (name.equals("")) { return new ConfigurationEmbeddingMV(mv); @@ -65,8 +69,8 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str return cw.toByteArray(); } - public static byte[] transformUnsafePropagator(InputStream in, String unsafeInternalName, - boolean patchUnsafeNames) throws IOException { + public static byte[] transformUnsafePropagator(InputStream in, String unsafeInternalName, boolean patchUnsafeNames) + throws IOException { ClassReader cr = new ClassReader(in); ClassWriter cw = new ClassWriter(cr, 0); ClassVisitor cv = new UnsafePatchingCV(cw, unsafeInternalName, patchUnsafeNames); @@ -97,12 +101,12 @@ private String patchDesc(String desc) { } private String patchMethodName(String owner, String name) { - return patchNames && owner.equals(UNSAFE_PROXY_INTERNAL_NAME) ? - name.replace("Reference", "Object") : name; + return patchNames && owner.equals(UNSAFE_PROXY_INTERNAL_NAME) ? name.replace("Reference", "Object") : name; } @Override - public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { + public MethodVisitor visitMethod( + int access, String name, String descriptor, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, patchDesc(descriptor), patchDesc(signature), exceptions); return new MethodVisitor(api, mv) { @Override @@ -126,9 +130,14 @@ public void visitFieldInsn(int opcode, String owner, String name, String descrip } @Override - public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) { - super.visitMethodInsn(opcode, patchInternalName(owner), patchMethodName(owner, name), - patchDesc(descriptor), isInterface); + public void visitMethodInsn( + int opcode, String owner, String name, String descriptor, boolean isInterface) { + super.visitMethodInsn( + opcode, + patchInternalName(owner), + patchMethodName(owner, name), + patchDesc(descriptor), + isInterface); } @Override @@ -137,8 +146,8 @@ public void visitTypeInsn(int opcode, String type) { } @Override - public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end, - int index) { + public void visitLocalVariable( + String name, String descriptor, String signature, Label start, Label end, int index) { super.visitLocalVariable(name, patchDesc(descriptor), signature, start, end, index); } }; diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/control/ControlStackInitializingMV.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/control/ControlStackInitializingMV.java index 7bf481ed1..ebc429bde 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/control/ControlStackInitializingMV.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/control/ControlStackInitializingMV.java @@ -1,7 +1,7 @@ package edu.columbia.cs.psl.phosphor.control; import edu.columbia.cs.psl.phosphor.Configuration; -import edu.columbia.cs.psl.phosphor.Instrumenter; +import edu.columbia.cs.psl.phosphor.Phosphor; import edu.columbia.cs.psl.phosphor.instrumenter.LocalVariableManager; import org.objectweb.asm.Handle; import org.objectweb.asm.MethodVisitor; @@ -75,7 +75,7 @@ public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootst * a control stack */ private int methodNotIgnoredAndPassedControlStack(String owner, String name, String descriptor) { - if(!Instrumenter.isIgnoredClass(owner) && !Instrumenter.isIgnoredMethod(owner, name, descriptor)) { + if(!Phosphor.isIgnoredClass(owner) && !Phosphor.isIgnoredMethod(owner, name, descriptor)) { Type[] args = Type.getArgumentTypes(descriptor); for(int dist = 0; dist < args.length; dist++) { Type arg = args[args.length - 1 - dist]; diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/control/OpcodesUtil.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/control/OpcodesUtil.java index 2385ce5da..c924eaef4 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/control/OpcodesUtil.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/control/OpcodesUtil.java @@ -1,6 +1,6 @@ package edu.columbia.cs.psl.phosphor.control; -import edu.columbia.cs.psl.phosphor.Instrumenter; +import edu.columbia.cs.psl.phosphor.ClassNodeCache; import edu.columbia.cs.psl.phosphor.TaintUtils; import edu.columbia.cs.psl.phosphor.struct.harmony.util.HashSet; import edu.columbia.cs.psl.phosphor.struct.harmony.util.LinkedList; @@ -365,7 +365,7 @@ private static MethodNode findMethod(String owner, String name, String descripto if(owner == null || name == null || descriptor == null) { throw new NullPointerException(); } - ClassNode cn = Instrumenter.getClassNode(owner); + ClassNode cn = ClassNodeCache.getClassNode(owner); if(cn != null) { for(MethodNode methodNode : cn.methods) { if(descriptor.equals(methodNode.desc) && name.equals(methodNode.name)) { @@ -394,7 +394,7 @@ private static Set getSuperClasses(String className) { ancestors.add(className); while(true) { String currentClass = ancestors.getLast(); - ClassNode classNode = Instrumenter.getClassNode(currentClass); + ClassNode classNode = ClassNodeCache.getClassNode(currentClass); if(classNode == null) { return null; } else if(classNode.superName == null) { diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/DefaultTaintCheckingMethodVisitor.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/DefaultTaintCheckingMethodVisitor.java index 71a7a55fa..7a2e44293 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/DefaultTaintCheckingMethodVisitor.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/DefaultTaintCheckingMethodVisitor.java @@ -1,7 +1,7 @@ package edu.columbia.cs.psl.phosphor.instrumenter; import edu.columbia.cs.psl.phosphor.Configuration; -import edu.columbia.cs.psl.phosphor.Instrumenter; +import edu.columbia.cs.psl.phosphor.Phosphor; import edu.columbia.cs.psl.phosphor.TaintUtils; import edu.columbia.cs.psl.phosphor.instrumenter.analyzer.NeverNullArgAnalyzerAdapter; import edu.columbia.cs.psl.phosphor.instrumenter.analyzer.ReferenceArrayTarget; @@ -91,7 +91,7 @@ public void visitFieldInsn(int opcode, String owner, String name, String desc) { super.visitFieldInsn(opcode, owner, name, desc); return; } - if(opcode == Opcodes.GETFIELD && !Instrumenter.isIgnoredClass(owner) && name.endsWith(TaintUtils.TAINT_WRAPPER_FIELD) && + if(opcode == Opcodes.GETFIELD && !Phosphor.isIgnoredClass(owner) && name.endsWith(TaintUtils.TAINT_WRAPPER_FIELD) && !checkedThisFrame.contains(owner + "." + name) && (owner.equals("java/lang/String") || implementsSerializable || owner.equals("java/io/BufferedInputStream") || owner.equals("java/lang/AssertionStatusDirectives") @@ -143,7 +143,7 @@ public void visitFieldInsn(int opcode, String owner, String name, String desc) { super.visitLabel(isOK); TaintAdapter.acceptFn(fn1, this); super.visitFieldInsn(opcode, owner, name, desc); - } else if(opcode == Opcodes.GETFIELD && !Instrumenter.isIgnoredClass(owner) && accessedType.getSort() == Type.ARRAY && !name.equals("taint") && + } else if(opcode == Opcodes.GETFIELD && !Phosphor.isIgnoredClass(owner) && accessedType.getSort() == Type.ARRAY && !name.equals("taint") && accessedType.getElementType().getSort() != Type.OBJECT && accessedType.getDimensions() == 2 && !checkedThisFrame.contains(owner + "." + name)) { //For 2D wrapped arrays //TODO @@ -189,7 +189,7 @@ public void visitFieldInsn(int opcode, String owner, String name, String desc) { super.visitInsn(SWAP); super.visitFieldInsn(opcode, owner, name, desc); throw new UnsupportedOperationException(); - } else if(opcode == Opcodes.GETFIELD && !Instrumenter.isIgnoredClass(owner) && accessedType.getSort() == Type.ARRAY && !name.endsWith(TaintUtils.TAINT_WRAPPER_FIELD) && !name.equals("taint") && + } else if(opcode == Opcodes.GETFIELD && !Phosphor.isIgnoredClass(owner) && accessedType.getSort() == Type.ARRAY && !name.endsWith(TaintUtils.TAINT_WRAPPER_FIELD) && !name.equals("taint") && accessedType.getElementType().getSort() != Type.OBJECT && accessedType.getDimensions() == 3 && !checkedThisFrame.contains(owner + "." + name)) { super.visitInsn(SWAP); super.visitInsn(POP); diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/ReflectionHidingMV.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/ReflectionHidingMV.java index c4773c39d..484d244de 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/ReflectionHidingMV.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/ReflectionHidingMV.java @@ -1,7 +1,7 @@ package edu.columbia.cs.psl.phosphor.instrumenter; import edu.columbia.cs.psl.phosphor.Configuration; -import edu.columbia.cs.psl.phosphor.Instrumenter; +import edu.columbia.cs.psl.phosphor.Phosphor; import edu.columbia.cs.psl.phosphor.runtime.*; import edu.columbia.cs.psl.phosphor.runtime.jdk.unsupported.RuntimeSunMiscUnsafePropagator; import org.objectweb.asm.MethodVisitor; @@ -61,7 +61,7 @@ private void maskGetter(TaintMethodRecord mask, Type[] args) { /* Returns whether a method instruction with the specified information is for a method added to Unsafe by Phosphor * that retrieves the value of a field of a Java heap object. */ private boolean isUnsafeFieldGetter(int opcode, String owner, String name, Type[] args, String nameWithoutSuffix) { - if (opcode != INVOKEVIRTUAL || !Instrumenter.isUnsafeClass(owner)) { + if (opcode != INVOKEVIRTUAL || !Phosphor.isUnsafeClass(owner)) { return false; } else { if (args.length < 1 || !args[0].equals(Type.getType(Object.class))) { @@ -99,7 +99,7 @@ private boolean isUnsafeFieldGetter(int opcode, String owner, String name, Type[ /* Returns whether a method instruction with the specified information is for a method added to Unsafe by Phosphor * that sets the value of a field of a Java heap object. */ private boolean isUnsafeFieldSetter(int opcode, String owner, String name, Type[] args, String nameWithoutSuffix) { - if (opcode != INVOKEVIRTUAL || !Instrumenter.isUnsafeClass(owner)) { + if (opcode != INVOKEVIRTUAL || !Phosphor.isUnsafeClass(owner)) { return false; } else { if (args.length < 1 || !args[0].equals(Type.getType(Object.class))) { @@ -140,7 +140,7 @@ private boolean isUnsafeFieldSetter(int opcode, String owner, String name, Type[ /* Returns whether a method instruction with the specified information is for a method added to Unsafe by Phosphor * for a compareAndSwap method. */ private boolean isUnsafeCAS(String owner, String name, String nameWithoutSuffix) { - if (!Instrumenter.isUnsafeClass(owner)) { + if (!Phosphor.isUnsafeClass(owner)) { return false; } else { if (Configuration.IS_JAVA_8) { @@ -156,7 +156,7 @@ private boolean isUnsafeIntrinsic(String owner, String name, String desc) { if(Configuration.IS_JAVA_8){ return false; //These intrinsics are only for 9+ } - if (!Instrumenter.isUnsafeClass(owner)) { + if (!Phosphor.isUnsafeClass(owner)) { return false; } // Java 11 uses get/putObject instead of Reference @@ -428,7 +428,7 @@ private boolean isUnsafeIntrinsic(String owner, String name, String desc) { } private boolean isUnsafeCopyMemory(String owner, String name, String nameWithoutSuffix) { - if (Instrumenter.isUnsafeClass(owner)) { + if (Phosphor.isUnsafeClass(owner)) { switch (nameWithoutSuffix) { case "copyMemory": case "copySwapMemory": @@ -472,7 +472,7 @@ public void visitMethodInsn(int opcode, String owner, String name, String desc, super.visitMethodInsn(opcode, owner, name, desc, isInterface); } } else { - if (patchAnonymousClasses && name.equals("defineAnonymousClass") && Instrumenter.isUnsafeClass(owner) && descWithoutStackFrame.equals("(Ljava/lang/Class;[B[Ljava/lang/Object;)Ljava/lang/Class;")) { + if (patchAnonymousClasses && name.equals("defineAnonymousClass") && Phosphor.isUnsafeClass(owner) && descWithoutStackFrame.equals("(Ljava/lang/Class;[B[Ljava/lang/Object;)Ljava/lang/Class;")) { super.visitInsn(POP); super.visitInsn(SWAP); INSTRUMENT_CLASS_BYTES_ANONYMOUS.delegateVisit(mv); @@ -500,7 +500,7 @@ public void visitMethodInsn(int opcode, String owner, String name, String desc, if (owner.equals("java/lang/reflect/Array") && !owner.equals(className)) { owner = Type.getInternalName(ArrayReflectionMasker.class); } - if (name.equals("allocateUninitializedArray") && Instrumenter.isUnsafeClass(owner)) { + if (name.equals("allocateUninitializedArray") && Phosphor.isUnsafeClass(owner)) { desc = "(L" + owner + ";" + desc.substring(1); super.visitMethodInsn(Opcodes.INVOKESTATIC, getRuntimeUnsafePropogatorClassName(), name, desc, false); return; diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/TaintPassingMV.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/TaintPassingMV.java index bf3e7d386..9a9ba8c94 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/TaintPassingMV.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/TaintPassingMV.java @@ -1,9 +1,6 @@ package edu.columbia.cs.psl.phosphor.instrumenter; -import edu.columbia.cs.psl.phosphor.Configuration; -import edu.columbia.cs.psl.phosphor.Instrumenter; -import edu.columbia.cs.psl.phosphor.PhosphorInstructionInfo; -import edu.columbia.cs.psl.phosphor.TaintUtils; +import edu.columbia.cs.psl.phosphor.*; import edu.columbia.cs.psl.phosphor.control.ControlFlowPropagationPolicy; import edu.columbia.cs.psl.phosphor.control.OpcodesUtil; import edu.columbia.cs.psl.phosphor.instrumenter.analyzer.NeverNullArgAnalyzerAdapter; @@ -268,9 +265,9 @@ public void visitFieldInsn(int opcode, String owner, String name, String desc) { if (descType.getSort() == Type.ARRAY && descType.getDimensions() > 1) { desc = MultiDArrayUtils.getTypeForType(descType).getDescriptor(); } - boolean isIgnoredTaint = Instrumenter.isIgnoredClass(owner); + boolean isIgnoredTaint = Phosphor.isIgnoredClass(owner); //|| Instrumenter.isIgnoredClassWithStubsButNoTracking(owner); - if (Instrumenter.isUninstrumentedField(owner, name) || isIgnoredTaint) { + if (Phosphor.isUninstrumentedField(owner, name) || isIgnoredTaint) { switch (opcode) { case GETFIELD: case GETSTATIC: @@ -834,7 +831,7 @@ When creating a new primitive wrapper (java.lang.Integer etc), assign the refere } private static boolean isIgnoredMethod(String owner, String name, String desc) { - if (Instrumenter.isIgnoredClass(owner) && !owner.equals("edu/columbia/cs/psl/phosphor/runtime/MultiTainter")) { + if (Phosphor.isIgnoredClass(owner) && !owner.equals("edu/columbia/cs/psl/phosphor/runtime/MultiTainter")) { return true; } if (StringUtils.startsWith(owner, "jdk/internal/module/SystemModules")) { @@ -883,12 +880,12 @@ private String prepareForCallTo(String owner, String name, String desc) { PREPARE_FOR_CALL_PREV.delegateVisit(mv); } else { if (Configuration.DEBUG_STACK_FRAME_WRAPPERS) { - String methodKey = getMethodKeyForStackFrame(name, desc, Instrumenter.isPolymorphicSignatureMethod(owner, name)); + String methodKey = getMethodKeyForStackFrame(name, desc, Phosphor.isPolymorphicSignatureMethod(owner, name)); mv.visitLdcInsn(methodKey); PREPARE_FOR_CALL_DEBUG.delegateVisit(mv); } else { push(TaintAdapter.getHashForStackFrame(name, desc, - Instrumenter.isPolymorphicSignatureMethod(owner, name))); + Phosphor.isPolymorphicSignatureMethod(owner, name))); PREPARE_FOR_CALL_FAST.delegateVisit(mv); } } @@ -896,7 +893,7 @@ private String prepareForCallTo(String owner, String name, String desc) { } else { if (Configuration.DEBUG_STACK_FRAME_WRAPPERS) { super.visitInsn(DUP); - String methodKey = getMethodKeyForStackFrame(name, desc, Instrumenter.isPolymorphicSignatureMethod(owner, name)); + String methodKey = getMethodKeyForStackFrame(name, desc, Phosphor.isPolymorphicSignatureMethod(owner, name)); mv.visitLdcInsn(methodKey); PREPARE_FOR_CALL_DEBUG.delegateVisit(mv); } diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/TaintTrackingClassVisitor.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/TaintTrackingClassVisitor.java index cfe8843ae..44ad701ac 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/TaintTrackingClassVisitor.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/TaintTrackingClassVisitor.java @@ -1,7 +1,7 @@ package edu.columbia.cs.psl.phosphor.instrumenter; import edu.columbia.cs.psl.phosphor.Configuration; -import edu.columbia.cs.psl.phosphor.Instrumenter; +import edu.columbia.cs.psl.phosphor.Phosphor; import edu.columbia.cs.psl.phosphor.TaintUtils; import edu.columbia.cs.psl.phosphor.control.ControlFlowPropagationPolicy; import edu.columbia.cs.psl.phosphor.control.ControlFlowStack; @@ -127,7 +127,7 @@ public void visit(int version, int access, String name, String signature, String isLambda = name.contains("$$Lambda$"); - if (superName != null && !superName.equals("java/lang/Object") && !Instrumenter.isIgnoredClass(superName)) { + if (superName != null && !superName.equals("java/lang/Object") && !Phosphor.isIgnoredClass(superName)) { addTaintField = false; addTaintMethod = true; } @@ -137,7 +137,7 @@ public void visit(int version, int access, String name, String signature, String if (addTaintField) { addTaintMethod = true; } - if (superName != null && (superName.equals("java/lang/Object") || Instrumenter.isIgnoredClass(superName)) && !isInterface + if (superName != null && (superName.equals("java/lang/Object") || Phosphor.isIgnoredClass(superName)) && !isInterface && !isAnnotation) { generateEquals = true; generateHashCode = true; @@ -164,7 +164,7 @@ public void visit(int version, int access, String name, String signature, String } } } - if (isNormalClass && !Instrumenter.isIgnoredClass(name) && !FIELDS_ONLY) { + if (isNormalClass && !Phosphor.isIgnoredClass(name) && !FIELDS_ONLY) { String[] newIntfcs = new String[interfaces.length + 1]; System.arraycopy(interfaces, 0, newIntfcs, 0, interfaces.length); newIntfcs[interfaces.length] = Type.getInternalName(TaintedWithObjTag.class); @@ -185,7 +185,7 @@ public void visit(int version, int access, String name, String signature, String this.className = name; this.superName = superName; - if (superName != null && Instrumenter.isIgnoredClass(superName)) { + if (superName != null && Phosphor.isIgnoredClass(superName)) { //Might need to override stuff. Class c; try { @@ -322,7 +322,7 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si if (className.equals("java/lang/reflect/Array") && name.equals("newArray")) { access = (access & ~Opcodes.ACC_PRIVATE) | Opcodes.ACC_PUBLIC; } - if (Instrumenter.isUnsafeClass(className)){ + if (Phosphor.isUnsafeClass(className)){ access = (access & ~Opcodes.ACC_PRIVATE) | Opcodes.ACC_PUBLIC; } diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/UninstrumentedCompatMV.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/UninstrumentedCompatMV.java index 36b704c4e..0a3cbcaa6 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/UninstrumentedCompatMV.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/instrumenter/UninstrumentedCompatMV.java @@ -1,7 +1,7 @@ package edu.columbia.cs.psl.phosphor.instrumenter; import edu.columbia.cs.psl.phosphor.Configuration; -import edu.columbia.cs.psl.phosphor.Instrumenter; +import edu.columbia.cs.psl.phosphor.Phosphor; import edu.columbia.cs.psl.phosphor.TaintUtils; import edu.columbia.cs.psl.phosphor.instrumenter.analyzer.NeverNullArgAnalyzerAdapter; import edu.columbia.cs.psl.phosphor.instrumenter.analyzer.ReferenceArrayTarget; @@ -316,7 +316,7 @@ public void visitCode() { @Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { - if (Instrumenter.isIgnoredClass(owner)) { + if (Phosphor.isIgnoredClass(owner)) { super.visitMethodInsn(opcode, owner, name, desc, itf); return; } diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/ReflectionMasker.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/ReflectionMasker.java index eac10e2ad..55f18ad30 100644 --- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/ReflectionMasker.java +++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/runtime/ReflectionMasker.java @@ -1,6 +1,6 @@ package edu.columbia.cs.psl.phosphor.runtime; -import edu.columbia.cs.psl.phosphor.Instrumenter; +import edu.columbia.cs.psl.phosphor.Phosphor; import edu.columbia.cs.psl.phosphor.TaintUtils; import edu.columbia.cs.psl.phosphor.instrumenter.InvokedViaInstrumentation; import edu.columbia.cs.psl.phosphor.runtime.proxied.InstrumentedJREFieldHelper; @@ -76,7 +76,7 @@ private static boolean isIgnoredClass(Class clazz) { return true; } String cName = clazz.getName().replace('.', '/'); - if (Instrumenter.isIgnoredClass(cName)) { + if (Phosphor.isIgnoredClass(cName)) { return true; } if (StringUtils.startsWith(cName, "jdk/internal/reflect/Generated") || StringUtils.startsWith(cName, "sun/reflect/Generated")) { diff --git a/phosphor-driver/src/main/java/edu/columbia/cs/psl/phosphor/driver/PhosphorInstrumentation.java b/phosphor-driver/src/main/java/edu/columbia/cs/psl/phosphor/driver/PhosphorInstrumentation.java index eb4930b05..50dd9ee88 100644 --- a/phosphor-driver/src/main/java/edu/columbia/cs/psl/phosphor/driver/PhosphorInstrumentation.java +++ b/phosphor-driver/src/main/java/edu/columbia/cs/psl/phosphor/driver/PhosphorInstrumentation.java @@ -1,7 +1,6 @@ package edu.columbia.cs.psl.phosphor.driver; import edu.columbia.cs.psl.phosphor.*; -import edu.columbia.cs.psl.phosphor.agent.PhosphorAgent; import edu.columbia.cs.psl.phosphor.instrumenter.TaintTrackingClassVisitor; import edu.columbia.cs.psl.phosphor.org.apache.commons.cli.CommandLine; @@ -44,7 +43,7 @@ public void initialize(CommandLine line) throws IOException { TaintTrackingClassVisitor.IS_RUNTIME_INST = false; transformer = new PCLoggingTransformer(); classPathElements = new HashSet<>(); - classPathElements.add(InstrumentUtil.getClassPathElement(PhosphorAgent.class)); + classPathElements.add(InstrumentUtil.getClassPathElement(Phosphor.class)); configurationClasses.stream() .map(InstrumentUtil::getClassPathElement) .forEach(classPathElements::add);