java.lang.Object
be.kuleuven.cs.distrinet.sparta.core.model.Threat
All Implemented Interfaces:
IInteractionThreat, IThreat
Direct Known Subclasses:
ObservableThreat, PatternThreat

public class Threat extends Object implements IThreat, IInteractionThreat
Class representing a security or privacy threat instance. This class requires a IPatternMatch from which the required information is retrieved to populate the threat's properties.
  • Field Details

    • riskModel

      protected final IRiskModel riskModel
    • patternMatch

      protected final org.eclipse.viatra.query.runtime.api.IPatternMatch patternMatch
    • threatenedElement

      protected DFDElement threatenedElement
    • threatType

      protected ThreatType threatType
    • matchType

      protected String matchType
    • dataFlow

      protected DataFlow dataFlow
    • message

      protected String message
    • nf

      protected final NumberFormat nf
  • Constructor Details

    • Threat

      protected Threat(org.eclipse.viatra.query.runtime.api.IPatternMatch match, IRiskModel model)
    • Threat

      public Threat(org.eclipse.viatra.query.runtime.api.IPatternMatch x)
      Create a new Threat instance.
      Parameters:
      x - the IPatternMatch from which the required information is retrieved to populate the threat's properties.
  • Method Details

    • getPatternMatch

      public org.eclipse.viatra.query.runtime.api.IPatternMatch getPatternMatch()
    • getThreatenedElement

      public DFDElement getThreatenedElement()
    • getThreatType

      public ThreatType getThreatType()
    • getMatchType

      public String getMatchType()
    • getDataFlow

      public DataFlow getDataFlow()
    • getDataFlowFrom

      public ModelElement getDataFlowFrom()
    • getDataFlowTo

      public ModelElement getDataFlowTo()
    • getMessage

      public String getMessage()
    • isRiskCalculated

      public boolean isRiskCalculated()
      Returns:
      whether this threat's risk has been calculated, i.e. whether the risk getters (getRisk(), getVulnerability(), ...) return values instead of throwing. False when the calculation was skipped, see performRiskCalculation(be.kuleuven.cs.distrinet.sparta.core.analysis.RiskAssessmentLoopConfiguration).
    • getVulnerability

      public Double getVulnerability()
      Specified by:
      getVulnerability in interface IThreat
    • getVulnerability_lower

      public Double getVulnerability_lower()
    • getVulnerability_upper

      public Double getVulnerability_upper()
    • getRisk

      public Double getRisk()
      Specified by:
      getRisk in interface IThreat
    • getRisk_lower

      public Double getRisk_lower()
    • getRisk_upper

      public Double getRisk_upper()
    • getPotentialRisk

      public Double getPotentialRisk()
      Specified by:
      getPotentialRisk in interface IThreat
    • getSle

      public Double getSle()
    • getTef

      public Double getTef()
    • getLef

      public Double getLef()
    • getMitigations

      public List<Mitigation> getMitigations()
      Returns:
      the countermeasures the risk calculation applied to this threat, with the role bindings (and hence solutions) they apply through
    • getModelElement

      protected ModelElement getModelElement(String propertyName)
    • getDataFlowElement

      protected DataFlow getDataFlowElement()
    • getThreatTypeElement

      protected ThreatType getThreatTypeElement()
    • simpleTypeName

      public static String simpleTypeName(Object element)
      Human-readable model type name of an element: the simple class name with the EMF-generated "Impl" suffix stripped, e.g. ProcessImpl -> "Process". Names that do not end in "Impl" are returned unchanged.
      Parameters:
      element - the model element (must not be null)
      Returns:
      the simple class name without a trailing "Impl"
    • typeAbbreviation

      protected static String typeAbbreviation(Object element)
      Abbreviated element type for match-type labels, e.g. ProcessImpl -> "P", DataStoreImpl -> "DS", ExternalEntityImpl -> "EE". Null-safe ("?" for an unresolved reference).
    • buildMatchTypeLabel

      protected String buildMatchTypeLabel()
      Build the match-type label describing the shape of the matched interaction, e.g. "P-DF*->EE": the sender and recipient type abbreviations around the data flow, with * marking the threatened element. Requires dataFlow and threatenedElement to be set.
      Returns:
      the match-type label
    • performRiskCalculation

      public void performRiskCalculation(RiskAssessmentLoopConfiguration loopConfiguration)
      Perform Risk calculation Overall formula: LEF x LM When the threat has no threatened element the calculation is skipped; any subsequent read of a risk figure then throws an IllegalStateException (see SpartaRiskModel) rather than an opaque NullPointerException.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDataFlowName

      public String getDataFlowName()
      Specified by:
      getDataFlowName in interface IInteractionThreat
    • getDataFlowFromName

      public String getDataFlowFromName()
      Specified by:
      getDataFlowFromName in interface IInteractionThreat
    • getDataFlowToName

      public String getDataFlowToName()
      Specified by:
      getDataFlowToName in interface IInteractionThreat
    • getThreatTypeName

      public String getThreatTypeName()
      Specified by:
      getThreatTypeName in interface IThreat
    • getThreatenedElementName

      public String getThreatenedElementName()
      Specified by:
      getThreatenedElementName in interface IThreat
    • getThreatenedElementTypeName

      public String getThreatenedElementTypeName()
      Specified by:
      getThreatenedElementTypeName in interface IThreat
    • getThreatenedElementId

      public String getThreatenedElementId()
      Specified by:
      getThreatenedElementId in interface IThreat
    • getThreatName

      public String getThreatName()
      Specified by:
      getThreatName in interface IThreat
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface IThreat