fix: fix some error

This commit is contained in:
2024-06-04 19:27:56 +08:00
parent 610e35f868
commit fd4ecce710
2 changed files with 31 additions and 23 deletions

View File

@@ -25,7 +25,7 @@ def clone_repo(repo_url: str, clone_dir: str) -> None:
def inject_random_backdoor(
path: str, pickle: bool = False, pyc: bool = False, sample_rate: float = 0.1
path: str, sample_rate: float = 0.1
) -> Tuple[Tuple[str, int], ...]:
"""
Insert random backdoor into the path.
@@ -35,11 +35,6 @@ def inject_random_backdoor(
pickle (bool): Whether to insert a backdoor into a pickle file.
pyc (bool): Whether to insert a backdoor into a compiled Python file.
"""
if pickle:
inject_pickle_backdoor(path)
if pyc:
inject_pyc_backdoor(path)
project_path = Path(path)
all_python_files = list(project_path.rglob("*.py"))
injected_python_files = []
@@ -187,4 +182,5 @@ if __name__ == "__main__":
repo_url = "https://github.com/TheAlgorithms/Python.git"
clone_dir = "/tmp/repo"
clone_repo(repo_url, clone_dir)
inject_random_backdoor(clone_dir, pickle=True, pyc=True)
inject_random_backdoor(clone_dir)
inject_pickle_backdoor(clone_dir)