-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#7 revamping likelihood and risk system
- Loading branch information
1 parent
683c8c7
commit 631e8cc
Showing
11 changed files
with
418 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...iskMatrixLogic/calculateLikelihood/calculateAttackEfficiency/calculateAttackEfficiency.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* | ||
* @param {string} protectionWeakness The protection weakness (see calculateProtectionWeakness) | ||
* @returns {string} The attack efficiency | ||
*/ | ||
export const calculateAttackEfficiency = (protectionWeakness) => { | ||
return protectionWeakness; | ||
}; |
21 changes: 21 additions & 0 deletions
21
...trixLogic/calculateLikelihood/calculateAttackEfficiency/calculateAttackEfficiency.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { calculateAttackEfficiency } from "./calculateAttackEfficiency"; | ||
|
||
describe("testing the calculateAttackEfficiency function", () => { | ||
it("should return High if the protectionWeakness is High", () => { | ||
const expectValue = "High"; | ||
const protectionWeakness = "High"; | ||
expect(calculateAttackEfficiency(protectionWeakness)).toBe(expectValue); | ||
}); | ||
|
||
it("should return Medium if the protectionWeakness is Medium", () => { | ||
const expectValue = "Medium"; | ||
const protectionWeakness = "Medium"; | ||
expect(calculateAttackEfficiency(protectionWeakness)).toBe(expectValue); | ||
}); | ||
|
||
it("should return Low if the protectionWeakness is Low", () => { | ||
const expectValue = "Low"; | ||
const protectionWeakness = "Low"; | ||
expect(calculateAttackEfficiency(protectionWeakness)).toBe(expectValue); | ||
}); | ||
}); |
110 changes: 2 additions & 108 deletions
110
...eatures/BinaryRiskMatrix/BinaryRiskMatrixLogic/calculateLikelihood/calculateLikelihood.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,4 @@ | ||
/** | ||
* | ||
* @param {boolean[]} values The users selected values for the questions in the binary risk matrix. | ||
* @returns {string} The threat likelihood. | ||
*/ | ||
export const calculateLikelihood = (values) => { | ||
const threatScore = calculateThreatScope(values[0], values[1]); | ||
const protectionWeakness = calculateProtectionWeakness( | ||
threatScore, | ||
values[2], | ||
values[3] | ||
); | ||
const attackEfficiency = calculateAttackEfficiency(protectionWeakness); | ||
const occurrence = calculateOccurrence( | ||
attackEfficiency, | ||
values[4], | ||
values[5] | ||
); | ||
|
||
export const calculateLikelihood = (occurrence) => { | ||
const threatLikelihood = occurrence; | ||
const likelihoodResults = [ | ||
threatScore, | ||
protectionWeakness, | ||
attackEfficiency, | ||
occurrence, | ||
threatLikelihood, | ||
]; | ||
return likelihoodResults; | ||
}; | ||
|
||
/** | ||
* | ||
* @param {boolean} Q1 The users answer for Q1. | ||
* @param {boolean} Q2 The users answer for Q2. | ||
* @returns {string} The threat scope | ||
*/ | ||
export const calculateThreatScope = (Q1, Q2) => { | ||
if (Q1 === true && Q2 === true) { | ||
return "High"; | ||
} else { | ||
if (Q1 === true || Q2 === true) { | ||
return "Medium"; | ||
} else { | ||
return "Low"; | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* | ||
* @param {string} threatScore | ||
* @param {boolean} Q3 | ||
* @param {boolean} Q4 | ||
* @returns {string} The protection weakness | ||
*/ | ||
export const calculateProtectionWeakness = (threatScore, Q3, Q4) => { | ||
if (Q3 === true && Q4 === true) { | ||
if (threatScore === "Low") { | ||
return "Medium"; | ||
} else { | ||
return "High"; | ||
} | ||
} else { | ||
if (Q3 === true || Q4 === true) { | ||
return threatScore; | ||
} else { | ||
if (threatScore === "High") { | ||
return "Medium"; | ||
} else { | ||
return "Low"; | ||
} | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* | ||
* @param {string} protectionWeakness The protection weakness (see calculateProtectionWeakness) | ||
* @returns {string} The attack efficiency | ||
*/ | ||
export const calculateAttackEfficiency = (protectionWeakness) => { | ||
return protectionWeakness; | ||
}; | ||
|
||
/** | ||
* | ||
* @param {string} attackEfficiency The attack efficiency | ||
* @param {boolean} Q5 The answer to Q5. | ||
* @param {boolean} Q6 The answer to Q6. | ||
* @returns {string} The threat occurrence | ||
*/ | ||
export const calculateOccurrence = (attackEfficiency, Q5, Q6) => { | ||
if (Q5 === true && Q6 === true) { | ||
if (attackEfficiency === "Low") { | ||
return "Medium"; | ||
} else { | ||
return "High"; | ||
} | ||
} else { | ||
if (Q5 === true || Q6 === true) { | ||
return attackEfficiency; | ||
} else { | ||
if (attackEfficiency === "High") { | ||
return "Medium"; | ||
} else { | ||
return "Low"; | ||
} | ||
} | ||
} | ||
return threatLikelihood; | ||
}; |
Oops, something went wrong.