Class Engine
java.lang.Object
be.kuleuven.cs.distrinet.sparta.core.Engine
- All Implemented Interfaces:
AutoCloseable
This is the core SPARTA Threat Elicitation Engine.
It uses the
ViatraQueryEngine internally to elicit threats in an eclipse emf model.-
Constructor Summary
ConstructorsConstructorDescriptionEngine(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 TypeMethodDescriptionvoidclose()Dispose the underlying VIATRA query engine.voiddispose()<T extends org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch,E extends org.eclipse.viatra.query.runtime.api.impl.BaseMatcher<T>>
EgetMatcherOnEngine(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.ViatraQueryEngineDeprecated.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.
-
Constructor Details
-
Engine
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
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 intoThreats 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 intoThreats 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
- 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 viaRiskAssessmentLoopConfiguration.setUpLoopParameters(Engine)and pass it to each threat'sperformRiskCalculation.
-
close
public void close()Dispose the underlying VIATRA query engine. Allows the engine to be used with try-with-resources; equivalent todispose().- Specified by:
closein interfaceAutoCloseable
-
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)
-