|
3 | 3 | import csv
|
4 | 4 | import sys
|
5 | 5 | import os
|
| 6 | +import argparse |
6 | 7 |
|
7 | 8 | """
|
8 | 9 | This script collects CodeQL queries that are part of code scanning query packs
|
|
16 | 17 | and 'codeql-go' directories both exist)
|
17 | 18 | """
|
18 | 19 |
|
| 20 | +parser = argparse.ArgumentParser(__name__) |
| 21 | +parser.add_argument( |
| 22 | + "--ignore-missing-query-packs", |
| 23 | + action="store_true", |
| 24 | + help="Don't fail if a query pack can't be found", |
| 25 | +) |
| 26 | +arguments = parser.parse_args() |
| 27 | +assert hasattr(arguments, "ignore_missing_query_packs") |
| 28 | + |
19 | 29 | # Define which languages and query packs to consider
|
20 | 30 | languages = [ "cpp", "csharp", "go", "java", "javascript", "python"]
|
21 | 31 | packs = [ "code-scanning", "security-and-quality", "security-extended" ]
|
@@ -129,11 +139,15 @@ def subprocess_run(cmd):
|
129 | 139 | except Exception as e:
|
130 | 140 | # Resolving queries might go wrong if the github/codeql and github/codeql-go repositories are not
|
131 | 141 | # on the search path.
|
| 142 | + level = "Warning" if arguments.ignore_missing_query_packs else "Error" |
132 | 143 | print(
|
133 |
| - "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), |
| 144 | + "%s: couldn't find query pack '%s' for language '%s'. Do you have the right repositories in the right places (search path: '%s')?" % (level, pack, lang, codeql_search_path), |
134 | 145 | file=sys.stderr
|
135 | 146 | )
|
136 |
| - continue |
| 147 | + if arguments.ignore_missing_query_packs: |
| 148 | + continue |
| 149 | + else: |
| 150 | + sys.exit("You can use '--ignore-missing-query-packs' to ignore this error") |
137 | 151 |
|
138 | 152 | # Investigate metadata for every query by using 'codeql resolve metadata'
|
139 | 153 | for queryfile in queries_subp.stdout.strip().split("\n"):
|
|
0 commit comments