Skip to content

Commit ad39705

Browse files
Added severity to markdown report and convert to proper commonmark
1 parent 77a1342 commit ad39705

File tree

2 files changed

+60
-78
lines changed

2 files changed

+60
-78
lines changed

src/server/__tests__/server.test.js

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -326,62 +326,38 @@ it('Download threat file', async () => {
326326
expect(response.text).toBe(`Threats ${date}
327327
=======
328328
329-
**1. title**
330-
331-
- *Author:* Player 1
332-
333-
- *Description:* <img src="" onerror="alert\\('XSS'\\) alt="Uh oh...">
334-
335-
- *Mitigation:* mitigation
336-
337-
338-
**2. title**
339-
340-
- *Author:* Player 1
341-
342-
- *Description:* description
343-
344-
- *Mitigation:* mitigation
345-
346-
347-
**3. title**
348-
349-
- *Author:* Player 1
350-
351-
- *Description:* description
352-
353-
- *Mitigation:* mitigation
354-
355-
356-
**4. Accessing DB credentials**
357-
358-
- *Description:* The Background Worker configuration stores the credentials used by the worker to access the DB. An attacker could compromise the Background Worker and get access to the DB credentials.
359-
360-
- *Mitigation:* \\[Click Me\\]\\(javascript:alert\\('XSS'\\)\\)
361-
362-
363-
**5. Unauthorised access**
364-
365-
- *Description:* An attacker could make an query call on the DB,
366-
367-
- *Mitigation:* Require all queries to be authenticated.
368-
369-
370-
**6. Credential theft**
371-
372-
- *Author:* The Model
373-
374-
- *Description:* An attacker could obtain the DB credentials ans use them to make unauthorised queries.
375-
376-
- *Mitigation:* Use a firewall to restrict access to the DB to only the Background Worker IP address.
377-
378-
379-
**7. \\!\\[Uh oh...\\]\\(https://www.example.com/image.png"onload="alert\\('XSS'\\)\\)**
380-
381-
- *Description:* The Web Application Config stores credentials used by the Web App to access the message queue. These could be stolen by an attacker and used to read confidential data or place poison message on the queue.
382-
383-
- *Mitigation:* The Message Queue credentials should be encrypted. newlines shouldn't break the formatting
384-
329+
1. **title**
330+
- *Severity:* High
331+
- *Author:* Player 1
332+
- *Description:* <img src="" onerror="alert\\('XSS'\\) alt="Uh oh...">
333+
- *Mitigation:* mitigation
334+
2. **title**
335+
- *Severity:* High
336+
- *Author:* Player 1
337+
- *Description:* description
338+
- *Mitigation:* mitigation
339+
3. **title**
340+
- *Severity:* High
341+
- *Author:* Player 1
342+
- *Description:* description
343+
- *Mitigation:* mitigation
344+
4. **Accessing DB credentials**
345+
- *Severity:* High
346+
- *Description:* The Background Worker configuration stores the credentials used by the worker to access the DB. An attacker could compromise the Background Worker and get access to the DB credentials.
347+
- *Mitigation:* \\[Click Me\\]\\(javascript:alert\\('XSS'\\)\\)
348+
5. **Unauthorised access**
349+
- *Severity:* High
350+
- *Description:* An attacker could make an query call on the DB,
351+
- *Mitigation:* Require all queries to be authenticated.
352+
6. **Credential theft**
353+
- *Severity:* Medium
354+
- *Author:* The Model
355+
- *Description:* An attacker could obtain the DB credentials ans use them to make unauthorised queries.
356+
- *Mitigation:* Use a firewall to restrict access to the DB to only the Background Worker IP address.
357+
7. **\\!\\[Uh oh...\\]\\(https://www.example.com/image.png"onload="alert\\('XSS'\\)\\)**
358+
- *Severity:* High
359+
- *Description:* The Web Application Config stores credentials used by the Web App to access the message queue. These could be stolen by an attacker and used to read confidential data or place poison message on the queue.
360+
- *Mitigation:* The Message Queue credentials should be encrypted. newlines shouldn't break the formatting
385361
`);
386362
});
387363

src/server/endpoints.js

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -277,32 +277,38 @@ function getThreats(gameState, metadata, model) {
277277
function formatThreats(threats, date) {
278278
return `Threats ${date}
279279
=======
280+
280281
${threats
281282
.map(
282-
(threat, index) => `
283-
**${index + 1}. ${escapeMarkdownText(threat.title.trim())}**
284-
${
285-
'owner' in threat
286-
? `
287-
- *Author:* ${escapeMarkdownText(threat.owner)}
288-
`
289-
: ''
290-
}
291-
- *Description:* ${
292-
escapeMarkdownText(
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(
293298
threat.description.replace(/(\r|\n)+/gm, ' '),
294-
) /* Stops newlines breaking md formatting */
295-
}
296-
297-
${
298-
threat.mitigation !== `No mitigation provided.`
299-
? ` - *Mitigation:* ${escapeMarkdownText(
300-
threat.mitigation.replace(/(\r|\n)+/gm, ' '),
301-
)}
302-
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+
: `
303310
`
304-
: ''
305-
}`,
311+
}`,
306312
)
307313
.join('')}`;
308314
}

0 commit comments

Comments
 (0)