Skip to content

Commit 76c5eda

Browse files
committed
Run 'make valid' #1287
Reference: #1287 Signed-off-by: John M. Horan <[email protected]>
1 parent ebd8cdc commit 76c5eda

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

vulnerabilities/templatetags/url_filters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
register = template.Library()
77

8-
@register.filter(name='url_quote')
8+
9+
@register.filter(name="url_quote")
910
def url_quote_filter(value):
1011
return quote(str(value))

vulnerabilities/tests/test_view.py

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_sorted_queryset(self):
207207

208208
pkg_package_urls = [obj.package_url for obj in sorted_pkgs_qs_all]
209209
sorted_purls = os.path.join(TEST_DIR, "sorted_purls.txt")
210-
with open(sorted_purls, 'r') as f:
210+
with open(sorted_purls, "r") as f:
211211
expected_content = f.read().splitlines()
212212
assert pkg_package_urls == expected_content
213213

@@ -236,16 +236,40 @@ def test_get_purl_version_class(self):
236236

237237

238238
class TestCustomFilters:
239-
@pytest.mark.parametrize("input_value, expected_output", [
240-
("pkg:rpm/redhat/[email protected]?arch=el6sat", "pkg%3Arpm/redhat/katello-client-bootstrap%401.1.0-2%3Farch%3Del6sat"),
241-
("pkg:alpine/[email protected]?arch=armhf&distroversion=v3.5&reponame=main", "pkg%3Aalpine/nginx%401.10.3-r1%3Farch%3Darmhf%26distroversion%3Dv3.5%26reponame%3Dmain"),
242-
("pkg:nginx/[email protected]?os=windows", "pkg%3Anginx/nginx%400.9.0%3Fos%3Dwindows"),
243-
("pkg:deb/ubuntu/[email protected]~intrepid1", "pkg%3Adeb/ubuntu/nginx%400.6.34-2ubuntu1~intrepid1"),
244-
("pkg:rpm/redhat/openssl@1:1.0.2k-16.el7_6?arch=1", "pkg%3Arpm/redhat/openssl%401%3A1.0.2k-16.el7_6%3Farch%3D1"),
245-
("pkg:golang/google.golang.org/genproto#googleapis/api/annotations", "pkg%3Agolang/google.golang.org/genproto%23googleapis/api/annotations"),
246-
("pkg:cocoapods/[email protected]#NSData+zlib", "pkg%3Acocoapods/GoogleUtilities%407.5.2%23NSData%2Bzlib"),
247-
("pkg:conda/[email protected]?build=py36h06a4308_0&channel=main&subdir=linux-64&type=tar.bz2", "pkg%3Aconda/absl-py%400.4.1%3Fbuild%3Dpy36h06a4308_0%26channel%3Dmain%26subdir%3Dlinux-64%26type%3Dtar.bz2"),
248-
])
239+
@pytest.mark.parametrize(
240+
"input_value, expected_output",
241+
[
242+
(
243+
"pkg:rpm/redhat/[email protected]?arch=el6sat",
244+
"pkg%3Arpm/redhat/katello-client-bootstrap%401.1.0-2%3Farch%3Del6sat",
245+
),
246+
(
247+
"pkg:alpine/[email protected]?arch=armhf&distroversion=v3.5&reponame=main",
248+
"pkg%3Aalpine/nginx%401.10.3-r1%3Farch%3Darmhf%26distroversion%3Dv3.5%26reponame%3Dmain",
249+
),
250+
("pkg:nginx/[email protected]?os=windows", "pkg%3Anginx/nginx%400.9.0%3Fos%3Dwindows"),
251+
(
252+
"pkg:deb/ubuntu/[email protected]~intrepid1",
253+
"pkg%3Adeb/ubuntu/nginx%400.6.34-2ubuntu1~intrepid1",
254+
),
255+
(
256+
"pkg:rpm/redhat/openssl@1:1.0.2k-16.el7_6?arch=1",
257+
"pkg%3Arpm/redhat/openssl%401%3A1.0.2k-16.el7_6%3Farch%3D1",
258+
),
259+
(
260+
"pkg:golang/google.golang.org/genproto#googleapis/api/annotations",
261+
"pkg%3Agolang/google.golang.org/genproto%23googleapis/api/annotations",
262+
),
263+
(
264+
"pkg:cocoapods/[email protected]#NSData+zlib",
265+
"pkg%3Acocoapods/GoogleUtilities%407.5.2%23NSData%2Bzlib",
266+
),
267+
(
268+
"pkg:conda/[email protected]?build=py36h06a4308_0&channel=main&subdir=linux-64&type=tar.bz2",
269+
"pkg%3Aconda/absl-py%400.4.1%3Fbuild%3Dpy36h06a4308_0%26channel%3Dmain%26subdir%3Dlinux-64%26type%3Dtar.bz2",
270+
),
271+
],
272+
)
249273
def test_url_quote_filter(self, input_value, expected_output):
250274
filtered = url_quote_filter(input_value)
251275
assert filtered == expected_output

vulnerabilities/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def purl_sort_key(purl: models.Package):
5151
purl_sort_version = purl_version_class(purl.version)
5252
return (purl.type, purl.namespace, purl.name, purl_sort_version, purl.qualifiers, purl.subpath)
5353

54+
5455
def get_purl_version_class(purl: models.Package):
5556
RANGE_CLASS_BY_SCHEMES["alpine"] = AlpineLinuxVersionRange
5657
purl_version_class = None
@@ -194,7 +195,10 @@ def get_context_data(self, **kwargs):
194195
and (fixed_by_package.name == sorted_affected_package.name)
195196
and (fixed_by_package.qualifiers == sorted_affected_package.qualifiers)
196197
and (fixed_by_package.subpath == sorted_affected_package.subpath)
197-
and (fixed_by_version_class(fixed_by_package.version) > sorted_affected_version_class(sorted_affected_package.version))
198+
and (
199+
fixed_by_version_class(fixed_by_package.version)
200+
> sorted_affected_version_class(sorted_affected_package.version)
201+
)
198202
):
199203
matched_fixed_by_packages.append(fixed_by_package.purl)
200204
affected_fixed_by_matches["matched_fixed_by_packages"] = matched_fixed_by_packages

0 commit comments

Comments
 (0)