Skip to content

Commit

Permalink
sort tags: buf fix for root_uid entries in tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke authored and maringuu committed Nov 7, 2023
1 parent fac5f5c commit 6779963
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/web_interface/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from re import Match
from string import ascii_letters
from time import localtime, strftime, struct_time, time
from typing import Union
from typing import Union, Iterable

from common_helper_files import human_readable_file_size
from flask import render_template
Expand Down Expand Up @@ -287,8 +287,7 @@ def render_analysis_tags(tags, size=14):
output = ''
if tags:
for plugin_name in sorted(tags):
# sort tags by "value" (the displayed text in the tag)
for key, tag in sorted(tags[plugin_name].items(), key=lambda t: t[1]['value']):
for key, tag in sorted(tags[plugin_name].items(), key=_sort_tags_key):
if key == 'root_uid':
continue
color = tag['color'] if tag['color'] in TagColor.ALL else TagColor.BLUE
Expand All @@ -302,6 +301,12 @@ def render_analysis_tags(tags, size=14):
return output


def _sort_tags_key(tag_tuples: Iterable[tuple[str, dict]]) -> str:
# Sort tags by "value" (the displayed text in the tag). There can be 'root_uid' entries which are no dicts
_, tag_dict = tag_tuples
return tag_dict['value'] if isinstance(tag_dict, dict) else ''


def fix_cwe(string):
if 'CWE' in string:
return string.split(']')[0].split('E')[-1]
Expand Down

0 comments on commit 6779963

Please sign in to comment.