diff --git a/vulnerabilities/helpers.py b/vulnerabilities/helpers.py index de4c1718a..dceaeb961 100644 --- a/vulnerabilities/helpers.py +++ b/vulnerabilities/helpers.py @@ -79,11 +79,10 @@ def create_etag(data_src, url, etag_key): return True -def split_markdown_front_matter(lines: Iterable) -> Tuple[str, str]: +def split_markdown_front_matter(lines: str) -> Tuple[str, str]: """ This function splits lines into markdown front matter and the markdown body and returns list of lines for both - NOTE: lines is expected to be an iterable containing strings for example : lines = @@ -94,7 +93,7 @@ def split_markdown_front_matter(lines: Iterable) -> Tuple[str, str]: --- # Markdown starts here - get_markdown_front_matter(lines) would return + split_markdown_front_matter(lines) would return ['title: ISTIO-SECURITY-2019-001','description: Incorrect access control.' ,'cves: [CVE-2019-12243]'], ["# Markdown starts here"] @@ -104,11 +103,10 @@ def split_markdown_front_matter(lines: Iterable) -> Tuple[str, str]: mdlines = [] splitter = mdlines - for index, line in enumerate(lines): - line = line.strip() - if index == 0 and line.startswith("---"): + for index, line in enumerate(lines.split("\n")): + if index == 0 and line.strip().startswith("---"): splitter = fmlines - elif line.startswith("---"): + elif line.strip().startswith("---"): splitter = mdlines else: splitter.append(line) diff --git a/vulnerabilities/importers/mozilla.py b/vulnerabilities/importers/mozilla.py index f1a988cef..4d45f9e78 100644 --- a/vulnerabilities/importers/mozilla.py +++ b/vulnerabilities/importers/mozilla.py @@ -81,7 +81,7 @@ def get_advisories_from_yml(self, mfsa_id, lines) -> List[Advisory]: return advisories def get_advisories_from_md(self, mfsa_id, lines) -> List[Advisory]: - yamltext, mdtext = split_markdown_front_matter(lines) + yamltext, mdtext = split_markdown_front_matter(lines.read()) data = yaml.safe_load(yamltext) data["mfsa_id"] = mfsa_id