soot.jimple.InvokeExpr Java Examples
The following examples show how to use
soot.jimple.InvokeExpr.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimingBombTransformer.java From FuzzDroid with Apache License 2.0 | 7 votes |
private void prepareAlarmManagerSet(Body body, InvokeStmt setStmt, SootMethodRef reportRef) { Value oldVal = setStmt.getInvokeExpr().getArg(1); Local longLocal = UtilInstrumenter.generateFreshLocal(body, LongType.v()); SootMethod currentTimeMillis = Scene.v().getMethod("<java.lang.System: long currentTimeMillis()>"); StaticInvokeExpr timeInvoke = Jimple.v().newStaticInvokeExpr(currentTimeMillis.makeRef()); AssignStmt timeInitalize = Jimple.v().newAssignStmt(longLocal, timeInvoke); AddExpr addTime = Jimple.v().newAddExpr(longLocal, LongConstant.v(2000L)); AssignStmt timeAssign = Jimple.v().newAssignStmt(longLocal, addTime); body.getUnits().insertBefore(timeInitalize, setStmt); body.getUnits().insertBefore(timeAssign, setStmt); InvokeExpr expr = setStmt.getInvokeExpr(); expr.setArg(0, IntConstant.v(0)); expr.setArg(1, longLocal); // Report the change InvokeStmt reportStmt = Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr( reportRef, oldVal, longLocal)); reportStmt.addTag(new InstrumentedCodeTag()); body.getUnits().insertAfter(reportStmt, setStmt); }
Example #2
Source File: Main.java From JAADAS with GNU General Public License v3.0 | 6 votes |
/** * @param args */ public static void main(String[] args) { PackManager.v().getPack("jtp").add(new Transform("jtp.fixedie", new BodyTransformer() { @Override protected void internalTransform(Body b, String phaseName, Map<String, String> options) { for(Unit u: b.getUnits()) { Stmt s = (Stmt) u; if(s.containsInvokeExpr()) { InvokeExpr ie = s.getInvokeExpr(); if(FixedMethods.isFixed(ie)) { System.err.println("+++ "+ie); yes++; } else { System.err.println(" - "+ie); no++; } } } } })); soot.Main.main(args); System.err.println("+++ "+yes); System.err.println(" - "+no); }
Example #3
Source File: AbstractBoomerangSolver.java From SPDS with Eclipse Public License 2.0 | 6 votes |
public boolean isParameter(Val value, Stmt u) { if (u.containsInvokeExpr()) { InvokeExpr invokeExpr = u.getInvokeExpr(); if (invokeExpr instanceof InstanceInvokeExpr) { InstanceInvokeExpr iie = (InstanceInvokeExpr) invokeExpr; if (iie.getBase().equals(value.value())) return true; } for (Value arg : invokeExpr.getArgs()) { if (arg.equals(value.value())) { return true; } } } return false; }
Example #4
Source File: FileFuzzer.java From FuzzDroid with Apache License 2.0 | 6 votes |
private AnalysisDecision getFileFormatFromDataflow(int codePosID ) { Unit unit = codePositionManager.getUnitForCodePosition(codePosID); if(unit instanceof Stmt) { Stmt stmt = (Stmt)unit; if(stmt.containsInvokeExpr()) { InvokeExpr inv = stmt.getInvokeExpr(); SootMethod sm = inv.getMethod(); Pair<Integer, Object> paramValue = retrieveCorrectFileInformation(sm); ServerResponse response = new ServerResponse(); response.setAnalysisName(getAnalysisName()); response.setResponseExist(true); response.setParamValues(Collections.singleton(paramValue)); AnalysisDecision finalDecision = new AnalysisDecision(); finalDecision.setAnalysisName(getAnalysisName()); finalDecision.setDecisionWeight(8); finalDecision.setServerResponse(response); return finalDecision; } else return noResults(); } else { return noResults(); } }
Example #5
Source File: AuthorityValueAnalysis.java From ic3 with Apache License 2.0 | 6 votes |
@Override public Set<Object> computeArgumentValues(Argument argument, Unit callSite) { ArgumentValueAnalysis stringAnalysis = ArgumentValueManager.v().getArgumentValueAnalysis( Constants.DefaultArgumentTypes.Scalar.STRING); Stmt stmt = (Stmt) callSite; if (!stmt.containsInvokeExpr()) { throw new RuntimeException("Statement " + stmt + " does not contain an invoke expression"); } InvokeExpr invokeExpr = stmt.getInvokeExpr(); Set<Object> hosts = stringAnalysis.computeVariableValues(invokeExpr.getArg(argument.getArgnum()[0]), stmt); Set<Object> ports = stringAnalysis.computeVariableValues(invokeExpr.getArg(argument.getArgnum()[1]), stmt); Set<Object> result = new HashSet<>(); for (Object host : hosts) { for (Object port : ports) { result.add(new DataAuthority((String) host, (String) port)); } } return result; }
Example #6
Source File: SmartConstantDataExtractorFuzzyAnalysis.java From FuzzDroid with Apache License 2.0 | 6 votes |
private boolean isSemanticallyCorrect(String loggingPoint, Stmt stmt) { if(loggingPoint == null) return false; if(stmt.containsInvokeExpr()) { InvokeExpr inv = stmt.getInvokeExpr(); String metSig = inv.getMethod().getSignature(); if(metSig.equals("<android.telephony.TelephonyManager: java.lang.String getSimOperator()>") || metSig.equals("<android.telephony.TelephonyManager: java.lang.String getNetworkOperator()>") ) { for(char c : loggingPoint.toCharArray()) { if(c < '0' || c > '9') return false; } } } return true; }
Example #7
Source File: SmartConstantDataExtractorFuzzyAnalysis.java From FuzzDroid with Apache License 2.0 | 6 votes |
private String fixSMTSolverIntegerOutput(String loggingPoint, Stmt stmt) { if(stmt.containsInvokeExpr()) { InvokeExpr inv = stmt.getInvokeExpr(); String metSig = inv.getMethod().getSignature(); if(metSig.equals("<android.telephony.TelephonyManager: java.lang.String getSimOperator()>") || metSig.equals("<android.telephony.TelephonyManager: java.lang.String getNetworkOperator()>") ) { String newLoggingPoint = ""; for(char c : loggingPoint.toCharArray()) { if(c < '0' || c > '9') { Random rand = new Random(); int num = rand.nextInt(10); newLoggingPoint += num; } else newLoggingPoint += c; } return newLoggingPoint; } } return loggingPoint; }
Example #8
Source File: DummyMainGenerator.java From DroidRA with GNU Lesser General Public License v2.1 | 6 votes |
public void instrumentDummyMainMethod(SootMethod mainMethod) { Body body = mainMethod.getActiveBody(); PatchingChain<Unit> units = body.getUnits(); for (Iterator<Unit> iter = units.snapshotIterator(); iter.hasNext(); ) { Stmt stmt = (Stmt) iter.next(); if (stmt instanceof IdentityStmt) { continue; } //For the purpose of confusion dex optimization (because of the strategy of generating dummyMain method) AssignStmt aStmt = (AssignStmt) stmt; SootMethod fuzzyMe = generateFuzzyMethod(mainMethod.getDeclaringClass()); InvokeExpr invokeExpr = Jimple.v().newVirtualInvokeExpr(body.getThisLocal(), fuzzyMe.makeRef()); Unit assignU = Jimple.v().newAssignStmt(aStmt.getLeftOp(), invokeExpr); units.insertAfter(assignU, aStmt); break; } }
Example #9
Source File: JimpleExprVisitorImpl.java From FuzzDroid with Apache License 2.0 | 6 votes |
public boolean isExpressionThatNeedsToBeConvertedToSMT(InvokeExpr invokeExpr) { String methodSignature = invokeExpr.getMethod().getSignature(); if(methodSignature.equals("<java.lang.Integer: int parseInt(java.lang.String)>") || methodSignature.equals("<org.apache.http.client.methods.HttpGet: void <init>(java.lang.String)>") || methodSignature.equals("<java.net.URL: void <init>(java.lang.String)>") || methodSignature.equals("<android.telephony.SmsManager: void sendTextMessage(java.lang.String,java.lang.String,java.lang.String,android.app.PendingIntent,android.app.PendingIntent)>") || methodSignature.equals("<android.telephony.gsm.SmsManager: void sendTextMessage(java.lang.String,java.lang.String,java.lang.String,android.app.PendingIntent,android.app.PendingIntent)>") || methodSignature.equals("<android.telephony.SmsMessage: java.lang.String getDisplayOriginatingAddress()>") || methodSignature.equals("<java.util.Map: java.lang.Object put(java.lang.Object,java.lang.Object)>") || methodSignature.equals("<java.util.Map: java.lang.Object get(java.lang.Object)>") || methodSignature.equals("<android.telephony.TelephonyManager: java.lang.String getNetworkOperator()>") || methodSignature.equals("<android.telephony.TelephonyManager: java.lang.String getSimOperator()>") ) return true; return false; }
Example #10
Source File: JimpleExprVisitorImpl.java From FuzzDroid with Apache License 2.0 | 6 votes |
private boolean isStringOperationSupportedBySMT(InvokeExpr invokeExpr) { String methodSignature = invokeExpr.getMethod().getSignature(); if(methodSignature.equals("<java.lang.String: java.lang.String substring(int,int)>") || methodSignature.equals("<java.lang.String: java.lang.String substring(int)>") || methodSignature.equals("<java.lang.String: boolean equals(java.lang.Object)>") || methodSignature.equals("<java.lang.String: boolean equalsIgnoreCase(java.lang.String)>") || methodSignature.equals("<java.lang.String: int indexOf(java.lang.String)>") || methodSignature.equals("<java.lang.String: int indexOf(int,int)>") || methodSignature.equals("<java.lang.String: boolean startsWith(java.lang.String)>") || methodSignature.equals("<java.lang.String: boolean matches(java.lang.String)>") || methodSignature.equals("<java.lang.String: java.lang.String replaceAll(java.lang.String,java.lang.String)>") || methodSignature.equals("<java.lang.String: boolean contains(java.lang.CharSequence)>") || methodSignature.equals("<java.lang.String: java.lang.String[] split(java.lang.String)>") || methodSignature.equals("<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>") ) return true; return false; }
Example #11
Source File: DavaBody.java From JAADAS with GNU General Public License v3.0 | 6 votes |
private void javafy_expr(ValueBox vb) { Expr e = (Expr) vb.getValue(); if (e instanceof BinopExpr) javafy_binop_expr(vb); else if (e instanceof UnopExpr) javafy_unop_expr(vb); else if (e instanceof CastExpr) javafy_cast_expr(vb); else if (e instanceof NewArrayExpr) javafy_newarray_expr(vb); else if (e instanceof NewMultiArrayExpr) javafy_newmultiarray_expr(vb); else if (e instanceof InstanceOfExpr) javafy_instanceof_expr(vb); else if (e instanceof InvokeExpr) javafy_invoke_expr(vb); else if (e instanceof NewExpr) javafy_new_expr(vb); }
Example #12
Source File: CopyConstantAnalysis.java From vasco with GNU Lesser General Public License v2.1 | 6 votes |
@Override public Map<Local, Constant> callEntryFlowFunction(Context<SootMethod, Unit, Map<Local, Constant>> context, SootMethod calledMethod, Unit unit, Map<Local, Constant> inValue) { // Initialise result to empty map Map<Local, Constant> entryValue = topValue(); // Map arguments to parameters InvokeExpr ie = ((Stmt) unit).getInvokeExpr(); for (int i = 0; i < ie.getArgCount(); i++) { Value arg = ie.getArg(i); Local param = calledMethod.getActiveBody().getParameterLocal(i); assign(param, arg, inValue, entryValue); } // And instance of the this local if (ie instanceof InstanceInvokeExpr) { Value instance = ((InstanceInvokeExpr) ie).getBase(); Local thisLocal = calledMethod.getActiveBody().getThisLocal(); assign(thisLocal, instance, inValue, entryValue); } // Return the entry value at the called method return entryValue; }
Example #13
Source File: BackwardBoomerangSolver.java From SPDS with Eclipse Public License 2.0 | 6 votes |
@Override public void onCalleeAdded(Unit callSite, SootMethod callee) { if (callee.isStaticInitializer()) { return; } if(!callee.hasActiveBody()) { normalFlow(icfg.getMethodOf(callSite), curr); return; } // onlyStaticInitializer = false; Set<State> out = Sets.newHashSet(); InvokeExpr invokeExpr = curr.stmt().getUnit().get().getInvokeExpr(); for (Unit calleeSp : icfg.getStartPointsOf(callee)) { for (Unit returnSite : icfg.getSuccsOf(callSite)) { Collection<? extends State> res = computeCallFlow(caller, new Statement((Stmt) returnSite, caller), new Statement((Stmt) callSite, caller), invokeExpr, curr.fact(), callee, (Stmt) calleeSp); out.addAll(res); } } for (State o : out) { BackwardBoomerangSolver.this.propagate(curr, o); } addReachable(callee); }
Example #14
Source File: InfoflowResults.java From JAADAS with GNU General Public License v3.0 | 6 votes |
/** * Checks whether there is an information flow between the two * given methods (specified by their respective Soot signatures). * @param sinkSignature The sink to which there may be a path * @param sourceSignature The source from which there may be a path * @return True if there is a path between the given source and sink, false * otherwise */ public boolean isPathBetweenMethods(String sinkSignature, String sourceSignature) { List<ResultSinkInfo> sinkVals = findSinkByMethodSignature(sinkSignature); for (ResultSinkInfo si : sinkVals) { Set<ResultSourceInfo> sources = this.results.get(si); if (sources == null) return false; for (ResultSourceInfo src : sources) if (src.getSource().containsInvokeExpr()) { InvokeExpr expr = src.getSource().getInvokeExpr(); if (expr.getMethod().getSignature().equals(sourceSignature)) return true; } } return false; }
Example #15
Source File: SootToDexUtils.java From JAADAS with GNU General Public License v3.0 | 6 votes |
public static int getOutWordCount(Collection<Unit> units) { int outWords = 0; for (Unit u : units) { Stmt stmt = (Stmt) u; if (stmt.containsInvokeExpr()) { int wordsForParameters = 0; InvokeExpr invocation = stmt.getInvokeExpr(); List<Value> args = invocation.getArgs(); for (Value arg : args) { wordsForParameters += getDexWords(arg.getType()); } if (!invocation.getMethod().isStatic()) { wordsForParameters++; // extra word for "this" } if (wordsForParameters > outWords) { outWords = wordsForParameters; } } } return outWords; }
Example #16
Source File: QueryForCallSiteDetector.java From SPDS with Eclipse Public License 2.0 | 6 votes |
@Override public Optional<? extends Query> test(Stmt unit) { Stmt stmt = unit; if (!(stmt.containsInvokeExpr())) return Optional.empty(); InvokeExpr invokeExpr = stmt.getInvokeExpr(); if (!invokeExpr.getMethod().getName().matches(methodNameMatcher)) return Optional.empty(); Value param = invokeExpr.getArg(0); if (!(param instanceof Local)) return Optional.empty(); SootMethod newMethod = icfg.getMethodOf(unit); Statement newStatement = new Statement(unit, newMethod); Val newVal = new Val(param, newMethod); BackwardQuery newBackwardQuery = new BackwardQuery(newStatement, newVal); return Optional.<Query> of(newBackwardQuery); }
Example #17
Source File: HasNextStateMachine.java From SPDS with Eclipse Public License 2.0 | 6 votes |
@Override public Set<WeightedForwardQuery<TransitionFunction>> generateSeed(SootMethod method, Unit unit) { Iterator<Edge> edIt = Scene.v().getCallGraph().edgesOutOf(unit); while (edIt.hasNext()) { SootMethod m = edIt.next().getTgt().method(); if (retrieveIteratorConstructors().contains(m)) { Stmt stmt = ((Stmt) unit); InvokeExpr invokeExpr = stmt.getInvokeExpr(); if (stmt instanceof AssignStmt) { AssignStmt assignStmt = (AssignStmt) stmt; InstanceInvokeExpr iie = (InstanceInvokeExpr) invokeExpr; return Collections .singleton(new WeightedForwardQuery<>( new Statement(stmt, method), new AllocVal(assignStmt.getLeftOp(), method, assignStmt.getLeftOp(), new Statement((Stmt) unit, m)), initialTransition())); } } } return Collections.emptySet(); }
Example #18
Source File: TypeStateMachineWeightFunctions.java From SPDS with Eclipse Public License 2.0 | 6 votes |
public TransitionFunction callToReturn(Node<Statement, Val> curr, Node<Statement, Val> succ, InvokeExpr invokeExpr) { Set<Transition> res = Sets.newHashSet(); if (invokeExpr instanceof InstanceInvokeExpr) { SootMethod method = invokeExpr.getMethod(); InstanceInvokeExpr e = (InstanceInvokeExpr) invokeExpr; if (e.getBase().equals(succ.fact().value())) { for (MatcherTransition trans : transition) { if (trans.matches(method) && (trans.getType().equals(Type.OnCallToReturn) || trans.getType().equals(Type.OnCallOrOnCallToReturn))) { res.add(trans); } } } } return (res.isEmpty() ? getOne() : new TransitionFunction(res, Collections.singleton(succ.stmt()))); }
Example #19
Source File: PolicyEnforcementPoint.java From DroidForce with GNU Lesser General Public License v2.1 | 6 votes |
private String getSourceCategory(ResultSourceInfo sourceInfo){ if(sourceInfo.getSource().containsInvokeExpr()){ InvokeExpr invExpr = sourceInfo.getSource().getInvokeExpr(); for(SourceSinkDefinition meth : sources) { AndroidMethod am = (AndroidMethod) meth.getMethod(); if(am.getSignature().equals(invExpr.getMethod().getSignature())){ return am.getCategory().toString(); } } } else if(isSourceInfoParameter(sourceInfo)){ return unknownCategory; } else throw new RuntimeException("Currently not supported"); return null; }
Example #20
Source File: PolicyEnforcementPoint.java From DroidForce with GNU Lesser General Public License v2.1 | 6 votes |
/** * This method iterates over all sources from the FlowDroid-results and extracts the * category of the specific source. If there is no category found, it will return an empty set, * otherwise the correct categories will be added. * @param sourcesInfo: all possible sources from which we try to identify the category * @return: set of categories for specific sink */ private Set<String> getDataIdList(Set<ResultSourceInfo> sourcesInfo){ Set<String> dataIdList = new HashSet<String>(); for(ResultSourceInfo sInfo : sourcesInfo){ if(sInfo.getSource().containsInvokeExpr()){ InvokeExpr invExpr = sInfo.getSource().getInvokeExpr(); for(SourceSinkDefinition meth : sources) { AndroidMethod am = (AndroidMethod) meth.getMethod(); if(am.getSignature().equals(invExpr.getMethod().getSignature())) { dataIdList.add(am.getCategory().toString()); } } } else if (isSourceInfoParameter(sInfo)){ dataIdList.add(unknownCategory); } else throw new RuntimeException("Currently not supported"); } return dataIdList; }
Example #21
Source File: Model.java From DroidRA with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns the arguments for a potential COAL query. * * @param stmt A program statement. * @return An array of arguments if the statement is for a COAL query, null otherwise. */ public Argument[] getArgumentsForQuery(Stmt stmt) { if (stmt.containsInvokeExpr()) { InvokeExpr invokeExpr = stmt.getInvokeExpr(); SootMethod method = invokeExpr.getMethod(); if (AnalysisParameters.v().isAnalysisClass(method.getDeclaringClass().getName()) && method.isConcrete() && method.hasActiveBody()) { MethodDescription description = queryToMethodDescriptionMap.get(method.getSignature()); if (description == null) { return null; } else { return description.getArguments(); } } return getArgumentsFromMethodDescription(queryToMethodDescriptionMap, invokeExpr); } return null; }
Example #22
Source File: PolicyEnforcementPoint.java From DroidForce with GNU Lesser General Public License v2.1 | 6 votes |
/** * Add Policy Enforcement Point (PEP) for Unit 'unit'. * @param methodSignature * @param unit * @param invExpr * @param body * @param assignmentStatement */ private void instrumentWithNoDataFlowInformation(String methodSignature, Unit unit, InvokeExpr invExpr, Body body, boolean assignmentStatement){ log.debug("add PEP without dataflow information for unit "+ unit); EventInformation eventInfo = allEventInformation.get(methodSignature); List<Unit> generated = generatePolicyEnforcementPoint(unit, invExpr, body, -1, assignmentStatement); log.debug("body no data flow:\n"+body); for (Unit u: generated) { log.debug("gen: "+ u); } if(eventInfo.isInstrumentAfterStatement()) { body.getUnits().insertAfter(generated, unit); } else { body.getUnits().insertBefore(generated, unit); } }
Example #23
Source File: PolicyEnforcementPoint.java From DroidForce with GNU Lesser General Public License v2.1 | 6 votes |
/** * Return true if the method corresponding to the source 'si' is an * Inter Component Communication source method such as "Intent.getExtras()". * @param si * @param cfg * @return */ private boolean isInterComponentSourceNoCallback(ResultSourceInfo si, BiDiInterproceduralCFG<Unit, SootMethod> cfg){ if(!si.getSource().containsInvokeExpr()) return false; InvokeExpr invExpr = si.getSource().getInvokeExpr(); SootMethod sm = invExpr.getMethod(); for(SourceSinkDefinition meth : sources){ AndroidMethod am = (AndroidMethod) meth.getMethod(); if(am.getCategory() == CATEGORY.INTER_APP_COMMUNICATION){ if(am.getSubSignature().equals(sm.getSubSignature())) { log.info("source is: "+ am); return true; } } } return false; }
Example #24
Source File: MethodReturnValueManager.java From DroidRA with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns the possible return values for a given method call. * * @param call A method call. * @return The possible return values for the method call. */ public Set<Object> getMethodReturnValues(Call call) { Stmt stmt = call.stmt; if (!stmt.containsInvokeExpr()) { throw new RuntimeException("Statement does not contain invoke expression: " + stmt); } InvokeExpr invokeExpr = stmt.getInvokeExpr(); // First consider the registered method return value analyses. MethodReturnValueAnalysis analysis = methodReturnValueAnalysisMap.get(invokeExpr.getMethod().getSubSignature()); if (analysis != null) { return analysis.computeMethodReturnValues(call); } else if (Model.v().getArgumentsForSource(invokeExpr) != null) { // Then consider the declared COAL sources. return sourceMethodReturnValueAnalysis.computeMethodReturnValues(call); } return null; }
Example #25
Source File: Model.java From DroidRA with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns the arguments associated with a method descriptor. * * @param signatureToMethodDescriptionMap A map from signatures to method descriptors. * @param invokeExpr An invoke expression. * @return An array of arguments if arguments are found for the method descriptor, null otherwise. */ private Argument[] getArgumentsFromMethodDescription( Map<String, MethodDescription> signatureToMethodDescriptionMap, InvokeExpr invokeExpr) { SootMethod method = invokeExpr.getMethod(); String signature = method.getSignature(); MethodDescription methodDescription = signatureToMethodDescriptionMap.get(signature); if (methodDescription != null) { return methodDescription.getArguments(); } signature = method.getSubSignature(); methodDescription = signatureToMethodDescriptionMap.get(signature); if (methodDescription == null) { return null; } String superclassName = methodDescription.getBaseClass(); if (superclassName == null || !Scene.v().containsClass(superclassName) || invokeExpr instanceof InterfaceInvokeExpr) { return null; } SootClass superclass = Scene.v().getSootClass(superclassName); String baseType; if (invokeExpr instanceof InstanceInvokeExpr) { Value baseValue = ((InstanceInvokeExpr) invokeExpr).getBase(); baseType = baseValue.getType().toString(); } else { baseType = invokeExpr.getMethod().getDeclaringClass().getName(); } if (Scene.v().containsClass(baseType) && Scene.v().getActiveHierarchy() .isClassSubclassOfIncluding(Scene.v().getSootClass(baseType), superclass)) { return methodDescription.getArguments(); } else { return null; } }
Example #26
Source File: ThisInliner.java From JAADAS with GNU General Public License v3.0 | 5 votes |
private InvokeStmt getFirstSpecialInvoke(Body b){ for (Unit u : b.getUnits()) { Stmt s = (Stmt)u; if (!(s instanceof InvokeStmt)) continue; InvokeExpr invokeExpr = ((InvokeStmt)s).getInvokeExpr(); if (!(invokeExpr instanceof SpecialInvokeExpr)) continue; return (InvokeStmt)s; } // but there will always be either a call to this() or to super() // from the constructor return null; }
Example #27
Source File: OnTheFlyJimpleBasedICFG.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Override public Set<SootMethod> load(Unit u) throws Exception { Stmt stmt = (Stmt)u; InvokeExpr ie = stmt.getInvokeExpr(); FastHierarchy fastHierarchy = Scene.v().getFastHierarchy(); //FIXME Handle Thread.start etc. if(ie instanceof InstanceInvokeExpr) { if(ie instanceof SpecialInvokeExpr) { //special return Collections.singleton(ie.getMethod()); } else { //virtual and interface InstanceInvokeExpr iie = (InstanceInvokeExpr) ie; Local base = (Local) iie.getBase(); RefType concreteType = bodyToLMNAA.getUnchecked(unitToOwner.get(u)).concreteType(base, stmt); if(concreteType!=null) { //the base variable definitely points to a single concrete type SootMethod singleTargetMethod = fastHierarchy.resolveConcreteDispatch(concreteType.getSootClass(), iie.getMethod()); return Collections.singleton(singleTargetMethod); } else { SootClass baseTypeClass; if(base.getType() instanceof RefType) { RefType refType = (RefType) base.getType(); baseTypeClass = refType.getSootClass(); } else if(base.getType() instanceof ArrayType) { baseTypeClass = Scene.v().getSootClass("java.lang.Object"); } else if(base.getType() instanceof NullType) { //if the base is definitely null then there is no call target return Collections.emptySet(); } else { throw new InternalError("Unexpected base type:"+base.getType()); } return fastHierarchy.resolveAbstractDispatch(baseTypeClass, iie.getMethod()); } } } else { //static return Collections.singleton(ie.getMethod()); } }
Example #28
Source File: UseChecker.java From JAADAS with GNU General Public License v3.0 | 5 votes |
private void handleInvokeExpr(InvokeExpr ie, Stmt stmt) { SootMethodRef m = ie.getMethodRef(); if ( ie instanceof InstanceInvokeExpr ) { InstanceInvokeExpr iie = (InstanceInvokeExpr)ie; iie.setBase(this.uv.visit( iie.getBase(),m.declaringClass().getType(), stmt)); } for ( int i = 0; i < ie.getArgCount(); i++ ) ie.setArg(i, this.uv.visit( ie.getArg(i), m.parameterType(i), stmt)); }
Example #29
Source File: NullnessAnalysis.java From JAADAS with GNU General Public License v3.0 | 5 votes |
private void handleInvokeExpr(InvokeExpr invokeExpr,AnalysisInfo out) { if(invokeExpr instanceof InstanceInvokeExpr) { InstanceInvokeExpr instanceInvokeExpr = (InstanceInvokeExpr) invokeExpr; //here we know that the receiver must point to an object Value base = instanceInvokeExpr.getBase(); out.put(base,NON_NULL); } }
Example #30
Source File: ResultProcessor.java From ic3 with Apache License 2.0 | 5 votes |
private int getResultIndex(Stmt stmt) { InvokeExpr invokeExpr = stmt.getInvokeExpr(); List<Type> types = invokeExpr.getMethod().getParameterTypes(); for (Type type : types) { if (type.toString().equals("android.content.IntentFilter")) { return 1; } else if (type.toString().equals("android.net.Uri")) { return 2; } } return 0; }