Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
- **mxGraph**: Updated the vendored mxGraph from 4.1.0 to 4.2.2, the final release before the project was archived. Upstream changed the modifier that deletes a cell together with its connected edges from Shift to Ctrl.
- **Editor**: The sidebar node palettes now open expanded, the export dialog offers only the XML and SVG formats the server can produce, and the Help button opens the ph膿nix documentation instead of the defunct `minimega.org`.
- **Topology validation**: Reject the node hostnames `all`, all-digit names, and `phenix` on Windows nodes, and warn about hostnames that may cause problems.
- **Topology schema**: Require node hostnames to be at least 2 characters long.

### Fixed

Expand Down
13 changes: 13 additions & 0 deletions src/go/types/schema_topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ func TestTopologySchema(t *testing.T) {
node: withHostname(validNode(), ""),
wantErr: true,
},
{
name: "1-character hostname is rejected",
node: withHostname(validNode(), "a"),
wantErr: true,
},
{
name: "2-character hostname is valid",
node: withHostname(validNode(), "a1"),
},
{
name: "63-character hostname is valid",
node: withHostname(validNode(), strings.Repeat("a", 63)),
},
{
name: "invalid vm_type is rejected",
node: func() map[string]any {
Expand Down
15 changes: 13 additions & 2 deletions src/go/types/version/schemas/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,21 @@ components:
- hostname
properties:
hostname:
# 2 to 63 letters, digits, and interior hyphens. Guest operating
# systems phenix configures reject 1-character hostnames.
#
# VyOS and Vyatta validate `system host-name` against
# `[A-Za-z0-9][-.A-Za-z0-9]*[A-Za-z0-9]`, which needs at least 2
# characters:
# https://docs.vyos.io/en/latest/configuration/system/host-name.html
# https://github.com/vyos/vyos-1x/blob/ed218c254d964775ddf24158ac6520972d575faf/interface-definitions/include/constraint/host-name.xml.i
#
# Windows DNS host names have a 2-character minimum:
# https://learn.microsoft.com/en-us/troubleshoot/windows-server/active-directory/naming-conventions-for-computer-domain-site-ou#dns-host-names
type: string
minLength: 1
minLength: 2
maxLength: 63
pattern: '^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'
pattern: '^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$'
example: ADServer
description:
type: string
Expand Down
15 changes: 13 additions & 2 deletions src/go/types/version/schemas/v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,21 @@ components:
- hostname
properties:
hostname:
# 2 to 63 letters, digits, and interior hyphens. Guest operating
# systems phenix configures reject 1-character hostnames.
#
# VyOS and Vyatta validate `system host-name` against
# `[A-Za-z0-9][-.A-Za-z0-9]*[A-Za-z0-9]`, which needs at least 2
# characters:
# https://docs.vyos.io/en/latest/configuration/system/host-name.html
# https://github.com/vyos/vyos-1x/blob/ed218c254d964775ddf24158ac6520972d575faf/interface-definitions/include/constraint/host-name.xml.i
#
# Windows DNS host names have a 2-character minimum:
# https://learn.microsoft.com/en-us/troubleshoot/windows-server/active-directory/naming-conventions-for-computer-domain-site-ou#dns-host-names
type: string
minLength: 1
minLength: 2
maxLength: 63
pattern: '^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'
pattern: '^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$'
example: ADServer
description:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"$id": "#/nodes/properties/general/properties/hostname",
"type": "string",
"title": "Hostname",
"minLength": 1,
"minLength": 2,
"default": "",
"examples": [
"power-provider"
],
"maxLength": 63,
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$"
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$"
},
"description": {
"$id": "#/nodes/properties/general/properties/description",
Expand Down
4 changes: 2 additions & 2 deletions src/go/web/public/grapheditor/utils/schemas/kvm_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@
"$id": "#/nodes/properties/general/properties/hostname",
"type": "string",
"title": "Hostname",
"minLength": 1,
"minLength": 2,
"examples": [
"ADServer"
],
"maxLength": 63,
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$"
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$"
},
"description": {
"$id": "#/nodes/properties/general/properties/description",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@
"$id": "#/nodes/properties/general/properties/hostname",
"type": "string",
"title": "Hostname",
"minLength": 1,
"minLength": 2,
"examples": [
"ADServer"
],
"maxLength": 63,
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$"
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$"
},
"description": {
"$id": "#/nodes/properties/general/properties/description",
Expand Down
4 changes: 2 additions & 2 deletions src/go/web/public/grapheditor/utils/schemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@
"$id": "#/properties/nodes/items/properties/general/properties/hostname",
"type": "string",
"title": "Hostname",
"minLength": 1,
"minLength": 2,
"default": "",
"examples": [
"power-provider"
],
"maxLength": 63,
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$"
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$"
},
"description": {
"$id": "#/properties/nodes/items/properties/general/properties/description",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@
"$id": "#/nodes/properties/general/properties/hostname",
"type": "string",
"title": "Hostname",
"minLength": 1,
"minLength": 2,
"examples": [
"ADServer"
],
"maxLength": 63,
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$"
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$"
},
"description": {
"$id": "#/nodes/properties/general/properties/description",
Expand Down Expand Up @@ -1076,12 +1076,12 @@
"$id": "#/nodes/properties/general/properties/hostname",
"type": "string",
"title": "Hostname",
"minLength": 1,
"minLength": 2,
"examples": [
"ADServer"
],
"maxLength": 63,
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$"
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$"
},
"description": {
"$id": "#/nodes/properties/general/properties/description",
Expand Down
Loading