MCPcopy Create free account
hub / github.com/aboutcode-org/vulnerablecode / is_vulnerable_nginx_version

Function is_vulnerable_nginx_version

vulnerabilities/utils.py:482–509  ·  view source on GitHub ↗

Return True if the ``version`` Version for nginx is vulnerable according to the nginx approach. A ``version`` is vulnerable as explained by @mdounin in https://marc.info/?l=nginx&m=164070162912710&w=2 : "Note that it is generally trivial to find out if a version is

(version, affected_version_range, fixed_versions)

Source from the content-addressed store, hash-verified

480
481
482def is_vulnerable_nginx_version(version, affected_version_range, fixed_versions):
483 """
484 Return True if the ``version`` Version for nginx is vulnerable according to
485 the nginx approach.
486
487 A ``version`` is vulnerable as explained by @mdounin
488 in https://marc.info/?l=nginx&m=164070162912710&w=2 :
489
490 "Note that it is generally trivial to find out if a version is
491 vulnerable or not from the information about a vulnerability,
492 without any knowledge about nginx branches. That is:
493
494 - Check if the version is in "Vulnerable" range. If it's not, the
495 version is not vulnerable.
496
497 - If it is, check if the branch is explicitly listed in the "Not
498 vulnerable". If it's not, the version is vulnerable. If it
499 is, check the minor number: if it's greater or equal to the
500 version listed as not vulnerable, the version is not vulnerable,
501 else the version is vulnerable."
502
503 """
504 if version in NginxVersionRange.from_string(affected_version_range.to_string()):
505 for fixed_version in fixed_versions:
506 if version.value.minor == fixed_version.value.minor and version >= fixed_version:
507 return False
508 return True
509 return False
510
511
512def get_severity_range(severity_list):

Callers 3

test_is_vulnerableMethod · 0.90
test_is_vulnerableMethod · 0.90

Calls 1

to_stringMethod · 0.45

Tested by 2

test_is_vulnerableMethod · 0.72
test_is_vulnerableMethod · 0.72