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

fix Bugzilla flaw summary exceeding #784

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

osoukup
Copy link
Contributor

@osoukup osoukup commented Oct 18, 2024

Closes OSIDB-3551

@osoukup osoukup requested a review from a team October 18, 2024 13:54
@osoukup osoukup self-assigned this Oct 18, 2024
Comment on lines +33 to +36
if len(description) <= len(MULTIPLE_DESCRIPTIONS_SUBSTITUTION):
raise UnsavableModelError(
f"Summary generated for the tracker is longer than {MAX_SUMMARY_LENGTH}"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is copied from old code, but we can move this to the top of the function. We avoid doing the operations on the cves array and remove this else clause making the code cleaner too.

Comment on lines +263 to +273
while True:

cve_string = " ".join(cve_ids) + " " if cve_ids else ""
summary = f"{embargoed}{cve_string}{components}{description}"

if len(summary) <= MAX_SUMMARY_LENGTH:
break

cve_ids, description = summary_shorten(cve_ids, description)

self._query["summary"] = summary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a long list of components, we may reach a point when summary_shorten can't shorten cve_ids and description further but we are still over the limit, ending in an infinite loop.

It might be a good idea to use a variable to keep track of whether we are still reducing the length at each step, and if we reach the limit (length is not reducing anymore but we are still over the max length) just exit the loop and shorten it the barbarian way

summary = summary[:MAX_SUMMARY_LENGTH-3] + "..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants