Use SSAInstructionKey for map lineNumbers.

This commit is contained in:
Achim D. Brucker 2016-09-18 02:06:08 +01:00
parent 9514d3633c
commit 73a9b8960f
2 changed files with 6 additions and 6 deletions

View File

@ -271,9 +271,9 @@ public class AnalysisUtil {
* @param print * @param print
* @return * @return
*/ */
public static HashMap<SSAInstruction, Integer> getLineNumbers(HashMap<Integer,BasicBlockInContext<IExplodedBasicBlock>> sgNodes) { public static HashMap<SSAInstructionKey, Integer> getLineNumbers(HashMap<Integer,BasicBlockInContext<IExplodedBasicBlock>> sgNodes) {
log.debug("** get source code line number for each instruction"); log.debug("** get source code line number for each instruction");
HashMap<SSAInstruction, Integer> map = new HashMap<SSAInstruction, Integer>(); HashMap<SSAInstructionKey, Integer> map = new HashMap<SSAInstructionKey, Integer>();
for(BasicBlockInContext<IExplodedBasicBlock> bbic : sgNodes.values()) { for(BasicBlockInContext<IExplodedBasicBlock> bbic : sgNodes.values()) {
SSAInstruction inst = bbic.getLastInstruction(); SSAInstruction inst = bbic.getLastInstruction();
if(inst == null) { if(inst == null) {
@ -282,7 +282,7 @@ public class AnalysisUtil {
// ConcreteJavaMethod method = (ConcreteJavaMethod) bbic.getMethod(); // ConcreteJavaMethod method = (ConcreteJavaMethod) bbic.getMethod();
IMethod method = bbic.getMethod(); IMethod method = bbic.getMethod();
int lineNumber = method.getLineNumber(bbic.getLastInstructionIndex()); int lineNumber = method.getLineNumber(bbic.getLastInstructionIndex());
map.put(inst, lineNumber); map.put(new SSAInstructionKey(inst), lineNumber);
log.debug(lineNumber + ". " + inst); log.debug(lineNumber + ". " + inst);
} }
return map; return map;

View File

@ -269,7 +269,7 @@ public class SuperGraphUtil {
//*/ //*/
//* <<< get source code line number for each instruction //* <<< get source code line number for each instruction
HashMap<SSAInstruction, Integer> lineNumbers = AnalysisUtil.getLineNumbers(sgNodes); HashMap<SSAInstructionKey, Integer> lineNumbers = AnalysisUtil.getLineNumbers(sgNodes);
//*/ //*/
//* <<< get the corresponding instruction for each condition inside the callgraph //* <<< get the corresponding instruction for each condition inside the callgraph
@ -283,7 +283,7 @@ public class SuperGraphUtil {
HashMap<Integer, Integer> conditionLineNumber = new HashMap<Integer, Integer>(); HashMap<Integer, Integer> conditionLineNumber = new HashMap<Integer, Integer>();
for (SSAInstruction instCondition : conditionsList) { for (SSAInstruction instCondition : conditionsList) {
int nodeId = sgNodesInstId.get(new SSAInstructionKey(instCondition)); int nodeId = sgNodesInstId.get(new SSAInstructionKey(instCondition));
int lineNumber = lineNumbers.get(instCondition); int lineNumber = lineNumbers.get(new SSAInstructionKey(instCondition));
conditionLineNumber.put(nodeId, lineNumber); conditionLineNumber.put(nodeId, lineNumber);
} }
@ -364,7 +364,7 @@ public class SuperGraphUtil {
if(isNotSanitized) { if(isNotSanitized) {
weaknessCount++; weaknessCount++;
containsVulnerability = true; containsVulnerability = true;
log.warn("SQL execute [" + lineNumbers.get(sink) + "] with bad source readLine [" + lineNumbers.get(source) + "] (" + entryClass + "." + entryMethod + ")"); log.warn("SQL execute [" + lineNumbers.get(new SSAInstructionKey(sink)) + "] with bad source readLine [" + lineNumbers.get(new SSAInstructionKey(source)) + "] (" + entryClass + "." + entryMethod + ")");
} }
} }
} }