@@ -290,6 +290,7 @@ async function createNote({ trigger, foam, resolver, foamDate }) {
290290 }
291291 }
292292
293+ // 1. Hosts Information
293294 let hostInformation = hostNoteList . map ( ( hostMeta ) => {
294295 return `## Host: ${ hostMeta . title }
295296
@@ -300,10 +301,7 @@ content-inline![[${getId(hostMeta.uri)}]]
300301 let attackPath = longestReferencePath ( Array . from ( graph . userEdges ) ) ;
301302 let extraNotePath = checkArrayDiffElements ( attackPath , userList ) ;
302303
303- let userInformation = [
304- "## Attack Path" ,
305- ""
306- ] ;
304+ // 2. Users Information with Attack Path
307305 let attackNotes = attackPath . map ( ( userPath , index ) => {
308306 let userMeta = graph . nodeInfo [ userPath ] ;
309307 if ( ! userMeta ) {
@@ -324,25 +322,27 @@ content-inline![[${getId(userMeta.uri)}]]
324322 }
325323 return `### User ${ userMeta . title } ` + currentNote ;
326324 } ) ;
327- userInformation = userInformation . concat ( attackNotes ) ;
325+ // userInformation = userInformation.concat(attackNotes);
328326
329- userInformation . push ( "## Extra Users" , "" ) ;
327+ // 3. Users Information - Extra Users not in attack path
328+ // userInformation.push("## Extra Users", "");
330329
331- let extraNotes = extraNotePath . forEach ( ( path ) => {
330+ let extraNotes = extraNotePath . map ( ( path ) => {
332331 let userMeta = graph . nodeInfo [ path ] ;
333332 if ( ! userMeta ) {
334333 return `> Note with path ${ path } not found in graph.` ;
335334 }
336335 if ( userMeta . type !== "user" ) {
337336 return `> Note with path ${ path } is not a user type.` ;
338337 }
339- userInformation . push ( `### User: ${ userMeta . title }
338+ return `### User: ${ userMeta . title }
340339
341- ![[${ getId ( userMeta . uri ) } ]]
342- ` ) ;
340+ content-inline ![[${ getId ( userMeta . uri ) } ]]
341+ ` ;
343342 } ) ;
344- userInformation . concat ( extraNotes ) ;
343+ // userInformation.concat(extraNotes);
345344
345+ // 4. Generate Mermaid graph for Users based attack path
346346 let grapher = calcTheMermaid ( foam , graph ) ;
347347 console . log ( "Grapher:" , grapher ) ;
348348
@@ -355,16 +355,23 @@ content-inline![[${getId(userMeta.uri)}]]
355355 mermaidDiagram = "```mermaid\n" + mermaidDiagram + "```" ;
356356 console . log ( "Mermaid Diagram:" , mermaidDiagram ) ;
357357
358-
358+ // 5. Final assembly in order
359359 let body = `${ meta }
360360## Hosts Information
361361
362362${ hostInformation . join ( "\n" ) }
363363
364- ## Users Relation graph
364+ ## Full Relations graph
365365${ mermaidDiagram }
366366
367- ${ userInformation . join ( "\n" ) }
367+ ## Privilege Escalation Path
368+
369+ ${ attackNotes . join ( "\n" ) }
370+
371+ ## Extra Pwned Users
372+
373+ ${ extraNotes . join ( "\n" ) }
374+
368375` ;
369376
370377 console . log ( "attack path:" , attackPath ) ;
0 commit comments