-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Correct CVSS calculation by accessing findings key properly #2511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixed an issue where the average CVSS score calculation was incorrect due to improper access to the findings key within the JSON structure. The calculation logic was bypassing the findings key and therefore failing to extract valid CVSS scores.
Thanks for the PR, I will review this and get back. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request fixes the bug in the average CVSS score calculation by ensuring the correct extraction of the CVSS scores from the JSON structure.
- Modified the CVSS calculation by passing the 'findings' key from code_analysis to get_avg_cvss
- Updated both dynamic context functions (for APK and source code analysis) to reflect the fix
|
||
def generate_dynamic_context(request, app_dic, checksum, context, api): | ||
"""Generate Dynamic Context.""" | ||
context['appsec'] = get_android_dashboard(context, True) |
There was a problem hiding this comment.
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.
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']['findings']) | ||
template = 'static_analysis/android_source_analysis.html' |
There was a problem hiding this comment.
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.
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.
Fixed an issue where the average CVSS score calculation was incorrect due to improper access to the findings key within the JSON structure. The calculation logic was bypassing the findings key and therefore failing to extract valid CVSS scores. Co-authored-by: Ajin Abraham <[email protected]>
Fixed an issue where the average CVSS score calculation was incorrect due to improper access to the findings key within the JSON structure. The calculation logic was bypassing the findings key and therefore failing to extract valid CVSS scores.
Describe the Pull Request
Checklist for PR
tox -e lint,test
StaticAnalyzer/tests.py
)Additional Comments (if any)