mirror of
https://github.com/hohn/sarif-cli.git
synced 2025-12-16 17:23:03 +01:00
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:
@@ -102,20 +102,13 @@ def joins_for_projects(basetables, external_info):
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user