Class SpartaCi

java.lang.Object
be.kuleuven.cs.distrinet.sparta.cli.ci.SpartaCi

public class SpartaCi extends Object
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 Classes
    Modifier and Type
    Class
    Description
    static class 
    Data class containing the analysis results of a SPARTA CI run.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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 void
    main(String[] args)
    Run SPARTA in a CI context.
    readConfig(File workingDir)
    Parse the .sparta.yml configuration from workingDir and, if the file sits inside a git repository, resolve the current HEAD commit onto the configuration.

    Methods inherited from class java.lang.Object

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

    • SpartaCi

      public SpartaCi()
  • Method Details

    • main

      public static void main(String[] args)
      Run SPARTA in a CI context.
      Parameters:
      args - command line arguments; SpartaCI currently does not have any cli args.
    • readConfig

      public static CiConfiguration readConfig(File workingDir) throws IOException
      Parse the .sparta.yml configuration from workingDir and, if the file sits inside a git repository, resolve the current HEAD commit onto the configuration.
      Parameters:
      workingDir - the directory containing the .sparta.yml file.
      Returns:
      the parsed configuration.
      Throws:
      FileNotFoundException - if there is no .sparta.yml in workingDir.
      IOException - if the .sparta.yml file is empty or not valid YAML.
    • analyze

      public static SpartaCi.AnalysisResults analyze(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. 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 null if the model could not be converted, contained no DFDModel, or failed to serialize.