introspector_page: only display if numbers are accurate (#9545)

Some old reports e.g.

https://storage.googleapis.com/oss-fuzz-introspector/upb/inspector-report/20221025/summary.json
have deprecated data. We should not display this information. Only show
if the percentage numbers make sense.

Signed-off-by: David Korczynski <david@adalogics.com>

Signed-off-by: David Korczynski <david@adalogics.com>
This commit is contained in:
DavidKorczynski 2023-02-01 09:40:48 +00:00 committed by GitHub
parent 47bdea931b
commit b048be69a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -212,6 +212,15 @@ def refine_percentage_string(percentage_string):
if len(percentage_string) > 5:
percentage_string = percentage_string[:5]
# Check if the percentage is withing range of [0.0 : 100.0]
# Some old reports from 2022 have deprecated data, which we do not want to
# display.
float_val = float(percentage_string)
if float_val < 0.0 or float_val > 100.0:
# Raise exception to make the code display '-' elements.
raise Exception('Out of range numbers')
return percentage_string + "%"