Skip to content

Commit 198f16a

Browse files
committed
use https.OK
Signed-off-by: thebigbone <pacman@duck.com>
1 parent 4a6734b commit 198f16a

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

vulnerabilities/utils.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from unittest.mock import MagicMock
2626
from urllib.parse import urljoin
2727
from uuid import uuid4
28+
from http import HTTPStatus
2829

2930
import requests
3031
import saneyaml
@@ -167,14 +168,17 @@ def nearest_patched_package(
167168
Return a list of Affected Packages for each Patched package.
168169
"""
169170

170-
vulnerable_packages = sorted([VersionedPackage(package) for package in vulnerable_packages])
171-
resolved_packages = sorted([VersionedPackage(package) for package in resolved_packages])
171+
vulnerable_packages = sorted(
172+
[VersionedPackage(package) for package in vulnerable_packages])
173+
resolved_packages = sorted([VersionedPackage(package)
174+
for package in resolved_packages])
172175

173176
resolved_package_count = len(resolved_packages)
174177
affected_package_with_patched_package_objects = []
175178

176179
for vulnerable_package in vulnerable_packages:
177-
patched_package_index = bisect.bisect_right(resolved_packages, vulnerable_package)
180+
patched_package_index = bisect.bisect_right(
181+
resolved_packages, vulnerable_package)
178182
patched_package = None
179183
if patched_package_index < resolved_package_count:
180184
patched_package = resolved_packages[patched_package_index]
@@ -405,7 +409,7 @@ def base32_custom(btes):
405409
from_bytes = int.from_bytes
406410

407411
for i in range(0, len(btes), 5):
408-
c = from_bytes(btes[i : i + 5], "big")
412+
c = from_bytes(btes[i: i + 5], "big")
409413
encoded += (
410414
_base32_table[c >> 30]
411415
+ _base32_table[(c >> 20) & 0x3FF] # bits 1 - 10
@@ -420,9 +424,10 @@ def fetch_response(url):
420424
Fetch and return `response` from the `url`
421425
"""
422426
response = requests.get(url)
423-
if response.status_code == 200:
427+
if response.status_code == HTTPStatus.OK:
424428
return response
425-
raise Exception(f"Failed to fetch data from {url!r} with status code: {response.status_code!r}")
429+
raise Exception(
430+
f"Failed to fetch data from {url!r} with status code: {response.status_code!r}")
426431

427432

428433
# This should be a method on PackageURL

0 commit comments

Comments
 (0)