Add quick check to verify that input is serif

An occasional output from LGTM is
    {"code":404,"error":"The specified analysis could not be found"}

With this patch, the csv output is now
    "ERROR","invalid json contents %s","some-file.json"

and the plain text output becomes
    ERROR: invalid json contents in some-file.json
This commit is contained in:
Michael Hohn
2021-12-06 14:24:08 -08:00
committed by =Michael Hohn
parent 120e673424
commit 92d904ee10
2 changed files with 14 additions and 0 deletions

View File

@@ -18,6 +18,12 @@ class NoFile:
whole file is to be used.
"""
def is_sarif_struct(struct):
"""A quick check to verify that `struct` is in fact a SARIF tree.
"""
return type(struct) == dict and "$schema" in struct and \
"sarif" in struct["$schema"] and "version" in struct
def get_csv_writer():
""" Set up and return the default csv writer on stdout.
"""