Пример #1
0
  public static SSAPropagationCallGraphBuilder makeVanillaZeroOneCFABuilder(
      AnalysisOptions options,
      AnalysisCache cache,
      IClassHierarchy cha,
      AnalysisScope scope,
      ContextSelector customSelector,
      SSAContextInterpreter customInterpreter,
      InputStream summariesStream,
      MethodSummary extraSummary) {

    if (options == null) {
      throw new IllegalArgumentException("options is null");
    }
    Util.addDefaultSelectors(options, cha);
    // addDefaultBypassLogic(options, scope, Util.class.getClassLoader(),
    // cha);
    // addBypassLogic(options, scope,
    // AndroidAppLoader.class.getClassLoader(), methodSpec, cha);
    addBypassLogic(options, scope, summariesStream, cha, extraSummary);

    return ZeroXCFABuilder.make(
        cha,
        options,
        cache,
        customSelector,
        customInterpreter,
        ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.CONSTANT_SPECIFIC);
  }
Пример #2
0
  public static Preset finalize(Preset empty, AnalysisScope scope, IClassHierarchy cha) {
    Preset p = empty;
    p.scfg.cha = cha;

    // The preliminary settings of WALAs AnalysisOptions
    p.options.setReflectionOptions(ReflectionOptions.FULL);
    AndroidEntryPointManager.MANAGER.setInstantiationBehavior(
        new DefaultInstantiationBehavior(cha));
    Util.addDefaultSelectors(p.options, cha);
    Util.addDefaultBypassLogic(p.options, scope, Util.class.getClassLoader(), cha); // ??

    // No changes to the settings of AndroidEntypointManager...
    // p.aem
    // p.entrypointLocatorFlags = EnumSet.of(LocatorFlags.EP_HEURISTIC, LocatorFlags.WITH_SUPER,
    //        LocatorFlags.INCLUDE_CALLBACKS, LocatorFlags.CB_HEURISTIC);
    p.entrypointLocatorFlags =
        EnumSet.of(
            LocatorFlags.EP_HEURISTIC, LocatorFlags.CB_HEURISTIC, LocatorFlags.INCLUDE_CALLBACKS);

    // The following selectors will be injected when Joana generates its new
    // AnalysisOptions
    // TODO: Add ReflectionContext ?
    p.ctxSel = new DefaultContextSelector(p.options, p.scfg.cha);
    p.ctxIpr = new DefaultSSAInterpreter(p.options, p.scfg.cache);
    p.instKeys = new ZeroXInstanceKeys(p.options, p.scfg.cha, p.ctxIpr, ZeroXInstanceKeys.NONE);

    return p;
  }
Пример #3
0
  /**
   * @param options options that govern call graph construction
   * @param cha governing class hierarchy
   * @param scope representation of the analysis scope
   * @param customSelector user-defined context selector, or null if none
   * @param customInterpreter user-defined context interpreter, or null if none
   * @return a 0-CFA Call Graph Builder.
   * @throws IllegalArgumentException if options is null
   *     <p>TODO: move
   */
  public static SSAPropagationCallGraphBuilder makeZeroCFABuilder(
      AnalysisOptions options,
      AnalysisCache cache,
      IClassHierarchy cha,
      AnalysisScope scope,
      ContextSelector customSelector,
      SSAContextInterpreter customInterpreter,
      Collection<InputStream> summariesStreams,
      MethodSummary extraSummary) {

    if (options == null) {
      throw new IllegalArgumentException("options is null");
    }
    Util.addDefaultSelectors(options, cha);
    for (InputStream stream : summariesStreams) {
      addBypassLogic(options, scope, stream, cha, extraSummary);
    }

    return ZeroXCFABuilder.make(
        cha, options, cache, customSelector, customInterpreter, ZeroXInstanceKeys.NONE);
  }
Пример #4
0
  /**
   * Default settings as described below.
   *
   * <p>These settings contain: * a relatively basic setting for the context-sensitivity * no
   * entrypoints have been set(!)
   *
   * @return a bunch of settings
   */
  public static Preset makeDefault(AnalysisScope scope, IClassHierarchy cha) {
    final Preset p = new Preset(scope);

    // The following settings are used by Joana. Based on them new settings of
    // WALAs AnalysisOptions will be generated by Joana.
    applyPrettyCLIOutput(p);
    p.scfg.cache = new AnalysisCache((IRFactory<IMethod>) new DexIRFactory());
    p.scfg.cha = cha;

    // On external stuff. These settings have little effect on the result.
    p.scfg.ext = makeStandardExternalCallCheck();
    p.scfg.accessPath = false; // Setting this to true overrides other settings

    // On debugging
    p.scfg.showTypeNameInValue = false; // on true: Second type-inference often breaks
    p.scfg.debugManyGraphsDotOutput = false;

    p.scfg.immutableNoOut = Main.IMMUTABLE_NO_OUT;
    p.scfg.immutableStubs = Main.IMMUTABLE_STUBS;
    p.scfg.ignoreStaticFields = Main.IGNORE_STATIC_FIELDS;

    // What to considder
    // p.scfg.exceptions = ExceptionAnalysis.ALL_NO_ANALYSIS;
    p.scfg.exceptions = ExceptionAnalysis.IGNORE_ALL;
    p.scfg.staticInitializers =
        StaticInitializationTreatment.SIMPLE; // Do not use ACCURATE: Is defunct

    // Precision
    p.scfg.pts = PointsToPrecision.INSTANCE_BASED;

    p.scfg.prunecg = Main.DEFAULT_PRUNE_CG;
    // p.scfg.fieldPropagation = FieldPropagation.OBJ_GRAPH;   // Do not use OBJ_TREE: Is outdated
    // p.scfg.fieldPropagation = FieldPropagation.OBJ_GRAPH_SIMPLE_PROPAGATION;
    p.scfg.fieldPropagation = FieldPropagation.OBJ_GRAPH_NO_FIELD_MERGE;
    p.scfg.computeInterference = false;

    // The preliminary settings of WALAs AnalysisOptions
    p.options.setReflectionOptions(ReflectionOptions.FULL);
    AndroidEntryPointManager.MANAGER.setInstantiationBehavior(
        new DefaultInstantiationBehavior(cha));
    Util.addDefaultSelectors(p.options, cha);
    Util.addDefaultBypassLogic(p.options, scope, Util.class.getClassLoader(), cha); // ??

    // No changes to the settings of AndroidEntypointManager...
    // p.aem
    // p.entrypointLocatorFlags = EnumSet.of(LocatorFlags.EP_HEURISTIC, LocatorFlags.WITH_SUPER,
    //        LocatorFlags.INCLUDE_CALLBACKS, LocatorFlags.CB_HEURISTIC);
    p.entrypointLocatorFlags =
        EnumSet.of(
            LocatorFlags.EP_HEURISTIC, LocatorFlags.CB_HEURISTIC, LocatorFlags.INCLUDE_CALLBACKS);

    // The following selectors will be injected when Joana generates its new
    // AnalysisOptions
    // TODO: Add ReflectionContext ?
    p.ctxSel = new DefaultContextSelector(p.options, p.scfg.cha);
    p.ctxIpr = new DefaultSSAInterpreter(p.options, p.scfg.cache);
    p.instKeys = new ZeroXInstanceKeys(p.options, p.scfg.cha, p.ctxIpr, ZeroXInstanceKeys.NONE);

    LogLevels.setLevels();

    Preset.aem.setOverrides(AndroidEntryPointManager.DEFAULT_INTENT_OVERRIDES);
    // XXX TEMP:
    Preset.aem.setDoBootSequence(false);

    return p;
  }