From 204ba078a01056a70a0b088cc9ab3be75724c88f Mon Sep 17 00:00:00 2001 From: Matthew Rich Date: Fri, 27 Sep 2024 00:51:07 +0000 Subject: [PATCH] add config schemas --- .../resource/schemas/config/block.schema.json | 25 +++++++ .../schemas/config/certificate.schema.json | 62 ++++++++++++++++++ .../schemas/config/config.schema.json | 18 +++++ .../schemas/config/document.schema.json | 19 ++++++ .../schemas/config/pkixname.schema.json | 65 +++++++++++++++++++ 5 files changed, 189 insertions(+) create mode 100644 internal/resource/schemas/config/block.schema.json create mode 100644 internal/resource/schemas/config/certificate.schema.json create mode 100644 internal/resource/schemas/config/config.schema.json create mode 100644 internal/resource/schemas/config/document.schema.json create mode 100644 internal/resource/schemas/config/pkixname.schema.json diff --git a/internal/resource/schemas/config/block.schema.json b/internal/resource/schemas/config/block.schema.json new file mode 100644 index 0000000..287f3eb --- /dev/null +++ b/internal/resource/schemas/config/block.schema.json @@ -0,0 +1,25 @@ +{ + "$id": "block.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "block", + "type": "object", + "required": [ "name", "values" ], + "properties": { + "name": { + "type": "string", + "description": "Config block name", + "minLength": 2 + }, + "type": { + "type": "string", + "description": "Config type name.", + "enum": [ "system", "generic", "exec", "certificate" ] + }, + "values": { + "oneOf": [ + { "type": "object" }, + { "$ref": "certificate.schema.json" } + ] + } + } +} diff --git a/internal/resource/schemas/config/certificate.schema.json b/internal/resource/schemas/config/certificate.schema.json new file mode 100644 index 0000000..27bc4d6 --- /dev/null +++ b/internal/resource/schemas/config/certificate.schema.json @@ -0,0 +1,62 @@ +{ + "$id": "certificate.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "certificate", + "type": "object", + "required": [ "path", "filetype" ], + "properties": { + "SerialNumber": { + "type": "integer", + "description": "Serial number", + "minLength": 1 + }, + "Issuer": { + "$ref": "pkixname.schema.json" + }, + "Subject": { + "$ref": "pkixname.schema.json" + }, + "NotBefore": { + "type": "string", + "format": "date-time", + "description": "Cert is not valid before time in YYYY-MM-DDTHH:MM:SS.sssssssssZ format." + }, + "NotAfter": { + "type": "string", + "format": "date-time", + "description": "Cert is not valid after time in YYYY-MM-DDTHH:MM:SS.sssssssssZ format." + }, + "KeyUsage": { + "type": "integer", + "enum": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "description": "Actions valid for a key. E.g. 1 = KeyUsageDigitalSignature" + }, + "ExtKeyUsage": { + "type": "array", + "items": { + "type": "integer", + "minimum": 0, + "maximum": 13 + }, + "description": "Extended set of actions valid for a key" + }, + "BasicConstraintsValid": { + "type": "boolean", + "description": "BasicConstraintsValid indicates whether IsCA, MaxPathLen, and MaxPathLenZero are valid" + }, + "IsCA": { + "type": "boolean", + "description": "" + } + } +} diff --git a/internal/resource/schemas/config/config.schema.json b/internal/resource/schemas/config/config.schema.json new file mode 100644 index 0000000..d4d8e41 --- /dev/null +++ b/internal/resource/schemas/config/config.schema.json @@ -0,0 +1,18 @@ +{ + "$id": "config.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "config", + "type": "object", + "required": [ "configurations" ], + "properties": { + "configurations": { + "type": "array", + "description": "Configurations list", + "items": { + "oneOf": [ + { "$ref": "block.schema.json" } + ] + } + } + } +} diff --git a/internal/resource/schemas/config/document.schema.json b/internal/resource/schemas/config/document.schema.json new file mode 100644 index 0000000..6b59cdd --- /dev/null +++ b/internal/resource/schemas/config/document.schema.json @@ -0,0 +1,19 @@ +{ + "$id": "document.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "document", + "type": "object", + "required": [ "configurations" ], + "properties": { + "configurations": { + "type": "array", + "description": "Configurations list", + "items": { + "oneOf": [ + { "$ref": "block.schema.json" } + ] + } + } + } +} + diff --git a/internal/resource/schemas/config/pkixname.schema.json b/internal/resource/schemas/config/pkixname.schema.json new file mode 100644 index 0000000..4a8dcdf --- /dev/null +++ b/internal/resource/schemas/config/pkixname.schema.json @@ -0,0 +1,65 @@ +{ + "$id": "pkixname.schema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "pkixname", + "type": "object", + "properties": { + "Country": { + "type": "array", + "description": "Country name", + "items": { + "type": "string" + } + }, + "Organization": { + "type": "array", + "description": "Organization name", + "items": { + "type": "string" + } + }, + "OrganizationalUnit": { + "type": "array", + "description": "Organizational Unit name", + "items": { + "type": "string" + } + }, + "Locality": { + "type": "array", + "description": "Locality name", + "items": { + "type": "string" + } + }, + "Province": { + "type": "array", + "description": "Province name", + "items": { + "type": "string" + } + }, + "StreetAddress": { + "type": "array", + "description": "Street address", + "items": { + "type": "string" + } + }, + "PostalCode": { + "type": "array", + "description": "Postal Code", + "items": { + "type": "string" + } + }, + "SerialNumber": { + "type": "string", + "description": "" + }, + "CommonName": { + "type": "string", + "description": "Name" + } + } +}