Java 类soot.jimple.infoflow.solver.cfg.InfoflowCFG 实例源码

项目:FuzzDroid    文件:UtilMain.java   
public static Set<InstanceIndependentCodePosition> convertUnitsToIndependentCodePosition(Set<Unit> units, InfoflowCFG cfg) {
    Set<InstanceIndependentCodePosition> positions = new HashSet<InstanceIndependentCodePosition>();

    for(Unit unit : units) {
        //now we have access to the CFG
        //check if target is reachable:
        if(!cfg.isReachable(unit) || cfg.getMethodOf(unit) == null) {
            LoggerHelper.logEvent(MyLevel.LOGGING_POINT, "target is not statically reachable!");
            continue;
        }


        String methodSig = cfg.getMethodOf(unit).getSignature();
        int lineNum = generateLineNumberOfUnit(unit, cfg);
        String statement = unit.toString();
        InstanceIndependentCodePosition position = new InstanceIndependentCodePosition(methodSig, lineNum, statement);
        positions.add(position);
    }

    return positions;
}
项目:FuzzDroid    文件:UtilMain.java   
private static int generateLineNumberOfUnit(Unit unit, InfoflowCFG cfg) {
    SootMethod sm = cfg.getMethodOf(unit);

    if(sm == null)
        return -1;

    int lineNum = 0;
    for (Iterator<Unit> unitIt = sm.getActiveBody().getUnits().iterator(); unitIt.hasNext(); ) {
        Unit currentUnit = unitIt.next();
        // Is this the statement
        if(unit == currentUnit)
            return lineNum;         
        lineNum++;
    }

    return -1;
}
项目:ideal    文件:HasNextStateMachine.java   
HasNextStateMachine(InfoflowCFG cfg) {
  this.icfg = cfg;
  initialTrans =
      new MatcherTransition(States.NONE, retrieveIteratorConstructors(),Parameter.This, States.INIT, Type.None);
  addTransition(initialTrans);
  addTransition(
      new MatcherTransition(States.INIT, retrieveNextMethods(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(
      new MatcherTransition(States.ERROR, retrieveNextMethods(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(
      new MatcherTransition(States.HASNEXT, retrieveNextMethods(),Parameter.This, States.INIT, Type.OnReturn));
  addTransition(new MatcherTransition(States.INIT, retrieveHasNextMethods(),Parameter.This, States.HASNEXT,
      Type.OnReturn));
  addTransition(new MatcherTransition(States.HASNEXT, retrieveHasNextMethods(),Parameter.This, States.HASNEXT,
      Type.OnReturn));
  addTransition(
      new MatcherTransition(States.ERROR, retrieveHasNextMethods(),Parameter.This, States.ERROR, Type.OnReturn));
}
项目:ideal    文件:HasNextStateMachine.java   
HasNextStateMachine(InfoflowCFG cfg) {
  this.icfg = cfg;
  initialTrans =
      new MatcherTransition(States.NONE, retrieveIteratorConstructors(),Parameter.This, States.INIT, Type.None);
  addTransition(initialTrans);
  addTransition(
      new MatcherTransition(States.INIT, retrieveNextMethods(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(
      new MatcherTransition(States.ERROR, retrieveNextMethods(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(
      new MatcherTransition(States.HASNEXT, retrieveNextMethods(),Parameter.This, States.INIT, Type.OnReturn));
  addTransition(new MatcherTransition(States.INIT, retrieveHasNextMethods(),Parameter.This, States.HASNEXT,
      Type.OnReturn));
  addTransition(new MatcherTransition(States.HASNEXT, retrieveHasNextMethods(),Parameter.This, States.HASNEXT,
      Type.OnReturn));
  addTransition(
      new MatcherTransition(States.ERROR, retrieveHasNextMethods(),Parameter.This, States.ERROR, Type.OnReturn));
}
项目:FuzzDroid    文件:DecisionMakerConfig.java   
private boolean registerProgressMetrics() {
    Set<String> registeredMetrics = getProgressMetricNames();
    for(String registeredMetricsClassName : registeredMetrics)
        if (!registeredMetricsClassName.startsWith("%")) {
            try{                        
                Class<?> metricClass = Class.forName(registeredMetricsClassName);
                Constructor<?> defaultConstructor = metricClass.getConstructor(Collection.class, InfoflowCFG.class);
                defaultConstructor.isAccessible();
                Object constructorObject = defaultConstructor.newInstance(allTargetLocations, backwardsCFG);
                if(!(constructorObject instanceof IProgressMetric))
                    throw new RuntimeException("There is a problem with the registered metric in the files/metricsNames.txt file!");
                IProgressMetric metric = (IProgressMetric)constructorObject;
                LoggerHelper.logEvent(MyLevel.ANALYSIS, "[METRIC-TYPE] " + registeredMetricsClassName);

                //currently, there can be only a single target
                if(allTargetLocations.size() != 1)
                    throw new RuntimeException("There can be only 1 target location per run");
                Unit target = allTargetLocations.iterator().next();
                if(backwardsCFG.getMethodOf(target) != null) {                                                  
                    metric.setCurrentTargetLocation(target);

                    //initialize the metric, otherwise it is empty!
                    metric.initalize();                                     
                    progressMetrics.add(metric);
                }
                else{
                    LoggerHelper.logEvent(MyLevel.LOGGING_POINT, "target is not statically reachable!");
                    return false;
                }
            }
            catch(Exception ex) {
                LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, ex.getMessage());
                ex.printStackTrace();
                System.exit(-1);
            }               
        }
    return true;
}
项目:ideal    文件:SocketStateMachine.java   
SocketStateMachine(InfoflowCFG icfg) {
  this.icfg = icfg;
  initialTrans =
      new MatcherTransition(States.NONE, socketConstructor(),Parameter.This, States.INIT, Type.OnReturn);
  addTransition(initialTrans);
  addTransition(new MatcherTransition(States.INIT, connect(),Parameter.This, States.CONNECTED, Type.OnReturn));
  addTransition(new MatcherTransition(States.INIT, useMethods(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(new MatcherTransition(States.ERROR, useMethods(),Parameter.This, States.ERROR, Type.OnReturn));
}
项目:ideal    文件:PrintStreamStateMachine.java   
PrintStreamStateMachine(InfoflowCFG icfg) {
  this.icfg = icfg;
  initialTrans = new MatcherTransition(States.NONE, closeMethods(),Parameter.This, States.CLOSED, Type.OnReturn);
  addTransition(initialTrans);
  addTransition(
      new MatcherTransition(States.CLOSED, closeMethods(),Parameter.This, States.CLOSED, Type.OnReturn));
  addTransition(new MatcherTransition(States.CLOSED, readMethods(),Parameter.This, States.ERROR, Type.OnReturn));
}
项目:ideal    文件:URLConnStateMachine.java   
URLConnStateMachine(InfoflowCFG icfg) {
    this.icfg = icfg;
    initialTrans = new MatcherTransition(States.NONE, connect(), Parameter.This, States.CONNECTED, Type.OnReturn);
    // addTransition(initialTrans);
    addTransition(new MatcherTransition(States.CONNECTED, illegalOpertaion(), Parameter.This, States.ERROR,
            Type.OnReturn));
    addTransition(
            new MatcherTransition(States.ERROR, illegalOpertaion(), Parameter.This, States.ERROR, Type.OnReturn));
}
项目:ideal    文件:PipedInputStreamStateMachine.java   
PipedInputStreamStateMachine(InfoflowCFG icfg) {
    initialTrans = new MatcherTransition(States.NONE, constructors(), Parameter.This, States.INIT, Type.OnReturn);
    addTransition(initialTrans);
    addTransition(
            new MatcherTransition(States.INIT, connect(), Parameter.This, States.CONNECTED, Type.OnReturn));
    addTransition(new MatcherTransition(States.INIT, readMethods(), Parameter.This, States.ERROR, Type.OnReturn));
    addTransition(new MatcherTransition(States.CONNECTED, readMethods(), Parameter.This, States.CONNECTED, Type.OnReturn));
    addTransition(new MatcherTransition(States.ERROR, readMethods(), Parameter.This, States.ERROR, Type.OnReturn));
}
项目:ideal    文件:VectorStateMachine.java   
VectorStateMachine(InfoflowCFG icfg) {
    this.icfg = icfg;
    initialTrans = new MatcherTransition(States.NONE, vectorConstructor(), Parameter.This,States.INIT, Type.OnReturn);
    addTransition(initialTrans);
    addTransition(new MatcherTransition(States.INIT, addElement(), Parameter.This, States.NOT_EMPTY, Type.OnReturn));
    addTransition(new MatcherTransition(States.INIT, accessElement(), Parameter.This,States.ACCESSED_EMPTY, Type.OnReturn));
    addTransition(new MatcherTransition(States.NOT_EMPTY, removeAllElements(), Parameter.This, States.INIT, Type.OnReturn));
    addTransition(new MatcherTransition(States.INIT, removeAllElements(),Parameter.This, States.INIT, Type.OnReturn));
    addTransition(
            new MatcherTransition(States.ACCESSED_EMPTY, accessElement(), Parameter.This,States.ACCESSED_EMPTY, Type.OnReturn));
}
项目:ideal    文件:InputStreamStateMachine.java   
InputStreamStateMachine(InfoflowCFG icfg) {
    this.icfg = icfg;
    initialTrans = new MatcherTransition(States.NONE, closeMethods(), Parameter.This, States.CLOSED, Type.OnReturn);
    addTransition(initialTrans);
    addTransition(
            new MatcherTransition(States.CLOSED, closeMethods(), Parameter.This, States.CLOSED, Type.OnReturn));
    addTransition(new MatcherTransition(States.CLOSED, readMethods(), Parameter.This, States.ERROR, Type.OnReturn));
    addTransition(new MatcherTransition(States.ERROR, readMethods(), Parameter.This, States.ERROR, Type.OnReturn));
}
项目:ideal    文件:SignatureStateMachine.java   
SignatureStateMachine(InfoflowCFG icfg) {
  this.icfg = icfg;
  initialTrans =
      new MatcherTransition(States.NONE, constructor(),Parameter.This, States.UNITIALIZED, Type.OnReturn);
  addTransition(initialTrans);
  addTransition(new MatcherTransition(States.UNITIALIZED, initSign(),Parameter.This, States.SIGN_CHECK, Type.OnReturn));
  addTransition(new MatcherTransition(States.UNITIALIZED, initVerify(),Parameter.This, States.VERIFY_CHECK, Type.OnReturn));
  addTransition(new MatcherTransition(States.UNITIALIZED, sign(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(new MatcherTransition(States.UNITIALIZED, verify(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(new MatcherTransition(States.UNITIALIZED, update(),Parameter.This, States.ERROR, Type.OnReturn));

  addTransition(new MatcherTransition(States.SIGN_CHECK, initSign(),Parameter.This, States.SIGN_CHECK, Type.OnReturn));
  addTransition(new MatcherTransition(States.SIGN_CHECK, initVerify(),Parameter.This, States.VERIFY_CHECK, Type.OnReturn));
  addTransition(new MatcherTransition(States.SIGN_CHECK, sign(),Parameter.This, States.SIGN_CHECK, Type.OnReturn));
  addTransition(new MatcherTransition(States.SIGN_CHECK, verify(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(new MatcherTransition(States.SIGN_CHECK, update(),Parameter.This, States.SIGN_CHECK, Type.OnReturn));

  addTransition(new MatcherTransition(States.VERIFY_CHECK, initSign(),Parameter.This, States.SIGN_CHECK, Type.OnReturn));
  addTransition(new MatcherTransition(States.VERIFY_CHECK, initVerify(),Parameter.This, States.VERIFY_CHECK, Type.OnReturn));
  addTransition(new MatcherTransition(States.VERIFY_CHECK, sign(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(new MatcherTransition(States.VERIFY_CHECK, verify(),Parameter.This, States.VERIFY_CHECK, Type.OnReturn));
  addTransition(new MatcherTransition(States.VERIFY_CHECK, update(),Parameter.This, States.VERIFY_CHECK, Type.OnReturn));

  addTransition(new MatcherTransition(States.ERROR, initSign(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(new MatcherTransition(States.ERROR, initVerify(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(new MatcherTransition(States.ERROR, sign(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(new MatcherTransition(States.ERROR, verify(),Parameter.This, States.ERROR, Type.OnReturn));
  addTransition(new MatcherTransition(States.ERROR, update(),Parameter.This, States.ERROR, Type.OnReturn));
}
项目:ideal    文件:PipedOutputStreamStateMachine.java   
PipedOutputStreamStateMachine(InfoflowCFG icfg) {
    this.icfg = icfg;
    initialTrans = new MatcherTransition(States.NONE, constructors(), Parameter.This, States.INIT, Type.OnReturn);
    addTransition(initialTrans);
    addTransition(
            new MatcherTransition(States.INIT, connect(), Parameter.This, States.CONNECTED, Type.OnReturn));
    addTransition(new MatcherTransition(States.INIT, readMethods(), Parameter.This, States.ERROR, Type.OnReturn));
    addTransition(new MatcherTransition(States.CONNECTED, readMethods(), Parameter.This, States.CONNECTED, Type.OnReturn));
    addTransition(new MatcherTransition(States.ERROR, readMethods(), Parameter.This, States.ERROR, Type.OnReturn));
}
项目:ideal    文件:PrintWriterStateMachine.java   
PrintWriterStateMachine(InfoflowCFG icfg) {
    this.icfg = icfg;
    initialTrans = new MatcherTransition(States.NONE, closeMethods(), Parameter.This, States.CLOSED, Type.OnReturn);
    addTransition(initialTrans);
    addTransition(
            new MatcherTransition(States.CLOSED, closeMethods(), Parameter.This, States.CLOSED, Type.OnReturn));
    addTransition(new MatcherTransition(States.CLOSED, readMethods(), Parameter.This, States.ERROR, Type.OnReturn));
    addTransition(new MatcherTransition(States.ERROR, readMethods(), Parameter.This, States.ERROR, Type.OnReturn));

}
项目:ideal    文件:OutputStreamStateMachine.java   
OutputStreamStateMachine(InfoflowCFG icfg) {
    this.icfg = icfg;
    initialTrans = new MatcherTransition(States.NONE, closeMethods(), Parameter.This, States.CLOSED, Type.OnReturn);
    addTransition(initialTrans);
    addTransition(
            new MatcherTransition(States.CLOSED, closeMethods(), Parameter.This, States.CLOSED, Type.OnReturn));
    addTransition(new MatcherTransition(States.CLOSED, writeMethods(), Parameter.This, States.ERROR, Type.OnReturn));
    addTransition(new MatcherTransition(States.ERROR, writeMethods(), Parameter.This, States.ERROR, Type.OnReturn));
}
项目:FuzzDroid    文件:SubpathNCoverage.java   
public SubpathNCoverage(Collection<Unit> targetUnits, InfoflowCFG cfg) {
    this(targetUnits, 2);
    this.cfg = cfg;
}
项目:FuzzDroid    文件:ApproachLevelMetric.java   
public ApproachLevelMetric(Collection<Unit> targetUnits, InfoflowCFG cfg) {
    this.targetUnits = targetUnits;
    this.cfg = cfg;
}
项目:FuzzDroid    文件:DecisionMakerConfig.java   
public void initializeCFG() {
    InfoflowCFG forwardCFG = new InfoflowCFG();
    backwardsCFG = new BackwardsInfoflowCFG(forwardCFG);
}
项目:FuzzDroid    文件:SourceConstantFuzzer.java   
@Override
    public void doPreAnalysis(Set<Unit> targetUnits, TraceManager traceManager) {

        ifCFG = new InfoflowCFG();

        for (SootClass sc : Scene.v().getClasses()) {

            if (!UtilInstrumenter.isAppDeveloperCode(sc)) {
                continue;
            }

            for (SootMethod m : sc.getMethods()) {
                if (m.hasActiveBody()) {
                    for (Unit u : m.getActiveBody().getUnits()) {
                        if (!u.hasTag(InstrumentedCodeTag.name))
                            getConstants(u, sc);
                    }
                }
            }

        }

        fillWithDummyValues();

        convertSets2Arrays();

        // debug output to show found strings
//      for (String className : doubleContainer.getArrayMap().keySet()) {
//          System.out.println("SourceConstantFuzzer: Classname: " + className);
//          Object[] valuesString = stringContainer.getArrayMap().get(className);
//          
//          Object[] valuesInt = intContainer.getArrayMap().get(className);
//          Object[] valuesLong = longContainer.getArrayMap().get(className);
//          Object[] valuesDouble = doubleContainer.getArrayMap().get(className);
//          Object[] valuesFloat = floatContainer.getArrayMap().get(className);
//          Object[] valuesBoolean = stringContainer.getArrayMap().get(className); //TODO!
//          
//          if(null != valuesString)
//          {
//              for (Object o : valuesString) {
//                  System.out.println("\tFound String: " + o);
//              }
//          }
//          else
//          {
//              System.out.println("###No Strings in this class###");
//          }           
//      }

        System.out.println("#Constants in App including dummy values");
        System.out.println("#Strings in App: " + stringContainer.getAllValues().length);
        System.out.println("#Integers in App: " + intContainer.getAllValues().length);
        System.out.println("#Longs in App: " + longContainer.getAllValues().length);
        System.out.println("#Doubles in App: " + doubleContainer.getAllValues().length);
        System.out.println("#Floats in App: " + floatContainer.getAllValues().length);
        System.out.println("#Booleans in App: " + booleanContainer.getAllValues().length);
        System.out.println("#Chars in App: " + charContainer.getAllValues().length);
        System.out.println("#Shorts in App: " + shortContainer.getAllValues().length);
        System.out.println("#bytes in App: " + byteContainer.getAllValues().length);

    }
项目:ideal    文件:TypestateAnalysis.java   
public TypestateAnalysis(TypestateChangeFunction func, InfoflowCFG cfg) {
    super(new TypestateAnalysisProblem(func), cfg);
}
项目:ideal    文件:TypestateAnalysis.java   
public TypestateAnalysis(TypestateChangeFunction func, InfoflowCFG cfg, IDebugger<TypestateDomainValue> debugger) {
    super(new TypestateAnalysisProblem(func), cfg, debugger);
}
项目:ideal    文件:SocketAnalysis.java   
public SocketAnalysis(InfoflowCFG icfg) {
  super(new SocketStateMachine(icfg), icfg);
}
项目:ideal    文件:SocketAnalysis.java   
public SocketAnalysis(InfoflowCFG icfg,
  IDebugger<TypestateDomainValue> debugger) {
  super(new SocketStateMachine(icfg), icfg, debugger);
}
项目:ideal    文件:PrintStreamAnalysis.java   
public PrintStreamAnalysis(InfoflowCFG icfg) {
  super(new PrintStreamStateMachine(icfg), icfg);
}
项目:ideal    文件:PrintStreamAnalysis.java   
public PrintStreamAnalysis(InfoflowCFG icfg,
  IDebugger<TypestateDomainValue> debugger) {
  super(new PrintStreamStateMachine(icfg), icfg, debugger);
}
项目:ideal    文件:URLConnAnalysis.java   
public URLConnAnalysis(InfoflowCFG icfg) {
  super(new URLConnStateMachine(icfg), icfg);
}
项目:ideal    文件:URLConnAnalysis.java   
public URLConnAnalysis(InfoflowCFG icfg,
  IDebugger<TypestateDomainValue> debugger) {
  super(new URLConnStateMachine(icfg), icfg, debugger);
}
项目:ideal    文件:PipedInputStreamAnalysis.java   
public PipedInputStreamAnalysis(InfoflowCFG icfg) {
  super(new PipedInputStreamStateMachine(icfg), icfg);
}
项目:ideal    文件:PipedInputStreamAnalysis.java   
public PipedInputStreamAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) {
  super(new PipedInputStreamStateMachine(icfg), icfg, debugger);
}
项目:ideal    文件:VectorAnalysis.java   
public VectorAnalysis(InfoflowCFG icfg) {
    super(new VectorStateMachine(icfg), icfg);
}
项目:ideal    文件:VectorAnalysis.java   
public VectorAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) {
    super(new VectorStateMachine(icfg), icfg, debugger);
}
项目:ideal    文件:InputStreamAnalysis.java   
public InputStreamAnalysis(InfoflowCFG icfg) {
  super(new InputStreamStateMachine(icfg), icfg);
}
项目:ideal    文件:InputStreamAnalysis.java   
public InputStreamAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) {
  super(new InputStreamStateMachine(icfg), icfg, debugger);
}
项目:ideal    文件:HasNextAnalysis.java   
public HasNextAnalysis(InfoflowCFG cfg) {
  super(new HasNextStateMachine(cfg), cfg);
}
项目:ideal    文件:HasNextAnalysis.java   
public HasNextAnalysis(InfoflowCFG cfg, IDebugger<TypestateDomainValue> debugger) {
super(new HasNextStateMachine(cfg),cfg, debugger);
 }
项目:ideal    文件:HasNextAnalysis.java   
public HasNextAnalysis(InfoflowCFG cfg) {
  super(new HasNextStateMachine(cfg), cfg);
}
项目:ideal    文件:HasNextAnalysis.java   
public HasNextAnalysis(InfoflowCFG cfg, IDebugger<TypestateDomainValue> debugger) {
  super(new HasNextStateMachine(cfg), cfg, debugger);
}
项目:ideal    文件:SignatureAnalysis.java   
public SignatureAnalysis(InfoflowCFG icfg) {
  super(new SignatureStateMachine(icfg), icfg);
}
项目:ideal    文件:SignatureAnalysis.java   
public SignatureAnalysis(InfoflowCFG icfg,
  IDebugger<TypestateDomainValue> debugger) {
  super(new SignatureStateMachine(icfg), icfg, debugger);
}
项目:ideal    文件:PipedOutputStreamAnalysis.java   
public PipedOutputStreamAnalysis(InfoflowCFG icfg) {
  super(new PipedOutputStreamStateMachine(icfg), icfg);
}