diff options
author | Emilio Pozuelo Monfort <pochu@debian.org> | 2023-03-20 16:12:21 +0100 |
---|---|---|
committer | Emilio Pozuelo Monfort <pochu@debian.org> | 2023-03-27 10:25:24 +0200 |
commit | 9e5d24dbc0edb896829e9ca7c4890423d580af84 (patch) | |
tree | a259759a1b2770398f5e33889a45f4cd4f273993 /bin | |
parent | ae600b80be44440f88abc46dd56bcf09e6b4b3d3 (diff) |
merge-cve-files: further simplify merge_notes
Diffstat (limited to 'bin')
-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 a924489ed9..2f130a29fb 100755 --- a/bin/merge-cve-files +++ b/bin/merge-cve-files @@ -21,23 +21,22 @@ from sectracker.parsers import ( XrefAnnotation ) -def merge_notes(bug, notes): +def merge_notes(annotations, new_annotation): """ Special support for StringAnnotations. - Merges notes into the bug's annotations, taking care not to + Merges a note 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_annotation is a new string annotation for this CVE (bug), """ old_descriptions = [ann.description - for ann in bug.annotations + for ann in annotations if isinstance(ann, StringAnnotation)] - for note in notes: - # prevent adding duplicate notes - if not note.description in old_descriptions: - bug.annotations.append(note) + + # prevent adding duplicate notes + if not new_annotation.description in old_descriptions: + annotations.append(new_annotation) def merge_annotations(annotations, new_annotation): @@ -113,18 +112,15 @@ extra_data = cvelist(extra_list) for extra_bug in extra_data: bug = next(bug for bug in data if bug.header.name == extra_bug.header.name) - notes = [] for extra_annotation in extra_bug.annotations: if isinstance(extra_annotation, FlagAnnotation): continue if isinstance(extra_annotation, StringAnnotation): - notes.append(extra_annotation) + merge_notes(bug.annotations, extra_annotation) continue merge_annotations(bug.annotations, extra_annotation) - merge_notes(bug, notes) - with open(main_list, 'w') as f: writecvelist(data, f) |