public ContentProviderTransform() { // init set of all content provider harness fields for (SootClass clz : Harness.v().getCreatedClasses()) { if (Hierarchy.inheritsFromAndroidComponent(AndroidComponents.CONTENT_PROVIDER, clz)) { allHarnessCPFlds.add(Harness.v().getFieldForCreatedClass(clz)); } } }
/** * For a Uri alloc node, try to find the set of target content providers targeted by the resolved * va values for the uri. If invalidated or unresolved, then target all providers. */ private boolean addToTargets(IAllocNode node, Set<SootField> targetCPFields, Stmt stmt) { try { Set<String> uriValues = new HashSet<String>(); SootField field = ((RefType) node.getType()).getSootClass().getFieldByName("uriString"); boolean isResolved = ValueAnalysis.v().getStringFieldValues(node, field, uriValues); if (isResolved) { for (String uriString : uriValues) { URI uri = new URI(uriString); String authority = uri.getAuthority(); for (Provider p : Resources.v().getManifest().providers) { if (p.definesAuthority(authority)) { // this provider is a target for the uri, // so find the field for it SootClass pClass = p.getSootClass(); targetCPFields.add(Harness.v().getFieldForCreatedClass(pClass)); logger.info( "Found target for Content Provider stmt {}, uri {}, target {}", stmt, uriString, pClass); } } } return true; } else { targetCPFields.addAll(allHarnessCPFlds); return false; } } catch (Exception e) { // just in case anything goes wrong with va resolution targetCPFields.addAll(allHarnessCPFlds); return false; } }