本文整理汇总了Java中soot.jimple.ArrayRef.getBase方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayRef.getBase方法的具体用法?Java ArrayRef.getBase怎么用?Java ArrayRef.getBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soot.jimple.ArrayRef
的用法示例。
在下文中一共展示了ArrayRef.getBase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: caseArrayRef
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
public void caseArrayRef(ArrayRef v) {
String oldName = varName;
Value base = v.getBase();
suggestVariableName("base");
String baseName = varName;
base.apply(this);
Value index = v.getIndex();
suggestVariableName("index");
String indexName = varName;
index.apply(this);
p.println("Value "+oldName+" = Jimple.v().newArrayRef("+baseName+", "+indexName+");");
varName = oldName;
}
示例2: treatByteArrayAssign
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
/**
* Modify the value for an array assignment
* @param ast
* @param locanalysis
* @param cc
*/
public void treatByteArrayAssign(AssignStmt ast, LocalAnalysis locanalysis,
CallContext cc) {
if (pag == null) return;
ArrayRef left = (ArrayRef) ast.getLeftOp();
Local l = (Local) left.getBase();
PointsToSet pts = pag.reachingObjects(l);
int index = getConstantValue(locanalysis, ast, left.getIndex());
int contents = getConstantValue(locanalysis, ast, ast.getRightOp());
AbsValue av = P2SAux.p2sContents(cc.nodeTable,pts);
if (!(av instanceof OrValue)) return;
List<AbsValue> lv = ((OrValue) av).vals;
for (AbsValue ava : lv) {
if (! (ava instanceof NodeValue)) continue;
int id = ((NodeValue) ava).ref;
BAAbstraction abs = get(id);
if (index == UNKNOWN_CONTENTS) abs.spoil();
else {
if (abs.contents == null || contents == UNKNOWN_CONTENTS) abs.spoil(index);
else abs.set(index, (byte) contents);
}
}
}
示例3: caseArrayRef
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
@Override
public void caseArrayRef(ArrayRef v) {
Value array = v.getBase();
Value index = v.getIndex();
SecurityConstraintValueReadSwitch baseSwitch = getReadSwitch(array);
SecurityConstraintValueReadSwitch indexSwitch = getReadSwitch(index);
addInheritedWriteEffects(baseSwitch.getInheritedWriteEffects());
addInheritedWriteEffects(indexSwitch.getInheritedWriteEffects());
addReadComponents(baseSwitch.getReadComponents());
addReadComponents(indexSwitch.getReadComponents());
setComponentDimension(getDimension(v.getType()));
if (baseSwitch.getEqualComponents().size() > 0) {
addReadComponent(baseSwitch.getEqualComponents().get(0));
for (int i = 1; i < baseSwitch.getEqualComponents().size(); i++) {
appendEqualComponent(baseSwitch.getEqualComponents().get(1));
}
}
}
示例4: retrieveArrayInitStmts
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
private static List<Value> retrieveArrayInitStmts(Body b, Local arrayLocal) {
List<Value> arrayInitValues = new ArrayList<Value>();
for (Unit u: b.getUnits()) {
if (u instanceof AssignStmt) {
AssignStmt ass = (AssignStmt) u;
if (ass.getLeftOp() instanceof ArrayRef) {
ArrayRef ar = (ArrayRef)ass.getLeftOp();
if (ar.getBase() == arrayLocal) {
arrayInitValues.add(ass.getRightOp());
}
}
}
}
return arrayInitValues;
}
示例5: getTaint
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
/***** Taints *****/
private FlowAbstraction getTaint(Value right, Value left, FlowAbstraction source, Unit src) {
FlowAbstraction fa = null;
if (right instanceof CastExpr)
right = ((CastExpr) right).getOp();
if (right instanceof Local && source.getLocal() == right) {
fa = FlowAbstraction.v(source.getSource(), left, src, icfg.getMethodOf(src), source);
fa = fa.append(source.getFields());
} else if (right instanceof InstanceFieldRef) {
InstanceFieldRef ifr = (InstanceFieldRef) right;
if (source.hasPrefix(ifr)) {
fa = FlowAbstraction.v(source.getSource(), left, src, icfg.getMethodOf(src), source);
fa = fa.append(source.getPostfix(ifr));
}
} else if (right instanceof StaticFieldRef) {
StaticFieldRef sfr = (StaticFieldRef) right;
if (source.hasPrefix(sfr)) {
fa = FlowAbstraction.v(source.getSource(), left, src, icfg.getMethodOf(src), source);
fa = fa.append(source.getPostfix(sfr));
}
} else if (right instanceof ArrayRef) {
ArrayRef ar = (ArrayRef) right;
if (ar.getBase() == source.getLocal())
fa = FlowAbstraction.v(source.getSource(), left, src, icfg.getMethodOf(src), source);
}
return fa;
}
示例6: buildArrayPutInsn
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
private Insn buildArrayPutInsn(ArrayRef destRef, Value source) {
Value array = destRef.getBase();
Register arrayReg = regAlloc.asLocal(array);
Value index = destRef.getIndex();
Register indexReg = regAlloc.asImmediate(index, constantV);
Register sourceReg = regAlloc.asImmediate(source, constantV);
String arrayTypeDescriptor = SootToDexUtils.getArrayTypeDescriptor((ArrayType) array.getType());
Opcode opc = getPutGetOpcodeWithTypeSuffix("aput", arrayTypeDescriptor);
return new Insn23x(opc, sourceReg, arrayReg, indexReg);
}
示例7: buildArrayGetInsn
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
private Insn buildArrayGetInsn(Register destinationReg, ArrayRef sourceRef) {
Value index = sourceRef.getIndex();
Register indexReg = regAlloc.asImmediate(index, constantV);
Value array = sourceRef.getBase();
Register arrayReg = regAlloc.asLocal(array);
String arrayTypeDescriptor = SootToDexUtils.getArrayTypeDescriptor((ArrayType) array.getType());
Opcode opc = getPutGetOpcodeWithTypeSuffix("aget", arrayTypeDescriptor);
return new Insn23x(opc, destinationReg, arrayReg, indexReg);
}
示例8: analyzeArrayRef
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
private AbsValue analyzeArrayRef(ArrayRef r, Unit u, Set <Unit> seen ) {
ProgramSpy.debug("******** ARRAY REF *******");
ArrayRef fr = (ArrayRef) r;
Value b = fr.getBase();
if (b instanceof Local) {
try {
PointsToSet ps1 = pag.reachingObjects((Local) b);
PointsToSet ps2 = ((PAG) pag).reachingObjectsOfArrayElement(ps1);
return possibleStringConstantsValue(b.toString(),ps2);
} catch (Exception e) {
return new UnknownValue(r.toString());
}
} else return new UnknownValue(r.toString());
}
示例9: getBackwardsBase
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
/**
* extracts array base values from array refs and values from cast
* expressions
*/
public static Value getBackwardsBase(Value val) {
if (val instanceof ArrayRef) {
ArrayRef arrayRef = (ArrayRef) val;
return arrayRef.getBase();
}
if (val instanceof CastExpr) {
CastExpr castExpr = (CastExpr) val;
return castExpr.getOp();
}
return val;
}
示例10: getForwardsBase
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
public static Value getForwardsBase(Value val) {
if (val instanceof ArrayRef) {
ArrayRef arrayRef = (ArrayRef) val;
return arrayRef.getBase();
}
return val;
}
示例11: getBase
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
/**
* extracts array base values from array refs and values from cast
* expressions
*/
private Value getBase(Value val) {
if (val instanceof ArrayRef) {
ArrayRef arrayRef = (ArrayRef) val;
return arrayRef.getBase();
}
if (val instanceof CastExpr) {
CastExpr castExpr = (CastExpr) val;
return castExpr.getOp();
}
return val;
}
示例12: getBase
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
private Value getBase(Value val) {
if (val instanceof ArrayRef) {
ArrayRef arrayRef = (ArrayRef) val;
return arrayRef.getBase();
}
return val;
}
示例13: caseArrayRef
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
/**
* The method should update the <em>security level</em> of an array
* reference, more precisely, the level is not changed, however, it is
* checked whether the assignment is possible. In this case, the level of
* the array, the level of the index and the level of the right hand side,
* which may be affected by the program counter, will be considered. In
* addition, a <em>write effect</em> is added and also checked, because an
* assignment to an array occurs. Note, that arrays may contain only values
* with the weakest available <em>security level</em>. Occurring exceptions
* are logged.
*
* @param v
* The array reference for which the <em>security level</em>
* should be updated.
* @see soot.jimple.RefSwitch#caseArrayRef(soot.jimple.ArrayRef)
*/
@Override
public void caseArrayRef(ArrayRef v) {
ILevel rightLevel = takePCintoAccount(level);
Value array = v.getBase();
ILevel arrayLevel = calculateLevel(array, v.toString());
addWriteEffectCausedByArrayAssign(arrayLevel, v);
Value index = v.getIndex();
ILevel indexLevel = calculateLevel(index, v.toString());
if (!isEqualLevel(rightLevel, getWeakestSecurityLevel())) {
// Only weakest security level array elements
logSecurity(getMsg("security.array.restrictions",
getSignatureOfAnalyzedMethod(),
getSourceLine(),
rightLevel.getName(),
getWeakestSecurityLevel().getName()));
}
if (!isWeakerOrEqualLevel(indexLevel, arrayLevel)) {
logSecurity(getMsg("security.array.stronger_index",
getSignatureOfAnalyzedMethod(),
getSourceLine(),
arrayLevel.getName(),
indexLevel.getName()));
}
if (!isWeakerOrEqualLevel(rightLevel, arrayLevel)) {
logSecurity(getMsg("security.array.stronger_assign",
getSignatureOfAnalyzedMethod(),
getSourceLine(),
rightLevel.getName(),
arrayLevel.getName()));
}
}
示例14: getArrayFromMethod
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
/**
* Get the definition of the Array starting from an ArrayRef.
* Two possibilities:
* 1) array = IdentityStmt in which case the previous method in the stack is analyzed
* 2) array = newarray in which case all statements array[i] = r are analyzed
* @param stack
* @param curDepth
* @param ar
* @param mpSet
*/
private static void getArrayFromMethod (Stack<SootMethod> stack, int curDepth, ArrayRef ar, Set<String> mpSet) {
SootMethod targetM = stack.elementAt(curDepth);
logger.info("getArrayFromMethod target: "+ targetM);
Body b = targetM.getActiveBody();
System.out.println("body: "+ b); // TODO: change to logger.debug
UnitGraph eug = new ExceptionalUnitGraph( b );
LocalDefinition ld = new LocalDefinition(b);
Local l = (Local)ar.getBase();
List<Unit> arrayDefs = ld.collectDefinitionsWithAliases(l);
for (Unit arrayDef: arrayDefs) {
if (arrayDef instanceof IdentityStmt) {
logger.info("array: right is IdentityStmt");
IdentityStmt ids = (IdentityStmt)arrayDef;
ParameterRef pref = (ParameterRef)ids.getRightOp();
int paramPos = pref.getIndex();
logger.info("index of array parameter: "+ paramPos); // TODO: should be debug
// List<MethodCall> methodCallsList = getStringParameterInCall(stack.elementAt(curDepth - 1), targetM, paramPos, mpSet);
// getArrayFromMethod (stack, stack.size()-1, ar, mpSet);
getStringFromMethod (stack, curDepth-1, targetM, paramPos, mpSet);
} else if (arrayDef instanceof AssignStmt) {
AssignStmt ass = (AssignStmt) arrayDef;
Value right = ass.getRightOp();
if (right instanceof NewArrayExpr) {
logger.info("array: right is NewArray");
// get the unit array[i] = str
// TODO: Limitation: we suppose the array is initialized in the body where it is created
// and that it is not aliased
Local arrayLocal = (Local)ass.getLeftOp();
List<Value> arrayInitValues = retrieveArrayInitStmts (b, arrayLocal);
for (Value v: arrayInitValues) {
if (v instanceof StringConstant) {
StringConstant sc = (StringConstant)v;
String p = sc.value;
mpSet.add(p);
logger.info("add perm from array inif: "+ p);
} else {
logger.warn("not handling this value for array init: "+ v);
}
}
} else if (right instanceof Local){
logger.info("alias "+ ass); // definitions *and* aliases are collected, so no need to handle them separately
} else {
throw new RuntimeException("error: right not instance of NewArrayExpr nor Local! "+ ass);
}
}
}
}
示例15: handleArrayRef
import soot.jimple.ArrayRef; //导入方法依赖的package包/类
private void handleArrayRef(ArrayRef arrayRef, AnalysisInfo out) {
Value array = arrayRef.getBase();
//here we know that the array must point to an object, but the array value might be anything
out.put(array, NON_NULL);
// out.put(arrayRef, TOP);
}