Add capability to read sourceLanguage if exists in CLI sarif

otherwise dummy val
previously assumed never present in CLI sarif
This commit is contained in:
Kristen Newbury
2023-01-05 12:50:54 -05:00
parent d602efd3f0
commit fc2c6bac99
3 changed files with 9 additions and 10 deletions

View File

@@ -101,21 +101,14 @@ def joins_for_projects(basetables, external_info):
else:
repo_url = "unknown"
project_name = pd.NA
if 'semmle.sourceLanguage' in b.project:
srcLang = b.project['semmle.sourceLanguage'][0]
allLang = ",".join(list(b.project['semmle.sourceLanguage']))
else:
srcLang = "unknown"
allLang = "unknown"
res = pd.DataFrame(data={
"id" : e.project_id,
"project_name" : project_name,
"creation_date" : pd.Timestamp(0.0, unit='s'), # TODO: external info
"repo_url" : repo_url,
"primary_language" : srcLang, # TODO: external info if CLI sarif
"languages_analyzed" : allLang # TODO: external info if CLI sarif
"primary_language" : b.project['semmle.sourceLanguage'][0],
"languages_analyzed" : ",".join(list(b.project['semmle.sourceLanguage']))
}, index=[0])
# Force all column types to ensure appropriate formatting

View File

@@ -235,6 +235,8 @@ dummy_relatedLocations_entry = [
dummy_message_entry = {'text': 'scli-dyys dummy value'}
dummy_sourceLanguage = 'unknown'
def fillsig_dict(args, elem, context):
""" Fill in the missing fields in dictionary signatures.
"""
@@ -286,6 +288,10 @@ def fillsig_dict(args, elem, context):
if 'level' in elem.keys():
full_elem['enabled'] = elem.get('enabled', True)
if 'semmle.formatSpecifier' in elem.keys():
# Ensure semmle.sourceLanguage is present at least in dummy form
full_elem['semmle.sourceLanguage'] = elem.get('semmle.sourceLanguage', dummy_sourceLanguage)
if 'versionControlProvenance' in elem.keys():
# Ensure newlineSequences is present when versionControlProvenance is
full_elem['newlineSequences'] = elem.get('newlineSequences', dummy_newlineSequences)

View File

@@ -28,7 +28,7 @@ struct_graph_CLI = (
('Struct3497', ('struct', ('index', 'Int'), ('uri', 'String'))),
('Struct9567', ('struct', ('location', 'Struct3497'))),
('Array6920', ('array', (0, 'Struct5277'), (1, 'Struct9567'))),
('Struct1509', ('struct', ('semmle.formatSpecifier', 'String'))),
('Struct1509', ('struct', ('semmle.formatSpecifier', 'String'), ('semmle.sourceLanguage', 'String'))),
('Struct2774', ('struct', ('text', 'String'))),
( 'Struct6299',
( 'struct',