diff --git a/internal/validation/schema/config/config.schema.json b/internal/validation/schema/config/config.schema.json new file mode 100644 index 0000000..2a8c292 --- /dev/null +++ b/internal/validation/schema/config/config.schema.json @@ -0,0 +1,36 @@ +{ + "$id": "https://nfsense.net/schema/config/config.schema.json", + "title": "Config", + "type": "object", + "properties": { + "config_version": { + "type": "number", + "const": 1 + }, + "firewall": { + "description": "System Settings", + "$ref": "https://nfsense.net/schema/firewall/firewall.schema.json" + }, + "object": { + "description": "Object Settings", + "$ref": "https://nfsense.net/schema/object/object.schema.json" + }, + "network": { + "description": "Network Settings", + "$ref": "https://nfsense.net/schema/network/network.schema.json" + }, + "service": { + "description": "Service Settings", + "$ref": "https://nfsense.net/schema/service/service.schema.json" + }, + "vpn": { + "description": "VPN Settings", + "$ref": "https://nfsense.net/schema/vpn/vpn.schema.json" + }, + "system": { + "description": "System Settings", + "$ref": "https://nfsense.net/schema/system/system.schema.json" + } + }, + "required": ["config_version", "firewall", "object", "network", "service", "vpn", "system"] +} \ No newline at end of file diff --git a/internal/validation/schema/firewall/destination_nat_rule.schema.json b/internal/validation/schema/firewall/destination_nat_rule.schema.json new file mode 100644 index 0000000..4cb8910 --- /dev/null +++ b/internal/validation/schema/firewall/destination_nat_rule.schema.json @@ -0,0 +1,14 @@ +{ + "$id": "https://nfsense.net/schema/firewall/destination_nat_rule.schema.json", + "title": "Destination NAT Rule", + "$ref": "https://nfsense.net/schema/firewall/rule.schema.json", + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "service": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/internal/validation/schema/firewall/firewall.schema.json b/internal/validation/schema/firewall/firewall.schema.json new file mode 100644 index 0000000..2ff63f8 --- /dev/null +++ b/internal/validation/schema/firewall/firewall.schema.json @@ -0,0 +1,26 @@ +{ + "$id": "https://nfsense.net/schema/firewall/firewall.schema.json", + "title": "Firewall", + "type": "object", + "properties": { + "forward_rules": { + "type": "array", + "items": { + "$ref": "https://nfsense.net/schema/firewall/forward_rule.schema.json" + } + }, + "destination_nat_rules": { + "type": "array", + "items": { + "$ref": "https://nfsense.net/schema/firewall/destination_nat_rule.schema.json" + } + }, + "source_nat_rules": { + "type": "array", + "items": { + "$ref": "https://nfsense.net/schema/firewall/source_nat_rule.schema.json" + } + } + }, + "required": ["forward_rules", "destination_nat_rules", "source_nat_rules"] +} \ No newline at end of file diff --git a/internal/validation/schema/firewall/forward_rule.schema.json b/internal/validation/schema/firewall/forward_rule.schema.json new file mode 100644 index 0000000..1d19dbf --- /dev/null +++ b/internal/validation/schema/firewall/forward_rule.schema.json @@ -0,0 +1,12 @@ +{ + "$id": "https://nfsense.net/schema/firewall/forward_rule.schema.json", + "title": "Forward Rule", + "$ref": "https://nfsense.net/schema/firewall/rule.schema.json", + "type": "object", + "properties": { + "verdict": { + "type": "string" + } + }, + "required": ["verdict"] +} \ No newline at end of file diff --git a/internal/validation/schema/firewall/match.schema.json b/internal/validation/schema/firewall/match.schema.json new file mode 100644 index 0000000..6837e34 --- /dev/null +++ b/internal/validation/schema/firewall/match.schema.json @@ -0,0 +1,25 @@ +{ + "$id": "https://nfsense.net/schema/firewall/match.schema.json", + "title": "Match", + "type": "object", + "properties": { + "services": { + "type": "array", + "items": { + "type": "string" + } + }, + "source_addresses": { + "type": "array", + "items": { + "type": "string" + } + }, + "destination_addresses": { + "type": "array", + "items": { + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/internal/validation/schema/firewall/rule.schema.json b/internal/validation/schema/firewall/rule.schema.json new file mode 100644 index 0000000..8169a96 --- /dev/null +++ b/internal/validation/schema/firewall/rule.schema.json @@ -0,0 +1,20 @@ +{ + "$id": "https://nfsense.net/schema/firewall/rule.schema.json", + "title": "Rule", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "match": { + "$ref": "https://nfsense.net/schema/firewall/match.schema.json" + }, + "comment": { + "type": "string" + }, + "counter": { + "type": "boolean" + } + }, + "required": ["name", "match"] +} \ No newline at end of file diff --git a/internal/validation/schema/firewall/source_nat_rule.schema.json b/internal/validation/schema/firewall/source_nat_rule.schema.json new file mode 100644 index 0000000..7593b53 --- /dev/null +++ b/internal/validation/schema/firewall/source_nat_rule.schema.json @@ -0,0 +1,17 @@ +{ + "$id": "https://nfsense.net/schema/firewall/source_nat_rule.schema.json", + "title": "Source NAT Rule", + "$ref": "https://nfsense.net/schema/firewall/rule.schema.json", + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "address": { + "type": "string" + }, + "service": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/internal/validation/schema/network/interface.schema.json b/internal/validation/schema/network/interface.schema.json new file mode 100644 index 0000000..42e5a86 --- /dev/null +++ b/internal/validation/schema/network/interface.schema.json @@ -0,0 +1,44 @@ +{ + "$id": "https://nfsense.net/schema/network/interface.schema.json", + "title": "Interface", + "type": "object", + "properties": { + "alias": { + "type": "string" + }, + "type": { + "type": "string" + }, + "addressing_mode": { + "type": "string" + }, + "address": { + "type": "string" + }, + "hardware_device": { + "type": "string" + }, + "vlan_id": { + "type": "number" + }, + "vlan_parent": { + "type": "string" + }, + "bond_members": { + "type": "array", + "items": { + "type": "string" + } + }, + "bridge_members": { + "type": "array", + "items": { + "type": "string" + } + }, + "comment": { + "type": "string" + } + }, + "required": ["type", "addressing_mode"] +} \ No newline at end of file diff --git a/internal/validation/schema/network/network.schema.json b/internal/validation/schema/network/network.schema.json new file mode 100644 index 0000000..15a11f1 --- /dev/null +++ b/internal/validation/schema/network/network.schema.json @@ -0,0 +1,20 @@ +{ + "$id": "https://nfsense.net/schema/network/network.schema.json", + "title": "Network", + "type": "object", + "properties": { + "interfaces": { + "type": "object", + "additionalProperties": { + "$ref": "https://nfsense.net/schema/network/interface.schema.json" + } + }, + "static_routes": { + "type": "array", + "items": { + "$ref": "https://nfsense.net/schema/network/static_route.schema.json" + } + } + }, + "required": ["interfaces"] +} \ No newline at end of file diff --git a/internal/validation/schema/network/static_route.schema.json b/internal/validation/schema/network/static_route.schema.json new file mode 100644 index 0000000..742d663 --- /dev/null +++ b/internal/validation/schema/network/static_route.schema.json @@ -0,0 +1,23 @@ +{ + "$id": "https://nfsense.net/schema/network/static_route.schema.json", + "title": "Static Route", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "interface": { + "type": "string" + }, + "gateway": { + "type": "string" + }, + "destination": { + "type": "string" + }, + "metric": { + "type": "number" + } + }, + "required": ["name", "interface", "gateway", "destination"] +} \ No newline at end of file diff --git a/internal/validation/schema/object/address.schema.json b/internal/validation/schema/object/address.schema.json new file mode 100644 index 0000000..3f5ca3b --- /dev/null +++ b/internal/validation/schema/object/address.schema.json @@ -0,0 +1,29 @@ +{ + "$id": "https://nfsense.net/schema/object/address.schema.json", + "title": "Address", + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "host": { + "type": "string" + }, + "range": { + "type": "string" + }, + "network": { + "type": "string" + }, + "children": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["type"] +} \ No newline at end of file diff --git a/internal/validation/schema/object/object.schema.json b/internal/validation/schema/object/object.schema.json new file mode 100644 index 0000000..a59f62d --- /dev/null +++ b/internal/validation/schema/object/object.schema.json @@ -0,0 +1,20 @@ +{ + "$id": "https://nfsense.net/schema/object/object.schema.json", + "title": "Object", + "type": "object", + "properties": { + "addresses": { + "type": "object", + "additionalProperties": { + "$ref": "https://nfsense.net/schema/object/address.schema.json" + } + }, + "services": { + "type": "object", + "additionalProperties": { + "$ref": "https://nfsense.net/schema/object/service.schema.json" + } + } + }, + "required": ["addresses", "services"] +} \ No newline at end of file diff --git a/internal/validation/schema/object/service.schema.json b/internal/validation/schema/object/service.schema.json new file mode 100644 index 0000000..47b15d4 --- /dev/null +++ b/internal/validation/schema/object/service.schema.json @@ -0,0 +1,35 @@ +{ + "$id": "https://nfsense.net/schema/object/service.schema.json", + "title": "Service", + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "comment": { + "type": "string" + }, + "sport_start": { + "type": "number" + }, + "sport_end": { + "type": "number" + }, + "dport_start": { + "type": "number" + }, + "dport_end": { + "type": "number" + }, + "icmp_code": { + "type": "number" + }, + "children": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["type"] +} \ No newline at end of file diff --git a/internal/validation/schema/service/dhcp_reservation.schema.json b/internal/validation/schema/service/dhcp_reservation.schema.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/internal/validation/schema/service/dhcp_reservation.schema.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/internal/validation/schema/service/dhcp_v4_server.schema.json b/internal/validation/schema/service/dhcp_v4_server.schema.json new file mode 100644 index 0000000..36147eb --- /dev/null +++ b/internal/validation/schema/service/dhcp_v4_server.schema.json @@ -0,0 +1,57 @@ +{ + "$id": "https://nfsense.net/schema/service/dhcp_v4_server.schema.json", + "title": "DHCP Server", + "type": "object", + "properties": { + "interface": { + "type": "string" + }, + "pool": { + "type": "array", + "items": { + "type": "string" + } + }, + "default_lease_time": { + "type": "number" + }, + "max_lease_time": { + "type": "number" + }, + "gateway_mode": { + "type": "string" + }, + "gateway": { + "type": "string" + }, + "dns_server_mode": { + "type": "string" + }, + "dns_servers": { + "type": "array", + "items": { + "type": "string" + } + }, + "ntp_server_mode": { + "type": "string" + }, + "ntp_servers": { + "type": "array", + "items": { + "type": "string" + } + }, + "reservations": { + "type": ["object", "null"], + "additionalProperties": { + "description": "DHCP Reservations", + "$ref": "https://nfsense.net/schema/service/dhcp_reservation.schema.json" + } + }, + "comment": { + "type": "string" + } + }, + "required": ["interface", "pool", "default_lease_time", "max_lease_time", "gateway_mode", "dns_server_mode", "ntp_server_mode"] +} \ No newline at end of file diff --git a/internal/validation/schema/service/dns_server.schema.json b/internal/validation/schema/service/dns_server.schema.json new file mode 100644 index 0000000..6075461 --- /dev/null +++ b/internal/validation/schema/service/dns_server.schema.json @@ -0,0 +1,14 @@ +{ + "$id": "https://nfsense.net/schema/service/dns_server.schema.json", + "title": "DNS Server", + "type": "object", + "properties": { + "interface": { + "type": "string" + }, + "comment": { + "type": "string" + } + }, + "required": ["interface"] +} \ No newline at end of file diff --git a/internal/validation/schema/service/ntp_server.schema.json b/internal/validation/schema/service/ntp_server.schema.json new file mode 100644 index 0000000..c8e3411 --- /dev/null +++ b/internal/validation/schema/service/ntp_server.schema.json @@ -0,0 +1,14 @@ +{ + "$id": "https://nfsense.net/schema/service/ntp_server.schema.json", + "title": "NTP Server", + "type": "object", + "properties": { + "interface": { + "type": "string" + }, + "comment": { + "type": "string" + } + }, + "required": ["interface"] +} \ No newline at end of file diff --git a/internal/validation/schema/service/service.schema.json b/internal/validation/schema/service/service.schema.json new file mode 100644 index 0000000..08bafb5 --- /dev/null +++ b/internal/validation/schema/service/service.schema.json @@ -0,0 +1,31 @@ +{ + "$id": "https://nfsense.net/schema/service/service.schema.json", + "title": "Service", + "type": "object", + "properties": { + "dhcp_v4_servers": { + "type": "array", + "items": { + "$ref": "https://nfsense.net/schema/service/dhcp_v4_server.schema.json" + } + }, + "dhcp_v6_servers": { + "type": "array", + "items": { + "$ref": "https://nfsense.net/schema/service/dhcp_v4_server.schema.json" + } + }, + "dns_servers": { + "type": "array", + "items": { + "$ref": "https://nfsense.net/schema/service/dns_server.schema.json" + } + }, + "ntp_servers": { + "type": "array", + "items": { + "$ref": "https://nfsense.net/schema/service/ntp_server.schema.json" + } + } + } +} \ No newline at end of file diff --git a/internal/validation/schema/system/system.schema.json b/internal/validation/schema/system/system.schema.json new file mode 100644 index 0000000..aa9adf1 --- /dev/null +++ b/internal/validation/schema/system/system.schema.json @@ -0,0 +1,15 @@ +{ + "$id": "https://nfsense.net/schema/system/system.schema.json", + "title": "System", + "type": "object", + "properties": { + "users": { + "type": "object", + "additionalProperties": { + "description": "System Settings", + "$ref": "https://nfsense.net/schema/system/user.schema.json" + } + } + }, + "required": ["users"] +} \ No newline at end of file diff --git a/internal/validation/schema/system/user.schema.json b/internal/validation/schema/system/user.schema.json new file mode 100644 index 0000000..282f292 --- /dev/null +++ b/internal/validation/schema/system/user.schema.json @@ -0,0 +1,18 @@ +{ + "$id": "https://nfsense.net/schema/system/user.schema.json", + "title": "User", + "type": "object", + "properties": { + "comment": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "salt": { + "type": "string" + } + }, + "required": ["hash", "salt"] + +} \ No newline at end of file diff --git a/internal/validation/schema/vpn/vpn.schema.json b/internal/validation/schema/vpn/vpn.schema.json new file mode 100644 index 0000000..3223a5e --- /dev/null +++ b/internal/validation/schema/vpn/vpn.schema.json @@ -0,0 +1,11 @@ +{ + "$id": "https://nfsense.net/schema/vpn/vpn.schema.json", + "title": "VPN", + "type": "object", + "properties": { + "wireguard": { + "$ref": "https://nfsense.net/schema/vpn/wireguard.schema.json" + } + }, + "required": ["wireguard"] +} \ No newline at end of file diff --git a/internal/validation/schema/vpn/wireguard.schema.json b/internal/validation/schema/vpn/wireguard.schema.json new file mode 100644 index 0000000..1803fff --- /dev/null +++ b/internal/validation/schema/vpn/wireguard.schema.json @@ -0,0 +1,22 @@ +{ + "$id": "https://nfsense.net/schema/vpn/wireguard.schema.json", + "title": "Wireguard", + "type": "object", + "properties": { + "interfaces": { + "type": "object", + "additionalProperties": { + "description": "Wireguard Interface", + "$ref": "https://nfsense.net/schema/vpn/wireguard_interface.schema.json" + } + }, + "peers": { + "type": "object", + "additionalProperties": { + "description": "Wireguard Peer", + "$ref": "https://nfsense.net/schema/vpn/wireguard_peer.schema.json" + } + } + }, + "required": ["interfaces", "peers"] +} \ No newline at end of file diff --git a/internal/validation/schema/vpn/wireguard_interface.schema.json b/internal/validation/schema/vpn/wireguard_interface.schema.json new file mode 100644 index 0000000..80a1285 --- /dev/null +++ b/internal/validation/schema/vpn/wireguard_interface.schema.json @@ -0,0 +1,26 @@ +{ + "$id": "https://nfsense.net/schema/vpn/wireguard_interface.schema.json", + "title": "Wireguard Interface", + "type": "object", + "properties": { + "public_key": { + "type": "string" + }, + "private_key": { + "type": "string" + }, + "listen_port": { + "type": "number" + }, + "peers": { + "type": "array", + "items": { + "type": "string" + } + }, + "comment": { + "type": "string" + } + }, + "required": ["public_key", "private_key", "listen_port", "peers"] +} \ No newline at end of file diff --git a/internal/validation/schema/vpn/wireguard_peer.schema.json b/internal/validation/schema/vpn/wireguard_peer.schema.json new file mode 100644 index 0000000..0ecc830 --- /dev/null +++ b/internal/validation/schema/vpn/wireguard_peer.schema.json @@ -0,0 +1,29 @@ +{ + "$id": "https://nfsense.net/schema/vpn/wireguard_peer.schema.json", + "title": "Wireguard Peer", + "type": "object", + "properties": { + "public_key": { + "type": "string" + }, + "preshared_key": { + "type": ["string", "null"] + }, + "allowed_ips": { + "type": "array", + "items": { + "type": "string" + } + }, + "endpoint": { + "type": ["string", "null"] + }, + "persistent_keepalive": { + "type": ["number", "null"] + }, + "comment": { + "type": "string" + } + }, + "required": ["public_key", "allowed_ips"] +} \ No newline at end of file diff --git a/internal/validation/schemas/config.schema.json b/internal/validation/schemas/config.schema.json deleted file mode 100644 index 9d0d4b7..0000000 --- a/internal/validation/schemas/config.schema.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$id": "https://nfsense.net/config.schema.json", - "title": "Config", - "type": "object", - "properties": { - "config_version": { - "type": "number", - "const": 1 - }, - "firewall": { - "type": ["number","string","boolean","object","array", "null"] - }, - "object": { - "type": ["number","string","boolean","object","array", "null"] - }, - "network": { - "type": ["number","string","boolean","object","array", "null"] - }, - "service": { - "type": ["number","string","boolean","object","array", "null"] - }, - "vpn": { - "type": ["number","string","boolean","object","array", "null"] - }, - "system": { - "description": "System Settings", - "$ref": "https://nfsense.net/system.schema.json" - } - }, - "required": ["config_version", "firewall", "object", "network", "service", "vpn", "system"] -} \ No newline at end of file diff --git a/internal/validation/schemas/system.schema.json b/internal/validation/schemas/system.schema.json deleted file mode 100644 index d66fe90..0000000 --- a/internal/validation/schemas/system.schema.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$id": "https://nfsense.net/system.schema.json", - "title": "System", - "type": "object", - "properties": { - "users": { - "type": "object", - "additionalProperties": { - "type": "object", - "properties": { - "comment": { - "type": "string" - }, - "hash": { - "type": "string" - }, - "salt": { - "type": "string" - } - }, - "required": ["hash", "salt"] - } - } - }, - "required": ["users"] -} \ No newline at end of file