forked from tuhh-softsec/vul4j
-
Notifications
You must be signed in to change notification settings - Fork 2
/
format_updater.py
50 lines (47 loc) · 1.49 KB
/
format_updater.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
import json
x = open("meta-data.json")
contents = json.load(x)
x.close()
for entry in contents:
entry["language"] = "java"
entry["src"] = {
"root_abspath": "/experiment/vul4j/{subject}/{bug_id}/src".format(
subject=entry["subject"], bug_id=entry["bug_id"]
),
"entrypoint": {
# "file": entry["source_file"]
# if entry.get("language", "_") != "java"
# else (
# (
# "src/main/java/"
# if "src/main/java/" not in entry["source_file"]
# else ""
# )
# + entry["source_file"][:-5].replace(".", "/")
# + ".java"
# ),
# "function": "main",
},
}
if len(entry["line_numbers"]) != 0:
entry["localization"] = [
{
"source_file": entry["source_file"]
if entry.get("language", "_") != "java"
else (
(
"src/main/java/"
if "src/main/java/" not in entry["source_file"]
else ""
)
+ entry["source_file"].replace(".", "/")
+ ".java"
),
"line_numbers": entry["line_numbers"],
"score": 1,
}
]
entry["output_dir_abspath"] = "/output"
y = open("meta-data.candidate.json", "w")
json.dump(contents, y)
y.close()