Threatcl Syntax Overview
The syntax used by threatcl
is built around Hashicorp’s Configuration Language, or HCL. You can read more about HCL at github.com/hashicorp/hcl.
HCL’s syntax is meant to be easy to read and write, and loosely feels closer like JSON.
Arguments
An argument assigns a value to an attribute. This is an example of a simple string assignment.
Most value types in threatcl
are strings, but you may also encounter numbers and boolean values too. Numbers don’t need "
characters, but boolean can work either way. The following are all valid.
String values can also accept multiline strings as well.
Values in some circumstances may be a list or array of values as well.
Blocks
Blocks are used extensively by threatcl
, and are used to contain other blocks and attributes.
Blocks will always have a type, and may optionally include a label or identifier. Here are some examples.
In many circumstances you can have multiple blocks, but if there is a label or identifier, these should be unique.
Comments
Just like HCL, we support the following comments syntax:
#
begins a single-line comment//
also begins a single-line comment/*
and*/
are start and end delimiters for comments that span multiple lines.
Variables
threatcl
supports defining variables outside of your threatmodel
blocks.
You can then use them for any attribute that accepts a string.
You can also interpolate variables into broader strings. For example
This works in multi-line values as well.
Minimum requirements
The minimum requirements for a .hcl
file to meet threatcl
’s spec is to include a spec_version
string, and at least one threatmodel
block.
You need to give each threatmodel
block a name.
The only required element inside each threatmodel
is an author
string.
This is a valid threat model file: