Class RiskCalculation
java.lang.Object
be.kuleuven.cs.distrinet.sparta.core.analysis.RiskCalculation
RiskAssessment class containing a number of static risk calculation methods
to assist in performing a threat's risk calculation.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]aggregateAvgMatrix(double[][][][] matrix, double[][][] applicabilityMatrix) This method reduces an four dimensional matrix (with the fourth dimension containing [lower,expected,upper], to a three value array containing the average of, respectively, the lower, expected, and upper values.static double[]aggregateMatrix(double[][][][] matrix) This method reduces an four dimensional matrix (with the fourth dimension containing [lower,expected,upper], to a three value array containing the sum of, respectively, the lower, expected, and upper values.static double[]calculateBoundaries(double[] tef) static double[][]calculateLefArray(double[] tefSamples, double[] vulnerabilityConfidenceInterval, int samples) Calculate the loss event frequency (LEF = TEF x vulnerability) per sample, for each bound of the vulnerability interval:result[i][s] = tefSamples[s] * vulnerabilityConfidenceInterval[i], soresult[0],result[1]andresult[2]are the LEF samples at the lower, expected and upper vulnerability.static double[]calculateTefArray(ThreatType tt, AttackerProfile attackerType, int samples) Calculate the threat event frequency.static doublecalculateVulnerability(double[] vulnerability) Calculate the vulnerability from a (binary) vector of attack success/failuresstatic double[]calculateVulnerabilityArray(DFDElement threatenedElement, DataFlow flow, ThreatType tt, List<RoleBinding> countermeasureBindings, AttackerProfile attacker, int samples) Calculate the vulnerability for flow, threattype, countermeasures and attacker profilestatic double[]calculateVulnerabilityConfidenceInterval(double[] vulnerability) Calculate the Clopper-Pearson vulnerability confidence intervalstatic double[]getSamplesFromNullableNeutral(Estimate estimate, int n) Get n samples from an estimate distribution.static double[]getSamplesFromNullableZero(Estimate estimate, int n) Get n samples from an estimate distribution.static double[]identity(int n) Get n identity samples (all 1).static booleanisInScope(CounterMeasure cm, DataFlow flow) Whether a countermeasure applies in the context of the given data flow: it has no scope, or the flow is bound to one of the roles in its scope.static booleanmitigates(CounterMeasure cm, ThreatType tt) Whether a countermeasure mitigates the given threat type: either it references the type (or a composite containing it) throughmitigates, or one of itsmitigatedThreatTypeIDs is the id of the type or one of its super types.static List<Mitigation> mitigations(DataFlow flow, ThreatType tt, List<RoleBinding> countermeasureBindings) The countermeasures that reduce the vulnerability of a threat, each with the role binding it applies through: those subjected to a bound role thatmitigates(be.kuleuven.cs.distrinet.sparta.spartamodel.CounterMeasure, be.kuleuven.cs.distrinet.sparta.spartamodel.ThreatType)the threat type and arein scopeof the flow.
-
Method Details
-
calculateVulnerability
public static double calculateVulnerability(double[] vulnerability) Calculate the vulnerability from a (binary) vector of attack success/failures- Parameters:
vulnerability- binary victor indicating an attacks success or failure- Returns:
- Single vulnerability number
-
calculateVulnerabilityConfidenceInterval
public static double[] calculateVulnerabilityConfidenceInterval(double[] vulnerability) Calculate the Clopper-Pearson vulnerability confidence interval- Parameters:
vulnerability- binary vector indicating an attacks success or failure- Returns:
- double[] containing {lower, expected, upper}
-
calculateBoundaries
public static double[] calculateBoundaries(double[] tef) - Parameters:
tef- frequency array- Returns:
- double[] containing {min, average, max}
-
calculateTefArray
Calculate the threat event frequency. This depends on the contact frequency and the probability of action. The contact frequency depends on the AttackerType. The probability of action depends on the AttackerType These values could be scaled according to theThreatType, for example an attacker may be more likely to attempt an denial of service. This is currently not implemented.- Parameters:
tt- - the threat typeattackerType- - the attacker profilesamples- - the number of samples to use- Returns:
- the threat event frequency array
-
calculateVulnerabilityArray
public static double[] calculateVulnerabilityArray(DFDElement threatenedElement, DataFlow flow, ThreatType tt, List<RoleBinding> countermeasureBindings, AttackerProfile attacker, int samples) Calculate the vulnerability for flow, threattype, countermeasures and attacker profile- Parameters:
threatenedElement- - the threatened DFDElementflow- - the data flow (for the context in which the threat applies)tt- - the threat typecountermeasureBindings- - list of bound countermeasuresattacker- - the attacker profilesamples- - the number of samples to use- Returns:
- binary vulnerability array double[SAMPLES]
-
mitigations
public static List<Mitigation> mitigations(DataFlow flow, ThreatType tt, List<RoleBinding> countermeasureBindings) The countermeasures that reduce the vulnerability of a threat, each with the role binding it applies through: those subjected to a bound role thatmitigates(be.kuleuven.cs.distrinet.sparta.spartamodel.CounterMeasure, be.kuleuven.cs.distrinet.sparta.spartamodel.ThreatType)the threat type and arein scopeof the flow. This is the single definition of the selection used by the vulnerability calculation; it does not depend on the attacker (an insider attacker ignores them, seecalculateVulnerabilityArray(be.kuleuven.cs.distrinet.sparta.spartamodel.DFDElement, be.kuleuven.cs.distrinet.sparta.spartamodel.DataFlow, be.kuleuven.cs.distrinet.sparta.spartamodel.ThreatType, java.util.List<be.kuleuven.cs.distrinet.sparta.spartamodel.RoleBinding>, be.kuleuven.cs.distrinet.sparta.spartamodel.AttackerProfile, int)).- Parameters:
flow- - the data flow the threat applies to (may be null)tt- - the threat typecountermeasureBindings- - the role bindings on the threatened element- Returns:
- the mitigations, in binding order
-
mitigates
Whether a countermeasure mitigates the given threat type: either it references the type (or a composite containing it) throughmitigates, or one of itsmitigatedThreatTypeIDs is the id of the type or one of its super types.- Parameters:
cm- - the countermeasurett- - the (leaf) threat type- Returns:
- true if cm mitigates tt
-
isInScope
Whether a countermeasure applies in the context of the given data flow: it has no scope, or the flow is bound to one of the roles in its scope.- Parameters:
cm- - the countermeasureflow- - the data flow the threat applies to (may be null)- Returns:
- true if cm applies to flow
-
calculateLefArray
public static double[][] calculateLefArray(double[] tefSamples, double[] vulnerabilityConfidenceInterval, int samples) Calculate the loss event frequency (LEF = TEF x vulnerability) per sample, for each bound of the vulnerability interval:result[i][s] = tefSamples[s] * vulnerabilityConfidenceInterval[i], soresult[0],result[1]andresult[2]are the LEF samples at the lower, expected and upper vulnerability.Not used by
SpartaRiskModel, which multiplies the TEF interval (calculateBoundaries(double[])) by the vulnerability interval directly. Reducingresult[0],result[1]andresult[2]with min, average and max respectively gives that same interval (the vulnerability bounds are non-negative constants); this method additionally keeps the full LEF sample distribution, e.g. for percentiles or histograms.- Parameters:
tefSamples- - the threat event frequency samplesvulnerabilityConfidenceInterval- - the vulnerability {lower, expected, upper}samples- - the number of samples; must equaltefSamples.length- Returns:
double[3][samples]: the LEF samples at the lower, expected and upper vulnerability (not a confidence interval)
-
aggregateMatrix
public static double[] aggregateMatrix(double[][][][] matrix) This method reduces an four dimensional matrix (with the fourth dimension containing [lower,expected,upper], to a three value array containing the sum of, respectively, the lower, expected, and upper values.- Parameters:
matrix-- Returns:
-
aggregateAvgMatrix
public static double[] aggregateAvgMatrix(double[][][][] matrix, double[][][] applicabilityMatrix) This method reduces an four dimensional matrix (with the fourth dimension containing [lower,expected,upper], to a three value array containing the average of, respectively, the lower, expected, and upper values. To prevent averaging with 0 values for entries for which there is actually NA, the applicabilityMatrix for the same index. This means that only entries matrix[i][j][k] are averaged for which applicabilityMatrix[i][j][k]!=0- Parameters:
matrix-applicabilityMatrix-- Returns:
-
getSamplesFromNullableNeutral
Get n samples from an estimate distribution. In case of null, samples are all 1.- Parameters:
estimate- the estimate for which samples have to be calculatedn- the number of samples- Returns:
- the samples themselves
-
getSamplesFromNullableZero
Get n samples from an estimate distribution. In case of null, samples are all 0.- Parameters:
estimate- the estimate for which samples have to be calculatedn- the number of samples- Returns:
- the samples themselves
-
identity
public static double[] identity(int n) Get n identity samples (all 1).- Parameters:
n- the number of samples- Returns:
- the samples themselves
-