Class Engine

java.lang.Object
be.kuleuven.cs.distrinet.sparta.core.Engine
All Implemented Interfaces:
AutoCloseable

public class Engine extends Object implements AutoCloseable
This is the core SPARTA Threat Elicitation Engine. It uses the ViatraQueryEngine internally to elicit threats in an eclipse emf model.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Engine(ResourceSet resource)
    Construct a new SPARTA threat elicitation engine for the given resource set.
    Engine(org.eclipse.viatra.query.runtime.emf.EMFScope scope)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Dispose the underlying VIATRA query engine.
    void
     
     
    <T extends org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch, E extends org.eclipse.viatra.query.runtime.api.impl.BaseMatcher<T>>
    E
    getMatcherOnEngine(Function<org.eclipse.viatra.query.runtime.api.ViatraQueryEngine,org.eclipse.viatra.query.runtime.api.impl.BaseMatcher<T>> func)
     
    List<Function<org.eclipse.viatra.query.runtime.api.ViatraQueryEngine,org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<? extends org.eclipse.viatra.query.runtime.api.IPatternMatch>>>
    Get the default set of viatra query engine pattern matchers.
    org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
    Deprecated.
    org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<?>
    getVQMatcherOnEngine(Function<org.eclipse.viatra.query.runtime.api.ViatraQueryEngine,org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<?>> func)
     
    runAnalysis(List<Function<org.eclipse.viatra.query.runtime.api.ViatraQueryEngine,org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<? extends org.eclipse.viatra.query.runtime.api.IPatternMatch>>> matchers)
    Run the threat analysis using a custom set of pattern matchers.
    runAnalysis(Map<ThreatPatternMatchMetadata,org.eclipse.viatra.query.patternlanguage.emf.util.PatternParsingResults> parseResults)
    Run the threat analysis using a custom set of parsed patterns.
    Run the analysis with the default set of pattern matchers and the ones obtained from catalogs in the ResourceSet with which the Engine was initialized.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Engine

      public Engine(ResourceSet resource)
      Construct a new SPARTA threat elicitation engine for the given resource set. Make sure the resource set contains information on the threat types to elicit; otherwise, the elicitation engine will not have any threats to find.
      Parameters:
      resource - - the resource set to analyze for threats
    • Engine

      public Engine(org.eclipse.viatra.query.runtime.emf.EMFScope scope)
  • Method Details

    • getPatternMatchers

      public List<Function<org.eclipse.viatra.query.runtime.api.ViatraQueryEngine,org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<? extends org.eclipse.viatra.query.runtime.api.IPatternMatch>>> getPatternMatchers()
      Get the default set of viatra query engine pattern matchers.
      Returns:
      List of functions to apply on the engine to obtain the querymatchers.
    • runAnalysis

      public List<Threat> runAnalysis(ResourceSet rs)
      Run the analysis with the default set of pattern matchers and the ones obtained from catalogs in the ResourceSet with which the Engine was initialized.
      Returns:
      The list of threats found in the model provided to the engine.
    • runAnalysis

      public List<Threat> runAnalysis(List<Function<org.eclipse.viatra.query.runtime.api.ViatraQueryEngine,org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<? extends org.eclipse.viatra.query.runtime.api.IPatternMatch>>> matchers)
      Run the threat analysis using a custom set of pattern matchers. Each of the functions will be applied on the query engine to obtain the pattern matchers. The resulting pattern matches will be converted into Threats provided in the results.
      Parameters:
      matchers - the pattern matchers to apply on the viatra query engine. These are actually functions that, when applied on a ViatraQueryEngine, return a ViatraQueryMatcher.
      Returns:
      The resulting list of Threats found in the provided model.
    • runAnalysis

      public List<Threat> runAnalysis(Map<ThreatPatternMatchMetadata,org.eclipse.viatra.query.patternlanguage.emf.util.PatternParsingResults> parseResults)
      Run the threat analysis using a custom set of parsed patterns. Matchers are extracted from the parsed patterns and applied on the query engine to obtain the pattern matches The resulting pattern matches will be converted into Threats provided in the results.
      Parameters:
      parseResults - The collection of parsed patterns.
      Returns:
      The resulting list of Threats found in the provided model.
    • dispose

      public void dispose()
    • getLoopConfiguration

      public RiskAssessmentLoopConfiguration getLoopConfiguration()
      Returns:
      the risk-assessment loop configuration owned by this engine. Callers that drive the risk calculation outside runAnalysis(ResourceSet) (e.g. the UI's observable-threat conversion) must populate it via RiskAssessmentLoopConfiguration.setUpLoopParameters(Engine) and pass it to each threat's performRiskCalculation.
    • close

      public void close()
      Dispose the underlying VIATRA query engine. Allows the engine to be used with try-with-resources; equivalent to dispose().
      Specified by:
      close in interface AutoCloseable
    • getQueryEngine

      @Deprecated public org.eclipse.viatra.query.runtime.api.ViatraQueryEngine getQueryEngine()
      Deprecated.
    • getVQMatcherOnEngine

      public org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<?> getVQMatcherOnEngine(Function<org.eclipse.viatra.query.runtime.api.ViatraQueryEngine,org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher<?>> func)
    • getMatcherOnEngine

      public <T extends org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch, E extends org.eclipse.viatra.query.runtime.api.impl.BaseMatcher<T>> E getMatcherOnEngine(Function<org.eclipse.viatra.query.runtime.api.ViatraQueryEngine,org.eclipse.viatra.query.runtime.api.impl.BaseMatcher<T>> func)