1212are on the PATH. It'll try to automatically set the CodeQL search path correctly,
1313as long as you run the script from one of the following locations:
1414 - anywhere from within a clone of the CodeQL Git repo
15- - from the parent directory of a clone of the CodeQL Git repo (assuming 'codeql'
15+ - from the parent directory of a clone of the CodeQL Git repo (assuming 'codeql'
1616 and 'codeql-go' directories both exist)
1717"""
1818
@@ -27,14 +27,14 @@ def prefix_repo_nwo(filename):
2727 This function relies on `git` being available.
2828
2929 For example:
30- /home/alice/git/ql/java/ql/src/MyQuery.ql
30+ /home/alice/git/ql/java/ql/src/MyQuery.ql
3131 becomes:
3232 github/codeql/java/ql/src/MyQuery.ql
33-
33+
3434 If we can't detect a known NWO (e.g. github/codeql, github/codeql-go), the
3535 path will be truncated to the root of the git repo:
3636 ql/java/ql/src/MyQuery.ql
37-
37+
3838 If the filename is not part of a Git repo, the return value is the
3939 same as the input value: the whole path.
4040 """
@@ -45,9 +45,9 @@ def prefix_repo_nwo(filename):
4545 except :
4646 # Not a Git repo
4747 return filename
48-
48+
4949 git_toplevel_dir = git_toplevel_dir_subp .stdout .strip ()
50-
50+
5151 # Detect 'github/codeql' and 'github/codeql-go' repositories by checking the remote (it's a bit
5252 # of a hack but will work in most cases, as long as the remotes have 'codeql' and 'codeql-go'
5353 # in the URL
@@ -100,7 +100,7 @@ def subprocess_run(cmd):
100100#
101101# (and assumes the codeql-go repo is in a similar location)
102102codeql_search_path = "./codeql:./codeql-go:." # will be extended further down
103-
103+
104104# Extend CodeQL search path by detecting root of the current Git repo (if any). This means that you
105105# can run this script from any location within the CodeQL git repository.
106106try :
@@ -116,7 +116,7 @@ def subprocess_run(cmd):
116116# Create CSV writer and write CSV header to stdout
117117csvwriter = csv .writer (sys .stdout )
118118csvwriter .writerow ([
119- "Query filename" , "Suite" , "Query name" , "Query ID" ,
119+ "Query filename" , "Suite" , "Query name" , "Query ID" ,
120120 "Kind" , "Severity" , "Precision" , "Tags"
121121])
122122
@@ -132,26 +132,25 @@ def subprocess_run(cmd):
132132 print (
133133 "Warning: couldn't find query pack '%s' for language '%s'. Do you have the right repositories in the right places (search path: '%s')?" % (pack , lang , codeql_search_path ),
134134 file = sys .stderr
135- )
135+ )
136136 continue
137137
138138 # Investigate metadata for every query by using 'codeql resolve metadata'
139139 for queryfile in queries_subp .stdout .strip ().split ("\n " ):
140140 query_metadata_json = subprocess_run (["codeql" ,"resolve" ,"metadata" ,queryfile ]).stdout .strip ()
141-
141+
142142 # Turn an absolute path to a query file into an nwo-prefixed path (e.g. github/codeql/java/ql/src/....)
143143 queryfile_nwo = prefix_repo_nwo (queryfile )
144144
145145 meta = json .loads (query_metadata_json )
146146
147147 # Python's CSV writer will automatically quote fields if necessary
148148 csvwriter .writerow ([
149- queryfile_nwo , pack ,
149+ queryfile_nwo , pack ,
150150 get_query_metadata ('name' , meta , queryfile_nwo ),
151151 get_query_metadata ('id' , meta , queryfile_nwo ),
152152 get_query_metadata ('kind' , meta , queryfile_nwo ),
153153 get_query_metadata ('problem.severity' , meta , queryfile_nwo ),
154154 get_query_metadata ('precision' , meta , queryfile_nwo ),
155155 get_query_metadata ('tags' , meta , queryfile_nwo )
156156 ])
157-
0 commit comments