File tree Expand file tree Collapse file tree
vulnerabilities/tests/pipelines Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ("..." )
You can’t perform that action at this time.
0 commit comments