portwhy
README.md
# portwhy
[](https://github.com/lostprotocol212/portwhy/actions/workflows/ci.yml) [](LICENSE) [](#) [](#) [](#mcp-mode)
Cross-platform zero-dependency listening socket tracer, **`docker-compose.yml` static port scanner**, and **Docker-bypasses-UFW** security auditor with SARIF 2.1.0 output and ready-to-apply `DOCKER-USER` / `nftables` remediation.

---
## Why Docker Silently Bypasses UFW
```mermaid
flowchart LR
Internet["Public Internet"] --> PREROUTING["iptables PREROUTING NAT"]
PREROUTING -->|"Published Container Port (0.0.0.0:5432)"| DOCKER["DOCKER Chain (BYPASSES UFW INPUT!)"]
PREROUTING -->|"Host Socket"| UFW["UFW INPUT Rules (Enforced)"]
DOCKER --> Guard["Fix: DOCKER-USER DROP or 127.0.0.1 Bind"]
```
---
## Quickstart (Zero Install)
```bash
# Audit live listening sockets on Linux (ss/docker/ufw), macOS (lsof), or Windows (netstat)
npx portwhy
# Statically audit docker-compose.yml in CI/CD before deploy
npx portwhy compose docker-compose.yml --fail-on high
# Emit SARIF 2.1.0 for GitHub Code Scanning
npx portwhy compose docker-compose.yml --sarif > portwhy.sarif
# Print ready-to-apply /etc/ufw/after.rules DOCKER-USER or nftables rules
npx portwhy --ufw-fix
npx portwhy --nft-fix
```
## MCP Mode & GitHub Action
```json
{ "mcpServers": { "portwhy": { "command": "npx", "args": ["portwhy@1.2.0", "--mcp"] } } }
```
```yaml
- uses: lostprotocol212/portwhy@v1
with:
compose-file: 'docker-compose.yml'
fail-on: 'high'
sarif-output: 'portwhy.sarif'
```
Interactive auditor + Network Designer export: [serversareup.com/tools/docker-ufw-port-auditor](https://serversareup.com/tools/docker-ufw-port-auditor).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues