Skip to content

Commit 7e5f42c

Browse files
author
john.guo
committedDec 19, 2023
1 parent 1f8c609 commit 7e5f42c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
 

‎mobsf/StaticAnalyzer/views/common/appsec.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
AppSec Dashboard
66
"""
77
import logging
8+
import math
89

910
from django.shortcuts import render
1011

@@ -179,19 +180,18 @@ def common_fields(findings, data):
179180
high = len(findings.get('high'))
180181
warn = len(findings.get('warning'))
181182
sec = len(findings.get('secure'))
182-
total = high + warn + sec
183-
score = 0
184-
if total > 0:
185-
score = int(100 - (
186-
((high * 1) + (warn * .5) - (sec * .2)) / total) * 100)
187-
if score > 100:
188-
score = 100
189-
findings['security_score'] = score
183+
findings['security_score'] = get_secure_score(high, warn, sec)
190184
findings['app_name'] = data.get('app_name', '')
191185
findings['file_name'] = data.get('file_name', '')
192186
findings['hash'] = data['md5']
193187

194188

189+
def get_secure_score(high, warn, sec):
190+
loss_score = high * 10 + warn * 5 - sec * 2
191+
normalize_reverse = 2 / (1 + pow(math.e, loss_score / 30))
192+
return int(min(normalize_reverse, 1) * 100)
193+
194+
195195
def get_android_dashboard(context, from_ctx=False):
196196
"""Get Android AppSec Dashboard."""
197197
findings = {

0 commit comments

Comments
 (0)
Please sign in to comment.