/** * Set the package of the analyzed application. * * Setting the package of the application is completely optional. However if you do it it helps * determining whether an Intent has an internal target. * * If a AndroidManifest.xml is read this getts set automaticly. * * @param pack The package of the analyzed application * @throws IllegalArgumentException if the package has already been set and the value of the * packages differ. Or if the given package is null. */ public void setPackage(String pack) { if (pack == null) { throw new IllegalArgumentException("Setting the package to null is disallowed."); } if ((! pack.startsWith("L") || pack.contains("."))) { pack = StringStuff.deployment2CanonicalTypeString(pack); } if (this.pack == null) { logger.info("Setting the package to {}", pack); this.pack = pack; } else if (!(this.pack.equals(pack))) { throw new IllegalArgumentException("The already set package " + this.pack + " and " + pack + " differ. You can only set pack once."); } }
/** * Set the package of the analyzed application. * * Setting the package of the application is completely optional. However if you do it it helps * determining whether an Intent has an internal target. * * If a AndroidManifest.xml is read this getts set automaticly. * * @param pack The package of the analyzed application * @throws IllegalArgumentException if the package has already been set and the value of the * packages differ. Or if the given package is null. */ public void setPackage(String pack) { if (pack == null) { throw new IllegalArgumentException("Setting the package to null is disallowed."); } if ((! pack.startsWith("L") || pack.contains("."))) { pack = StringStuff.deployment2CanonicalTypeString(pack); } if (this.pack == null) { logger.info("Setting the package to {}", pack); this.pack = pack; } else if (!(this.pack.equals(pack))) { throw new IllegalArgumentException("The already set package " + this.pack + " and " + pack + " differ. You can only set pack once."); } }
/** * Returns the Element the type matches exactly the given type. * * @return The Element if found or AndroidComponent.UNKNOWN if not */ public static AndroidComponent explicit(String type) { if (!(type.startsWith("L") || type.contains("/"))) { type = StringStuff.deployment2CanonicalTypeString(type); } return explicit(TypeName.findOrCreate(type)); }
public static MethodReference makeMethodReference(Language l, String methodSig) throws IllegalArgumentException { if (methodSig == null) { throw new IllegalArgumentException("methodSig is null"); } if (methodSig.lastIndexOf('.') < 0) { throw new IllegalArgumentException("ill-formed sig " + methodSig); } String type = methodSig.substring(0, methodSig.lastIndexOf('.')); type = deployment2CanonicalTypeString(type); TypeReference t = TypeReference.findOrCreate(ClassLoaderReference.Application, type); String methodName = methodSig.substring(methodSig.lastIndexOf('.') + 1, methodSig.indexOf('(')); String desc = methodSig.substring(methodSig.indexOf('(')); return MethodReference.findOrCreate(l, t, methodName, desc); }
public static MethodReference makeMethodReference(Language l, String methodSig) throws IllegalArgumentException { if (methodSig == null) { throw new IllegalArgumentException("methodSig is null"); } if (methodSig.lastIndexOf('.') < 0) { throw new IllegalArgumentException("ill-formed sig " + methodSig); } String type = methodSig.substring(0, methodSig.lastIndexOf('.')); type = deployment2CanonicalTypeString(type); TypeReference t = TypeReference.findOrCreate(ClassLoaderReference.Application, type); String methodName = methodSig.substring(methodSig.lastIndexOf('.') + 1, methodSig.indexOf('(')); String desc = methodSig.substring(methodSig.indexOf('(')); return MethodReference.findOrCreate(l, t, methodName, desc); }
/** * Returns the Element the type matches exactly the given type. * * @return The Element if found or AndroidComponent.UNKNOWN if not */ public static AndroidComponent explicit(String type) { if (!(type.startsWith("L") || type.contains("/"))) { type = StringStuff.deployment2CanonicalTypeString(type); } return explicit(TypeName.findOrCreate(type)); }
String baseType = dString.substring(0, arrayIndex); int dim = (dString.length() - arrayIndex) / 2; baseType = deployment2CanonicalTypeString(baseType); StringBuilder result = new StringBuilder("["); for (int i = 1; i < dim; i++) {
String baseType = dString.substring(0, arrayIndex); int dim = (dString.length() - arrayIndex) / 2; baseType = deployment2CanonicalTypeString(baseType); StringBuilder result = new StringBuilder("["); for (int i = 1; i < dim; i++) {
name = StringStuff.deployment2CanonicalTypeString(name);
name = StringStuff.deployment2CanonicalTypeString(name);
public Intent setAction(final InstanceKey key, final InstanceKey actionKey, boolean isExplicit) { if (actionKey == null) { return find(key); } final String action; { if (actionKey instanceof ConstantKey) { final Object actionO = ((ConstantKey<?>) actionKey).getValue(); if (actionO instanceof String) { action = StringStuff.deployment2CanonicalTypeString((String) actionO); } else if (actionO instanceof IClass) { action = ((IClass) actionO).getName().toString(); } else { throw new IllegalArgumentException("Wrong action type: " + actionO.getClass()); } } else { unbind(key); return null; } } return setAction(key, action, isExplicit); } }
public Intent setAction(final InstanceKey key, final InstanceKey actionKey, boolean isExplicit) { if (actionKey == null) { return find(key); } final String action; { if (actionKey instanceof ConstantKey) { final Object actionO = ((ConstantKey<?>) actionKey).getValue(); if (actionO instanceof String) { action = StringStuff.deployment2CanonicalTypeString((String) actionO); } else if (actionO instanceof IClass) { action = ((IClass) actionO).getName().toString(); } else { throw new IllegalArgumentException("Wrong action type: " + actionO.getClass()); } } else { unbind(key); return null; } } return setAction(key, action, isExplicit); } }
private static Iterable<Entrypoint> makePublicEntrypoints(IClassHierarchy cha, String entryClass) { Collection<Entrypoint> result = new ArrayList<>(); IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application, StringStuff.deployment2CanonicalTypeString(entryClass))); for (IMethod m : klass.getDeclaredMethods()) { if (m.isPublic()) { result.add(new DefaultEntrypoint(m, cha)); } } return result; } }
@Test public void testExclusions() throws IOException { AnalysisScope scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("GUIExclusions.txt"), ExclusionsTest.class.getClassLoader()); TypeReference buttonRef = TypeReference.findOrCreate(ClassLoaderReference.Application, StringStuff.deployment2CanonicalTypeString("java.awt.Button")); Assert.assertTrue(scope.getExclusions().contains(buttonRef.getName().toString().substring(1))); } }
/** * returns the instance key corresponding to the single allocation site of * type FlowsToType */ private InstanceKey getFlowsToInstanceKey(CGNode mainMethod, HeapModel heapModel) { // TODO Auto-generated method stub TypeReference flowsToTypeRef = TypeReference.findOrCreate(ClassLoaderReference.Application, StringStuff.deployment2CanonicalTypeString("demandpa.FlowsToType")); final IR mainIR = mainMethod.getIR(); if (debug) { System.err.println(mainIR); } for (NewSiteReference n : Iterator2Iterable.make(mainIR.iterateNewSites())) { if (n.getDeclaredType().equals(flowsToTypeRef)) { return heapModel.getInstanceKeyForAllocation(mainMethod, n); } } assert false : "could not find appropriate allocation"; return null; }
String className = StringStuff.deployment2CanonicalTypeString(symbolTable.getStringValue(use)); TypeReference t = TypeReference.findOrCreate(caller.getMethod().getDeclaringClass().getClassLoader().getReference(), className); ConstantKey ik = (ConstantKey) receiver[nameVn]; if (ik.getConcreteType().getReference().equals(TypeReference.JavaLangString)) { String className = StringStuff.deployment2CanonicalTypeString(ik.getValue().toString()); for(IClassLoader cl : caller.getClassHierarchy().getLoaders()) { TypeReference t = TypeReference.findOrCreate(cl.getReference(), className);
String className = StringStuff.deployment2CanonicalTypeString(symbolTable.getStringValue(use)); TypeReference t = TypeReference.findOrCreate(caller.getMethod().getDeclaringClass().getClassLoader().getReference(), className); ConstantKey ik = (ConstantKey) receiver[nameVn]; if (ik.getConcreteType().getReference().equals(TypeReference.JavaLangString)) { String className = StringStuff.deployment2CanonicalTypeString(ik.getValue().toString()); for(IClassLoader cl : caller.getClassHierarchy().getLoaders()) { TypeReference t = TypeReference.findOrCreate(cl.getReference(), className);