#!/bin/bash
#
# Configuration file for ssDecode
#
# Usage: ./t2plconf
#
# Enter configurations items as follows:
#
#   "NAME" "TYPE" "DEPENDENCIES" "DESCRIPTION"
#
#   - TYPE can be:
#       - check (boolean),
#       - radio (set of values),
#       - range (min <= val <= max)
#       - text
#
#   - DEPENDENCIES MUST be numeric, e.g., "A == 1 && (B < 4 || C >= 1)"
#
#   - DESCRIPTION for type 'check' MUST NOT contain tabs ('\t')
#   - DESCRIPTION for TYPE 'range' MUST NOT contain '\t' or ':'
#   - DESCRIPTION for TYPE 'radio' MUST NOT contain '\t', ':' or ';'
#   - DESCRIPTION for TYPE 'text'  MUST NOT contain '\t'
#
#   - DESCRIPTION MUST be formatted according to the type (see examples below):
#       - check: description
#       - radio: description ';' val1 ':' description1 ';' valN ':' descriptionN
#       - range: description ':' min ' ' max
#       - text : description

ITEMS=(
    SS_DATE_FORMAT radio ""
        "Representation of dates; 0: Unix timestamp; 1: human readable date time"

    # SSH
    SS_ANALYZE_SSH check "" "Analyze SSH"
    SS_SSH_USE_PORT check "SS_ANALYZE_SSH == 1"
        "Count all packets to/from port SSH_PORT as SSH"

    SS_ANALYZE_SSL check "" "Analyze SSL/TLS"

    SS_EXT_LIST check "SS_ANALYZE_SSL == 1"
        "Output the list and number of extensions"
    SS_MAX_EXT range "SS_ANALYZE_SSL == 1 && SS_EXT_LIST == 1"
        "Maximum number of extensions to store: 0 255"

    SS_PROTO_LIST check "SS_ANALYZE_SSL == 1"
        "Output the list and number of protocols"
    SS_MAX_PROTO range "SS_ANALYZE_SSL == 1 && SS_PROTO_LIST == 1"
        "Maximum number of protocols to store: 0 255"
    SS_PROTO_LEN range "SS_ANALYZE_SSL == 1 && SS_PROTO_LIST == 1"
        "Maximum number of characters per protocols: 0 255"

    SS_CIPHER_LIST check "SS_ANALYZE_SSL == 1"
        "Output the list and number of supported ciphers"
    SS_MAX_CIPHER range "SS_ANALYZE_SSL == 1 && SS_CIPHER_LIST == 1"
        "Maximum number of ciphers to store: 0 255"

    SS_ANALYZE_CERT check "SS_ANALYZE_SSL == 1"
        "Analyze certificates"

    SS_CERT_SERIAL check "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1"
        "Print the certificate serial number"
    SS_CERT_FINGPRINT radio "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1"
        "Extraction of certificate fingerprint; \
            0: no certificate fingerprint; \
            1: SHA1; \
            2: MD5"
    SS_CERT_VALIDITY check "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1"
        "Print the certificate validity (Valid from/to)"
    SS_CERT_SIG_ALG check "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1"
        "Print the certificate signature algorithm"
    SS_CERT_PUBKEY_ALG check "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1"
        "Print the certificate public key algorithm"
    SS_CERT_ALG_NAME_LONG radio "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1"
        "Algorithm names; 0: Short names; 1: long names"
    SS_CERT_PUBKEY_TS check "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1"
        "Print the certificate public key type and size"

    SS_CERT_SUBJECT radio "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1"
        "Certificate subject representation; \
            0: no information about the certificate subject; \
            1: Whole subject as one string; \
            2: Selected fields only"
    SS_CERT_ISSUER radio "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1"
        "Certificate issuer representation; \
            0: no information about the certificate subject; \
            1: Whole subject as one string; \
            2: Selected fields only"

    SS_CERT_COMMON_NAME check
        "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1 && (SS_CERT_SUBJECT == 2 || SS_CERT_ISSUER == 2)"
        "Print the common name of the issuer/subject"
    SS_CERT_ORGANIZATION check
        "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1 && (SS_CERT_SUBJECT == 2 || SS_CERT_ISSUER == 2)"
        "Print the organization name of the issuer/subject"
    SS_CERT_ORG_UNIT check
        "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1 && (SS_CERT_SUBJECT == 2 || SS_CERT_ISSUER == 2)"
        "Print the organizational unit name of the issuer/subject"
    SS_CERT_LOCALITY check
        "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1 && (SS_CERT_SUBJECT == 2 || SS_CERT_ISSUER == 2)"
        "Print the locality name of the issuer/subject"
    SS_CERT_STATE check
        "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1 && (SS_CERT_SUBJECT == 2 || SS_CERT_ISSUER == 2)"
        "Print the state or province of the issuer/subject"
    SS_CERT_COUNTRY check
        "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1 && (SS_CERT_SUBJECT == 2 || SS_CERT_ISSUER == 2)"
        "Print the country of the issuer/subject"

    SS_DETECT_TOR check
        "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1 && (SS_CERT_SUBJECT > 0 || SS_CERT_ISSUER > 0)"
        "Detect likely Tor connections"

    # Certificates
    SS_SAVE_CERT check "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1" "Save certificates"
    SS_CERT_PATH text
        "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1 && SS_SAVE_CERT == 1"
        "Folder for saved certificates"  # TODO dir chooser
    SS_CERT_EXT text
        "SS_ANALYZE_SSL == 1 && SS_ANALYZE_CERT == 1 && SS_SAVE_CERT == 1"
        "Extension for saved certificates"
)

# Source the main config file
source ../scripts/t2conf/t2plconf
