{
  "$schema": "http://json-schema.org/schema#",
  "id": "http://volatilityfoundation.org/intermediate-format/schema",
  "title": "Symbol Container",
  "type": "object",
  "definitions": {
    "metadata_producer": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string",
          "pattern": "^[0-9]+.[0-9]+.[0-9]+$"
        },
        "datetime": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required":[
        "name",
        "version"
      ]
    },
    "metadata_windows_pe": {
      "type": "object",
      "properties": {
        "major": {
          "type": "integer"
        },
        "minor": {
          "type": "integer"
        },
        "revision": {
          "type": "integer"
        },
        "build": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "required": [
        "major",
        "minor",
        "revision"
      ]
    },
    "metadata_windows_pdb": {
      "type": "object",
      "properties": {
        "GUID": {
          "type": "string"
        },
        "age": {
          "type": "integer"
        },
        "database": {
          "type": "string"
        },
        "machine_type": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "required": [
        "GUID",
        "age",
        "database",
        "machine_type"
      ]
    },
    "metadata_windows": {
      "type": "object",
      "properties": {
        "pe": {
          "$ref": "#/definitions/metadata_windows_pe"
        },
        "pdb": {
          "$ref": "#/definitions/metadata_windows_pdb"
        }
      },
      "additionalProperties": false
    },
    "metadata_nix": {
      "type": "object",
      "properties": {
        "symbols": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/metadata_nix_item"
          }
        },
        "types": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/metadata_nix_item"
          }
        }
      },
      "additionalProperties": false
    },
    "metadata_format": {
      "type": "string",
      "pattern": "^6.[0-9]+.[0-9]+$"
    },
    "metadata_nix_item": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "pattern": "^(dwarf|symtab|system-map)$"
        },
        "name": {
          "type": "string"
        },
        "hash_type": {
          "type": "string",
          "pattern": "^(sha256)$"
        },
        "hash_value": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]+$"
        }
      },
      "additionalProperties": false
    },
    "element_metadata": {
      "type": "object",
      "oneOf": [
        {
          "properties": {
            "format": {
              "$ref": "#/definitions/metadata_format"
            },
            "producer": {
              "$ref": "#/definitions/metadata_producer"
            }
          },
          "required": [
            "format",
            "producer"
          ],
          "additionalProperties": false
        },
        {
          "properties": {
            "format": {
              "$ref": "#/definitions/metadata_format"
            },
            "producer": {
              "$ref": "#/definitions/metadata_producer"
            },
            "windows": {
              "$ref": "#/definitions/metadata_windows"
            }
          },
          "required": [
            "format",
            "producer",
            "windows"
          ],
          "additionalProperties": false
        },
        {
          "properties": {
            "format": {
              "$ref": "#/definitions/metadata_format"
            },
            "producer": {
              "$ref": "#/definitions/metadata_producer"
            },
            "linux": {
              "$ref": "#/definitions/metadata_nix"
            }
          },
          "required": [
            "format",
            "producer",
            "linux"
          ],
          "additionalProperties": false
        },
        {
          "properties": {
            "format": {
              "$ref": "#/definitions/metadata_format"
            },
            "producer": {
              "$ref": "#/definitions/metadata_producer"
            },
            "mac": {
              "$ref": "#/definitions/metadata_nix"
            }
          },
          "required": [
            "format",
            "producer",
            "mac"
          ],
          "additionalProperties": false
        }
      ]
    },
    "element_enum": {
      "properties": {
        "size": {
          "type": "integer"
        },
        "base": {
          "type": "string"
        },
        "constants": {
          "type": "object",
          "additionalProperties": {
            "type": "integer"
          }
        }
      },
      "required": [
        "size",
        "base",
        "constants"
      ],
      "additionalProperties": false
    },
    "element_symbol": {
      "properties": {
        "address": {
          "type": "number"
        },
        "linkage_name": {
          "type": "string"
        },
        "type": {
          "$ref": "#/definitions/type_descriptor"
        },
        "constant_data": {
          "type": "string",
          "media": {
            "binaryEncoding": "base64",
            "readOnly": true
          }
        }
      },
      "required": [
        "address"
      ],
      "additionalProperties": false
    },
    "element_base_type": {
      "properties": {
        "size": {
          "type": "integer"
        },
        "signed": {
          "type": "boolean"
        },
        "kind": {
          "type": "string",
          "pattern": "^(void|int|float|char|bool)$"
        },
        "endian": {
          "type": "string",
          "pattern": "^(little|big)$"
        }
      },
      "required": [
        "size",
        "kind",
        "signed",
        "endian"
      ],
      "additionalProperties": false
    },
    "element_user_type": {
      "properties": {
        "kind": {
          "type": "string",
          "pattern": "^(struct|union|class)$"
        },
        "size": {
          "type": "integer"
        },
        "fields": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/field"
          }
        }
      },
      "required": [
        "kind",
        "size",
        "fields"
      ],
      "additionalProperties": false
    },
    "field": {
      "properties": {
        "type": {
          "$ref": "#/definitions/type_descriptor"
        },
        "offset": {
          "type": "integer"
        },
        "anonymous": {
          "type": "boolean"
        }
      },
      "required": [
        "type",
        "offset"
      ],
      "additionalProperties": false
    },
    "type_descriptor": {
      "oneOf": [
        {
          "$ref": "#/definitions/type_pointer"
        },
        {
          "$ref": "#/definitions/type_base"
        },
        {
          "$ref": "#/definitions/type_array"
        },
        {
          "$ref": "#/definitions/type_struct"
        },
        {
          "$ref": "#/definitions/type_enum"
        },
        {
          "$ref": "#/definitions/type_function"
        },
        {
          "$ref": "#/definitions/type_bitfield"
        }
      ]
    },
    "type_pointer": {
      "properties": {
        "kind": {
          "type": "string",
          "pattern": "^pointer$"
        },
        "base": {
          "type": "string"
        },
        "subtype": {
          "$ref": "#/definitions/type_descriptor"
        }
      },
      "required": [
        "kind",
        "subtype"
      ],
      "additionalProperties": false
    },
    "type_base": {
      "properties": {
        "kind": {
          "type": "string",
          "pattern": "^base$"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "name"
      ],
      "additionalProperties": false
    },
    "type_array": {
      "properties": {
        "kind": {
          "type": "string",
          "pattern": "^array$"
        },
        "subtype": {
          "$ref": "#/definitions/type_descriptor"
        },
        "count": {
          "type": "integer"
        }
      },
      "required": [
        "kind",
        "subtype",
        "count"
      ],
      "additionalProperties": false
    },
    "type_struct": {
      "properties": {
        "kind": {
          "type": "string",
          "pattern": "^(struct|class|union)$"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "name"
      ],
      "additionalProperties": false
    },
    "type_enum": {
      "properties": {
        "kind": {
          "type": "string",
          "pattern": "^enum$"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "name"
      ],
      "additionalProperties": false
    },
    "type_function": {
      "properties": {
        "kind": {
          "type": "string",
          "pattern": "^function$"
        }
      },
      "required": [
        "kind"
      ],
      "additionalProperties": false
    },
    "type_bitfield": {
      "properties": {
        "kind": {
          "type": "string",
          "pattern": "^bitfield$"
        },
        "bit_position": {
          "type": "integer"
        },
        "bit_length": {
          "type": "integer"
        },
        "type": {
          "oneOf": [
            {
              "$ref": "#/definitions/type_base"
            },
            {
              "$ref": "#/definitions/type_enum"
            }
          ]
        }
      },
      "required": [
        "kind",
        "bit_position",
        "bit_length",
        "type"
      ],
      "additionalProperties": false
    }
  },
  "properties": {
    "metadata": {
      "$ref": "#/definitions/element_metadata"
    },
    "base_types": {
      "additionalProperties": {
        "$ref": "#/definitions/element_base_type"
      }
    },
    "user_types": {
      "additionalProperties": {
        "$ref": "#/definitions/element_user_type"
      }
    },
    "enums": {
      "additionalProperties": {
        "$ref": "#/definitions/element_enum"
      }
    },
    "symbols": {
      "additionalProperties": {
        "$ref": "#/definitions/element_symbol"
      }
    }
  },
  "required": [
    "metadata",
    "base_types",
    "user_types",
    "enums",
    "symbols"
  ],
  "additionalProperties": false
}
