diff options
author | Emilio Pozuelo Monfort <pochu@debian.org> | 2023-03-20 13:10:39 +0100 |
---|---|---|
committer | Emilio Pozuelo Monfort <pochu@debian.org> | 2023-03-27 10:25:24 +0200 |
commit | b46022d88e991d5f909f7b36a28ba3d88fea8d55 (patch) | |
tree | 718bbd07095b03399d9314637ba5ec1d7e543d3a /bin/merge-cve-files | |
parent | 9d36be993d2db2f099372f7252b32a2e53621bf8 (diff) |
merge-cve-files: simplify extra string notes
The notes dict is only going to contain notes for the current
CVE, so we can simply keep and pass the list.
Diffstat (limited to 'bin/merge-cve-files')
-rwxr-xr-x | bin/merge-cve-files | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/bin/merge-cve-files b/bin/merge-cve-files index b5382aa6fb..d1ca8fb91a 100755 --- a/bin/merge-cve-files +++ b/bin/merge-cve-files @@ -3,7 +3,7 @@ # Merge a separate CVE file (such as data/next-point-update.txt) back into # the main one. # -# Copyright © 2020 Emilio Pozuelo Monfort <pochu@debian.org> +# Copyright © 2020-2023 Emilio Pozuelo Monfort <pochu@debian.org> # Copyright (c) 2021-2022 Neil Williams <codehelp@debian.org> import os @@ -25,23 +25,20 @@ def merge_notes(bug, notes): """ Special support for StringAnnotations. - notes is a dict containing a list of string annotations for - each CVE in the file being merged. Pick out the string annotations - for this bug, ignore if already exist, append if new. + notes is a list of extra string annotations for this CVE (bug), + and may be empty. """ new_notes = [] - cve = bug.header.name - merge_list = notes.get(cve) # list of notes to merge - if not merge_list: + if not notes: # nothing to merge return bug - tagged_notes = [note.description for note in merge_list] + 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 bug - for new_ann in merge_list: + for new_ann in notes: if new_ann.description in new_strings: new_notes.append(new_ann) bug_list = list(bug.annotations) @@ -133,16 +130,15 @@ extra_data = parse_list(extra_list) for extra_bug in extra_data: bug = next(bug for bug in data if bug.header.name == extra_bug.header.name) - notes = {} + notes = [] new_annotations = bug.annotations for extra_annotation in extra_bug.annotations: if isinstance(extra_annotation, FlagAnnotation): continue if isinstance(extra_annotation, StringAnnotation): - cve = f"{extra_bug.header.name}" - note_tag = notes.setdefault(cve, []) - note_tag.append(extra_annotation) + notes.append(extra_annotation) continue + new_annotations = merge_annotations(new_annotations, extra_annotation) bug = bug._replace(annotations=new_annotations) |