Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit: Better display CVE #337

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions github_app_geo_project/module/audit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ async def snyk(
message.title = f"Error while installing the dependencies from {file}"
_LOGGER.warning(message)
result.append(message)
message.title = f"Dependencies installed from {file}"
else:
message.title = f"Dependencies installed from {file}"
_LOGGER.debug(message)

proc = subprocess.run( # nosec # pylint: disable=subprocess-run-check
Expand Down Expand Up @@ -258,7 +259,7 @@ async def snyk(
fixable_vulnerabilities: dict[str, int] = {}
for row in test_json:
message = module_utils.HtmlMessage(
"<br>\n".join(
"\n".join(
[
f"Package manager: {row.get('packageManager', '-')}",
f"Target file: {row.get('displayTargetFile', '-')}",
Expand All @@ -267,7 +268,7 @@ async def snyk(
]
)
)
message.title = row.get("summary", "Snyk test")
message.title = f'{row.get("summary", "Snyk test")} in {row.get("displayTargetFile", "-")}.'
_LOGGER.info(message)

if "error" in row:
Expand All @@ -288,7 +289,8 @@ async def snyk(
[
f"[{vuln['severity'].upper()}]",
f"{vuln['packageName']}@{vuln['version']}:",
f'<a href="https://security.snyk.io/vuln/{vuln["id"]}">{vuln["title"]}</a>',
vuln["id"],
*(vuln.get("identifiers", {}).get("CWE", [])),
]
)
if vuln.get("isUpgradable", False):
Expand All @@ -298,17 +300,14 @@ async def snyk(
else:
title += "."
message = module_utils.HtmlMessage(
"\n".join(
"<br>\n".join(
[
vuln["id"],
f'<a href="https://security.snyk.io/vuln/{vuln["id"]}">{vuln["title"]}</a>',
" > ".join(vuln["from"]),
*[
f"{identifier_type} {', '.join(identifiers)}"
for identifier_type, identifiers in vuln["identifiers"].items()
],
*[f"[{reference['title']}]({reference['url']})" for reference in vuln["references"]],
"",
markdown.markdown(vuln["description"]),
*[", ".join(identifiers) for identifiers in vuln.get("identifiers", {}).values()],
# *[f'<a href="{reference['url']}>{reference["title"]}</a>' for reference in vuln["references"]],
# "",
# markdown.markdown(vuln["description"]),
]
),
title,
Expand Down
Loading