File tree 1 file changed +8
-8
lines changed
mobsf/StaticAnalyzer/views/common
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 5
5
AppSec Dashboard
6
6
"""
7
7
import logging
8
+ import math
8
9
9
10
from django .shortcuts import render
10
11
@@ -179,19 +180,18 @@ def common_fields(findings, data):
179
180
high = len (findings .get ('high' ))
180
181
warn = len (findings .get ('warning' ))
181
182
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 )
190
184
findings ['app_name' ] = data .get ('app_name' , '' )
191
185
findings ['file_name' ] = data .get ('file_name' , '' )
192
186
findings ['hash' ] = data ['md5' ]
193
187
194
188
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
+
195
195
def get_android_dashboard (context , from_ctx = False ):
196
196
"""Get Android AppSec Dashboard."""
197
197
findings = {
You can’t perform that action at this time.
0 commit comments