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; }
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; }
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)); }
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; }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
public SubpathNCoverage(Collection<Unit> targetUnits, InfoflowCFG cfg) { this(targetUnits, 2); this.cfg = cfg; }
public ApproachLevelMetric(Collection<Unit> targetUnits, InfoflowCFG cfg) { this.targetUnits = targetUnits; this.cfg = cfg; }
public void initializeCFG() { InfoflowCFG forwardCFG = new InfoflowCFG(); backwardsCFG = new BackwardsInfoflowCFG(forwardCFG); }
@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); }
public TypestateAnalysis(TypestateChangeFunction func, InfoflowCFG cfg) { super(new TypestateAnalysisProblem(func), cfg); }
public TypestateAnalysis(TypestateChangeFunction func, InfoflowCFG cfg, IDebugger<TypestateDomainValue> debugger) { super(new TypestateAnalysisProblem(func), cfg, debugger); }
public SocketAnalysis(InfoflowCFG icfg) { super(new SocketStateMachine(icfg), icfg); }
public SocketAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) { super(new SocketStateMachine(icfg), icfg, debugger); }
public PrintStreamAnalysis(InfoflowCFG icfg) { super(new PrintStreamStateMachine(icfg), icfg); }
public PrintStreamAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) { super(new PrintStreamStateMachine(icfg), icfg, debugger); }
public URLConnAnalysis(InfoflowCFG icfg) { super(new URLConnStateMachine(icfg), icfg); }
public URLConnAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) { super(new URLConnStateMachine(icfg), icfg, debugger); }
public PipedInputStreamAnalysis(InfoflowCFG icfg) { super(new PipedInputStreamStateMachine(icfg), icfg); }
public PipedInputStreamAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) { super(new PipedInputStreamStateMachine(icfg), icfg, debugger); }
public VectorAnalysis(InfoflowCFG icfg) { super(new VectorStateMachine(icfg), icfg); }
public VectorAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) { super(new VectorStateMachine(icfg), icfg, debugger); }
public InputStreamAnalysis(InfoflowCFG icfg) { super(new InputStreamStateMachine(icfg), icfg); }
public InputStreamAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) { super(new InputStreamStateMachine(icfg), icfg, debugger); }
public HasNextAnalysis(InfoflowCFG cfg) { super(new HasNextStateMachine(cfg), cfg); }
public HasNextAnalysis(InfoflowCFG cfg, IDebugger<TypestateDomainValue> debugger) { super(new HasNextStateMachine(cfg),cfg, debugger); }
public HasNextAnalysis(InfoflowCFG cfg, IDebugger<TypestateDomainValue> debugger) { super(new HasNextStateMachine(cfg), cfg, debugger); }
public SignatureAnalysis(InfoflowCFG icfg) { super(new SignatureStateMachine(icfg), icfg); }
public SignatureAnalysis(InfoflowCFG icfg, IDebugger<TypestateDomainValue> debugger) { super(new SignatureStateMachine(icfg), icfg, debugger); }
public PipedOutputStreamAnalysis(InfoflowCFG icfg) { super(new PipedOutputStreamStateMachine(icfg), icfg); }