Пример #1
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;
  }
Пример #2
0
  /** A Preset without cha, scope and AnalysisOptions. */
  public static Preset makeEmpty() {
    final Preset p = new Preset(null);

    // 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());

    // 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;

    // 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);

    Preset.aem.setOverrides(AndroidEntryPointManager.DEFAULT_INTENT_OVERRIDES);
    Preset.aem.setDoBootSequence(false);

    return p;
  }
Пример #3
0
  /**
   * Make the analysis as cheap as possible.
   *
   * <p>These settings barely respect context. They are intended for testing purposes. Remember to
   * call {@link #regenerate(Preset)} when you alter these settings outside.
   *
   * @param p preset to alter
   * @return altered preset
   */
  public static Preset applyFast(final Preset p) {
    // Let the model use a single global instance for each type..
    p.scfg.fieldPropagation = FieldPropagation.FLAT;
    p.scfg.pts = PointsToPrecision.TYPE_BASED;

    Preset.aem.setDoBootSequence(false);
    // The setting of entrypointLocatorFlags causes missed entrypoints!
    p.entrypointLocatorFlags = EnumSet.noneOf(LocatorFlags.class);

    // Create a dummy Context Selector and interpreter...
    p.options.setReflectionOptions(ReflectionOptions.NONE);
    p.ctxSel = ReflectionContextSelector.createReflectionContextSelector(p.options);
    p.ctxIpr =
        ReflectionContextInterpreter.createReflectionContextInterpreter(
            p.scfg.cha, p.options, p.scfg.cache);

    return p;
  }
Пример #4
0
  /**
   * Enable optional computations in a preset.
   *
   * @param p Preset to alter
   * @return altered Preset
   * @todo TODO: Make the full-Preset object-sensitive.
   */
  public static Preset applyFull(final Preset p) {
    p.scfg.exceptions = ExceptionAnalysis.IGNORE_ALL;
    // p.scfg.exceptions = ExceptionAnalysis.INTERPROC;
    p.scfg.staticInitializers =
        StaticInitializationTreatment.SIMPLE; // Do not use ACCURATE: Is defunct
    p.scfg.pts = PointsToPrecision.OBJECT_SENSITIVE; // TODO: Enable in "full"

    // Some of the following settings will match the dafults of AndroidEntypointManager.
    // However they are repeated here to be shure.
    Preset.aem.setDoBootSequence(false);
    p.entrypointLocatorFlags = EnumSet.allOf(LocatorFlags.class);

    return p;
  }
Пример #5
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;
  }