Class SpartaCi
java.lang.Object
be.kuleuven.cs.distrinet.sparta.cli.ci.SpartaCi
Simple class to run sparta in a CI context. This processes a .sparta.yml file
to determine which model to load and to which CTAM server to send the
analysis results.
The flow is split into readConfig(File) (parse .sparta.yml + resolve the
git commit), analyze(CiConfiguration) (load the model, run the analysis and
serialize the result), and the server submission. main orchestrates them and owns
the process exit codes, which keeps the analysis pipeline testable without a live server.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classData class containing the analysis results of a SPARTA CI run. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SpartaCi.AnalysisResultsanalyze(CiConfiguration conf) Load the configured model, run the threat analysis and serialize the (pattern-stripped) DFD model, producing the payload that would be submitted to the server.static voidRun SPARTA in a CI context.static CiConfigurationreadConfig(File workingDir) Parse the.sparta.ymlconfiguration fromworkingDirand, if the file sits inside a git repository, resolve the current HEAD commit onto the configuration.
-
Constructor Details
-
SpartaCi
public SpartaCi()
-
-
Method Details
-
main
Run SPARTA in a CI context.- Parameters:
args- command line arguments; SpartaCI currently does not have any cli args.
-
readConfig
Parse the.sparta.ymlconfiguration fromworkingDirand, if the file sits inside a git repository, resolve the current HEAD commit onto the configuration.- Parameters:
workingDir- the directory containing the.sparta.ymlfile.- Returns:
- the parsed configuration.
- Throws:
FileNotFoundException- if there is no.sparta.ymlinworkingDir.IOException- if the.sparta.ymlfile is empty or not valid YAML.
-
analyze
Load the configured model, run the threat analysis and serialize the (pattern-stripped) DFD model, producing the payload that would be submitted to the server. Performs no network I/O, so it is safe to run without a CTAM server.- Parameters:
conf- the CI configuration.- Returns:
- the analysis results (threats + serialized model), or
nullif the model could not be converted, contained noDFDModel, or failed to serialize.
-