private boolean isMethodInterComponentSink(SootMethod sm) { for (SourceSinkDefinition meth : sinks) { AndroidMethod am = (AndroidMethod) meth.getMethod(); if (am.getCategory() == CATEGORY.INTER_APP_COMMUNICATION) { if (am.getSubSignature().equals(sm.getSubSignature())) return true; } } return false; }
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; }
/** * 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; }
/** * 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; }