diff --git a/entrypoint/entrypoint/converter.py b/entrypoint/entrypoint/converter.py index 46a96b7..215ddb1 100644 --- a/entrypoint/entrypoint/converter.py +++ b/entrypoint/entrypoint/converter.py @@ -358,10 +358,25 @@ def to_markdown(vulns, return markdown -def merge_cell(pkg: str): +def merge_cell(a_string: str): + """ + This function expects a string of data + that is intended to be placed in a markdown + table. The provided data may include multiple + elements in a string, such as multiple PURLs + separated with a semi-colon character ';'. + This function splits the provided string + so that multiple elements can fit in one + cell in a markdown table. + """ + + # return early on empty string + if a_string == "": + return "" + # we may have multiple PURLs for a single CVE, # so split purls into a list we can iterate on - original_list = pkg.split(";") + original_list = a_string.split(";") seen = set() unique_list = [] @@ -374,9 +389,13 @@ def merge_cell(pkg: str): unique_formatted = [] for each in unique_list: + # make each element preformatted text, + # otherwise the markdown report renders + # with malformed characters on GitHub each = f"`{each}`" unique_formatted.append(each) + # separate multiple elements in cell with HTML break characters merged_cell = '

'.join(unique_formatted) return merged_cell