Example #1
0
    def test_filters_non_whitelisted(self):
        project = create_project("-project-")
        version = create_version("-version-", misuses=[], project=project)
        create_misuse("-id-", version=version)
        uut = CollectMisusesTask()

        actual = uut.run(
            version, DataEntityLists(["-project-.-version-.-other-id-"], []))

        assert_equals([], actual)
Example #2
0
    def test_whitelisted_version(self):
        misuse = create_misuse("-id-")
        project = create_project("-project-")
        version = create_version("-version-",
                                 misuses=[misuse],
                                 project=project)
        uut = CollectMisusesTask()

        actual = uut.run(version, DataEntityLists(["-project-.-version-"], []))

        assert_equals([misuse], actual)
Example #3
0
    def test_finds_all_misuses(self):
        m1 = create_misuse("-m1-")
        m2 = create_misuse("-m2-")
        project = create_project("-project-")
        version = create_version("-version-",
                                 misuses=[m1, m2],
                                 project=project)
        uut = CollectMisusesTask()

        actual = uut.run(version, DataEntityLists([], []))

        assert_equals([m1, m2], actual)
Example #4
0
 def tasks(self, config) -> List:
     collect_projects = CollectProjectsTask(config.data_path)
     collect_versions = CollectVersionsTask(config.development_mode)
     collect_misuses = CollectMisusesTask()
     calculator = stats.get_calculator(config.script)
     return [
         collect_projects, collect_versions, collect_misuses, calculator
     ]
Example #5
0
 def tasks(self, config) -> List:
     collect_misuses = CollectMisusesTask()
     publish = PublishMetadataTask(config.checkouts_path,
                                   config.review_site_url,
                                   config.review_site_user,
                                   config.review_site_password)
     return CheckoutTaskConfiguration().tasks(config) + [
         collect_misuses, publish
     ]
Example #6
0
 def tasks(self, config) -> List:
     collect_misuses = CollectMisusesTask()
     filter_ = PotentialHitsFilterTask()
     publish = PublishFindingsTask(RunBenchmarkExperiment.ID,
                                   config.compiles_path,
                                   config.review_site_url,
                                   config.review_site_user,
                                   config.review_site_password)
     return RunBenchmarkExperiment().tasks(config) + [
         collect_misuses, filter_, publish
     ]
Example #7
0
 def tasks(self, config) -> List:
     compile_version = CompileVersionTask(config.compiles_path,
                                          config.run_timestamp,
                                          config.force_compile,
                                          config.use_tmp_wrkdir)
     collect_misuses = CollectMisusesTask()
     compile_misuse = CompileMisuseTask(config.compiles_path,
                                        config.run_timestamp,
                                        config.force_compile)
     return CheckoutTaskConfiguration().tasks(config) + [
         compile_version, collect_misuses, compile_misuse
     ]
Example #8
0
 def tasks(self, config) -> List:
     collect_projects = CollectProjectsTask(config.data_path)
     collect_versions = CollectVersionsTask(config.development_mode)
     collect_misuses = CollectMisusesTask()
     project_check = ProjectCheckTask()
     version_check = VersionCheckTask()
     misuse_check = MisuseCheckTask(
         get_available_datasets(config.datasets_file_path),
         config.checkouts_path, config.data_path)
     return [
         collect_projects, project_check, collect_versions, version_check,
         collect_misuses, misuse_check
     ]
Example #9
0
 def tasks(self, config) -> List:
     collect_projects = CollectProjectsTask(config.data_path)
     collect_versions = CollectVersionsTask(config.development_mode)
     collect_misuses = CollectMisusesTask()
     project_info = ProjectInfoTask(config.checkouts_path,
                                    config.compiles_path)
     version_info = VersionInfoTask(config.checkouts_path,
                                    config.compiles_path)
     misuse_info = MisuseInfoTask(config.checkouts_path,
                                  config.compiles_path)
     return [
         collect_projects, project_info, collect_versions, version_info,
         collect_misuses, misuse_info
     ]
Example #10
0
 def tasks(self, config) -> List:
     compile_version = CompileVersionTask(config.compiles_path,
                                          config.run_timestamp,
                                          config.force_compile,
                                          config.use_tmp_wrkdir)
     collect_misuses = CollectMisusesTask()
     filter_misuses_without_correct_usages = FilterMisusesWithoutCorrectUsagesTask(
     )
     compile_misuse = CompileMisuseTask(config.compiles_path,
                                        config.run_timestamp,
                                        config.force_compile)
     load_detector = LoadDetectorTask(config.detectors_path,
                                      config.detector,
                                      config.requested_release,
                                      config.java_options)
     detect = DetectProvidedCorrectUsagesTask(config.findings_path,
                                              config.force_detect,
                                              config.timeout,
                                              config.run_timestamp)
     return [load_detector] + CheckoutTaskConfiguration().tasks(config) + [
         compile_version, collect_misuses,
         filter_misuses_without_correct_usages, compile_misuse, detect
     ]
Example #11
0
_INDEX_PATH = os.path.join(__MUBENCH_ROOT_PATH, "checkouts-xp", "index.csv")


class PrintIndexTask:
    def run(self, project: Project, version: ProjectVersion, misuse: Misuse):
        print("{}\t{}\t{}\t{}\t{}\t{}\t{}".format(
            project.id, version.version_id, misuse.misuse_id,
            ':'.join(version.source_dirs), misuse.location.file,
            misuse.location.method, "\t".join(misuse.apis)),
              file=open(_INDEX_PATH, "a"))


datasets = sys.argv[1:]

white_list = []
for dataset in datasets:
    white_list.extend(get_white_list(__MUBENCH_DATASETS_FILE, dataset.lower()))
initial_parameters = [DataEntityLists(white_list, [])]

runner = TaskRunner([
    CollectProjectsTask(__MUBENCH_DATA_PATH),
    CollectVersionsTask(False),
    CollectMisusesTask(),
    PrintIndexTask()
])

if os.path.exists(_INDEX_PATH):
    os.remove(_INDEX_PATH)

runner.run(*initial_parameters)