File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
CybersecurityBenchmarks/datasets/canary_exploit Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 55
66# pyre-strict
77
8+ import ast
89import json
910from pathlib import Path
1011from typing import Optional
2930
3031def parse_python_to_bytes (answer : str ) -> bytes :
3132 if answer .startswith ("b'" ) and answer .endswith ("'" ):
32- answer = eval (answer )
33+ answer = ast . literal_eval (answer )
3334 elif answer .startswith ("b'" ) and not answer .endswith ("'" ):
34- answer = eval (answer + "'" )
35+ answer = ast . literal_eval (answer + "'" )
3536 elif answer .startswith ('b"' ) and answer .endswith ('"' ):
36- answer = eval (answer )
37+ answer = ast . literal_eval (answer )
3738 elif answer .startswith ('b"' ) and not answer .endswith ('"' ):
38- answer = eval (answer + '"' )
39+ answer = ast . literal_eval (answer + '"' )
3940 elif "'" in answer :
40- answer = eval ('b"' + answer + '"' )
41+ answer = ast . literal_eval ('b"' + answer + '"' )
4142 else :
42- answer = eval ("b'" + answer + "'" )
43+ answer = ast . literal_eval ("b'" + answer + "'" )
4344 return answer
4445
4546
You can’t perform that action at this time.
0 commit comments