Exemple #1
0
  private static void computeVariants(
      final MoJo mojo, final IMethod im, final MethodInfo nfo, final String outDir)
      throws IllegalArgumentException, FileNotFoundException, CancelException, PDGFormatException,
          WalaException {
    final boolean ignoreExceptions = true;
    final Aliasing minMax = mojo.computeMinMaxAliasing(im);

    computeAliasVariants(mojo, minMax, im, ignoreExceptions, outDir + File.separator + "minmax");

    if (nfo.hasIFCStmts()) {
      int num = 0;
      for (IFCStmt ifc : nfo.getIFCStmts()) {
        num++;

        if (ifc.hasAliasStmt()) {
          try {
            final Aliasing stmtAlias = mojo.computeMayAliasGraphs(nfo, ifc);

            computeAliasVariants(
                mojo, stmtAlias, im, ignoreExceptions, outDir + File.separator + "ifc" + num);
          } catch (AliasGraphException exc) {
            System.err.println("Could not compute alias graph for " + nfo);
            System.err.println(exc.getMessage());
            exc.printStackTrace();
          } catch (NoSuchElementException exc) {
            System.err.println("Could not compute alias graph for " + nfo);
            System.err.println(exc.getMessage());
            exc.printStackTrace();
          } catch (FlowAstException exc) {
            System.err.println("Could not compute alias graph for " + nfo);
            System.err.println(exc.getMessage());
            exc.printStackTrace();
          }
        }
      }
    }

    // TODO do pair method param alias
  }
Exemple #2
0
  /**
   * @param args
   * @throws CancelException
   * @throws UnsoundGraphException
   * @throws IOException
   * @throws WalaException
   * @throws PDGFormatException
   * @throws IllegalArgumentException
   */
  public static void main(String[] args)
      throws IOException, UnsoundGraphException, CancelException, IllegalArgumentException,
          PDGFormatException, WalaException {
    // check for ifc annotations

    System.out.print("Parsing source files for ifc annotations... ");
    List<ClassInfo> clsInfos = MoJo.parseSourceFiles("../joana.wala.modular.testdata/src");
    System.out.println("done.");
    System.out.print("Checking for syntactic errors... ");
    final int errors = MoJo.prepareFlowLessStmts(clsInfos);
    if (errors > 0) {
      System.out.print("(" + errors + " errors) ");
    }
    System.out.println("done.");

    // prepare base sdg

    MethodListCheck mlc = new MethodListCheck(null, "./out/", /* do debug output */ false);

    for (ClassInfo cls : clsInfos) {
      for (MethodInfo m : cls.getMethods()) {
        if (m.hasIFCStmts()) {
          // mark as external call targets
          //					System.err.println(m.toString());
          mlc.addMethod(m);
        }
      }
    }

    //		mlc.addMethod("module.Module.encrypt(II)I");
    //		mlc.addMethod("module.Module.encrypt(Lmodule/Module$Message;I)Lmodule/Module$Message;");

    Config cfg =
        new Config(
            "program",
            "program.Program.main([Ljava/lang/String;)V",
            "../joana.wala.modular.testdata/dist/mojo-test-program.jar",
            PointsToPrecision.CONTEXT_SENSITIVE,
            ExceptionAnalysis.INTRAPROC,
            false,
            Main.STD_EXCLUSION_REG_EXP,
            "../../contrib/lib/stubs/natives_empty.xml",
            "../../contrib/lib/stubs/jSDG-stubs-jre1.4.jar",
            mlc,
            "./out/",
            FieldPropagation.FLAT);

    Main.run(System.out, cfg);

    // precompute library methods
    final String binlib1 = "../joana.wala.modular.testdata/dist/mojo-test-modules1.jar";
    runComputeModule(binlib1, cfg, "./out/lib_module1");

    final String binlib2 = "../joana.wala.modular.testdata/dist/mojo-test-modules2.jar";
    runComputeModule(binlib2, cfg, "./out/lib_module2");

    // merge precomputed dependency graphs
    final ModuleCFG mainModule =
        new ModuleCFG(
            "program.Program.main([Ljava/lang/String;)V",
            "../joana.wala.modular.testdata/dist/mojo-test-program.jar");
    final ModuleCFG[] otherModules1 =
        new ModuleCFG[] {
          new ModuleCFG("module1", "../joana.wala.modular.testdata/dist/mojo-test-modules1.jar")
        };
    MergeModules.runMergeModules("merge_modules1", "./out/", mainModule, otherModules1, mlc);

    final ModuleCFG[] otherModules2 =
        new ModuleCFG[] {
          new ModuleCFG("module2", "../joana.wala.modular.testdata/dist/mojo-test-modules2.jar")
        };
    MergeModules.runMergeModules("merge_modules2", "./out/", mainModule, otherModules2, mlc);
  }