Command-line tools

SPARTA provides two command-line tools, built on the standalone libraries (see SPARTA Standalone libraries):

sparta-cli

A tool for the threat elicitation and risk analysis of a SPARTA model from the command line, with exports of the threats to CSV, XLSX, text files, a statistics report or a code-quality report, or a submission to a server that is not part of SPARTA.

sparta-ci

A tool for continuous integration pipelines, configured with a .sparta.yml file, that analyzes a model and submits the threats and the model to a server that is not part of SPARTA.

Both tools use the threat elicitation and risk analysis engine of sparta-core, with the threat type catalogs that the model references.

Obtaining the tools

Each tool is a single runnable jar that contains all its dependencies (EMF, VIATRA, …):

Tool

Maven coordinates

Runnable jar

Main class

sparta-cli

be.kuleuven.cs.distrinet.sparta:sparta-cli:2026.1.0, classifier shaded

sparta-cli-2026.1.0-shaded.jar (about 92 MB)

be.kuleuven.cs.distrinet.sparta.cli.SpartaCli

sparta-ci

be.kuleuven.cs.distrinet.sparta:sparta-ci:2026.1.0, classifier shaded

sparta-ci-2026.1.0-shaded.jar (about 95 MB)

be.kuleuven.cs.distrinet.sparta.cli.ci.SpartaCi

The jars without classifier (sparta-cli-2026.1.0.jar and sparta-ci-2026.1.0.jar) are library jars and cannot be run with java -jar.

Download the runnable jars from the GitHub release page. Put them in a folder without spaces in its path (see Known limitations in 2026.1). The 2026.1.0 artifacts are not available from the SPARTA Maven repository.

You can also build the jars from source. Building the whole repository with mvn clean package from the repository root (see Building SPARTA from source) produces them in the target folders of the standalone modules:

  • standalone/sparta-cli/target/sparta-cli-2026.1.0-shaded.jar

  • standalone/sparta-ci/target/sparta-ci-2026.1.0-shaded.jar

The tools are compiled for Java 11 and run on Java 11 or later (tested with Java 11 and Java 21). Run them with java -jar, for example:

java -jar sparta-cli-2026.1.0-shaded.jar -i MyModel.sparta -oc threats.csv

sparta-cli

Usage

sparta-cli loads one model, runs threat elicitation and risk analysis, and passes the resulting threats to every exporter whose option you give, so a single run can produce several outputs. -h prints the following help (the jar name in the usage line is always sparta-cli.jar):

usage: java -jar sparta-cli.jar [-ab] [-cqr <arg>] [-h] [-i <arg>] [-it
       <arg>] [-oc <arg>] [-os <arg>] [-ot <arg>] [-ox <arg>] [-sc <arg>]
       [-st <arg>] [-su <arg>] [-v] [-ve]
 -ab,--about                      About SPARTA
 -cqr,--codequalityreport <arg>   Export Code Quality Report
 -h,--help                        Show help
 -i,--input <arg>                 Model to analyze
 -it,--inputtree <arg>            Threat Tree to process
 -oc,--outcsv <arg>               CSV Export file
 -os,--outstatistics <arg>        Output txt file with threat statistics
 -ot,--outtxt <arg>               TXT export files
 -ox,--outxlsx <arg>              XLSX export file
 -sc,--commitid <arg>             Server submission commit id
 -st,--token <arg>                Server submission token
 -su,--server <arg>               Server submission url
 -v,--verbose                     Provide verbose output
 -ve,--version                    Show version info

A run proceeds as follows:

  1. The arguments are parsed. An unknown option or a missing option argument prints an error and the help, and ends the run with exit status 1.

  2. --about, --help and --version are handled, in that order. They do not stop the run: -h -i MyModel.sparta prints the help and also analyzes the model.

  3. If -i is given, the model is loaded and analyzed, and the exporters run in this order: CSV, XLSX, text files, statistics, code-quality report, server submission. Without -i, nothing is analyzed or exported.

Options

No option is required and no option has a default value. You can use the short and the long form of each option (for example -oc threats.csv or --outcsv threats.csv).

Short

Long

Argument

Description

-i

--input

file

Model to analyze: a .sparta (or legacy .securitydfd) file, relative to the working directory. See Input model.

-oc

--outcsv

file

Write the threats to a CSV file.

-ox

--outxlsx

file

Write the threats to an Excel (XLSX) file. Does not work in 2026.1, see Known limitations in 2026.1.

-ot

--outtxt

directory

Write one text file per threat into this directory.

-os

--outstatistics

file

Write a plain-text statistics report.

-cqr

--codequalityreport

file

Write a code-quality report (JSON).

-su

--server

URL

Submit the threats to this URL. Requires -st and -sc.

-st

--token

token

Value of the token header of the submission.

-sc

--commitid

commit id

Value of the commitId header of the submission.

-h

--help

Print the help to standard output.

-ve

--version

Log the version, for example Version: 2026.1.0.

-ab

--about

Log a short description of the tool.

-v

--verbose

No effect in 2026.1. See Logging for more detailed output.

-it

--inputtree

file

No effect in 2026.1.

Input model

  • The -i path is always appended to the working directory, so it must be a relative path, such as MyModel.sparta or models/MyModel.sparta. An absolute path fails with a FileNotFoundException.

  • Only the extensions .sparta and .securitydfd (the legacy name) are accepted. Any other extension fails with Cannot create a resource for ....

  • After loading the model, sparta-cli loads every resource the model references, such as the threat type catalogs and solution catalogs that are linked to it (see Pairing existing threat type catalogs). Relative references are resolved against the location of the model file, so the catalog files must be at the same relative location as in your workspace. Catalog files that the model does not reference are not loaded, and there is no option to add catalogs or pattern files.

  • If a referenced catalog cannot be loaded, for example because the file is missing or the reference is an Eclipse workspace URI (platform:/resource/...), the run still succeeds, without a warning, but finds no threats from that catalog (no threats at all if no catalog could be loaded).

  • Risk is calculated with a Monte Carlo simulation of 1000 samples and no fixed seed, so risk values differ slightly between runs. The order of the threats is not stable either.

Exports

After the analysis, sparta-cli passes the threats to every exporter whose option you give; you can combine several. The first five exporters below write the threats to files; the server submission sends them to a server instead.

For the files:

  • Output paths are relative to the working directory.

  • Missing parent directories are not created: the exporter logs an error and the run continues.

  • Existing files are overwritten.

  • Text files use the default character encoding of the JVM (UTF-8 on Java 18 and later).

CSV (-oc)

One header line followed by one line per threat. Fields are separated by ; and every field is enclosed in double quotes; quotes inside values are not escaped. The format is the same as the CSV export of the ThreatAnalysis view; Analysis results and exports describes the columns.

For legacy key-based threat types (see Writing threat type patterns), Type and Name are both the name of the threat type.

Numbers have at most 4 decimals and are formatted with the default locale of the JVM, including grouping separators: for example 7,700.1363 in en-US and 7.700,1363 in nl-BE. To get a predictable format, set the locale explicitly, for example java -Duser.language=en -Duser.country=US -jar ....

"Type";"Name";"Location";"Flow From";"Data Flow";"Flow To";"Vulnerability";"Risk";"Risk (lower)";"Risk (upper)";"Risk (potential)"
"Repudiation";"Contoso repudiates action";"Contoso";"Contoso";"Write";"Database";"1";"7,700.1363";"78.9585";"45,704.8636";"7,700.1363"

XLSX (-ox)

In 2026.1, this option fails; see Known limitations in 2026.1 and use -oc instead. The columns of the XLSX file are those of ThreatXlsxOutputStream (see Exporters).

Text files (-ot)

Creates the directory (one level only) and writes one file per threat, with one line for each CSV column: the column name, a colon, a tab character, and the value:

Type:        Tampering
Name:        Database corrupted
Location:    Database
Flow From:   Contoso
Data Flow:   Write
Flow To:     Database
Vulnerability:       1
Risk:        23,763.1892
Risk (lower):        959.8419
Risk (upper):        118,439.7156
Risk (potential):    23,763.1892

The file name joins the raw threat type name, the threatened element name and the data flow name with _, replaces every run of other characters than ASCII letters, digits and _ with one space, and appends .txt. For example, the threat type <$location$> corrupted on element Database and flow Write gives a file named location corrupted_Database_Write.txt preceded by a space. Threats with the same threat type, element and flow overwrite each other’s file.

Statistics (-os)

Writes a plain-text report with statistics over all threats, computed with ThreatAggregationAnalysis (see Aggregated risk analyses):

  • the number of threats, threat types and element types;

  • the total risk reduction by the countermeasures;

  • the average number of threats per threatened element;

  • the risk reduction per threat type and per element type;

  • the number of threats per threat type and per element type, with their share of all threats.

For example:

SPARTA Threat Statistics Report
===============================

55 threats encountered (9 threat types, 3 element types)

Risk reduction:      13.33% (389262.23/449107.86)

Average threat count:        9.17

Threat Type Reduction Progress
------------------------------
<$location$> spoofed
             42.82% (42323.46/74013.39)
...
Element Type Reduction Progress
-------------------------------
Process
             14.47% (277608.07/324559.27)
...

Threat Type Threat Counts
-------------------------
<$location$> spoofed
             10      (18.18%)
...
Element Type Threat Counts
--------------------------
Process
             44      (80.00%)
...
  • The totals are sums of the expected risk values of the threats. The numbers in parentheses are residual risk / potential risk; the percentage is the reduction, 1 - residual / potential.

  • “Average threat count” is the average number of threats per threatened element.

  • Threat types are listed with their raw names (placeholders are not replaced), and element types by class name (Process, DataFlow, DataStore, ExternalEntity, …).

  • The order of the entries within a section is unspecified, and numbers use the default locale of the JVM.

Code-quality report (-cqr)

Writes a report in the format of GitLab Code Quality reports, so that a CI system can show the threats as code-quality findings on the model file. The report is a single-line JSON array with one entry per threat, which identifies the threat, gives it a severity based on its risk, and points to the model file.

For example:

[{"description":" location disrupted_Database_Write.txt","fingerprint":"795a653ba8f51ca08131f1d80afd2232","severity":"blocking","location":{"path":"Contoso.sparta","lines":{"begin":1}}}]
description

The text file name of the threat (see Text files (-ot)).

fingerprint

The MD5 hash of description. Threats with the same threat type, element and flow therefore share a fingerprint.

severity

The risk of the threat relative to the highest potential risk among all threats (r = risk / maximum potential risk): info (r < 0.125), minor (r < 0.375), major (r < 0.625), critical (r < 0.875) or blocking. GitLab expects blocker for the highest severity: it shows threats with blocking with the severity “Unknown”, at the bottom of the list (see Using the tools in a CI pipeline for a workaround).

location

path is the path of the model file relative to the working directory, and lines.begin is always 1. For a model in a subdirectory, the path contains a double slash, for example models//MyModel.sparta.

Server submission (-su, -st, -sc)

Note

The server is not part of SPARTA: to use the submission, you need a server of your own that accepts the request described below.

Sends the threats as JSON to a server, together with a token and a commit id. -su gives the URL of the server, -st the token and -sc the commit id. sparta-cli only sends the threats if all three options are given; if one of them is missing, it sends nothing and does not report this.

sparta-cli sends POST <url> with the headers Content-Type: application/json; utf-8, token: <token> and commitId: <commit id>. The body is a JSON array with one object per threat, with these properties: threatTypeName, threatName, description, vulnerability, risk, potentialRisk, threatenedElementName, threatenedElementTypeName, threatenedElementId, dataFlowName, dataFlowFromName and dataFlowToName. The body is written in the default character encoding of the JVM (UTF-8 on Java 18 and later), whatever the Content-Type header says.

For example, one object of the array:

{"dataFlowName":"Write","dataFlowToName":"Database","dataFlowFromName":"Contoso","risk":7803.1698230017455,
 "description":"Contoso claims not to have written to Database.","vulnerability":1.0,"threatName":"Contoso repudiates action",
 "threatTypeName":"Repudiation","potentialRisk":7803.1698230017455,"threatenedElementTypeName":"Process",
 "threatenedElementId":"652176954","threatenedElementName":"Contoso"}

threatenedElementId is an in-memory identifier that changes between runs. The response body is logged, followed by SPARTA Server submission successful. HTTP and connection errors are logged as IOError submitting to SPARTA Server: ...; the exit status stays 0.

Logging

sparta-cli logs to standard error at level INFO, in the form [main] INFO <logger> - <message>; the help goes to standard output. The --version and --about texts are logged, so they also appear on standard error. For more detail, set the log level with a system property:

java -Dorg.slf4j.simpleLogger.defaultLogLevel=debug -jar sparta-cli-2026.1.0-shaded.jar -i MyModel.sparta

At level debug, the log shows the working directory, the name of the loaded model and one Threat: ... line per threat; at level trace it also lists the threat types and threat specifications that were loaded.

The pattern parser also prints some lines to standard output, such as WARNING:Recursive pattern call: ... and empty lines. These are harmless.

Exit status

sparta-cli exits with status 0 in most situations, including when an exporter fails. Check the outputs yourself (for example, test that the expected files exist) if a pipeline must fail on errors.

Situation

Exit status

Successful run, run without options, -h, -ve or -ab

0

Referenced catalogs not found (no threats)

0

Exporter error (for example a missing output directory or an HTTP error)

0 (error is logged)

Unknown option or missing option argument

1

Model not found, absolute model path, or unsupported file extension

1 (uncaught exception)

-ox (see Known limitations in 2026.1)

1 (uncaught exception)

There is no option to fail on a risk threshold.

Examples

Analyze Contoso.sparta in the working directory and write a CSV file, text files, a statistics report and a code-quality report:

java -jar sparta-cli-2026.1.0-shaded.jar -i Contoso.sparta -oc threats.csv -ot txt -os stats.txt -cqr cqr.json

The same with long options, writing into an existing directory out:

java -jar sparta-cli-2026.1.0-shaded.jar --input Contoso.sparta --outcsv out/threats.csv --outtxt out/threats --outstatistics out/statistics.txt --codequalityreport out/gl-code-quality-report.json

Write the CSV with en-US number formatting:

java -Duser.language=en -Duser.country=US -jar sparta-cli-2026.1.0-shaded.jar -i Contoso.sparta -oc threats.csv

Submit the threats to a server:

java -jar sparta-cli-2026.1.0-shaded.jar -i Contoso.sparta -su https://server.example.org/api/submit -st <token> -sc <commit id>

A typical run logs:

[main] INFO be.kuleuven.cs.distrinet.sparta.cli.SpartaCliProcessor - LS: false
[main] INFO be.kuleuven.cs.distrinet.sparta.cli.SpartaCliProcessor - Rete: true
[main] INFO be.kuleuven.cs.distrinet.sparta.cli.SpartaCliProcessor - Running SPARTA Analysis ...
[main] INFO be.kuleuven.cs.distrinet.sparta.cli.cmd.export.ExportCSV - Exporting to csv
[main] INFO be.kuleuven.cs.distrinet.sparta.cli.cmd.export.ExportTXT - Exporting to txt files
[main] INFO be.kuleuven.cs.distrinet.sparta.cli.cmd.export.ExportStatistics - Exporting threat statistics
[main] INFO be.kuleuven.cs.distrinet.sparta.cli.cmd.export.ExportCQR - Exporting to cqr

sparta-ci

Note

The server that sparta-ci submits to is not part of SPARTA: you need a server of your own that accepts the request described below and in Server submission (-su, -st, -sc).

sparta-ci analyzes the model configured in .sparta.yml and submits the threats, together with the model, to a server. It writes no local output files and ignores all command-line arguments (including --help). Run it in the directory that contains .sparta.yml:

java -jar sparta-ci-2026.1.0-shaded.jar

A run proceeds as follows:

  1. sparta-ci reads .sparta.yml from the working directory.

  2. It looks for a git repository, starting from the directory of .sparta.yml and searching upward (the GIT_DIR environment variable is honored). If it finds one, the commit id of HEAD becomes the commit id of the submission; a detached HEAD, as in many CI checkouts, works as well.

  3. It analyzes the model exactly like sparta-cli, so the same Input model rules apply.

  4. It builds a self-contained copy of the model: the catalogs and other SPARTA resources that the model references are copied into the model, and the legacy key-based patterns and types maps of threat types and threat specifications are cleared. The VQL patterns of the catalogs are kept. This copy is serialized as XMI (UTF-8).

  5. It sends POST <server.url> with the headers Content-Type: application/json; utf-8, token: <server.token> and commitId: <commit id>, and logs the response followed by SPARTA Server submission finished.

Configuration file

.sparta.yml has the following keys. Unknown keys are ignored.

Key

Required

Meaning

input.model

yes

Path of the model, relative to the working directory (.sparta or .securitydfd).

server.url

yes

URL to submit the results to.

server.token

no

Value of the token header. The value is used literally; there is no environment variable substitution.

overrideCommit

no

Commit id to send when no git repository is found. Inside a git repository, the HEAD commit is always used instead. Without a git repository and without overrideCommit, the commitId header is empty.

version

no

An integer. Read but not used in 2026.1.

For example:

version: 1
input:
  model: Contoso.sparta
server:
  url: https://server.example.org/api/submit
  token: <submission token>
overrideCommit: deadbeef    # only used outside a git repository

Warning

Because the token is read literally from the file, do not commit a real token to your repository.

Payload

The request body is a JSON object with two properties:

threatList

The threats, with the same properties as the sparta-cli server submission (see Server submission (-su, -st, -sc)).

model

The self-contained model as an XMI string.

As with sparta-cli, the body is written in the default character encoding of the JVM (UTF-8 on Java 18 and later), whatever the Content-Type header says.

{"threatList":[{"dataFlowName":"Write", ... }, ...],"model":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<spartamodel:DFDModel ...>"}

Exit status

sparta-ci exits with status 0 even when the submission fails, so a failed submission does not fail a pipeline job.

Situation

Result

Exit status

Successful run

Results submitted

0

No .sparta.yml in the working directory

Logs Did not find SPARTA ci configuration.

0

Server unreachable or HTTP error

Logs IOError submitting to SPARTA Server: (without details) and SPARTA Server submission finished.

0

server section missing

Logs an error

0

input.model missing

NullPointerException

1

Model not found, absolute path, or unsupported extension

Uncaught exception

1

Using the tools in a CI pipeline

The SPARTA 2026.1 repository contains no ready-made pipeline configuration. You can run the tools in any CI system that can run Java. For example, the following GitLab CI job runs sparta-cli on a model. It assumes that the shaded jar and the model, with its catalogs at the referenced relative paths, are available in the job’s working directory:

threat-model:
  image: eclipse-temurin:21-jre
  script:
    - java -jar sparta-cli-2026.1.0-shaded.jar -i model/MySystem.sparta -oc threats.csv -os threat-statistics.txt -cqr gl-code-quality-report.json
    - test -s threats.csv
    - sed -i 's/"severity":"blocking"/"severity":"blocker"/g' gl-code-quality-report.json
  artifacts:
    paths: [threats.csv, threat-statistics.txt]
    reports:
      codequality: gl-code-quality-report.json

The test -s threats.csv step makes the job fail when no CSV was written, because sparta-cli itself exits with status 0 on most errors. It does not detect a run that finds no threats (for example when catalogs are missing): the CSV then contains only the header line.

The sed step replaces the severity blocking, which GitLab does not know, by blocker, so that GitLab shows the threats with the highest risk as “Blocker” instead of “Unknown”.

To use sparta-ci instead, commit a .sparta.yml in the directory the job runs from and run java -jar sparta-ci-2026.1.0-shaded.jar. The commit id is then taken from the checked-out commit. Keep in mind that sparta-ci reads the token from the file; with sparta-cli, you can pass the token on the command line (-st) from a protected CI variable, but sparta-cli does not send the model.

Known limitations in 2026.1

XLSX export fails

-ox aborts the run with NoClassDefFoundError: org/apache/poi/util/POILogFactory and exit status 1, leaving an empty file. The exporters that come after it (text files, statistics, code-quality report, server submission) do not run. The cause is a conflict between the Apache POI versions in the jar (see Known limitation: XLSX export). Use -oc instead and open the CSV file in a spreadsheet program.

Catalogs with patterns without a data flow fail

Every threat must have a data flow in 2026.1. If a referenced catalog contains patterns that bind no flow or df parameter, for example a STRIDE-per-element catalog, the analysis fails with a NullPointerException before any exporter runs.

FileNotFoundException for an existing model

-i (and input.model in .sparta.yml) must be relative to the working directory.

Severity “Unknown” in GitLab

The code-quality report uses the severity blocking for the threats with the highest risk, but GitLab only knows blocker. GitLab still reads the report, but shows these threats with the severity “Unknown”, at the bottom of the list. Replace the severity in the report before GitLab reads it, as in Using the tools in a CI pipeline.

ProvisionException at startup

When the path of the jar contains a space, for example C:\Users\Jane Doe\tools\sparta-cli-2026.1.0-shaded.jar, both tools abort before the analysis with a com.google.inject.ProvisionException and exit status 1. The cause is a NoSuchFileException for the jar itself, with the space written as %20. Put the jar in a folder without spaces in its path.

.txt models in sparta-ci

sparta-ci tries to convert an input.model that ends with txt from a simple YAML description into a model. This does not work in 2026.1: the conversion fails with a NullPointerException, and the converted model would not be found anyway. Use a .sparta model.

Exit status 0 after errors

sparta-cli exits with status 0 in most situations, including when an exporter fails, and sparta-ci also when the submission fails. A CI job therefore does not fail by itself; see Using the tools in a CI pipeline for a check you can add.

Troubleshooting

No threats found

The catalogs referenced by the model were not found. Check that the catalog files exist at the relative paths stored in the model, and that the model does not reference them with platform:/resource/... URIs. See Input model.

Risk values differ between runs

The risk calculation uses Monte Carlo sampling without a fixed seed. Small differences between runs on the same model are expected; the order of the threats can also differ.

Unexpected number format

CSV, text and statistics output use the default locale of the JVM. Set -Duser.language and -Duser.country to choose a locale.