Repository navigation
Remove v1 code - #2469
Remove v1 code#2469TG1999 wants to merge 8 commits into
Conversation
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
|
#2469 PR is in progress here |
keshav-space
left a comment
There was a problem hiding this comment.
Thanks @TG1999, see few nits below.
| # Skip test double pipelines defined under vulnerabilities.tests | ||
| if ".tests." in obj.__module__ or obj.__module__.startswith("vulnerabilities.tests"): | ||
| continue |
There was a problem hiding this comment.
Not needed we only import modules inside vulnerabilities.pipelines
| # Skip test double pipelines defined under vulnerabilities.tests | |
| if ".tests." in obj.__module__ or obj.__module__.startswith("vulnerabilities.tests"): | |
| continue |
|
|
||
| <link rel="stylesheet" href="{% static 'css/bulma.css' %}" /> | ||
| <link rel="stylesheet" href="{% static 'css/custom.css' %}" /> | ||
| <link rel="stylesheet" href="{% static 'css/custom.css' %}?v=tabs3" /> |
There was a problem hiding this comment.
Ahh my mistake, tabs was not working, so I was versioning different changes. This should not have been pushed. Good catch!
| <script> | ||
| function goToTab(tabName) { | ||
| var tabs = document.getElementById('tabs'); | ||
| if (!tabs) return false; | ||
| var targetLink = tabs.querySelector('[data-tab="' + tabName + '"]'); | ||
| var targetContent = document.querySelector('#tab-content > .tab-div[data-content="' + tabName + '"]'); | ||
| if (!targetLink || !targetContent) return false; | ||
| tabs.querySelectorAll('li.is-active').forEach(function (el) { el.classList.remove('is-active'); }); | ||
| document.querySelectorAll('#tab-content > .tab-div.is-active').forEach(function (el) { el.classList.remove('is-active'); }); | ||
| targetLink.classList.add('is-active'); | ||
| targetContent.classList.add('is-active'); | ||
| return false; | ||
| } | ||
| </script> |
There was a problem hiding this comment.
Why do we need to move script to the middle? It should be at the bottom of template, inside {% block scripts %}. Moreover we should not duplicate this script, we should instead reuse <script src="{% static 'js/main.js' %}"></script>
| def compute_vulnerability_risk_factors(references, severities, exploits): | ||
| """ | ||
| Risk may be expressed as a number ranging from 0 to 10. | ||
| Risk is calculated from weighted severity and exploitability values. | ||
| It is the maximum value of (the weighted severity multiplied by its exploitability) or 10 | ||
|
|
||
| Risk = min(weighted severity * exploitability, 10) | ||
| """ | ||
| weighted_severity = get_weighted_severity(severities) | ||
| exploitability = get_exploitability_level(exploits, references, severities) | ||
| return weighted_severity, exploitability | ||
|
|
||
|
|
||
| def get_weighted_severity(severities): | ||
| """ | ||
| Weighted Severity is the maximum value obtained when each Severity is multiplied | ||
| by its associated Weight/10. | ||
| Example of Weighted Severity: max(7*(10/10), 8*(3/10), 6*(8/10)) = 7 | ||
| """ | ||
| if not severities: | ||
| return 0 | ||
|
|
||
| score_map = { | ||
| "low": 3, | ||
| "moderate": 6.9, | ||
| "medium": 6.9, | ||
| "high": 8.9, | ||
| "important": 8.9, | ||
| "critical": 10.0, | ||
| "urgent": 10.0, | ||
| } | ||
|
|
||
| score_list = [] | ||
| for severity in severities: | ||
| if not severity.url: | ||
| continue | ||
| parsed_url = urlparse(severity.url) | ||
| severity_source = parsed_url.netloc.replace("www.", "", 1) | ||
| weight = WEIGHT_CONFIG.get(severity_source, DEFAULT_WEIGHT) | ||
| max_weight = float(weight) / 10 | ||
| vul_score = severity.value | ||
| if not vul_score: | ||
| continue | ||
| try: | ||
| vul_score = float(vul_score) | ||
| vul_score_value = vul_score * max_weight | ||
| except ValueError: | ||
| vul_score = vul_score.lower() | ||
| vul_score_value = score_map.get(vul_score, 0) * max_weight | ||
|
|
||
| score_list.append(vul_score_value) | ||
|
|
||
| max_score = max(score_list) if score_list else 0 | ||
| return round(max_score, 1) | ||
|
|
||
|
|
||
| def get_exploitability_level(exploits, references, severities): | ||
| """ | ||
| Exploitability refers to the potential or | ||
| probability of a software package vulnerability being exploited by | ||
| malicious actors to compromise systems, applications, or networks. | ||
| It is determined automatically by discovery of exploits. | ||
| """ | ||
| # no exploit known ( default .5) | ||
| exploit_level = 0.5 | ||
|
|
||
| if exploits: | ||
| # Automatable Exploit with PoC script published OR known exploits (KEV) in the wild OR known ransomware | ||
| exploit_level = 2 | ||
|
|
||
| elif severities: | ||
| # high EPSS. | ||
| for severity in severities: | ||
| if severity.scoring_system == EPSS.identifier and float(severity.value) > 0.8: | ||
| exploit_level = 2 | ||
| break | ||
|
|
||
| elif references: | ||
| # PoC/Exploit script published | ||
| for reference in references: | ||
| if reference.reference_type == AdvisoryReference.EXPLOIT: | ||
| exploit_level = 1 | ||
| break | ||
|
|
||
| return exploit_level |
There was a problem hiding this comment.
These pipeline-specific utilities should be in vulnerabilities/pipes/risk_score.py.
| from vulnerabilities.pipelines.v2_improvers.compute_package_risk import ( | ||
| compute_vulnerability_risk_factors, | ||
| ) |
There was a problem hiding this comment.
compute_vulnerability_risk_factors should reside in this module.
This PR removes vulnerability model and related importers/improvers completely from VCIO codebase.