Port Expose Guard

Port Expose Guard is a copy-paste React component that stops helps prevent a database port being opened to the internet before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/port-expose-guard
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsHelps prevent a database port being opened to the internet

Was this component page useful?

How do I install Port Expose Guard?

pnpm dlx shadcn@latest add @bollard/port-expose-guard

The files land in your project. They're yours to edit.

How do I use Port Expose Guard in React?

port-expose-guard-usage.tsx
import { PortExposeGuard } from "@/components/ui/port-expose-guard"

<PortExposeGuard
  label="docker-compose.yml ports"
  defaultValue={COMPOSE}
  onValueChange={() => setApplied(false)}
  onApply={() => new Promise<void>((resolve) => setTimeout(() => { setApplied(true); resolve() }, 600))}
/>

What input mistakes does Port Expose Guard catch?

  • Database or admin ports bound to every interface
  • Docker's iptables rules bypassing ufw
  • Host networking, -P, NodePort or public LoadBalancer for internal services
  • Container port the image doesn't listen on (5432:5433)
  • Unquoted 22:22 that YAML 1.1 reads as a number
  • On Docker older than 28, 127.0.0.1 binds reachable from the LAN

What props does Port Expose Guard accept?

PortExposeGuard props
PropTypeDefault
label

Visible label.

string—
value

Controlled config text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the text on every edit and one-tap fix.

(text: string) => void—
listening

Ports your own images listen on, keyed by image or Service name, for the mismatch check.

CheckPortsOptions["listening"]—
sensitivePorts

Extra sensitive ports, e.g. `{ 9000: "the MinIO API" }`.

CheckPortsOptions["sensitivePorts"]—
dockerVersion

Docker Engine version on the host, e.g. "27.5.1". Below 28 (or unknown) a note says 127.0.0.1 binds are reachable from the LAN.

string—
delay

Pause in ms before the readback refreshes while typing.

number500
onApply

Called on Apply. With findings left, the first click jumps to them and the second applies. May return a Promise.

(text: string) => void | Promise<void>—
messages

Any visible string; `source` and `reach` may be partial.

Partial<Omit<PortExposeMessages, "source" | "reach">> & { source?: Partial<PortExposeMessages["source"]>; reach?: Partial<PortExposeMessa…—
className

Class for the outer wrapper.

string—

* required. Also accepts the native props of <textarea> (className, aria-*, data-*…), passed through to it.

How is Port Expose Guard accessible?

  • Visible label; textarea is described by the readback
  • Announcements go to a polite live region
  • Reach is shown as text with icons aria-hidden; focus moves to the first fix

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Enforce network policy and firewalls at the host or cloud level; never rely on a config review alone.

  • Reads the config you paste; it can't see cloud security groups or host firewalls
  • ${VAR} binds without defaults can't be judged until run time
  • Sensitive-port list is a default; pass your own

What validation rules apply to Port Expose Guard?

Rules last verified:

Informational. Confirmed: before 28.0.0, hosts on the same L2 segment can reach ports published to localhost; Docker's rules divert traffic before ufw. The YAML 1.1 sexagesimal reading was not re-checked. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What expensive mistakes does Port Expose Guard stop?

Helps prevent a database port being opened to the internet

Also known as

docker run -p · docker compose · ports · 0.0.0.0 · kubernetes service · loadbalancer · nodeport · firewall

Field type

What dependencies does Port Expose Guard require?

Port Expose Guard facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component namePort Expose Guard
Registry identifier@bollard/port-expose-guard
Install commandnpx shadcn@latest add @bollard/port-expose-guard
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Port Expose Guard

What form validation mistake does Port Expose Guard catch?

Port Expose Guard prevents a database port being opened to the internet. Reads docker run, compose ports or a Kubernetes Service back as who can reach each port, so a database isn't published to the internet by accident. Catches: Database or admin ports bound to every interface, Docker's iptables rules bypassing ufw, Host networking, -P, NodePort or public LoadBalancer for internal services, Container port the image doesn't listen on (5432:5433), Unquoted 22:22 that YAML 1.1 reads as a number, On Docker older than 28, 127.0.0.1 binds reachable from the LAN. Limitation: validate port-expose-guard schemas on backend.

How do I install port-expose-guard with shadcn?

Run `npx shadcn@latest add @bollard/port-expose-guard`. Sources added: registry/default/port-expose-guard/parse-ports.ts, registry/default/port-expose-guard/port-expose-guard.tsx, registry/default/port-expose-guard/ports.ts. Package requirements: lucide-react.

What props customize Port Expose Guard?

Port Expose Guard accepts `label`, `value`, `defaultValue`, `onValueChange`, `listening`. Configures docker run -p, docker compose, ports behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of port-expose-guard?

Reads the config you paste; it can't see cloud security groups or host firewalls. ${VAR} binds without defaults can't be judged until run time. Sensitive-port list is a default; pass your own Server requirement: Enforce network policy and firewalls at the host or cloud level; never rely on a config review alone.

How does Port Expose Guard meet accessibility guidelines?

Visible label; textarea is described by the readback. Announcements go to a polite live region. Reach is shown as text with icons aria-hidden; focus moves to the first fix. Minimizes errors: docker port exposed publicly, docker bypasses ufw.

Which components pair with Port Expose Guard?