{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "$id": "https://pvs-studio.com/pvs-studio-log-schema.json",
  "title": "Structured log for the PVS-Studio C++ Core",
  "type": "object",
  "required": [
    "pvsDiagVersion",
    "utility",
    "environment",
    "input",
    "output",
    "basicPerformance",
    "source",
    "annotations",
    "ruleConfigs",
    "configuration"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Path to the data schema"
    },
    "pvsDiagVersion": {
      "type": "integer",
      "minimum": 1,
      "description": "Marker that this is a log from PVS tools and the format version"
    },
    "utility": {
      "$ref": "#/definitions/utility"
    },
    "environment": {
      "$ref": "#/definitions/environment"
    },
    "input": {
      "$ref": "#/definitions/input"
    },
    "output": {
      "$ref": "#/definitions/output"
    },
    "basicPerformance": {
      "$ref": "#/definitions/basicPerformance"
    },
    "source": {
      "$ref": "#/definitions/source"
    },
    "annotations": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Paths to included annotation files"
    },
    "ruleConfigs": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Paths to rule configuration files (order matters)"
    },
    "configuration": {
      "$ref": "#/definitions/configuration"
    }
  },
  "additionalProperties": false,
  "definitions": {
    "timepoint": {
      "$comment": "A point in time in extended ISO-8601 UTC+0 format (YYYY-MM-DDThh:mm:ss.sssZ)",
      "type": "string",
      "format": "date-time"
    },
    "durationNS": {
      "$comment": "Duration (in nanoseconds)",
      "type": "integer",
      "minimum": 0
    },
    "durationISO": {
      "$comment": "Duration in ISO-8601 format (hh:mm:ss.sssZ)",
      "type": "string",
      "format": "time"
    },
    "memorySize": {
      "$comment": "Amount of memory",
      "type": "integer",
      "minimum": 0
    },
    "envVars": {
      "$comment": "List of environment variables",
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "classPointer": {
      "$comment": "Class descriptor",
      "type": "object",
      "required": [
        "namespace",
        "class"
      ],
      "properties": {
        "namespace": {
          "type": "string",
          "description": "Namespace"
        },
        "class": {
          "type": "string",
          "description": "Class name",
          "minLength": 1
        }
      }
    },
    "functionPointer": {
      "$comment": "Function descriptor",
      "type": "object",
      "required": [
        "namespace",
        "class",
        "function"
      ],
      "properties": {
        "namespace": {
          "type": "string",
          "description": "Namespace"
        },
        "class": {
          "type": "string",
          "description": "Class name"
        },
        "function": {
          "type": "string",
          "description": "Function name",
          "minLength": 1
        }
      }
    },
    "functionPointerWithVirtual": {
      "$comment": "Virtual function descriptor",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/definitions/functionPointer"
        }
      ],
      "required": [
        "enableOnVirtual",
        "propagateVirtual"
      ],
      "properties": {
        "enableOnVirtual": {
          "type": "boolean",
          "description": "Enabled for virtual functions"
        },
        "propagateVirtual": {
          "type": "boolean",
          "description": "Propagate the setting to overriding (derived) functions"
        }
      }
    },
    "utility": {
      "type": "object",
      "description": "Information about the utility that produced the log",
      "required": [
        "name",
        "path",
        "version",
        "hash",
        "isStable",
        "logVersion"
      ],
      "properties": {
        "name": {
          "type": "string",
          "const": "pvs-studio",
          "description": "Human-readable platform-independent utility name"
        },
        "path": {
          "type": "string",
          "description": "Path to the utility executable"
        },
        "version": {
          "type": "string",
          "description": "Utility version"
        },
        "hash": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{32}$",
          "description": "MD5 checksum of the utility file"
        },
        "isStable": {
          "type": "boolean",
          "description": "Release version flag"
        },
        "logVersion": {
          "type": "integer",
          "minimum": 1,
          "description": "Versioning of the log format for this specific utility"
        }
      },
      "additionalProperties": false
    },
    "environment": {
      "type": "object",
      "description": "Information about the environment where the utility was run (host)",
      "required": [
        "os",
        "osVersion",
        "platform",
        "totalRam",
        "totalRamMiB",
        "physicalRam",
        "physicalRamMiB",
        "availableRam",
        "availableRamMiB",
        "variables"
      ],
      "properties": {
        "os": {
          "type": "string",
          "description": "Operating system (Windows, Linux, macOS, AstraLinux, ...)"
        },
        "osVersion": {
          "type": "string",
          "description": "Operating system version"
        },
        "platform": {
          "type": "string",
          "description": "Host platform"
        },
        "totalRam": {
          "$ref": "#/definitions/memorySize",
          "description": "Total RAM (bytes)"
        },
        "totalRamMiB": {
          "$ref": "#/definitions/memorySize",
          "description": "Total RAM (MiB)"
        },
        "physicalRam": {
          "$ref": "#/definitions/memorySize",
          "description": "Physical memory (bytes)"
        },
        "physicalRamMiB": {
          "$ref": "#/definitions/memorySize",
          "description": "Physical memory (MiB)"
        },
        "availableRam": {
          "$ref": "#/definitions/memorySize",
          "description": "Available RAM at startup (bytes)"
        },
        "availableRamMiB": {
          "$ref": "#/definitions/memorySize",
          "description": "Available RAM at startup (MiB)"
        },
        "variables": {
          "$ref": "#/definitions/envVars",
          "description": "Environment variables"
        }
      },
      "additionalProperties": false
    },
    "input": {
      "type": "object",
      "description": "Utility input parameters (explicit and implicit)",
      "required": [
        "arguments",
        "cwd",
        "timestamp",
        "logging"
      ],
      "properties": {
        "arguments": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Utility command-line arguments"
        },
        "cwd": {
          "type": "string",
          "description": "Current working directory of the process"
        },
        "cfg": {
          "type": "string",
          "description": "Path to the cfg file with launch settings"
        },
        "timestamp": {
          "$ref": "#/definitions/timepoint",
          "description": "Start date and time in ISO-8601 UTC+0 format (YYYY-MM-DDThh:mm:ss.sssZ)"
        },
        "logging": {
          "$ref": "#/definitions/logging"
        }
      },
      "additionalProperties": false
    },
    "logging": {
      "type": "object",
      "required": [
        "categories",
        "options",
        "sourceLog"
      ],
      "properties": {
        "categories": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "basic",
              "parser",
              "performance"
            ]
          },
          "minItems": 1,
          "description": "Logging categories"
        },
        "options": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "skip-sensitive",
              "dump-intermediate-files",
              "performance"
            ]
          },
          "description": "Logging options"
        },
        "sourceLog": {
          "type": "string",
          "description": "Path to the raw log file the structured log was produced from"
        }
      },
      "additionalProperties": false
    },
    "output": {
      "type": "object",
      "description": "Utility results",
      "required": [
        "returnCode",
        "stdout",
        "stderr",
        "isFailed"
      ],
      "properties": {
        "returnCode": {
          "type": "integer",
          "description": "Utility exit code"
        },
        "stdout": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "stdout contents (excluding analyzer warnings)"
        },
        "stderr": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "stderr contents (excluding analyzer warnings)"
        },
        "stacktraceFile": {
          "type": "string",
          "description": "Path to the stacktrace file"
        },
        "outputFilePath": {
          "type": "string",
          "description": "Path to the report file. May be absent when output is written to stdout"
        },
        "isFailed": {
          "type": "boolean",
          "description": "Whether the utility considers that it completed successfully"
        }
      },
      "additionalProperties": false
    },
    "basicPerformance": {
      "type": "object",
      "description": "Basic performance metrics",
      "required": [
        "elapsedTime",
        "elapsedTimeISO",
        "peakMemoryConsumption",
        "peakMemoryConsumptionMiB"
      ],
      "properties": {
        "elapsedTime": {
          "$ref": "#/definitions/durationNS",
          "description": "Elapsed time (nanoseconds)"
        },
        "elapsedTimeISO": {
          "$ref": "#/definitions/durationISO",
          "description": "Elapsed time in ISO-8601 format (hh:mm:ss.sssZ)"
        },
        "peakMemoryConsumption": {
          "$ref": "#/definitions/memorySize",
          "description": "Peak memory usage (bytes)"
        },
        "peakMemoryConsumptionMiB": {
          "$ref": "#/definitions/memorySize",
          "description": "Peak memory usage (MiB)"
        }
      },
      "additionalProperties": false
    },
    "source": {
      "type": "object",
      "description": "Information about the analyzed file",
      "required": [
        "sourceFilePath",
        "preprocessedFilePath",
        "comments",
        "pragmas"
      ],
      "properties": {
        "sourceFilePath": {
          "type": "string",
          "description": "Path to the source file"
        },
        "preprocessedFilePath": {
          "type": "string",
          "description": "Path to the preprocessed file"
        },
        "comments": {
          "type": "object",
          "required": [
            "suppression",
            "modifiers"
          ],
          "properties": {
            "suppression": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/sourceCodeEntry"
              },
              "description": "Comments for suppressing warnings"
            },
            "modifiers": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/sourceCodeEntry"
              },
              "description": "Comments for modifying analyzer behavior"
            }
          },
          "additionalProperties": false
        },
        "pragmas": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/sourceCodeEntry"
          },
          "description": "PVS pragmas found in the source file"
        }
      },
      "additionalProperties": false
    },
    "sourceCodeEntry": {
      "$comment": "An entry inside the source code",
      "type": "object",
      "required": [
        "text",
        "source",
        "line"
      ],
      "properties": {
        "text": {
          "type": "string",
          "description": "Text"
        },
        "source": {
          "type": "string",
          "description": "Path to the source file"
        },
        "line": {
          "type": "integer",
          "description": "Line number in the source file"
        }
      },
      "additionalProperties": false
    },
    "configuration": {
      "type": "object",
      "description": "Configuration of diagnostic rules",
      "required": [
        "categories",
        "disabledRules",
        "paths",
        "tweaks",
        "disableTemplateInstantiation",
        "timeout",
        "useHashOnly",
        "useOldParser"
      ],
      "properties": {
        "categories": {
          "type": "object",
          "required": [
            "ga",
            "op",
            "cs",
            "x64",
            "misra",
            "autosar",
            "owasp"
          ],
          "properties": {
            "ga": {
              "type": "boolean",
              "description": "General"
            },
            "op": {
              "type": "boolean",
              "description": "Optimization"
            },
            "cs": {
              "type": "boolean",
              "description": "Customer Specific"
            },
            "x64": {
              "type": "boolean",
              "description": "64-bit"
            },
            "misra": {
              "type": "boolean",
              "description": "MISRA"
            },
            "autosar": {
              "type": "boolean",
              "description": "AUTOSAR"
            },
            "owasp": {
              "type": "boolean",
              "description": "OWASP"
            }
          },
          "additionalProperties": false
        },
        "disabledRules": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^V[0-9]{3,4}$"
          },
          "uniqueItems": true,
          "description": "List of disabled diagnostic rules"
        },
        "paths": {
          "$ref": "#/definitions/pathSettings"
        },
        "tweaks": {
          "$ref": "#/definitions/tweaks"
        },
        "disableTemplateInstantiation": {
          "type": "boolean",
          "description": "Disables template instantiation. Enabled by the comment `//V_DISABLE_TEMPLATE_INSTANTIATION`."
        },
        "timeout": {
          "type": "integer",
          "description": "Time (in seconds) after which file analysis will be automatically terminated. Set by the comment `//V_ANALYSIS_TIMEOUT`.",
          "minimum": 0
        },
        "useHashOnly": {
          "type": "string",
          "enum": [
            "enabled",
            "disabled",
            "verbose"
          ],
          "description": "Enables or disables emitting a warning when any suppression marker without hashes is found. Configured by comments `//V_HASH_ONLY ENABLE` and `//V_HASH_ONLY DISABLE`. When `//V_HASH_ONLY ENABLE_VERBOSE` is enabled, warnings are emitted for all found suppression markers without hashes."
        },
        "useOldParser": {
          "type": "boolean",
          "description": "Enables the old parser instead of the new one. Enabled by the comment `//V_USE_OLD_PARSER`."
        }
      },
      "additionalProperties": false
    },
    "pathSettings": {
      "type": "object",
      "required": [
        "skipSettingsFrom",
        "skipAnalysisFrom"
      ],
      "properties": {
        "skipSettingsFrom": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Paths whose settings are ignored"
        },
        "skipAnalysisFrom": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Paths whose warnings are ignored"
        }
      },
      "additionalProperties": false
    },
    "tweaks": {
      "type": "object",
      "description": "Fine-tuning options for diagnostic rules",
      "required": [
        "assertContract",
        "assertLikeMacros",
        "b64highOnly",
        "b64ignoreSignedness",
        "changeLevel",
        "extendedMessages",
        "formattedIOFunctions",
        "functionAliases",
        "renamedMessages",
        "retNull",
        "retNullAll",
        "retUseAll",
        "showSecID",
        "treatAsUnrealEngineFile",
        "v002verbose",
        "v112ignorePointers",
        "v128includeFunctions",
        "v512overflowOff",
        "v512underflowOff",
        "v512warnOnUnknownFormatArgs",
        "v530includeFunctions",
        "v560pedanticMode",
        "v570warnOnArgumentSelfAssign",
        "v610leftSignOff",
        "v614ignoreSmartPointers",
        "v730printAllUninitDataMembers",
        "v730suppress",
        "v773suppress",
        "v796warnOnAllSwitch",
        "v1007pedanticMode",
        "v1007printCheckers",
        "v1048ignoredValues",
        "v1083checkUnsignedOverflow",
        "v1084turnOffOnMSVC",
        "v1096enableOnTemplates",
        "v1112enableOnUnknownValues",
        "v2005mode",
        "v2016dangerousFunctions",
        "v2021ignoredFunctions",
        "v2591allowedTypes"
      ],
      "properties": {
        "assertContract": {
          "type": "boolean",
          "description": "Treat all assert calls as noreturn function calls."
        },
        "assertLikeMacros": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Names of macros treated as assert."
        },
        "b64highOnly": {
          "type": "boolean",
          "description": "Emit 64-bit diagnostic warnings only at level 1."
        },
        "b64ignoreSignedness": {
          "type": "boolean",
          "description": "Ignore comparisons of signed/unsigned variables for 64-bit diagnostic rules."
        },
        "changeLevel": {
          "type": "object",
          "description": "Override warning levels.",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3
          },
          "propertyNames": {
            "pattern": "^V[0-9]{3,4}$"
          }
        },
        "extendedMessages": {
          "type": "object",
          "description": "Modified messages of diagnostic rules",
          "additionalProperties": {
            "type": "string",
            "minLength": 1
          },
          "propertyNames": {
            "pattern": "^V[0-9]{3,4}$"
          }
        },
        "formattedIOFunctions": {
          "type": "array",
          "items": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/definitions/functionPointerWithVirtual"
              }
            ],
            "required": [
              "formatArgPosition",
              "ellipsisPosition"
            ],
            "properties": {
              "formatArgPosition": {
                "type": "integer",
                "description": "Position of the format-string argument",
                "minimum": 0,
                "exclusiveMaximum": 14
              },
              "ellipsisPosition": {
                "$comment": "Must be less than formatArgPosition",
                "type": "integer",
                "description": "Ellipsis position",
                "minimum": 0,
                "exclusiveMaximum": 15
              }
            },
            "unevaluatedProperties": false
          },
          "description": "Functions marked as 'formatted output' functions"
        },
        "functionAliases": {
          "type": "array",
          "items": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/definitions/functionPointerWithVirtual"
              }
            ],
            "required": [
              "implementation"
            ],
            "properties": {
              "implementation": {
                "type": "string",
                "description": "Implementation for which an alias is created",
                "minLength": 1
              }
            },
            "unevaluatedProperties": false
          },
          "description": "Functions marked as 'formatted output' functions"
        },
        "renamedMessages": {
          "type": "object",
          "description": "Changed diagnostic rule messages.",
          "additionalItems": {
            "type": "object",
            "description": "Rename entry",
            "required": [
              "original",
              "replacement"
            ],
            "properties": {
              "original": {
                "type": "string",
                "description": "Original substring",
                "minLength": 1
              },
              "replacement": {
                "type": "string",
                "description": "Replacement string"
              }
            },
            "additionalProperties": false
          }
        },
        "retNull": {
          "type": "array",
          "description": "Whether a function may return a null pointer.",
          "items": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/definitions/functionPointerWithVirtual"
              }
            ],
            "required": [
              "isNotNullResult"
            ],
            "properties": {
              "isNotNullResult": {
                "type": "boolean",
                "description": "Returns null or not"
              }
            },
            "unevaluatedProperties": false
          }
        },
        "retNullAll": {
          "type": "boolean",
          "description": "Emit warnings for all places where pointers are used without a check."
        },
        "retUseAll": {
          "type": "boolean",
          "description": "Emit warnings for all places where a function's return value is not used."
        },
        "showSecID": {
          "type": "boolean",
          "description": "Enables or disables displaying potential security issues."
        },
        "treatAsUnrealEngineFile": {
          "type": "boolean",
          "description": "Treat the file as using Unreal Engine functionality."
        },
        "v002verbose": {
          "type": "boolean",
          "description": "[V002] Enables the mechanism for detecting potential shifts in preprocessed files."
        },
        "v112ignorePointers": {
          "type": "boolean",
          "description": "[V112] Do not emit warnings on pointers."
        },
        "v128includeFunctions": {
          "type": "array",
          "description": "[V128] Emit a warning when a memsize-type value is passed to the specified function.",
          "items": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/definitions/functionPointer"
              }
            ],
            "required": [
              "position"
            ],
            "properties": {
              "position": {
                "type": "integer",
                "description": "Parameter position that must not receive a memsize-type value",
                "minimum": 0,
                "exclusiveMaximum": 15
              }
            },
            "unevaluatedProperties": false
          }
        },
        "v512overflowOff": {
          "type": "boolean",
          "description": "[V512] Disable the diagnostic rule for buffer overflow cases."
        },
        "v512underflowOff": {
          "type": "boolean",
          "description": "[V1086] Disable the diagnostic rule for cases of incomplete buffer processing."
        },
        "v512warnOnUnknownFormatArgs": {
          "type": "boolean",
          "description": "[V512] Emit warnings for variables of unknown size used in formatted I/O functions."
        },
        "v530includeFunctions": {
          "type": "array",
          "description": "[V530] Requires checking the return value for the specified function.",
          "items": {
            "$ref": "#/definitions/functionPointerWithVirtual",
            "unevaluatedProperties": false
          }
        },
        "v560pedanticMode": {
          "type": "boolean",
          "description": "[V560] Enables more checks in the diagnostic rule."
        },
        "v570warnOnArgumentSelfAssign": {
          "type": "boolean",
          "description": "[V570] Emit warnings for cases where a variable is assigned to itself."
        },
        "v610leftSignOff": {
          "type": "boolean",
          "description": "[V610] Do not emit warnings in cases where the left operand is negative."
        },
        "v614ignoreSmartPointers": {
          "type": "boolean",
          "description": "[V614] Disable the diagnostic rule for smart pointers."
        },
        "v730printAllUninitDataMembers": {
          "type": "boolean",
          "description": "[V730] Include names of all uninitialized class members in the diagnostic message."
        },
        "v730suppress": {
          "description": "[V730] Do not emit warnings for variables of the specified type.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/classPointer",
            "unevaluatedProperties": false
          }
        },
        "v773suppress": {
          "description": "[V773] Do not emit warnings for variables of the specified type.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/classPointer",
            "unevaluatedProperties": false
          }
        },
        "v796warnOnAllSwitch": {
          "type": "boolean",
          "description": "[V796] Emit warnings for small switch statements without break (up to two cases)."
        },
        "v1007pedanticMode": {
          "type": "boolean",
          "description": "[V1007] Treat unknown optionals as potentially uninitialized."
        },
        "v1007printCheckers": {
          "type": "boolean",
          "description": "[V1007] Add the list of value-checking functions to the diagnostic message."
        },
        "v1048ignoredValues": {
          "description": "[V1048] Values for which no warning should be emitted when assigned.",
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "v1083checkUnsignedOverflow": {
          "type": "boolean",
          "description": "[V1083] Emit warnings on unsigned integer overflow."
        },
        "v1084turnOffOnMSVC": {
          "type": "boolean",
          "description": "[V1084] Disable the diagnostic rule on the MSVC compiler."
        },
        "v1096enableOnTemplates": {
          "type": "boolean",
          "description": "[V1096] Emit warnings in template classes."
        },
        "v1112enableOnUnknownValues": {
          "type": "boolean",
          "description": "[V1112] Emit warnings when comparing operands with different signedness."
        },
        "v2005mode": {
          "type": "string",
          "enum": [
            "None",
            "All",
            "NoSimple"
          ],
          "description": "[V2005] Sets the mode for hints about possible casts."
        },
        "v2016dangerousFunctions": {
          "description": "[V2016] Functions marked as dangerous.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/functionPointerWithVirtual",
            "unevaluatedProperties": false
          }
        },
        "v2021ignoredFunctions": {
          "description": "[2021] Functions in which calling assert is allowed.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/functionPointerWithVirtual",
            "unevaluatedProperties": false
          }
        },
        "v2591allowedTypes": {
          "description": "[V2591] Allowed types for declaring bit fields.",
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "char",
              "short",
              "long",
              "longLong"
            ],
            "uniqueItems": true
          }
        }
      },
      "additionalProperties": false
    }
  }
}
