Skip to content

Commit

Permalink
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions data_prep/parse_training_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
import json
import logging
import os
import re
import sys
from concurrent.futures import ThreadPoolExecutor
from typing import Any, Dict, List

from google.cloud import storage

STORAGE_CLIENT = storage.Client()
FUZZ_TARGET_FIXING_DIR_PATTERN = r'\d+-F\d+'


class Benchmark:
Expand All @@ -53,6 +55,14 @@ def prompt(self) -> str:
with open(prompt_path) as prompt_file:
return prompt_file.read()

def _get_code_fixing_dirs(self, fixed_target_dir):
"""Gets the directories for fixing fuzz targets."""
return [
item for item in os.listdir(fixed_target_dir)
if (os.path.isdir(os.path.join(fixed_target_dir, item)) and
re.match(FUZZ_TARGET_FIXING_DIR_PATTERN, item))
]

@property
def targets(self) -> Dict[str, List[str]]:
"""Returns the generated targets of a benchmark in a directory, mapping
Expand All @@ -75,10 +85,7 @@ def targets(self) -> Dict[str, List[str]]:
if not os.path.isdir(fixed_target_dir):
logging.warning('Fixed target dir does not exist: %s', fixed_target_dir)
return {}
fix_dirs = [
instance for instance in os.listdir(fixed_target_dir)
if os.path.isdir(os.path.join(fixed_target_dir, instance))
]
fix_dirs = self._get_code_fixing_dirs(fixed_target_dir)
for fix_dir in sorted(fix_dirs):
instance, _ = fix_dir.split('-F')
code_path = [
Expand Down

0 comments on commit f31cf2b

Please sign in to comment.