JSON Schema 2020-12
Реестр контрольных сумм
Реестр SHA-256 с безопасными относительными путями.
Схема
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://sharprod.com/schemas/checksum-inventory.schema.json",
"title": "SHAR Production Checksum Inventory Contract",
"type": "object",
"additionalProperties": false,
"properties": {
"algorithm": {
"const": "sha256"
},
"files": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": [
"path",
"sha256"
],
"properties": {
"path": {
"type": "string",
"pattern": "^[^./][^\\\\]*$"
},
"sha256": {
"type": "string",
"pattern": "^[a-f0-9]{64}$"
}
}
}
}
},
"required": [
"algorithm",
"files"
]
}Проверенный пример
{
"input": {
"algorithm": "sha256",
"files": [
{
"path": "masters/final.mov",
"sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
}
]
},
"result": {
"valid": true,
"errors": []
}
}Отклонённый пример
{
"input": {
"algorithm": "md5",
"files": []
},
"result": {
"valid": false,
"errors": [
{
"instancePath": "/algorithm",
"schemaPath": "#/properties/algorithm/const",
"keyword": "const",
"params": {
"allowedValue": "sha256"
},
"message": "must be equal to constant"
}
]
}
}