Skip to content

Commit 1b01004

Browse files
committed
test: add coverage for truncated reference_id
1 parent 2408be8 commit 1b01004

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

vulnerabilities/tests/pipelines/test_enhance_with_exploitdb.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,29 @@ def test_invalid_exploit_db_improver(mock_get):
6060
status, _ = improver.execute()
6161
assert status == 0
6262
assert Exploit.objects.count() == 0
63+
@pytest.mark.django_db
64+
@mock.patch("requests.get")
65+
def test_reference_id_is_truncated_with_ellipsis(mock_get):
66+
mock_response = Mock(status_code=200)
67+
68+
with open(TEST_DATA, "r") as f:
69+
data = f.read()
70+
71+
# make long exploit id/reference text
72+
data = data.replace("CVE-2009-3699", "A" * 300)
73+
74+
mock_response.text = data
75+
mock_get.return_value = mock_response
76+
77+
v1 = Vulnerability.objects.create(vulnerability_id="VCIO-123-2002")
78+
v1.save()
79+
80+
Alias.objects.create(alias="A" * 300, vulnerability=v1)
81+
82+
improver = ExploitDBImproverPipeline()
83+
improver.execute()
84+
85+
exploit = Exploit.objects.first()
86+
assert exploit is not None
87+
assert len(exploit.reference_id) <= 200
88+
assert exploit.reference_id.endswith("...")

0 commit comments

Comments
 (0)