mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Misc: Fail by default if query pack can't be found
This commit is contained in:
@@ -3,6 +3,7 @@ import json
|
||||
import csv
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
|
||||
"""
|
||||
This script collects CodeQL queries that are part of code scanning query packs
|
||||
@@ -16,6 +17,15 @@ as long as you run the script from one of the following locations:
|
||||
and 'codeql-go' directories both exist)
|
||||
"""
|
||||
|
||||
parser = argparse.ArgumentParser(__name__)
|
||||
parser.add_argument(
|
||||
"--ignore-missing-query-packs",
|
||||
action="store_true",
|
||||
help="Don't fail if a query pack can't be found",
|
||||
)
|
||||
arguments = parser.parse_args()
|
||||
assert hasattr(arguments, "ignore_missing_query_packs")
|
||||
|
||||
# Define which languages and query packs to consider
|
||||
languages = [ "cpp", "csharp", "go", "java", "javascript", "python"]
|
||||
packs = [ "code-scanning", "security-and-quality", "security-extended" ]
|
||||
@@ -129,11 +139,15 @@ for lang in languages:
|
||||
except Exception as e:
|
||||
# Resolving queries might go wrong if the github/codeql and github/codeql-go repositories are not
|
||||
# on the search path.
|
||||
level = "Warning" if arguments.ignore_missing_query_packs else "Error"
|
||||
print(
|
||||
"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),
|
||||
"%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),
|
||||
file=sys.stderr
|
||||
)
|
||||
continue
|
||||
if arguments.ignore_missing_query_packs:
|
||||
continue
|
||||
else:
|
||||
sys.exit("You can use '--ignore-missing-query-packs' to ignore this error")
|
||||
|
||||
# Investigate metadata for every query by using 'codeql resolve metadata'
|
||||
for queryfile in queries_subp.stdout.strip().split("\n"):
|
||||
|
||||
Reference in New Issue
Block a user