@@ -218,6 +218,7 @@ describe('securityViewUtils', () => {
218218 expect ( toSafeExternalUrl ( 'javascript:alert(1)' ) ) . toBeNull ( ) ;
219219 expect ( toSafeExternalUrl ( 'ftp://example.com' ) ) . toBeNull ( ) ;
220220 expect ( toSafeExternalUrl ( 'data:text/html,<h1>hi</h1>' ) ) . toBeNull ( ) ;
221+ expect ( toSafeExternalUrl ( 'file:///etc/passwd' ) ) . toBeNull ( ) ;
221222 } ) ;
222223
223224 it ( 'returns null for invalid URLs' , ( ) => {
@@ -240,15 +241,17 @@ describe('securityViewUtils', () => {
240241 } ;
241242
242243 it ( 'returns only header row for empty array' , ( ) => {
243- expect ( vulnReportToCsv ( [ ] ) ) . toBe ( 'ID,Severity,Package,Version,Fixed In,Title,Target,URL' ) ;
244+ expect ( vulnReportToCsv ( [ ] ) ) . toBe (
245+ '"ID","Severity","Package","Version","Fixed In","Title","Target","URL"' ,
246+ ) ;
244247 } ) ;
245248
246249 it ( 'formats a single vulnerability as CSV' , ( ) => {
247250 const csv = vulnReportToCsv ( [ baseVuln ] ) ;
248251 const lines = csv . split ( '\n' ) ;
249252 expect ( lines ) . toHaveLength ( 2 ) ;
250253 expect ( lines [ 1 ] ) . toBe (
251- 'CVE-2026-1234, HIGH, openssl, 1.1.1, 1.1.2, Buffer overflow, usr/lib/libssl.so, https://nvd.nist.gov/vuln/detail/CVE-2026-1234' ,
254+ '" CVE-2026-1234"," HIGH"," openssl"," 1.1.1"," 1.1.2"," Buffer overflow"," usr/lib/libssl.so"," https://nvd.nist.gov/vuln/detail/CVE-2026-1234" ' ,
252255 ) ;
253256 } ) ;
254257
@@ -262,7 +265,7 @@ describe('securityViewUtils', () => {
262265 } ;
263266 const csv = vulnReportToCsv ( [ vuln ] ) ;
264267 const lines = csv . split ( '\n' ) ;
265- expect ( lines [ 1 ] ) . toBe ( 'CVE-2026-1234, HIGH, openssl, 1.1.1,,,, ' ) ;
268+ expect ( lines [ 1 ] ) . toBe ( '" CVE-2026-1234"," HIGH"," openssl"," 1.1.1","","","","" ' ) ;
266269 } ) ;
267270
268271 it ( 'escapes fields containing commas and quotes' , ( ) => {
@@ -290,7 +293,22 @@ describe('securityViewUtils', () => {
290293 const lines = csv . split ( '\n' ) ;
291294
292295 expect ( lines [ 1 ] ) . toBe (
293- "'=CVE-2026-1234,'+HIGH,'-openssl,'@1.1.1,1.1.2,Buffer overflow,usr/lib/libssl.so,https://nvd.nist.gov/vuln/detail/CVE-2026-1234" ,
296+ `"'=CVE-2026-1234","'+HIGH","'-openssl","'@1.1.1","1.1.2","Buffer overflow","usr/lib/libssl.so","https://nvd.nist.gov/vuln/detail/CVE-2026-1234"` ,
297+ ) ;
298+ } ) ;
299+
300+ it ( 'prefixes tab-leading fields and escapes embedded quotes' , ( ) => {
301+ const vuln : Vulnerability = {
302+ ...baseVuln ,
303+ id : '\t=cmd' ,
304+ title : 'Buffer "overflow"' ,
305+ } ;
306+
307+ const csv = vulnReportToCsv ( [ vuln ] ) ;
308+ const lines = csv . split ( '\n' ) ;
309+
310+ expect ( lines [ 1 ] ) . toBe (
311+ '"\'\t=cmd","HIGH","openssl","1.1.1","1.1.2","Buffer ""overflow""","usr/lib/libssl.so","https://nvd.nist.gov/vuln/detail/CVE-2026-1234"' ,
294312 ) ;
295313 } ) ;
296314 } ) ;
0 commit comments