import os, servlet_def, os.path, sys classify_script = os.path.join(os.path.dirname(sys.argv[0]), "classify_results.py") eval_dir = os.path.dirname(sys.argv[1]) serv_def = servlet_def.load(sys.argv[1]) args = [ "python", classify_script ] + sys.argv[2:] + [ os.path.join(eval_dir, "reports.yml"), os.path.join(eval_dir, "classify.yml"), os.path.join(eval_dir, "sites.yml") ] + serv_def.get("app_source_dir", []) os.execvp("python", args)
def get_legato_parameters(root_project_dir, servlet_file): servlet_spec = servlet_def.load(servlet_file) util_dir = os.path.join(root_project_dir, "util") eval_dir = os.path.dirname(servlet_file) propagation_model = [ os.path.join(root_project_dir, "model/jcl-common.yml"), os.path.join(root_project_dir, "model/collections.yml"), os.path.join(root_project_dir, "model/io.yml") ] prop_file = os.path.join(eval_dir, "propagation.yml") resource_file = os.path.join(eval_dir, "resources.yml") if os.path.exists(prop_file): propagation_model.append(prop_file) if not os.path.exists(resource_file): print "Need at least resources.yml" return None subprocess.check_call(["python", os.path.join(util_dir, "compile_servlet_model.py"), servlet_file]) soot_class_path = ":".join([ os.path.join(root_project_dir, "build/build-deps/javax.servlet-api-3.0.1.jar"), os.path.join(root_project_dir, "build/build-deps/jsp-api-2.0.jar"), os.path.join(root_project_dir, "simple-servlet/build/libs/simple-servlet.jar"), os.path.join(eval_dir, "generated"), legato_env.TOMCAT_PATH ]) if "jsp_dir" in servlet_spec: soot_class_path += ":" + servlet_spec["jsp_dir"] if "struts" in servlet_spec: soot_class_path += ":" + servlet_spec["struts"]["generated_dir"] soot_class_path += ":" + servlet_spec["struts"]["struts_jar"] if "extra_libs" in servlet_spec: el_sect = servlet_spec["extra_libs"] soot_class_path += ":" + ":".join(el_sect["jars"]) soot_class_path += ":" + servlet_spec["app_classes"] main_class = servlet_spec["output_package"] + ".PseudoMain" resource_string = "hybrid:" + resource_file analysis_class_path = ":".join([ os.path.join(root_project_dir, "build/classes/eclipse"), os.path.join(root_project_dir, "build/build-deps/*") ]) # not how you should do this routing_file = subprocess.check_output(['find', os.path.join(eval_dir, 'generated'), '-name', 'routing.yml']).split()[0] include_exclude = subprocess.check_output(['find', os.path.join(eval_dir, 'generated'), '-name', 'include.list']).split()[0] ignore_file = os.path.join(eval_dir, "ignore.list") if not os.path.exists(ignore_file): ignore_file = None return LegatoParams(soot_class_path, analysis_class_path, resource_string, ":".join(propagation_model), routing_file, include_exclude, main_class, resource_file, eval_dir, ignore_file, servlet_spec.get("use_cha", False))
os.path.join(root_project_dir, "build/build-deps/jsp-api-2.0.jar"), os.path.join(root_project_dir, "simple-servlet/build/libs/simple-servlet.jar"), "{0}/jasper.jar".format(legato_env.TOMCAT_PATH) ]) base_dir = os.path.dirname(sys.argv[1]) output_dir = os.path.join(base_dir, "generated") cache_file = os.path.join(output_dir, "_digest") if not os.path.exists(output_dir): os.makedirs(output_dir) servlet_def = sd_load.load(sys.argv[1]) # This has to be here because we may instrument the application classes # (to make unspecified public) if "struts" in servlet_def: struts_sec = servlet_def["struts"] class_path += ":" + struts_sec["generated_dir"] + ":" + struts_sec[ "struts_jar"] class_path += ":" + servlet_def["app_classes"] if "jsp_dir" in servlet_def: class_path += ":" + servlet_def["jsp_dir"] if "extra_libs" in servlet_def: el_section = servlet_def["extra_libs"]