Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12 from cisagov/improvement/enforce_string_conver…
Browse files Browse the repository at this point in the history
…sion

Ensure values are `str` types when converting from YAML to Markdown
  • Loading branch information
mcdonnnj committed Jan 24, 2022
2 parents 2e626de + 8107038 commit d21ed8d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/ymlmd/yml2md.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,18 @@ def generate_markdown(software: Software) -> None:
vendor=s["vendor"],
product=s["product"],
affected_versions=", ".join(
[x for x in default_cve["affected_versions"] if len(x) != 0]
[
v
for x in default_cve["affected_versions"]
if x and len(v := str(x)) != 0
]
),
patched_versions=", ".join(
[x for x in default_cve["fixed_versions"] if len(x) != 0]
[
v
for x in default_cve["fixed_versions"]
if x and len(v := str(x)) != 0
]
),
status=s["status"],
# convert vendor links to Markdown links if they start
Expand All @@ -110,7 +118,9 @@ def generate_markdown(software: Software) -> None:
]
),
notes=s["notes"],
references="; ".join([x for x in s["references"] if len(x) != 0]),
references="; ".join(
[r for x in s["references"] if x and len(r := str(x)) != 0]
),
reporter=", ".join(
f"[{i['name']}]({i['url']})" for i in s["reporter"]
),
Expand All @@ -120,8 +130,8 @@ def generate_markdown(software: Software) -> None:
),
)
)
except KeyError as err:
print(f"{i}: {err} - {s}", file=sys.stderr)
except KeyError:
logging.exception("%d: %s", i, s)


def main() -> None:
Expand Down

0 comments on commit d21ed8d

Please sign in to comment.