Skip to content

Commit 56c952f

Browse files
authored
Merge pull request #898 from TG1999/case_insensitive_search
Allow case insensitive search for VCIDs #875
2 parents 9f89bca + d36f12d commit 56c952f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# VulnerableCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/vulnerablecode for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
from django.test import TestCase
11+
12+
from vulnerabilities.forms import CVEForm
13+
from vulnerabilities.models import Vulnerability
14+
15+
16+
class TestCVEForm(TestCase):
17+
def setUp(self) -> None:
18+
vuln1 = Vulnerability.objects.create(summary="test-vuln1", vulnerability_id="VCID-1234")
19+
self.id = vuln1.id
20+
21+
def test_cve_form(self):
22+
form = CVEForm(data={"vuln_id": "vcid-1234"})
23+
assert form.is_valid()
24+
25+
def test_client(self):
26+
response = self.client.get(f"/vulnerabilities/{self.id}?vuln_id=vcid-1234")
27+
self.assertContains(response, "test-vuln1", status_code=200)

vulnerabilities/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def request_to_vulnerabilities(request):
199199
vuln_id = request.GET["vuln_id"]
200200
return list(
201201
models.Vulnerability.objects.filter(
202-
Q(vulnerability_id=vuln_id) | Q(aliases__alias__icontains=vuln_id)
202+
Q(vulnerability_id__iexact=vuln_id) | Q(aliases__alias__icontains=vuln_id)
203203
)
204204
.order_by("vulnerability_id")
205205
.annotate(

0 commit comments

Comments
 (0)