• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UnitGraph类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中soot.toolkits.graph.UnitGraph的典型用法代码示例。如果您正苦于以下问题:Java UnitGraph类的具体用法?Java UnitGraph怎么用?Java UnitGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UnitGraph类属于soot.toolkits.graph包,在下文中一共展示了UnitGraph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: StringValues

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
public StringValues(UnitGraph graph, Stack<SootMethod> stack)
 {

     StringAnalysis analysis = new StringAnalysis(graph, stack);

     // build map
     {
         unitToStringAnalysis = new HashMap<Unit, List>(graph.size() * 2 + 1, 0.7f);
         Iterator unitIt = graph.iterator();

while (unitIt.hasNext()) {
	Unit s = (Unit) unitIt.next();
	FlowSet setB = (FlowSet) analysis.getFlowBefore(s);
	FlowSet setA = (FlowSet) analysis.getFlowAfter(s);
	List listB = setB.toList();
	List listA = setA.toList();
	List unionList = new ArrayList();
	unionList.addAll(listA);
	unionList.addAll(listB);
	unitToStringAnalysis.put(s,Collections.unmodifiableList((unionList)));
}
     }
 }
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:24,代码来源:StringValues.java


示例2: getUnitInBetween

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
private static void getUnitInBetween(UnitGraph ug, List<Unit>inBetween, Unit u) {

    for (Unit succ: ug.getSuccsOf(u)) {
      Stmt s = (Stmt)succ;
      if (inBetween.contains(succ)) {
        continue;
      }
      if (s.containsInvokeExpr()) {
        InvokeExpr ie = s.getInvokeExpr();
        if (ie.getMethodRef().name().contains("restoreCallingIdentity")) {
          return;
        } 
      }
      inBetween.add(succ);
      getUnitInBetween(ug, inBetween, succ);
    }
  }
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:18,代码来源:ClearRestoreCallingIdentity.java


示例3: Loop

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
/**
 * Creates a new loop. Expects that the last statement in the list is the loop head
 * and the second-last statement is the back-jump to the head. {@link LoopFinder} will
 * normally guarantee this.
 * @param head the loop header
 * @param loopStatements an ordered list of loop statements, ending with the header
 * @param g the unit graph according to which the loop exists
 */
Loop(Stmt head, List<Stmt> loopStatements, UnitGraph g) {
    this.header = head;
    this.g = g;

    //put header to the top
    loopStatements.remove(head);
    loopStatements.add(0, head);
    
    //last statement
    this.backJump = loopStatements.get(loopStatements.size()-1);
    
    assert g.getSuccsOf(this.backJump).contains(head); //must branch back to the head

    this.loopStatements = loopStatements;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:24,代码来源:Loop.java


示例4: LocalMustAliasAnalysis

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
/**
    * Creates a new {@link LocalMustAliasAnalysis}. If tryTrackFieldAssignments,
    * we run an interprocedural side-effects analysis to determine which fields
    * are (transitively) written to by this method. All fields which that are not written
    * to are tracked just as local variables. This semantics is sound for single-threaded programs.  
    */
public LocalMustAliasAnalysis(UnitGraph g, boolean tryTrackFieldAssignments) {
       super(g);
       this.container = g.getBody().getMethod();
       this.localsAndFieldRefs = new HashSet<Value>(); 
       
       //add all locals
       for (Local l : (Collection<Local>) g.getBody().getLocals()) {
           if (l.getType() instanceof RefLikeType)
               this.localsAndFieldRefs.add(l);
       }
	
       if(tryTrackFieldAssignments) {
       	this.localsAndFieldRefs.addAll(trackableFields());
       }

      	this.rhsToNumber = new HashMap<Value, Integer>();
       this.mergePointToValueToNumber = new HashMap<Unit,Map<Value,Integer>>();
       
       doAnalysis();
       
       //not needed any more
       this.rhsToNumber = null;
       this.mergePointToValueToNumber = null;
   }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:31,代码来源:LocalMustAliasAnalysis.java


示例5: internalTransform

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
	if (!b.getMethod().isSynchronized() || b.getMethod().isStatic())
		return;
	
	Iterator<Unit> it = b.getUnits().snapshotIterator();
	while (it.hasNext()) {
		Unit u = it.next();
		if (u instanceof IdentityStmt)
			continue;
		
		// This the first real statement. If it is not a MonitorEnter
		// instruction, we generate one
		if (!(u instanceof EnterMonitorStmt)) {
			b.getUnits().insertBeforeNoRedirect(Jimple.v().newEnterMonitorStmt(b.getThisLocal()), u);
			
			// We also need to leave the monitor when the method terminates
			UnitGraph graph = new ExceptionalUnitGraph(b);
			for (Unit tail : graph.getTails())
    			b.getUnits().insertBefore(Jimple.v().newExitMonitorStmt(b.getThisLocal()), tail);
		}
		break;
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:24,代码来源:SynchronizedMethodTransformer.java


示例6: SimpleLiveLocals

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
/**
 * Computes the analysis given a UnitGraph computed from a method body. It
 * is recommended that a ExceptionalUnitGraph (or similar) be provided for
 * correct results in the case of exceptional control flow.
 *
 * @param graph a graph on which to compute the analysis.
 * 
 * @see ExceptionalUnitGraph
 */
public SimpleLiveLocals(UnitGraph graph) {
	if (Options.v().time())
		Timers.v().liveTimer.start();

	if (Options.v().verbose())
		G.v().out.println("[" + graph.getBody().getMethod().getName()
				+ "]     Constructing SimpleLiveLocals...");

	analysis = new Analysis(graph);

	if (Options.v().time())
		Timers.v().liveAnalysisTimer.start();

	analysis.doAnalysis();

	if (Options.v().time())
		Timers.v().liveAnalysisTimer.end();

	if (Options.v().time())
		Timers.v().liveTimer.end();
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:31,代码来源:SimpleLiveLocals.java


示例7: findAllUnitsBeforeRestore

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
void findAllUnitsBeforeRestore(List<Unit> restores, Unit from, UnitGraph ug, String mname) throws IOException {
	seen.add(from);
	Iterator<Unit> succ = ug.getSuccsOf(from).iterator();
	while(succ.hasNext()) {
		Stmt s = (Stmt) succ.next();
		if (restores.contains(s)) {
			//done
		} else {
			if (s.containsInvokeExpr()) {
				print (mname+";"+s.getInvokeExpr().getMethod().toString());
			}
			if (!seen.contains(s))
				findAllUnitsBeforeRestore(restores, s, ug, mname);
		}
	}
}
 
开发者ID:USC-NSL,项目名称:SIF,代码行数:17,代码来源:FindClearRestoreUid.java


示例8: analyse

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
@Override
protected void analyse(SootClass clazz, SootMethod method, Body body) {
	if (!clazz.implementsInterface(Types.X509_TRUST_MANAGER.getClassName()))
		return;

	if (!Signatures.methodSignatureMatches(method, VoidType.v(), "checkServerTrusted", Types.X509_CERTIFICATE_ARRAY, Types.STRING))
		return;

	VulnerabilityState state = VulnerabilityState.UNKNOWN;

	UnitGraph graph = new ExceptionalUnitGraph(body);
	if (!FlowGraphUtils.anyExitThrowsException(graph, Types.CERTIFICATE_EXCEPTION)) {
		state = VulnerabilityState.VULNERABLE;
	}

	clazz.addTag(new TrustManagerTag(state));
	vulnerabilities.add(new Vulnerability(clazz, VulnerabilityType.PERMISSIVE_TRUST_MANAGER, state));
}
 
开发者ID:grahamedgecombe,项目名称:android-ssl,代码行数:19,代码来源:TrustManagerAnalyser.java


示例9: analyse

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
@Override
protected void analyse(SootClass clazz, SootMethod method, Body body) {
	if (!clazz.getSuperclass().getType().equals(Types.ABSTRACT_VERIFIER))
		return;

	if (!Signatures.methodSignatureMatches(method, VoidType.v(), "verify", Types.STRING, Types.STRING_ARRAY, Types.STRING_ARRAY))
		return;

	VulnerabilityState state = VulnerabilityState.UNKNOWN;

	UnitGraph graph = new ExceptionalUnitGraph(body);
	if (!FlowGraphUtils.anyExitThrowsException(graph, Types.SSL_EXCEPTION)) {
		state = VulnerabilityState.VULNERABLE;
	}

	clazz.addTag(new HostnameVerifierTag(state));
	vulnerabilities.add(new Vulnerability(clazz, VulnerabilityType.PERMISSIVE_HOSTNAME_VERIFIER, state));
}
 
开发者ID:grahamedgecombe,项目名称:android-ssl,代码行数:19,代码来源:AbstractVerifierAnalyser.java


示例10: analyse

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
@Override
protected void analyse(SootClass clazz, SootMethod method, Body body) {
	if (!clazz.implementsInterface(Types.HOSTNAME_VERIFIER.getClassName()))
		return;

	if (!Signatures.methodSignatureMatches(method, BooleanType.v(), "verify", Types.STRING, Types.SSL_SESSION))
		return;

	VulnerabilityState state = VulnerabilityState.UNKNOWN;

	UnitGraph graph = new BriefUnitGraph(body);
	if (FlowGraphUtils.allExitsReturnTrue(graph)) {
		state = VulnerabilityState.VULNERABLE;
	}

	clazz.addTag(new HostnameVerifierTag(state));
	vulnerabilities.add(new Vulnerability(clazz, VulnerabilityType.PERMISSIVE_HOSTNAME_VERIFIER, state));
}
 
开发者ID:grahamedgecombe,项目名称:android-ssl,代码行数:19,代码来源:HostnameVerifierAnalyser.java


示例11: internalTransform

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
/**
 * This method is called to perform the transformation itself. The method
 * executes the {@link SecurityLevelAnalysis} analysis and checks the
 * <em>write effects</em>, if the given body isn't from a
 * {@code SootSecurityLevel} method.
 * 
 * @param body
 *            The body on which to apply the transformation.
 * @param phaseName
 *            The phase name for this transform; not typically used by
 *            implementations.
 * @param options
 *            The actual computed options; a combination of default options
 *            and Scene specified options.
 * @see soot.BodyTransformer#internalTransform(soot.Body, java.lang.String,
 *      java.util.Map)
 */
@SuppressWarnings("rawtypes")
@Override
protected void internalTransform(Body body, String phaseName, Map options) {
    doInitialChecks();
    UnitGraph graph = new BriefUnitGraph(body);
    SootMethod sootMethod = graph.getBody().getMethod();
    SootClass sootClass = sootMethod.getDeclaringClass();
    if (!isInnerClassOfDefinitionClass(sootClass)) {
        if (!visitedClasses.contains(sootClass)) {
            if (!containsStaticInitializer(sootClass.getMethods())) {
                SootMethod clinit =
                    generatedEmptyStaticInitializer(sootClass);
                UnitGraph clinitGraph =
                    new BriefUnitGraph(clinit.getActiveBody());
                doAnalysis(clinit, clinitGraph);
            }
            visitedClasses.add(sootClass);
        }
        if ((!isMethodOfDefinitionClass(sootMethod))
            || isLevelFunction(sootMethod, mediator.getAvailableLevels())) {
            doAnalysis(sootMethod, graph);
        }
    }
}
 
开发者ID:proglang,项目名称:jgs,代码行数:42,代码来源:SecurityTransformer.java


示例12: findConditionalStatementForBooleanUnit

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
private static IfStmt findConditionalStatementForBooleanUnit(IInfoflowCFG cfg, Unit booleanUnit) {
	Stack<Unit> worklist = new Stack<Unit>();
	Set<Unit> processedUnits = new HashSet<Unit>();
	worklist.add(booleanUnit);	
		
	while(!worklist.isEmpty()) {
		Unit currentUnit = worklist.pop();
		//in case of a loop or recursion
		if(processedUnits.contains(currentUnit))
			continue;
		processedUnits.add(currentUnit);
		
		//skip our own instrumented code
		if(currentUnit.hasTag(InstrumentedCodeTag.name))
			continue;
		
		
		//we reached the condition
		if(currentUnit instanceof IfStmt) {
			return (IfStmt)currentUnit;		 	
		}
		
		SootMethod methodOfBooleanUnit = cfg.getMethodOf(booleanUnit);		
		DirectedGraph<Unit> graph = cfg.getOrCreateUnitGraph(methodOfBooleanUnit);
		//Comment: Steven said it should always be a UnitGraph + he will implement a more convenient way in the near future :-)
		UnitGraph unitGraph = (UnitGraph)graph;

		SimpleLocalDefs defs = new SimpleLocalDefs(unitGraph);
        SimpleLocalUses uses = new SimpleLocalUses(unitGraph, defs);	        
        List<UnitValueBoxPair> usesOfCurrentUnit = uses.getUsesOf(booleanUnit);
        for(UnitValueBoxPair valueBoxPair : usesOfCurrentUnit)
        	worklist.add(valueBoxPair.getUnit());
		
	}
	return null;
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:37,代码来源:UtilSMT.java


示例13: findUriDef

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
private String findUriDef(Body b, Unit u, Local l) {
    final UnitGraph g = new ExceptionalUnitGraph(b);
    final SmartLocalDefs localDefs = new SmartLocalDefs(g, new SimpleLiveLocals(g));
    final SimpleLocalUses localUses = new SimpleLocalUses(g, localDefs);

    List<Unit> defs = localDefs.getDefsOfAt((Local) l, u);
    if (defs.size() == 0) {
        System.out.println("warning: uri def empty!");
        return null;
    }
    Unit def = defs.get(0);
    logger.debug("uri def: " + def);
    if (def instanceof IdentityStmt) {
        System.out.println("warning: do not handle uri from identity stmt");
        return null;
    } else if (def instanceof AssignStmt) {
        AssignStmt ass = (AssignStmt) def;
        Value r = ass.getRightOp();
        if (r instanceof FieldRef) {
            FieldRef fr = (FieldRef) r;
            SootField sf = fr.getField();
            if (sf.getName().contains("URI")) {
                String auth = getFieldFromClass(sf);
                return auth;
            }
        } else {
            System.out.println("warning: uri: do not handle def '" + def + "'");
            return null;
        }
    }
    return null;
}
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:33,代码来源:HandleContentProviders.java


示例14: StrayRWFinder

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
StrayRWFinder(UnitGraph graph, Body b, List tns)
{
	super(graph);
	body = b;
	this.tns = tns;
	if( G.v().Union_factory == null ) {
	    G.v().Union_factory = new UnionFactory() {
		public Union newUnion() { return FullObjectSet.v(); }
	    };
	}
   	sea = Scene.v().getSideEffectAnalysis();
	sea.findNTRWSets( body.getMethod() );
       doAnalysis();
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:15,代码来源:StrayRWFinder.java


示例15: MultiRunStatementsFinder

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
public MultiRunStatementsFinder(UnitGraph g, SootMethod sm, Set<SootMethod> multiCalledMethods, CallGraph cg)
{
	super(g);
	
	nodeToIndex = new HashMap<Object, Integer>();
			
	//      System.out.println("===entering MultiObjectAllocSites==");	
	doAnalysis();
	
	//testMultiObjSites(sm);
	findMultiCalledMethodsIntra(multiCalledMethods, cg);
	
	// testMultiObjSites(sm);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:15,代码来源:MultiRunStatementsFinder.java


示例16: byMCalledS0

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
private void byMCalledS0(PegCallGraph pcg) {
	Iterator it = pcg.iterator();
	while (it.hasNext()){
		SootMethod sm = (SootMethod)it.next();
		UnitGraph graph = new CompleteUnitGraph(sm.getActiveBody());
		CallGraph callGraph = Scene.v().getCallGraph();
		MultiRunStatementsFinder finder = new MultiRunStatementsFinder(graph, sm, multiCalledMethods, callGraph);
		FlowSet fs = finder.getMultiRunStatements();
	}
	
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:12,代码来源:MultiCalledMethods.java


示例17: isRedefined

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
/**
 * Checks whether the given local has been redefined between the original
 * definition unitDef and the use unitUse.
 * @param l The local for which to check for redefinitions
 * @param unitUse The unit that uses the local
 * @param unitDef The unit that defines the local
 * @param graph The unit graph to use for the check
 * @return True if there is at least one path between unitDef and unitUse on
 * which local l gets redefined, otherwise false 
 */
   private boolean isRedefined(Local l, Unit unitUse, AssignStmt unitDef,
   		UnitGraph graph) {
   	List<Unit> workList = new ArrayList<Unit>();
   	workList.add(unitUse);
   	
   	Set<Unit> doneSet = new HashSet<Unit>();
   	
	// Check for redefinitions of the local between definition and use
   	while (!workList.isEmpty()) {
   		Unit curStmt = workList.remove(0);
   		if (!doneSet.add(curStmt))
   			continue;
   		
    	for (Unit u : graph.getPredsOf(curStmt)) {
    		if (u != unitDef) {
	    		if (u instanceof DefinitionStmt) {
	    			DefinitionStmt defStmt = (DefinitionStmt) u;
	    			if (defStmt.getLeftOp() == l)
	    				return true;
	    		}
	    		workList.add(u);
    		}
    	}
   	}
   	return false;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:37,代码来源:DexReturnValuePropagator.java


示例18: getUnitsWithMonitor

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
public Set<Unit> getUnitsWithMonitor(UnitGraph ug) {
	Set<Unit> unitsWithMonitor = new HashSet<Unit>();
	
	for (Unit head : ug.getHeads()) {
		List<Unit> workList = new ArrayList<Unit>();
		workList.add(head);
		Set<Unit> doneSet = new HashSet<Unit>();
		
		while (!workList.isEmpty()) {
			Unit curUnit = workList.remove(0);
			if (!doneSet.add(curUnit))
				continue;
			
			workList.addAll(ug.getSuccsOf(curUnit));
			
			// If this is an "entermonitor" construct,
			// we're in a monitor from now on
			if (curUnit instanceof EnterMonitorStmt)
				unitsWithMonitor.add(curUnit);
			// If we leave a monitor, we're out now
			else if (curUnit instanceof ExitMonitorStmt)
				continue;
			else {
				for (Unit pred : ug.getPredsOf(curUnit))
					if (unitsWithMonitor.contains(pred))
						unitsWithMonitor.add(curUnit);
			}
		}
	}
	
	// Get rid of the entermonitor statements themselves
	for (Iterator<Unit> it = unitsWithMonitor.iterator(); it.hasNext(); )
		if (it.next() instanceof EnterMonitorStmt)
			it.remove();
	
	return unitsWithMonitor;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:38,代码来源:TrapTransformer.java


示例19: InitAnalysis

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
public InitAnalysis(UnitGraph g) {
    super(g);
    allLocals = new ArraySparseSet<Local>();        
    for (Local loc : g.getBody().getLocals()) {
        allLocals.add(loc);
    }

    doAnalysis();
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:10,代码来源:InitAnalysis.java


示例20: Region

import soot.toolkits.graph.UnitGraph; //导入依赖的package包/类
public Region(int id, List<Block> blocks, SootMethod m, SootClass c, UnitGraph ug)
{
	
	this.m_blocks = blocks;
	this.m_id = id;
	this.m_method = m;
	this.m_class = c;
	this.m_unitGraph = ug;
	this.m_units = null;
	
	
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:13,代码来源:Region.java



注:本文中的soot.toolkits.graph.UnitGraph类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MemoryCacheUtils类代码示例发布时间:2022-05-21
下一篇:
Java StanzaFilter类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap