KMNS logo KMNS / Validate Docs
v0.4.0 ← Platform Hub GitHub ↗

Ports & Sockets

Asserts TCP and UDP listening ports and IP interface bindings via direct kernel socket syscalls.


Canonical Syntax (kmns.io/validate/v1alpha1)

Local Port Listener (kind: port)

Inspects local host socket tables without executing external CLI tools like netstat or ss:

# yaml-language-server: $schema=https://kmns.io/validate/v1alpha1
schema_version: kmns.io/validate/v1alpha1
id: network-ports-contract
metadata:
  name: "Network Listener Sockets"
  description: "Verify TCP/UDP ports are listening locally"
  severity: high
checks:
  - id: PORT_SSH
    kind: resource
    metadata:
      name: "SSH Daemon Listener"
      severity: high
    resource:
      kind: port
      port: tcp:22
    expect:
      listening: true

  - id: PORT_HTTPS
    kind: resource
    metadata:
      name: "HTTPS Public Listener"
      severity: high
    resource:
      kind: port
      port: tcp:443
    expect:
      listening: true

Remote Address Reachability (kind: addr)

Tests remote network connectivity across hosts or edge proxies:

  - id: ADDR_API_GATEWAY
    kind: resource
    metadata:
      name: "API Gateway HTTPS Reachability"
      severity: high
    resource:
      kind: addr
      address: tcp://192.0.2.1:443
      timeout: 3000
    expect:
      reachable: true

Supported Attributes

Local Port (resource.kind: port)

ParameterTypeRequiredDescription
portstringYesSocket descriptor in protocol:port format (e.g. tcp:80, udp:53)
listening (expect)booleanNoSocket must be in LISTEN state (true)
ip (expect)string / listNoSpecific bound IP address (e.g. "127.0.0.1", "0.0.0.0")

Remote Addr (resource.kind: addr)

ParameterTypeRequiredDescription
addressstringYesTarget URI formatted as protocol://host:port (e.g. tcp://192.0.2.1:80)
timeoutintegerNoConnection timeout in milliseconds (default: 5000)
reachable (expect)booleanYesTarget socket must complete TCP handshake (true)