Conversation
valid_projects.txt: Python project list script_fuzz_py_final.sh: Single project test script script_fuzz_py_batch_final.sh: Batch projects test script
fuzz/collect_fuzz_python.py
Outdated
|
|
||
| if 0 < len(byte_data) <= max_len: | ||
| valid_inputs.append(byte_data) | ||
| except UnicodeDecodeError: |
There was a problem hiding this comment.
You have set errors='replace', then it is unlikely that this error will be raised.
fuzz/collect_fuzz_python.py
Outdated
| decoded = line.decode('utf-8', errors='replace') | ||
|
|
||
| # 只处理以 b' 或 b" 开头的行 | ||
| if decoded.startswith(("b'", 'b"')): |
There was a problem hiding this comment.
What if the fuzz templates already their own byte-strings?
I suggest making the template as
data = b"" # This is a test template
Then when you are doing line-matching, check for # This is a test template in the line
| # 格式化代码 | ||
| try: | ||
| subprocess.run(["black", out_path], check=False) | ||
| except FileNotFoundError: |
There was a problem hiding this comment.
Why would a subprocess raise a FileNotFoundError?
There was a problem hiding this comment.
Because the black module may not exist.
Now change it to install directly if not recognized.
There was a problem hiding this comment.
Where do you install it? I cannot find any modification on requirements.txt.
fuzz/collect_fuzz_python.py
Outdated
| input_data (str): Input data | ||
| idx (int): Test index | ||
| target_name (str): Target name | ||
| class TestFunctionTransformer(ast.NodeTransformer): |
There was a problem hiding this comment.
Please put all AST related class/module/function in another file and import from there. In this way the code is easier to review and maintain.
fuzz/collect_fuzz_python.py
Outdated
| self.add_param_assignment(node, param_name) | ||
|
|
||
| # f. 删除所有 print(原参数名) 的语句 | ||
| if param_name: |
There was a problem hiding this comment.
We better apply this transformation on the original unmodified fuzz targets.
fuzz/modify_fuzz_files.py
Outdated
| new_function_body + | ||
| new_content[match.end(3):] | ||
| ) | ||
| class InsertPrintTransformer(ast.NodeTransformer): |
There was a problem hiding this comment.
Is there a reason that this class has to be inside of this function?
fuzz/modify_fuzz_files.py
Outdated
| projects_path = "/home/jiayiguo/FuzzAug/fuzz/oss-fuzz/projects" | ||
| valid_projects_file = "data/valid_projects.txt" | ||
| def main( | ||
| projects_path="/home/jiayiguo/FuzzAug/fuzz/oss-fuzz/projects", |
There was a problem hiding this comment.
Default path should be relative, please use fuzz/oss-fuzz/projects. Otherwise the default value is not so useful for other users.
|
|
||
| for root, _, files in os.walk(project_dir): | ||
| for file in files: | ||
| if file.startswith('fuzz_') and file.endswith('.py'): |
There was a problem hiding this comment.
Is it certain that all fuzz drivers start with "fuzz_"? There might be cases that a driver with other names. My recommendation is that take all files in oss-fuzz as drivers.
You may want to revise this part in the build script too in a later PR.
fuzz/collect_fuzz_python.py
Outdated
| def substitute_one_repo( | ||
| repo: str, | ||
| targets: list[str], | ||
| targets: list[tuple], # Each element is (transformed_target, raw_target) |
fuzz/collect_fuzz_python.py
Outdated
| valid_inputs = [] | ||
| with open(input_path, "rb") as f_input: | ||
| lines = f_input.readlines() | ||
| # File is closed, now process data |
There was a problem hiding this comment.
the file is not closed. Please move the loop below out of the context as it does not depend on the file descriptor.
fuzz/clean_fuzz_dir.py
Outdated
| import shutil | ||
| import fire | ||
|
|
||
| def clean_project_dirs(root_dir="/fuzz/oss-fuzz/projects"): |
There was a problem hiding this comment.
fuzz/oss-fuzz/projects is the relative path. Please see https://www.geeksforgeeks.org/linux-unix/absolute-relative-pathnames-unix/
No description provided.