soot.jimple.infoflow.solver.cfg.InfoflowCFG Java Examples

The following examples show how to use soot.jimple.infoflow.solver.cfg.InfoflowCFG. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UtilMain.java    From FuzzDroid with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: UtilMain.java    From FuzzDroid with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: DecisionMakerConfig.java    From FuzzDroid with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #4
Source File: SubpathNCoverage.java    From FuzzDroid with Apache License 2.0 4 votes vote down vote up
public SubpathNCoverage(Collection<Unit> targetUnits, InfoflowCFG cfg) {
	this(targetUnits, 2);
	this.cfg = cfg;
}
 
Example #5
Source File: ApproachLevelMetric.java    From FuzzDroid with Apache License 2.0 4 votes vote down vote up
public ApproachLevelMetric(Collection<Unit> targetUnits, InfoflowCFG cfg) {
	this.targetUnits = targetUnits;
	this.cfg = cfg;
}
 
Example #6
Source File: DecisionMakerConfig.java    From FuzzDroid with Apache License 2.0 4 votes vote down vote up
public void initializeCFG() {
	InfoflowCFG forwardCFG = new InfoflowCFG();
	backwardsCFG = new BackwardsInfoflowCFG(forwardCFG);
}
 
Example #7
Source File: SourceConstantFuzzer.java    From FuzzDroid with Apache License 2.0 4 votes vote down vote up
@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);
		
	}
 
Example #8
Source File: AbstractInteractiveAliasStrategy.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public AbstractInteractiveAliasStrategy(InfoflowCFG cfg) {
	super(cfg);
}
 
Example #9
Source File: IFDSForwardReachingConstantDefinitions.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public IFDSForwardReachingConstantDefinitions(InfoflowCFG icfg) {
	super(icfg);
	infoflowCFG = icfg;
}
 
Example #10
Source File: InfoflowProblem.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public InfoflowProblem(ISourceSinkManager sourceSinkManager,
		IAliasingStrategy aliasingStrategy) {
	this(new InfoflowCFG(), sourceSinkManager, aliasingStrategy);
}
 
Example #11
Source File: InfoflowProblem.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public InfoflowProblem(InfoflowCFG icfg, List<String> sourceList, List<String> sinkList,
		IAliasingStrategy aliasingStrategy) {
	this(icfg, new DefaultSourceSinkManager(sourceList, sinkList), aliasingStrategy);
}
 
Example #12
Source File: InfoflowProblem.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public InfoflowProblem(ISourceSinkManager mySourceSinkManager, Set<Unit> analysisSeeds,
IAliasingStrategy aliasingStrategy) {
  this(new InfoflowCFG(), mySourceSinkManager, aliasingStrategy);
  for (Unit u : analysisSeeds)
  	this.initialSeeds.put(u, Collections.singleton(getZeroValue()));
 }