Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mobsf/StaticAnalyzer/views/android/apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def apk_analysis_task(checksum, app_dic, rescan, queue=False):
def generate_dynamic_context(request, app_dic, checksum, context, api):
"""Generate Dynamic Context."""
context['appsec'] = get_android_dashboard(context, True)
Copy link

Copilot AI Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated call correctly accesses the 'findings' key to retrieve the necessary CVSS scores. Consider adding a brief inline comment to document the expected JSON structure for future maintenance.

Suggested change
context['appsec'] = get_android_dashboard(context, True)
context['appsec'] = get_android_dashboard(context, True)
# The 'code_analysis' key in the context is expected to contain a 'findings' key,
# which holds a list of CVSS scores used to calculate the average CVSS.

Copilot uses AI. Check for mistakes.
context['average_cvss'] = get_avg_cvss(context['code_analysis'])
context['average_cvss'] = get_avg_cvss(context['code_analysis']['findings'])
logcat_file = Path(app_dic['app_dir']) / 'logcat.txt'
context['dynamic_analysis_done'] = logcat_file.exists()
context['virus_total'] = None
Expand Down Expand Up @@ -365,7 +365,7 @@ def src_analysis_task(checksum, app_dic, rescan, pro_type, queue=False):
def generate_dynamic_src_context(request, context, api):
"""Generate Dynamic Source Context."""
context['appsec'] = get_android_dashboard(context, True)
context['average_cvss'] = get_avg_cvss(context['code_analysis'])
context['average_cvss'] = get_avg_cvss(context['code_analysis']['findings'])
template = 'static_analysis/android_source_analysis.html'
Comment on lines +368 to 369
Copy link

Copilot AI Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change properly extracts the CVSS scores from the 'findings' key. A short inline note explaining why the 'findings' key is used could aid future maintainers.

Suggested change
context['average_cvss'] = get_avg_cvss(context['code_analysis']['findings'])
template = 'static_analysis/android_source_analysis.html'
# The 'findings' key in 'context['code_analysis']' contains the results of the code analysis,
# including CVSS scores. It is used here to calculate the average CVSS score.
findings = context['code_analysis'].get('findings', None)
context['average_cvss'] = get_avg_cvss(findings) if findings else None

Copilot uses AI. Check for mistakes.
return context if api else render(request, template, context)

Expand Down