-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed issue with failure in AnnotationInstCase not being reported f…
…or Java 8 * Fixed failure in AnnotationInstCase for Java 8 by patching ASM for Java 8 * Fixed JavaDoc warnings * Refactored ConfigurationEmbeddingMV * Moved classes not used to by the agent at runtime to the package edu.columbia.cs.psl.phosphor.agent
- Loading branch information
1 parent
805c4d6
commit 0772550
Showing
27 changed files
with
400 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/agent/AsmPatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package edu.columbia.cs.psl.phosphor.agent; | ||
|
||
import edu.columbia.cs.psl.phosphor.Configuration; | ||
import edu.columbia.cs.psl.phosphor.instrumenter.TaintMethodRecord; | ||
import org.objectweb.asm.*; | ||
|
||
public class AsmPatcher extends ClassVisitor { | ||
private static final String ASM_PREFIX = "edu/columbia/cs/psl/phosphor/org/objectweb/asm/"; | ||
private static final Type OBJECT_TYPE = Type.getType(Object.class); | ||
|
||
public AsmPatcher(ClassWriter cw) { | ||
super(Configuration.ASM_VERSION, cw); | ||
} | ||
|
||
@Override | ||
public MethodVisitor visitMethod( | ||
int access, String name, String descriptor, String signature, String[] exceptions) { | ||
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions); | ||
return new MethodVisitor(api, mv) { | ||
|
||
@Override | ||
public void visitMethodInsn( | ||
int opcode, String owner, String name, String descriptor, boolean isInterface) { | ||
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface); | ||
// Ensure that the return value is unwrapped if necessary | ||
if (owner.startsWith("java/") && OBJECT_TYPE.equals(Type.getReturnType(descriptor))) { | ||
TaintMethodRecord.TAINTED_REFERENCE_ARRAY_UNWRAP.delegateVisit(mv); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
public static byte[] patch(byte[] classFileBuffer) { | ||
ClassReader cr = new ClassReader(classFileBuffer); | ||
ClassWriter cw = new ClassWriter(cr, 0); | ||
ClassVisitor cv = new AsmPatcher(cw); | ||
cr.accept(cv, 0); | ||
return cw.toByteArray(); | ||
} | ||
|
||
public static boolean isApplicable(String className) { | ||
return className.startsWith(ASM_PREFIX); | ||
} | ||
} |
Oops, something went wrong.