Return True or False depending on whether the given version satisfies the snyk constraint For example: >>> assert snyk_constraints_satisfied(">=4.0.0, <4.0.10.16", "4.0.10.15") == True >>> assert snyk_constraints_satisfied(" >=4.1.0, <4.4.15.7", "4.0.10.15") == False >>> assert
(snyk_constraint, version)
| 109 | |
| 110 | |
| 111 | def snyk_constraints_satisfied(snyk_constraint, version): |
| 112 | """ |
| 113 | Return True or False depending on whether the given version satisfies the snyk constraint |
| 114 | For example: |
| 115 | >>> assert snyk_constraints_satisfied(">=4.0.0, <4.0.10.16", "4.0.10.15") == True |
| 116 | >>> assert snyk_constraints_satisfied(" >=4.1.0, <4.4.15.7", "4.0.10.15") == False |
| 117 | >>> assert snyk_constraints_satisfied("[3.0.0,3.1.25)", "3.0.2") == True |
| 118 | """ |
| 119 | snyk_constraints = snyk_constraint.strip().replace(" ", "") |
| 120 | constraints = snyk_constraints.split(",") |
| 121 | for constraint in constraints: |
| 122 | snyk_comparator, snyk_version = parse_constraint(constraint) |
| 123 | if not snyk_version: |
| 124 | continue |
| 125 | if not compare(GenericVersion(version), snyk_comparator, GenericVersion(snyk_version)): |
| 126 | return False |
| 127 | return True |
| 128 | |
| 129 | |
| 130 | def gitlab_constraints_satisfied(gitlab_constraint, version): |
no test coverage detected