-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprocess_repos.py
52 lines (40 loc) · 1.66 KB
/
process_repos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import json
import shutil
def process_first_repo(n=1):
# Read all lines
with open("repos.txt", "r") as file:
lines = file.readlines()
if not lines:
return False
# Process n repos or all repos if n > len(lines)
repos_to_process = min(n, len(lines))
for i in range(repos_to_process):
line = lines[i].strip()
language, repo_url = line.split(" ")
# Create directory if it doesn't exist
owner = repo_url.split("/")[-2]
repo_name = repo_url.split("/")[-1]
config_dir = os.path.join(language, owner, repo_name)
os.makedirs(config_dir, exist_ok=True)
# Create config.json
config = {
"repo_url": repo_url,
"analyzer_args": "--deep-analysis",
"agent_provider": "google",
"agent_model": "gemini-2.0-pro-exp",
"agent_temperature": 0,
"agent_prompt_types": ["sec-design", "threat-modeling", "attack-surface", "attack-tree", "mitigations"],
}
# Write config.json
config_path = os.path.join(config_dir, "config.json")
with open(config_path, "w") as f:
json.dump(config, f, indent=4)
# Remove processed lines and write back remaining lines
with open("repos.txt", "w") as file:
file.writelines(lines[repos_to_process:])
return True
if __name__ == "__main__":
import sys
n = int(sys.argv[1]) if len(sys.argv) > 1 else 1 # Get n from command line args
process_first_repo(n)