Class YmlToEmfConverter

java.lang.Object
be.kuleuven.cs.distrinet.sparta.io.convert.YmlToEmfConverter

public class YmlToEmfConverter extends Object
  • Method Details

    • main

      public static void main(String[] args) throws IOException
      Run the YmlToEmfConverter from the command line. The first argument is the file name.
      Parameters:
      args - Command line arguments. The first argument should be the filename.
      Throws:
      IOException
    • convert

      public static File convert(String file) throws IOException
      Convert the given txt/yml DFD model to an EMF SPARTA model. The input file is resolved against the current working directory (user.dir), which is also where the converted model is written.
      Parameters:
      file - the txt/yml input file (absolute, or relative to user.dir).
      Returns:
      the file the converted model was written to.
      Throws:
      IOException - if the input cannot be read or parsed, or the converted model cannot be written.
    • convert

      public static File convert(File workingDir, String file) throws IOException
      Convert the given txt/yml DFD model to an EMF SPARTA model.

      The converted model is written to <workingDir>/dfd.sparta and the threat catalog is loaded from <workingDir>/ThreatSpecification.sparta.

      Parameters:
      workingDir - the directory against which the input is resolved and to which the output is written.
      file - the txt/yml input file (absolute, or relative to workingDir).
      Returns:
      the file the converted model was written to.
      Throws:
      IOException - if the input cannot be read or parsed, or the converted model cannot be written.
    • parseDataFlowEndpoints

      public static String[] parseDataFlowEndpoints(String entry)
      Parse a data-flow entry of the form "sender->recipient" into its two endpoints. The entry must contain exactly one "->" separator and both endpoints must be non-blank.
      Parameters:
      entry - the raw data-flow entry.
      Returns:
      a two-element array [sender, recipient] (both trimmed).
      Throws:
      IllegalArgumentException - if the entry is null, does not contain exactly one "->" separator, or has an empty endpoint.