Package com.h3xstream.findsecbugs.common
Class ByteCode
- java.lang.Object
-
- com.h3xstream.findsecbugs.common.ByteCode
-
public class ByteCode extends Object
-
-
Constructor Summary
Constructors Constructor Description ByteCode()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IntegergetConstantInt(org.apache.bcel.generic.InstructionHandle h)Extract the integer value from the Instruction ICONST.static <T> TgetConstantLDC(org.apache.bcel.generic.InstructionHandle h, org.apache.bcel.generic.ConstantPoolGen cpg, Class<T> clazz)Get the constant value of the given instruction.static <T> TgetPrevInstruction(org.apache.bcel.generic.InstructionHandle startHandle, Class<T> clazz)Get the previous instruction matching the given type of instruction (second parameter)static NumbergetPushNumber(org.apache.bcel.generic.InstructionHandle h)Extract the number from a push operation (BIPUSH/SIPUSH).static voidprintOpCode(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg)Print the the detail of the given instruction (class, method, etc.)
-
-
-
Method Detail
-
printOpCode
public static void printOpCode(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg)Print the the detail of the given instruction (class, method, etc.)- Parameters:
ins- Instructioncpg- Constant Pool
-
getConstantLDC
public static <T> T getConstantLDC(org.apache.bcel.generic.InstructionHandle h, org.apache.bcel.generic.ConstantPoolGen cpg, Class<T> clazz)Get the constant value of the given instruction. (The instruction must refer to the Constant Pool otherwise null is return) <T> is the Type of the constant value return This utility method should be used only when the taint analysis is not needed. For example, to detect api where the value will typically be hardcoded. (Call such as setConfig("valueHardcoded"), setActivateStuff(true) )- Parameters:
h- Instruction Handlecpg- Constant Poolclazz- Type of the constant being read- Returns:
- The constant value if any is found
-
getConstantInt
public static Integer getConstantInt(org.apache.bcel.generic.InstructionHandle h)
Extract the integer value from the Instruction ICONST.- Parameters:
h- Instruction Handle- Returns:
-
getPushNumber
public static Number getPushNumber(org.apache.bcel.generic.InstructionHandle h)
Extract the number from a push operation (BIPUSH/SIPUSH).- Parameters:
h- Instruction Handle- Returns:
- The constant number if any is found
-
getPrevInstruction
public static <T> T getPrevInstruction(org.apache.bcel.generic.InstructionHandle startHandle, Class<T> clazz)Get the previous instruction matching the given type of instruction (second parameter)- Parameters:
startHandle- Location to start fromclazz- Type of instruction to look for- Returns:
- The instruction found (null if not found)
-
-