public SootClass getDeclaringClass() { if (variable instanceof SootField) { return ((SootField) variable).getDeclaringClass(); } return null; } }
public Object getFieldInfo(SootField field) { SootClass c = field.getDeclaringClass(); Map<SootField, IntValueContainer> fieldInfoTable = classToFieldInfoMap.get(c); if (fieldInfoTable == null) { internalTransform(c); fieldInfoTable = classToFieldInfoMap.get(c); } return fieldInfoTable.get(field); }
FieldRWTag(Set<SootField> fields) { StringBuffer sb = new StringBuffer(); boolean first = true; for (SootField field : fields) { if (!first) { sb.append("%"); } first = false; sb.append(field.getDeclaringClass().getName()); sb.append(":"); sb.append(field.getName()); } fieldNames = sb.toString(); }
public boolean validateMatchesForField(SparkField field) { if (field instanceof ArrayElement) { return true; } SootField sootField = (SootField) field; String fieldTypeStr = sootField.getDeclaringClass().getType().toString(); for (String typeName : importantTypes) { if (fieldTypeStr.equals(typeName)) { return true; } } return false; }
public boolean validFromBothEnds(SparkField field) { if (allNotBothEnds) { return false; } if (field instanceof SootField) { SootField sootField = (SootField) field; String fieldTypeStr = sootField.getDeclaringClass().getType().toString(); for (String typeName : notBothEndsTypes) { if (fieldTypeStr.equals(typeName)) { return false; } } } return true; }
public boolean validFromBothEnds(SparkField field) { if (field instanceof SootField) { SootField sootField = (SootField) field; RefType declaringType = sootField.getDeclaringClass().getType(); for (RefType type : notBothEndsTypes) { if (manager.castNeverFails(declaringType, type)) { return false; } } } return true; }
public String getSignature() { if (sig == null) { synchronized (this) { if (sig == null) { sig = getSignature(getDeclaringClass(), getSubSignature()); } } } return sig; }
public boolean validFromBothEnds(SparkField field) { if (allNotBothEnds) { return false; } if (field instanceof ArrayElement) { return true; } SootField sootField = (SootField) field; RefType declaringType = sootField.getDeclaringClass().getType(); if (bothEndsTypes.contains(declaringType)) { return true; } else if (notBothEndsTypes.contains(declaringType)) { return false; } else { if (SootUtil.hasRecursiveField(declaringType.getSootClass())) { notBothEndsTypes.add(declaringType); return false; } else { bothEndsTypes.add(declaringType); return true; } } }
public boolean isFieldLocalToParent(SootField sf) // To parent class! { // Handle obvious case if (sf.isStatic()) { return false; } ClassLocalObjectsAnalysis cloa = getClassLocalObjectsAnalysis(sf.getDeclaringClass()); return cloa.isFieldLocal(sf); }
private boolean analyzeProtectedField(SootField sf, SootClass callingClass) { SootClass fieldClass = sf.getDeclaringClass(); boolean insidePackageAccess = isCallSamePackage(callingClass, fieldClass); boolean subClassAccess = isCallClassSubClass(callingClass, fieldClass); boolean sameClassAccess = isCallClassMethodClass(callingClass, fieldClass); if (!insidePackageAccess && subClassAccess) { fieldResultsMap.put(sf, new Integer(RESULT_PROTECTED)); return true; } else if (insidePackageAccess && !sameClassAccess) { updateToPackage(sf); return false; } else { updateToPrivate(sf); return false; } }
public static String getNodeLabel(Object o) { Value node = ((EquivalentValue) o).getValue(); /* * if(node instanceof InstanceFieldRef) { InstanceFieldRef ifr = (InstanceFieldRef) node; if(ifr.getBase() instanceof * FakeJimpleLocal) return ifr.getField().getDeclaringClass().getShortName() + "." + ifr.getFieldRef().name(); else * return ifr.getField().getDeclaringClass().getShortName() + "." + ifr.getFieldRef().name(); } else */ if (node instanceof FieldRef) { FieldRef fr = (FieldRef) node; return fr.getField().getDeclaringClass().getShortName() + "." + fr.getFieldRef().name(); } return node.toString(); } }
public void caseFieldGetInst(FieldGetInst i) { remove_types = new Type[] { i.getField().getDeclaringClass().getType() }; add_types = new Type[] { i.getField().getType() }; }
public void caseFieldPutInst(FieldPutInst i) { remove_types = new Type[] { i.getField().getDeclaringClass().getType(), i.getField().getType() }; add_types = null; }
private boolean analyzePublicField(SootField sf, SootClass callingClass) { SootClass fieldClass = sf.getDeclaringClass(); boolean insidePackageAccess = isCallSamePackage(callingClass, fieldClass); boolean subClassAccess = isCallClassSubClass(callingClass, fieldClass); boolean sameClassAccess = isCallClassMethodClass(callingClass, fieldClass); if (!insidePackageAccess && !subClassAccess) { fieldResultsMap.put(sf, new Integer(RESULT_PUBLIC)); return true; } else if (!insidePackageAccess && subClassAccess) { updateToProtected(sf); return false; } else if (insidePackageAccess && !sameClassAccess) { updateToPackage(sf); return false; } else { updateToPrivate(sf); return false; } }
/** * Removes the given field from this class. */ public void removeField(SootField f) { checkLevel(SIGNATURES); if (!f.isDeclared() || f.getDeclaringClass() != this) { throw new RuntimeException("did not declare: " + f.getName()); } if (fields != null) { fields.remove(f); } f.setDeclared(false); f.setDeclaringClass(null); }
private boolean analyzePackageField(SootField sf, SootClass callingClass) { SootClass fieldClass = sf.getDeclaringClass(); boolean insidePackageAccess = isCallSamePackage(callingClass, fieldClass); boolean subClassAccess = isCallClassSubClass(callingClass, fieldClass); boolean sameClassAccess = isCallClassMethodClass(callingClass, fieldClass); if (insidePackageAccess && !sameClassAccess) { updateToPackage(sf); return true; } else { updateToPrivate(sf); return false; } }
protected static FieldReference toFieldReference(SootField f) { FieldReference fieldRef = new ImmutableFieldReference(SootToDexUtils.getDexClassName(f.getDeclaringClass().getName()), f.getName(), SootToDexUtils.getDexTypeDescriptor(f.getType())); return fieldRef; }
/** * Obtain or create an internal representation of an object field. */ public IVarAbstraction findAndInsertInstanceField(AllocNode obj, SparkField field) { AllocDotField af = findAllocDotField(obj, field); IVarAbstraction pn = null; if (af == null) { // We create a new instance field node w.r.t type compatiblity Type decType = ((SootField) field).getDeclaringClass().getType(); Type baseType = obj.getType(); // baseType must be a sub type of decType if (typeManager.castNeverFails(baseType, decType)) { af = makeAllocDotField(obj, field); pn = makeInternalNode(af); pointers.add(pn); } } else { pn = consG.get(af); } return pn; }
public static EquivalentValue getNodeForFieldRef(SootMethod sm, SootField sf, Local realLocal) { if (sf.isStatic()) { return new CachedEquivalentValue(Jimple.v().newStaticFieldRef(sf.makeRef())); } else { // Jimple.v().newThisRef(sf.getDeclaringClass().getType()) if (sm.isConcrete() && !sm.isStatic() && sm.getDeclaringClass() == sf.getDeclaringClass() && realLocal == null) { JimpleLocal fakethis = new FakeJimpleLocal("fakethis", sf.getDeclaringClass().getType(), sm.retrieveActiveBody().getThisLocal()); return new CachedEquivalentValue(Jimple.v().newInstanceFieldRef(fakethis, sf.makeRef())); // fake thisLocal } else { // Pretends to be a this.<somefield> ref for a method without a body, // for a static method, or for an inner field JimpleLocal fakethis = new FakeJimpleLocal("fakethis", sf.getDeclaringClass().getType(), realLocal); return new CachedEquivalentValue(Jimple.v().newInstanceFieldRef(fakethis, sf.makeRef())); // fake thisLocal } } }
private void printFieldRef(FieldRef v) { String refTypeName = v.getClass().getSimpleName(); p.openBlock(); String oldName = varName; SootField f = v.getField(); ttp.setVariableName("type"); f.getType().apply(ttp); p.print("SootFieldRef fieldRef = "); p.printNoIndent("Scene.v().makeFieldRef("); String className = f.getDeclaringClass().getName(); p.printNoIndent("Scene.v().getSootClass(\"" + className + "\"),"); p.printNoIndent("\"" + f.getName() + "\","); p.printNoIndent("type,"); p.printNoIndent(f.isStatic() + ");"); p.println("Value " + oldName + " = Jimple.v().new" + refTypeName + "(fieldRef);"); varName = oldName; p.closeBlock(); }