Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
john.guo committed Dec 19, 2023
1 parent 1f8c609 commit 7e5f42c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mobsf/StaticAnalyzer/views/common/appsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
AppSec Dashboard
"""
import logging
import math

from django.shortcuts import render

Expand Down Expand Up @@ -179,19 +180,18 @@ def common_fields(findings, data):
high = len(findings.get('high'))
warn = len(findings.get('warning'))
sec = len(findings.get('secure'))
total = high + warn + sec
score = 0
if total > 0:
score = int(100 - (
((high * 1) + (warn * .5) - (sec * .2)) / total) * 100)
if score > 100:
score = 100
findings['security_score'] = score
findings['security_score'] = get_secure_score(high, warn, sec)
findings['app_name'] = data.get('app_name', '')
findings['file_name'] = data.get('file_name', '')
findings['hash'] = data['md5']


def get_secure_score(high, warn, sec):
loss_score = high * 10 + warn * 5 - sec * 2
normalize_reverse = 2 / (1 + pow(math.e, loss_score / 30))
return int(min(normalize_reverse, 1) * 100)


def get_android_dashboard(context, from_ctx=False):
"""Get Android AppSec Dashboard."""
findings = {
Expand Down

0 comments on commit 7e5f42c

Please sign in to comment.