diff options
author | Emilio Pozuelo Monfort <pochu@debian.org> | 2023-03-20 16:05:27 +0100 |
---|---|---|
committer | Emilio Pozuelo Monfort <pochu@debian.org> | 2023-03-27 10:25:24 +0200 |
commit | ae600b80be44440f88abc46dd56bcf09e6b4b3d3 (patch) | |
tree | e699c63af972e937d8ba878081075aaeff23aaf8 /bin/merge-cve-files | |
parent | d2c8ae0ad681d005f50d2ca76b1de7dc2fe732eb (diff) |
merge-cve-files: simplify merge_notes
It's just appending the new string annotations to the current
annotations, with special care not to add them if they are
already there (probably needed by grab-cve-in-fix or update-vuln).
Diffstat (limited to 'bin/merge-cve-files')
-rwxr-xr-x | bin/merge-cve-files | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/bin/merge-cve-files b/bin/merge-cve-files index 8521eb6969..a924489ed9 100755 --- a/bin/merge-cve-files +++ b/bin/merge-cve-files @@ -25,28 +25,19 @@ def merge_notes(bug, notes): """ Special support for StringAnnotations. - Merges notes into the bug's annotations. + Merges notes into the bug's annotations, taking care not to + add duplicate notes. notes is a list of extra string annotations for this CVE (bug), and may be empty. """ - new_notes = [] - if not notes: - # nothing to merge - return - tagged_notes = [note.description for note in notes] - bug_notes = [ann.description for ann in bug.annotations if isinstance(ann, StringAnnotation)] - # get the list items in tagged_notes which are not in bug_notes - new_strings = list(set(tagged_notes) - set(bug_notes)) - if not new_strings: - return - for new_ann in notes: - if new_ann.description in new_strings: - new_notes.append(new_ann) - bug_list = list(bug.annotations) - bug_list.extend(new_notes) - - bug.annotations = bug_list + old_descriptions = [ann.description + for ann in bug.annotations + if isinstance(ann, StringAnnotation)] + for note in notes: + # prevent adding duplicate notes + if not note.description in old_descriptions: + bug.annotations.append(note) def merge_annotations(annotations, new_annotation): |