-
Notifications
You must be signed in to change notification settings - Fork 0
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
add-security-linter-results-to-workflow-summary #254
base: main
Are you sure you want to change the base?
add-security-linter-results-to-workflow-summary #254
Conversation
exasol/toolbox/tools/security.py
Outdated
def issues_to_markdown(issues: Iterable[Issue]) -> str: | ||
markdown_str = "" | ||
markdown_str += "# Security\n\n" | ||
markdown_str += "|File|Cve|Cwe|Details|\n" | ||
markdown_str += "|---|:-:|:-:|---|\n" | ||
for issue in issues: | ||
row = "|" + issue.coordinates + "|" | ||
row += issue.cve + "|" | ||
row += issue.cwe + "|" | ||
for element in issue.references: | ||
row += element + " ,<br>" | ||
markdown_str += row[:-5] + "|\n" | ||
return markdown_str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def issues_to_markdown(issues: Iterable[Issue]) -> str: | |
markdown_str = "" | |
markdown_str += "# Security\n\n" | |
markdown_str += "|File|Cve|Cwe|Details|\n" | |
markdown_str += "|---|:-:|:-:|---|\n" | |
for issue in issues: | |
row = "|" + issue.coordinates + "|" | |
row += issue.cve + "|" | |
row += issue.cwe + "|" | |
for element in issue.references: | |
row += element + " ,<br>" | |
markdown_str += row[:-5] + "|\n" | |
return markdown_str | |
from inspect import cleandoc | |
def issues_to_markdown(issues: Iterable[Issue]) -> str: | |
template = cleandoc(""" | |
{header} | |
{rows} | |
""") | |
def _header(): | |
header = "" | |
markdown_str += "# Security\n\n" | |
header += "|File|Cve|Cwe|Details|\n" | |
header += "|---|:-:|:-:|---|\n" | |
return header | |
def _row(issue): | |
row = "|" + issue.coordinates + "|" | |
row += issue.cve + "|" | |
row += issue.cwe + "|" | |
for element in issue.references: | |
row += element + " ,<br>" | |
row += row[:-5] + "|" | |
return row | |
return template.format( | |
header=_header() | |
rows = "\n".jon(_entry(i) for i in issues) | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally if you make use of "".join()
you can safe yourself the head egg with removing the bits from the last line here:
for element in issue.references:
row += element + " ,<br>"
row += row[:-5] + "|"
Similar to what is done in the new return statement for rows
description=issue["issue_text"], | ||
coordinates=issue["filename"].replace( | ||
str(PROJECT_CONFIG.root) + "/", "" | ||
) + ":" + str(issue["line_number"]) + ":" + str(issue["col_offset"]) + ":", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f'{issue["line_number"]}'
has the same effect as str(issue["line_number"])
str(PROJECT_CONFIG.root) + "/", "" | ||
) + ":" + str(issue["line_number"]) + ":" + str(issue["col_offset"]) + ":", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str(PROJECT_CONFIG.root) + "/", "" | |
) + ":" + str(issue["line_number"]) + ":" + str(issue["col_offset"]) + ":", | |
f'{PROJECT_CONFIG.root}/, ""') + f':{issue["line_number"]}:{issue["col_offset"]}:', |
closes #248