Class ObservableThreat

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

public class ObservableThreat extends Threat
Observable threat which contains the threat data to enable automatic updating in SPARTA's threat analysis views.

Threading model: all WritableValues are explicitly bound to the SWT display realm (rather than the constructing thread's default realm, which only exists on the display thread), so instances can be constructed on any thread. In the normal flow the ThreatAnalysisService builds its databinding graph on the UI thread, so conversion - and therefore construction and the initial value population - happens on the realm; VIATRA may however deliver later match updates on other threads, so every value mutation goes through setOnRealm(WritableValue, Object), which applies it directly when on the realm and via Realm.asyncExec otherwise. Getters are meant for the UI thread (JFace bindings and label providers).

Because off-realm mutations are queued while on-realm ones apply immediately, a value written from both sides could otherwise be overwritten by an older queued write. The risk figures of one risk calculation are therefore published together, and a queued publication is dropped once a newer calculation has been published.

  • Field Details

    • threatenedElementName

      protected org.eclipse.core.databinding.observable.value.WritableValue<String> threatenedElementName
    • threatName

      protected org.eclipse.core.databinding.observable.value.WritableValue<String> threatName
    • threatTypeName

      protected org.eclipse.core.databinding.observable.value.WritableValue<String> threatTypeName
    • flowName

      protected org.eclipse.core.databinding.observable.value.WritableValue<String> flowName
    • message

      protected org.eclipse.core.databinding.observable.value.WritableValue<String> message
    • vulnerability

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> vulnerability
    • vulnerability_lower

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> vulnerability_lower
    • vulnerability_upper

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> vulnerability_upper
    • risk

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> risk
    • risk_lower

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> risk_lower
    • risk_upper

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> risk_upper
    • potentialRisk

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> potentialRisk
    • sle

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> sle
    • tef

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> tef
    • lef

      protected org.eclipse.core.databinding.observable.value.WritableValue<Double> lef
    • loopConfiguration

      protected RiskAssessmentLoopConfiguration loopConfiguration
      Loop configuration owned by the analysing engine; used to drive the risk calculation.
    • sender

      protected String sender
    • recipient

      protected String recipient
    • CURRENCY_LOCALE

      public static final Locale CURRENCY_LOCALE
      Single source of truth for the currency locale used across the analysis views.
  • Constructor Details

    • ObservableThreat

      public ObservableThreat(org.eclipse.core.databinding.DataBindingContext dbc, org.eclipse.viatra.query.runtime.api.IPatternMatch x, RiskAssessmentLoopConfiguration loopConfiguration)
    • ObservableThreat

      protected ObservableThreat(org.eclipse.viatra.query.runtime.api.IPatternMatch x, IRiskModel riskModel, RiskAssessmentLoopConfiguration loopConfiguration)
  • Method Details

    • setOnRealm

      protected static <T> void setOnRealm(org.eclipse.core.databinding.observable.value.WritableValue<T> observable, T value)
      Apply a value mutation on the observable's realm: directly when already running on it, asynchronously otherwise (e.g. VIATRA delivering a match update on a non-UI thread). Off-realm callers get eventual consistency; the realm serialises all mutations and change notifications.
    • formatCurrency

      protected static String formatCurrency(double value)
    • formatRisk

      protected static String formatRisk(double value)
    • newCurrencyFormat

      public static NumberFormat newCurrencyFormat()
      Returns:
      a freshly configured currency formatter (grouping, exactly two fraction digits) using the shared CURRENCY_LOCALE. Intended for callers such as the analysis view header that need their own formatter instance.
    • processMatch

      public void processMatch()
    • getThreat

      public String getThreat()
    • getThreatName

      public String getThreatName()
      Specified by:
      getThreatName in interface IThreat
      Overrides:
      getThreatName in class Threat
    • getThreatTypeName

      public String getThreatTypeName()
      Specified by:
      getThreatTypeName in interface IThreat
      Overrides:
      getThreatTypeName in class Threat
    • setThreat

      public void setThreat(String threat)
    • setThreatTypeName

      public void setThreatTypeName(String threat)
    • getFlow

      public String getFlow()
    • setFlow

      public void setFlow(String flow)
    • getMessage

      public String getMessage()
      Overrides:
      getMessage in class Threat
    • setMessage

      public void setMessage(String message)
    • getVulnerabilityString

      public String getVulnerabilityString()
    • setVulnerability

      public void setVulnerability(double vulnerability)
    • getVulnerability_lowerString

      public String getVulnerability_lowerString()
    • setVulnerability_lower

      public void setVulnerability_lower(double vulnerability_lower)
    • getVulnerability_upperString

      public String getVulnerability_upperString()
    • setVulnerability_upper

      public void setVulnerability_upper(double vulnerability_upper)
    • getRiskString

      public String getRiskString()
    • setRisk

      public void setRisk(double risk)
    • getPotentialRiskString

      public String getPotentialRiskString()
    • setPotentialRisk

      public void setPotentialRisk(double risk)
    • getRisk_lowerString

      public String getRisk_lowerString()
    • setRisk_lower

      public void setRisk_lower(double risk)
    • getRisk_upperString

      public String getRisk_upperString()
    • setRisk_upper

      public void setRisk_upper(double risk)
    • getSleString

      public String getSleString()
    • setSle

      public void setSle(double sle)
    • getTefString

      public String getTefString()
    • setTef

      public void setTef(double tef)
    • getLefString

      public String getLefString()
    • setLef

      public void setLef(double lef)
    • getRiskAsDouble

      public double getRiskAsDouble()
    • getPotentialRiskAsDouble

      public double getPotentialRiskAsDouble()
    • getRisk_lowerAsDouble

      public double getRisk_lowerAsDouble()
    • getRisk_upperAsDouble

      public double getRisk_upperAsDouble()
    • getVulnerabilityAsDouble

      public double getVulnerabilityAsDouble()
    • getVulnerability_lowerAsDouble

      public double getVulnerability_lowerAsDouble()
    • getVulnerability_upperAsDouble

      public double getVulnerability_upperAsDouble()
    • getSleAsDouble

      public double getSleAsDouble()
    • getTefAsDouble

      public double getTefAsDouble()
    • getLefAsDouble

      public double getLefAsDouble()
    • getMatchType

      public String getMatchType()
      Overrides:
      getMatchType in class Threat
    • getSender

      public String getSender()
    • getRecipient

      public String getRecipient()
    • getMatchObservable

      protected org.eclipse.core.databinding.observable.value.IObservableValue getMatchObservable(String propertyName)
    • recalculateRisk

      public void recalculateRisk()
      Recalculate this threat's risk after its inputs changed in the model, e.g. a new role binding. Failures are logged, like for the initial calculation.
    • logRiskCalculationFailure

      protected void logRiskCalculationFailure(Exception e)
      Report a risk-calculation failure to the platform log rather than stderr.
    • performRiskCalculation

      public void performRiskCalculation(RiskAssessmentLoopConfiguration loopConfiguration)
      Description copied from class: Threat
      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.
      Overrides:
      performRiskCalculation in class Threat
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface IThreat
      Overrides:
      getDescription in class Threat
    • getFullDescription

      public String getFullDescription()