@@ -278,37 +278,41 @@ function formatThreats(threats, date) {
278278  return  `Threats ${ date }  
279279======= 
280280
281- ${ threats 
282-   . map (  
283-     ( threat ,  index )  =>  
284-       `${ index  +  1 } ${ escapeMarkdownText ( threat . title . trim ( ) ) } ${   
285-         'severity'  in  threat  
286-           ? `  
287-     - *Severity:* ${ escapeMarkdownText ( threat . severity ) }  
288-           : ``  
289-       }  ${ 
290-         'owner'  in  threat  
291-           ? `  
292-     - *Author:* ${ escapeMarkdownText ( threat . owner ) }  
293-           : ``  
294-       }  ${ 
295-         'description'  in  threat  
296-           ? `  
297-     - *Description:* ${ escapeMarkdownText (  
298-       threat . description . replace ( / ( \r | \n ) + / gm,  ' ' ) ,  
299-     ) }  `
300-           : ``  
301-       }  ${ 
302-         'mitigation'  in  threat  &&  
303-         threat . mitigation  !==  `No mitigation provided.`  
304-           ? `  
305-     - *Mitigation:* ${ escapeMarkdownText (  
306-       threat . mitigation . replace ( / ( \r | \n ) + / gm,  ' ' ) ,  
307-     ) }  
308- ` 
309-           : `  
310- ` 
311-       }  `, 
312-   )  
313-   . join ( '' ) }  `; 
281+ ${ threats . map ( formatSingleThreat ) . join ( '\n' ) } 
282+ ` ; 
283+ } 
284+ 
285+ function  formatSingleThreat ( threat ,  index )  { 
286+   const  lines  =  [ 
287+     `${ index  +  1 } ${ escapeMarkdownText ( threat . title . trim ( ) ) }  , 
288+   ] ; 
289+ 
290+   if  ( 'severity'  in  threat )  { 
291+     lines . push ( `    - *Severity:* ${ escapeMarkdownText ( threat . severity ) }  ) ; 
292+   } 
293+ 
294+   if  ( 'owner'  in  threat )  { 
295+     lines . push ( `    - *Author:* ${ escapeMarkdownText ( threat . owner ) }  ) ; 
296+   } 
297+ 
298+   if  ( 'description'  in  threat )  { 
299+     lines . push ( 
300+       `    - *Description:* ${ escapeMarkdownText (  
301+         threat . description . replace ( / ( \r | \n ) + / gm,  ' ' ) ,  
302+       ) }  `, 
303+     ) ; 
304+   } 
305+ 
306+   if  ( 
307+     'mitigation'  in  threat  && 
308+     threat . mitigation  !==  `No mitigation provided.` 
309+   )  { 
310+     lines . push ( 
311+       `    - *Mitigation:* ${ escapeMarkdownText (  
312+         threat . mitigation . replace ( / ( \r | \n ) + / gm,  ' ' ) ,  
313+       ) }  `, 
314+     ) ; 
315+   } 
316+ 
317+   return  lines . join ( '\n' ) ; 
314318} 
0 commit comments