Schema/exception.schema.json

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/xGreeny/hardening-lens/v1.0.1/src/HardeningLens/Schema/exception.schema.json",
  "title": "Hardening Lens exception register",
  "type": "object",
  "required": [
    "schemaVersion",
    "exceptions"
  ],
  "properties": {
    "$schema": {
      "type": "string"
    },
    "schemaVersion": {
      "const": "1.0"
    },
    "exceptions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/exception"
      }
    }
  },
  "$defs": {
    "exception": {
      "type": "object",
      "required": [
        "id",
        "controlId",
        "status",
        "owner",
        "reason",
        "ticket",
        "expires",
        "targets"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^EXC-[A-Za-z0-9._-]+$"
        },
        "controlId": {
          "type": "string",
          "pattern": "^HL-[A-Z]+-[0-9]{3}$"
        },
        "status": {
          "enum": [
            "Draft",
            "Approved",
            "Revoked"
          ]
        },
        "owner": {
          "type": "string",
          "minLength": 2,
          "maxLength": 120
        },
        "reason": {
          "type": "string",
          "minLength": 10,
          "maxLength": 1000
        },
        "ticket": {
          "type": "string",
          "minLength": 2,
          "maxLength": 120
        },
        "expires": {
          "type": "string",
          "format": "date"
        },
        "targets": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          }
        },
        "baselines": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          }
        },
        "compensatingControls": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 3,
            "maxLength": 500
          }
        },
        "approvedBy": {
          "type": "string",
          "minLength": 2,
          "maxLength": 120
        },
        "approvedOn": {
          "type": "string",
          "format": "date"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "const": "Approved"
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "required": [
              "approvedBy",
              "approvedOn",
              "compensatingControls"
            ],
            "properties": {
              "compensatingControls": {
                "minItems": 1
              }
            }
          }
        }
      ],
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}