public List<SootField> getExtFields(SootClass sc) { if (classToExtFieldAccesses.containsKey(sc)) { List extAccesses = classToExtFieldAccesses.get(sc); List<SootField> extFields = new ArrayList<SootField>(); for (Iterator accessIt = extAccesses.iterator(); accessIt.hasNext();) { Pair access = (Pair) accessIt.next(); SootField accessedField = ((Stmt) access.getO2()).getFieldRef().getField(); if (!extFields.contains(accessedField)) { extFields.add(accessedField); } } return extFields; } throw new RuntimeException("UseFinder does not search non-application classes: " + sc); }
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(); } }
/** * Checks whether two field references point to the same field * * @param ref1 * The first field reference * @param ref2 * The second reference * @return True if the two references point to the same field, otherwise false */ private static boolean isSameField(FieldRef ref1, FieldRef ref2) { if (ref1 == ref2) { return true; } return ref1.getFieldRef().equals(ref2.getFieldRef()); }
if (((Stmt) u).containsFieldRef() && ((Stmt) u).getFieldRef().getType() instanceof ArrayType) { FieldRef fr = ((Stmt) u).getFieldRef(); String sig = fr.getField().getSignature(); Verify.verify(fieldSubstitutionMap.containsKey(sig), "No entry found for " + fr + " in stmt " + u); fr.setFieldRef(fieldSubstitutionMap.get(sig).makeRef()); } else if (((Stmt) u).containsInvokeExpr()) { InvokeExpr ive = ((Stmt) u).getInvokeExpr();
public boolean equals(Object o) { if (type == null) { return true; } if (o instanceof WholeObject) { WholeObject other = (WholeObject) o; if (other.type == null) { return true; } else { return (type == other.type); } } else if (o instanceof FieldRef) { return type == ((FieldRef) o).getType(); } else if (o instanceof SootFieldRef) { return type == ((SootFieldRef) o).type(); } else if (o instanceof SootField) { return type == ((SootField) o).getType(); } else { return true; } } }
if (fieldSubstitutionMap.containsKey(fr.getField().getSignature())) { fr.setFieldRef(fieldSubstitutionMap.get(fr.getField().getSignature()).makeRef());
if (value instanceof FieldRef) { final FieldRef fieldRef = (FieldRef) value; SootFieldRef sootFieldRef = fieldRef.getFieldRef(); if (sootFieldRef.declaringClass().isLibraryClass()) { continue; fieldRef.setFieldRef(sootFieldRef); try { sootFieldRef.resolve();
if (v instanceof FieldRef) { FieldRef fr = (FieldRef) v; String name = fr.getFieldRef().name(); lastnamelength = name.length(); if (lastnamelength > sourcesnamelength) {
public void analyseThrowStmt(ThrowStmt s) { Value op = (s).getOp(); if (op instanceof Local) { add_ThrownType(((Local) op).getType()); } else if (op instanceof FieldRef) { add_ThrownType(((FieldRef) op).getType()); } }
public void inDefinitionStmt(DefinitionStmt s) { Value leftOp = s.getLeftOp(); if (leftOp instanceof FieldRef) { // System.out.println("leftOp is a fieldRef:"+s); SootField field = ((FieldRef) leftOp).getField(); // check if this is a final field if (field.isFinal()) { // System.out.println("the field is a final variable"); finalFieldDefined = true; } } }
@Override protected void internalTransform(Body b, String phaseName, Map<String, String> options) { // Some apps reference static fields as instance fields. We need to fix // this for not breaking the client analysis. for (Iterator<Unit> unitIt = b.getUnits().iterator(); unitIt.hasNext();) { Stmt s = (Stmt) unitIt.next(); if (s.containsFieldRef() && s instanceof AssignStmt) { FieldRef ref = s.getFieldRef(); // Make sure that the target class has already been loaded if (isTypeLoaded(ref.getFieldRef().type())) { try { if (ref instanceof InstanceFieldRef) { SootField fld = ref.getField(); if (fld != null && fld.isStatic()) { AssignStmt assignStmt = (AssignStmt) s; if (assignStmt.getLeftOp() == ref) { assignStmt.setLeftOp(Jimple.v().newStaticFieldRef(ref.getField().makeRef())); } else if (assignStmt.getRightOp() == ref) { assignStmt.setRightOp(Jimple.v().newStaticFieldRef(ref.getField().makeRef())); } } } } catch (ConflictingFieldRefException ex) { // That field is broken, just don't touch it } } } } }
if (s.containsFieldRef()) { FieldRef fr = s.getFieldRef(); if (fr.getFieldRef().resolve().getDeclaringClass() == appClass) { if (fr instanceof StaticFieldRef) { List<Pair> otherClassList = classToExtFieldAccesses.get(fr.getFieldRef().resolve().getDeclaringClass()); if (otherClassList == null) { otherClassList = new ArrayList<Pair>(); classToExtFieldAccesses.put(fr.getFieldRef().resolve().getDeclaringClass(), otherClassList);
private boolean isObjectArray(Value v, Body body) { for (Unit u : body.getUnits()) { if (u instanceof AssignStmt) { AssignStmt assign = (AssignStmt) u; if (assign.getLeftOp() == v) { if (assign.getRightOp() instanceof NewArrayExpr) { NewArrayExpr nea = (NewArrayExpr) assign.getRightOp(); if (isObject(nea.getBaseType())) { return true; } } else if (assign.getRightOp() instanceof FieldRef) { FieldRef fr = (FieldRef) assign.getRightOp(); if (fr.getType() instanceof ArrayType) { if (isObject(((ArrayType) fr.getType()).getArrayElementType())) { return true; } } } } } } return false; }
public void checkConditionalUses(ASTCondition cond, ASTNode node) { List<Value> useList = getUseList(cond); // System.out.println("FOR NODE with condition:"+cond+"USE list is:"+useList); // FOR EACH USE Iterator<Value> it = useList.iterator(); while (it.hasNext()) { Value temp = it.next(); if (temp instanceof Local) { addLocalUse((Local) temp, node); } else if (temp instanceof FieldRef) { FieldRef field = (FieldRef) temp; SootField sootField = field.getField(); addFieldUse(sootField, node); } } // end of going through all locals uses in condition }
soot.util.Chain containerStmts = containerBody.getUnits(); SootClass target = ref.getField().getDeclaringClass(); String name = createAccessorName(ref.getField(), false); accessor = target.getMethodByNameUnsafe(name); if (accessor == null) { Type returnType = ref.getField().getType(); Local thisLocal = lg.generateLocal(target.getType()); if (ref instanceof InstanceFieldRef) { accStmts.addFirst(Jimple.v().newIdentityStmt(thisLocal, Jimple.v().newParameterRef(target.getType(), 0))); Local l = lg.generateLocal(ref.getField().getType()); Value v; if (ref instanceof InstanceFieldRef) { v = Jimple.v().newInstanceFieldRef(thisLocal, ref.getFieldRef()); } else { v = Jimple.v().newStaticFieldRef(ref.getFieldRef());
Value r = stmt.getRightOp(); if (r instanceof FieldRef) { Type t = ((FieldRef) r).getFieldRef().type(); if (t instanceof ArrayType) { ArrayType at = (ArrayType) t;
if (val instanceof FieldRef) { FieldRef fieldRef = (FieldRef) val; if (fieldRef.getType() instanceof RefLikeType) { usedFieldRefs.add(new EquivalentValue(fieldRef));