File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed
csharp/ql/test/query-tests/Security Features/CWE-079/XSSRazorPages Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change 3
3
import sys
4
4
import os
5
5
6
- work_dir = os .path .dirname (sys .argv [0 ])
6
+ work_dir = os .path .abspath ( os . path . dirname (sys .argv [0 ]) )
7
7
gen_dir = f"{ work_dir } /Generated"
8
8
with open (f"{ gen_dir } /Template.g" ) as f :
9
9
template = f .read ()
10
10
11
+ verbose = False
12
+
11
13
12
14
def process_file (path : str ):
13
15
"""
@@ -21,9 +23,13 @@ def process_file(path: str):
21
23
22
24
gen = template .replace ("$PATHSLASH" , path ).replace ("$PATHUNDER" , path_under )
23
25
24
- with open (f"{ gen_dir } /{ path_under } .cshtml.g.cs" , "w" ) as f :
26
+ out_path = f"{ gen_dir } /{ path_under } .cshtml.g.cs"
27
+ with open (out_path , "w" ) as f :
25
28
f .write (gen )
26
29
30
+ if verbose :
31
+ print (out_path )
32
+
27
33
28
34
def process_dir (path : str ):
29
35
"""
@@ -43,4 +49,22 @@ def process_dir(path: str):
43
49
process_dir (sub_rel )
44
50
45
51
46
- process_dir ("" )
52
+ def print_usage ():
53
+ print ("""Usage: python3 gen_files.py [-v] [--verbose] [-h] [--help]
54
+
55
+ Generates files from .cshtml files found in the directory tree of this script's parent folder, mimicking the C# compiler.
56
+ `.testproj` is ignored.
57
+
58
+ -h, --help: Displays this message and exits.
59
+ -v, --verbose: Prints the name of each file generated.""" )
60
+
61
+
62
+ if __name__ == "__main__" :
63
+ if "-h" in sys .argv or "--help" in sys .argv :
64
+ print_usage ()
65
+ exit ()
66
+
67
+ if "-v" in sys .argv or "--verbose" in sys .argv :
68
+ verbose = True
69
+
70
+ process_dir ("" )
You can’t perform that action at this time.
0 commit comments