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

Function github_constraints_satisfied

vulntotal/vulntotal_utils.py:93–108  ·  view source on GitHub ↗

Return True or False depending on whether the given version satisfies the github constraint For example: >>> assert github_constraints_satisfied(">= 7.0.0, <= 7.6.57", "7.1.1") == True >>> assert github_constraints_satisfied(">= 10.4.0, <= 10.4.1", "10.6.0") == False

(github_constraint, version)

Source from the content-addressed store, hash-verified

91
92
93def github_constraints_satisfied(github_constraint, version):
94 """
95 Return True or False depending on whether the given version satisfies the github constraint
96 For example:
97 >>> assert github_constraints_satisfied(">= 7.0.0, <= 7.6.57", "7.1.1") == True
98 >>> assert github_constraints_satisfied(">= 10.4.0, <= 10.4.1", "10.6.0") == False
99 """
100 gh_constraints = github_constraint.strip().replace(" ", "")
101 constraints = gh_constraints.split(",")
102 for constraint in constraints:
103 gh_comparator, gh_version = parse_constraint(constraint)
104 if not gh_version:
105 continue
106 if not compare(GenericVersion(version), gh_comparator, GenericVersion(gh_version)):
107 return False
108 return True
109
110
111def snyk_constraints_satisfied(snyk_constraint, version):

Callers 1

extract_interesting_edgeFunction · 0.90

Calls 3

parse_constraintFunction · 0.85
GenericVersionClass · 0.85
compareFunction · 0.70

Tested by

no test coverage detected