portexpose-lite 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PyForge (https://py-forge.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ include portexpose_lite.py
5
+ include test_portexpose_lite.py
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: portexpose-lite
3
+ Version: 0.1.0
4
+ Summary: Find Docker Compose ports that publish past UFW: 0.0.0.0 bindings and exposed databases. Read-only.
5
+ Author: Alessio Auretto
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://py-forge.com/products/portexpose-docker-firewall-auditor?utm_source=pypi&utm_medium=pypi&utm_campaign=portexpose-lite
8
+ Project-URL: Repository, https://github.com/alessio1999xx-debug/portexpose-lite
9
+ Keywords: docker,docker-compose,ufw,firewall,ports,security,selfhosted,homelab,cli,stdlib
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: POSIX
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Security
23
+ Classifier: Topic :: System :: Networking :: Firewalls
24
+ Classifier: Topic :: Utilities
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Dynamic: license-file
29
+
30
+ # portexpose-lite: find Docker Compose ports that publish past UFW
31
+
32
+ portexpose-lite reads one or more Docker Compose files and reports every published port: whether it binds to `0.0.0.0` / `::` (public), to loopback, or to a private/VPN address, and whether it is a sensitive service (PostgreSQL, MySQL/MariaDB, Redis, MongoDB, or the Docker API). It is read-only: it never changes Compose files, containers, or firewall rules. One file, Python 3.8+ standard library only, MIT.
33
+
34
+ Docker publishes ports through `nat`/`FORWARD` rules that sit in front of UFW's `INPUT` chain, so `ufw status` can say a port is denied while the container is still reachable. Official behaviour: [Docker packet filtering and firewalls](https://docs.docker.com/network/packet-filtering-firewalls/).
35
+
36
+ Need a live `docker inspect` of running containers, a check of the host `DOCKER-USER` iptables chain, or JSON output? That is the full [PortExpose](https://py-forge.com/products/portexpose-docker-firewall-auditor?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) (one-time payment, yours to keep, no subscription). A table later in this README lists what lite does and what the paid tool adds. Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) ($99, one payment).
37
+
38
+ - Nothing to `pip install` yet (PyPI publishing is not live). Download the one file. No Docker socket, no iptables, no network access.
39
+ - Short and long Compose `ports:` syntax, port ranges, `host_ip`, IPv6, and a protocol suffix (`/tcp`, `/udp`).
40
+ - `expose:` is not a published port and is not reported.
41
+ - Exit code `1` when any binding is `HIGH` or `CRITICAL`, so it fits a CI job or a pre-check script.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/portexpose-lite/main/portexpose_lite.py
47
+ python3 portexpose_lite.py --help
48
+ ```
49
+
50
+ ## See the output first (offline demo)
51
+
52
+ ```bash
53
+ python3 portexpose_lite.py --demo
54
+ ```
55
+
56
+ ```
57
+ ======================================================================
58
+ portexpose-lite: Docker Compose published-port report
59
+ ======================================================================
60
+ [CRITICAL] db -> 0.0.0.0:5432 | Sensitive service (PostgreSQL) exposed publicly on wildcard 0.0.0.0:5432
61
+ [CRITICAL] redis -> 0.0.0.0:6379 | Sensitive service (Redis) exposed publicly on wildcard 0.0.0.0:6379
62
+ [SAFE ] web -> 127.0.0.1:8080 | Bound strictly to loopback 127.0.0.1:8080
63
+ [HIGH ] adminer -> 0.0.0.0:8081 | Port 8081 exposed publicly on wildcard 0.0.0.0
64
+ ======================================================================
65
+ Read-only: no files or firewall rules were changed.
66
+ ```
67
+
68
+ The demo uses a built-in sample Compose file. Captured on 25 November 2026, Europe/Rome; real command and output.
69
+
70
+ ## Audit your Compose file
71
+
72
+ ```bash
73
+ python3 portexpose_lite.py # docker-compose.yml / compose.yaml in the current directory
74
+ python3 portexpose_lite.py -f docker-compose.yml
75
+ python3 portexpose_lite.py -f compose.yaml compose.override.yaml
76
+ ```
77
+
78
+ ## What gets flagged
79
+
80
+ | Level | Meaning |
81
+ | --- | --- |
82
+ | `CRITICAL` | A sensitive port is published on a wildcard (`0.0.0.0` / `::`) or a public address. Sensitive ports in lite: 5432 PostgreSQL, 3306 MySQL/MariaDB, 6379 Redis, 27017 MongoDB, 2375/2376 Docker API |
83
+ | `HIGH` | Some other port is published on a wildcard or a public address |
84
+ | `LOW` | The port is bound to a private or VPN address (for example `10.0.0.0/8`, `192.168.0.0/16`, `172.16.0.0/12`) |
85
+ | `SAFE` | The port is bound only to loopback (`127.0.0.1` or `::1`) |
86
+
87
+ Omitted `host_ip` in Compose is treated as `0.0.0.0`, which is also Docker's default.
88
+
89
+ ## Exit codes for CI
90
+
91
+ | Exit code | Meaning |
92
+ | --- | --- |
93
+ | `0` | No `HIGH` or `CRITICAL` findings (only `SAFE` / `LOW`, or no published ports) |
94
+ | `1` | At least one `HIGH` or `CRITICAL` binding |
95
+ | `2` | The file could not be read or parsed |
96
+
97
+ ## portexpose-lite vs PortExpose
98
+
99
+ portexpose-lite reads Compose files and prints a plain-text report. That's it.
100
+
101
+ The full [PortExpose](https://py-forge.com/products/portexpose-docker-firewall-auditor?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) also reads `docker inspect` JSON, checks the host `DOCKER-USER` iptables chain, and writes JSON. One-time payment, yours to keep. No subscription.
102
+
103
+ Lite is not a strict subset: it exits `1` when a public binding is found (the paid tool exits `0` with findings). Lite also treats only database, cache and Docker API ports as sensitive; the paid tool also labels some web-admin ports (for example 8080, 3000, 9000) as sensitive.
104
+
105
+ | Capability | Lite (free) | Paid PortExpose |
106
+ | --- | --- | --- |
107
+ | Read Compose files (short and long `ports:` syntax, ranges, several files) | Yes | Yes |
108
+ | Rate bindings: public wildcard, loopback, private/VPN | Yes | Yes |
109
+ | Flag PostgreSQL, Redis, MongoDB, Docker API (and, in lite, MySQL/MariaDB) | Yes | Yes |
110
+ | Live `docker inspect` JSON (`--inspect-json`) | No | Yes |
111
+ | Host `DOCKER-USER` iptables chain (`--check-iptables`) | No | Yes |
112
+ | JSON output (`--json`) | No | Yes |
113
+ | Exit code `1` when a public binding is found | Yes | No (exits `0`) |
114
+ | Offline `--demo` | Yes | Yes, plus a built-in `--self-test` |
115
+
116
+ Neither version changes firewall rules, Compose files, or running containers.
117
+
118
+ Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) ($99, one payment).
119
+
120
+ ## Limits
121
+
122
+ - This is a Compose-file reader, not a live firewall audit. It does not look at running containers or iptables.
123
+ - The YAML parser is a Compose-sized subset: mappings, lists, quoted/plain scalars, comments, and flow `[...]` / `{...}`. Anchors, merge keys and multiline `\|` / `>` scalars are not supported; the tool exits `2` if it cannot parse the file.
124
+ - IPv4 and IPv6 addresses are classified with the Python standard library (`ipaddress`). Unusual Docker host-network setups are outside the scope of lite.
125
+
126
+ ## Tests
127
+
128
+ ```bash
129
+ python3 test_portexpose_lite.py
130
+ ```
131
+
132
+ The tests are offline. No Docker and no network needed.
133
+
134
+ ## Other free tools from the same author
135
+
136
+ - [agentconfig-audit-lite](https://github.com/alessio1999xx-debug/agentconfig-audit-lite) — Audit MCP config for secrets: plaintext tokens and unpinned npx/uvx servers in `.mcp.json` and `CLAUDE.md`.
137
+ - [agenttrail-scrub-lite](https://github.com/alessio1999xx-debug/agenttrail-scrub-lite) — Claude Code secret scanner: find API keys and tokens leaked in AI agent transcripts.
138
+ - [cronpulse-lite](https://github.com/alessio1999xx-debug/cronpulse-lite) — Cron job monitoring in one Python file: alerts on failure or hang.
139
+ - [depcooldown-lite](https://github.com/alessio1999xx-debug/depcooldown-lite) — Dependency cooldown check: fail CI when a pinned PyPI or npm package is newer than N days.
140
+ - [homelab-doctor-lite](https://github.com/alessio1999xx-debug/homelab-doctor-lite) — Read-only homelab health check: stale images, exposed ports, expiring certs, silent cron, disk.
141
+ - [imagenudge-lite](https://github.com/alessio1999xx-debug/imagenudge-lite) — Docker image update checker: find running containers with a newer image (digest or tag).
142
+ - [pthguard-lite](https://github.com/alessio1999xx-debug/pthguard-lite) — Scan Python site-packages for malicious `.pth` files and startup backdoors.
143
+ - [pulseping-lite](https://github.com/alessio1999xx-debug/pulseping-lite) — Check SSL certificate expiry and URL/port uptime from cron.
144
+ - [sbom-snapshot-lite](https://github.com/alessio1999xx-debug/sbom-snapshot-lite) — Snapshot installed Python packages to a CycloneDX 1.5 SBOM, offline.
145
+ - [secenv-lite](https://github.com/alessio1999xx-debug/secenv-lite) — Find `.env` files committed to git or missing from `.gitignore`, plus obvious API keys inside.
146
+ - [ssh-keyaudit-lite](https://github.com/alessio1999xx-debug/ssh-keyaudit-lite) — Audit authorized_keys: SHA256 fingerprints; flags DSA, weak RSA, no comment and invalid lines.
147
+
148
+ ## License
149
+
150
+ MIT (this lite version). The full PortExpose is sold separately under its own license.
@@ -0,0 +1,121 @@
1
+ # portexpose-lite: find Docker Compose ports that publish past UFW
2
+
3
+ portexpose-lite reads one or more Docker Compose files and reports every published port: whether it binds to `0.0.0.0` / `::` (public), to loopback, or to a private/VPN address, and whether it is a sensitive service (PostgreSQL, MySQL/MariaDB, Redis, MongoDB, or the Docker API). It is read-only: it never changes Compose files, containers, or firewall rules. One file, Python 3.8+ standard library only, MIT.
4
+
5
+ Docker publishes ports through `nat`/`FORWARD` rules that sit in front of UFW's `INPUT` chain, so `ufw status` can say a port is denied while the container is still reachable. Official behaviour: [Docker packet filtering and firewalls](https://docs.docker.com/network/packet-filtering-firewalls/).
6
+
7
+ Need a live `docker inspect` of running containers, a check of the host `DOCKER-USER` iptables chain, or JSON output? That is the full [PortExpose](https://py-forge.com/products/portexpose-docker-firewall-auditor?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) (one-time payment, yours to keep, no subscription). A table later in this README lists what lite does and what the paid tool adds. Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) ($99, one payment).
8
+
9
+ - Nothing to `pip install` yet (PyPI publishing is not live). Download the one file. No Docker socket, no iptables, no network access.
10
+ - Short and long Compose `ports:` syntax, port ranges, `host_ip`, IPv6, and a protocol suffix (`/tcp`, `/udp`).
11
+ - `expose:` is not a published port and is not reported.
12
+ - Exit code `1` when any binding is `HIGH` or `CRITICAL`, so it fits a CI job or a pre-check script.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/portexpose-lite/main/portexpose_lite.py
18
+ python3 portexpose_lite.py --help
19
+ ```
20
+
21
+ ## See the output first (offline demo)
22
+
23
+ ```bash
24
+ python3 portexpose_lite.py --demo
25
+ ```
26
+
27
+ ```
28
+ ======================================================================
29
+ portexpose-lite: Docker Compose published-port report
30
+ ======================================================================
31
+ [CRITICAL] db -> 0.0.0.0:5432 | Sensitive service (PostgreSQL) exposed publicly on wildcard 0.0.0.0:5432
32
+ [CRITICAL] redis -> 0.0.0.0:6379 | Sensitive service (Redis) exposed publicly on wildcard 0.0.0.0:6379
33
+ [SAFE ] web -> 127.0.0.1:8080 | Bound strictly to loopback 127.0.0.1:8080
34
+ [HIGH ] adminer -> 0.0.0.0:8081 | Port 8081 exposed publicly on wildcard 0.0.0.0
35
+ ======================================================================
36
+ Read-only: no files or firewall rules were changed.
37
+ ```
38
+
39
+ The demo uses a built-in sample Compose file. Captured on 25 November 2026, Europe/Rome; real command and output.
40
+
41
+ ## Audit your Compose file
42
+
43
+ ```bash
44
+ python3 portexpose_lite.py # docker-compose.yml / compose.yaml in the current directory
45
+ python3 portexpose_lite.py -f docker-compose.yml
46
+ python3 portexpose_lite.py -f compose.yaml compose.override.yaml
47
+ ```
48
+
49
+ ## What gets flagged
50
+
51
+ | Level | Meaning |
52
+ | --- | --- |
53
+ | `CRITICAL` | A sensitive port is published on a wildcard (`0.0.0.0` / `::`) or a public address. Sensitive ports in lite: 5432 PostgreSQL, 3306 MySQL/MariaDB, 6379 Redis, 27017 MongoDB, 2375/2376 Docker API |
54
+ | `HIGH` | Some other port is published on a wildcard or a public address |
55
+ | `LOW` | The port is bound to a private or VPN address (for example `10.0.0.0/8`, `192.168.0.0/16`, `172.16.0.0/12`) |
56
+ | `SAFE` | The port is bound only to loopback (`127.0.0.1` or `::1`) |
57
+
58
+ Omitted `host_ip` in Compose is treated as `0.0.0.0`, which is also Docker's default.
59
+
60
+ ## Exit codes for CI
61
+
62
+ | Exit code | Meaning |
63
+ | --- | --- |
64
+ | `0` | No `HIGH` or `CRITICAL` findings (only `SAFE` / `LOW`, or no published ports) |
65
+ | `1` | At least one `HIGH` or `CRITICAL` binding |
66
+ | `2` | The file could not be read or parsed |
67
+
68
+ ## portexpose-lite vs PortExpose
69
+
70
+ portexpose-lite reads Compose files and prints a plain-text report. That's it.
71
+
72
+ The full [PortExpose](https://py-forge.com/products/portexpose-docker-firewall-auditor?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) also reads `docker inspect` JSON, checks the host `DOCKER-USER` iptables chain, and writes JSON. One-time payment, yours to keep. No subscription.
73
+
74
+ Lite is not a strict subset: it exits `1` when a public binding is found (the paid tool exits `0` with findings). Lite also treats only database, cache and Docker API ports as sensitive; the paid tool also labels some web-admin ports (for example 8080, 3000, 9000) as sensitive.
75
+
76
+ | Capability | Lite (free) | Paid PortExpose |
77
+ | --- | --- | --- |
78
+ | Read Compose files (short and long `ports:` syntax, ranges, several files) | Yes | Yes |
79
+ | Rate bindings: public wildcard, loopback, private/VPN | Yes | Yes |
80
+ | Flag PostgreSQL, Redis, MongoDB, Docker API (and, in lite, MySQL/MariaDB) | Yes | Yes |
81
+ | Live `docker inspect` JSON (`--inspect-json`) | No | Yes |
82
+ | Host `DOCKER-USER` iptables chain (`--check-iptables`) | No | Yes |
83
+ | JSON output (`--json`) | No | Yes |
84
+ | Exit code `1` when a public binding is found | Yes | No (exits `0`) |
85
+ | Offline `--demo` | Yes | Yes, plus a built-in `--self-test` |
86
+
87
+ Neither version changes firewall rules, Compose files, or running containers.
88
+
89
+ Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) ($99, one payment).
90
+
91
+ ## Limits
92
+
93
+ - This is a Compose-file reader, not a live firewall audit. It does not look at running containers or iptables.
94
+ - The YAML parser is a Compose-sized subset: mappings, lists, quoted/plain scalars, comments, and flow `[...]` / `{...}`. Anchors, merge keys and multiline `\|` / `>` scalars are not supported; the tool exits `2` if it cannot parse the file.
95
+ - IPv4 and IPv6 addresses are classified with the Python standard library (`ipaddress`). Unusual Docker host-network setups are outside the scope of lite.
96
+
97
+ ## Tests
98
+
99
+ ```bash
100
+ python3 test_portexpose_lite.py
101
+ ```
102
+
103
+ The tests are offline. No Docker and no network needed.
104
+
105
+ ## Other free tools from the same author
106
+
107
+ - [agentconfig-audit-lite](https://github.com/alessio1999xx-debug/agentconfig-audit-lite) — Audit MCP config for secrets: plaintext tokens and unpinned npx/uvx servers in `.mcp.json` and `CLAUDE.md`.
108
+ - [agenttrail-scrub-lite](https://github.com/alessio1999xx-debug/agenttrail-scrub-lite) — Claude Code secret scanner: find API keys and tokens leaked in AI agent transcripts.
109
+ - [cronpulse-lite](https://github.com/alessio1999xx-debug/cronpulse-lite) — Cron job monitoring in one Python file: alerts on failure or hang.
110
+ - [depcooldown-lite](https://github.com/alessio1999xx-debug/depcooldown-lite) — Dependency cooldown check: fail CI when a pinned PyPI or npm package is newer than N days.
111
+ - [homelab-doctor-lite](https://github.com/alessio1999xx-debug/homelab-doctor-lite) — Read-only homelab health check: stale images, exposed ports, expiring certs, silent cron, disk.
112
+ - [imagenudge-lite](https://github.com/alessio1999xx-debug/imagenudge-lite) — Docker image update checker: find running containers with a newer image (digest or tag).
113
+ - [pthguard-lite](https://github.com/alessio1999xx-debug/pthguard-lite) — Scan Python site-packages for malicious `.pth` files and startup backdoors.
114
+ - [pulseping-lite](https://github.com/alessio1999xx-debug/pulseping-lite) — Check SSL certificate expiry and URL/port uptime from cron.
115
+ - [sbom-snapshot-lite](https://github.com/alessio1999xx-debug/sbom-snapshot-lite) — Snapshot installed Python packages to a CycloneDX 1.5 SBOM, offline.
116
+ - [secenv-lite](https://github.com/alessio1999xx-debug/secenv-lite) — Find `.env` files committed to git or missing from `.gitignore`, plus obvious API keys inside.
117
+ - [ssh-keyaudit-lite](https://github.com/alessio1999xx-debug/ssh-keyaudit-lite) — Audit authorized_keys: SHA256 fingerprints; flags DSA, weak RSA, no comment and invalid lines.
118
+
119
+ ## License
120
+
121
+ MIT (this lite version). The full PortExpose is sold separately under its own license.
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: portexpose-lite
3
+ Version: 0.1.0
4
+ Summary: Find Docker Compose ports that publish past UFW: 0.0.0.0 bindings and exposed databases. Read-only.
5
+ Author: Alessio Auretto
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://py-forge.com/products/portexpose-docker-firewall-auditor?utm_source=pypi&utm_medium=pypi&utm_campaign=portexpose-lite
8
+ Project-URL: Repository, https://github.com/alessio1999xx-debug/portexpose-lite
9
+ Keywords: docker,docker-compose,ufw,firewall,ports,security,selfhosted,homelab,cli,stdlib
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: POSIX
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Security
23
+ Classifier: Topic :: System :: Networking :: Firewalls
24
+ Classifier: Topic :: Utilities
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Dynamic: license-file
29
+
30
+ # portexpose-lite: find Docker Compose ports that publish past UFW
31
+
32
+ portexpose-lite reads one or more Docker Compose files and reports every published port: whether it binds to `0.0.0.0` / `::` (public), to loopback, or to a private/VPN address, and whether it is a sensitive service (PostgreSQL, MySQL/MariaDB, Redis, MongoDB, or the Docker API). It is read-only: it never changes Compose files, containers, or firewall rules. One file, Python 3.8+ standard library only, MIT.
33
+
34
+ Docker publishes ports through `nat`/`FORWARD` rules that sit in front of UFW's `INPUT` chain, so `ufw status` can say a port is denied while the container is still reachable. Official behaviour: [Docker packet filtering and firewalls](https://docs.docker.com/network/packet-filtering-firewalls/).
35
+
36
+ Need a live `docker inspect` of running containers, a check of the host `DOCKER-USER` iptables chain, or JSON output? That is the full [PortExpose](https://py-forge.com/products/portexpose-docker-firewall-auditor?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) (one-time payment, yours to keep, no subscription). A table later in this README lists what lite does and what the paid tool adds. Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) ($99, one payment).
37
+
38
+ - Nothing to `pip install` yet (PyPI publishing is not live). Download the one file. No Docker socket, no iptables, no network access.
39
+ - Short and long Compose `ports:` syntax, port ranges, `host_ip`, IPv6, and a protocol suffix (`/tcp`, `/udp`).
40
+ - `expose:` is not a published port and is not reported.
41
+ - Exit code `1` when any binding is `HIGH` or `CRITICAL`, so it fits a CI job or a pre-check script.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/portexpose-lite/main/portexpose_lite.py
47
+ python3 portexpose_lite.py --help
48
+ ```
49
+
50
+ ## See the output first (offline demo)
51
+
52
+ ```bash
53
+ python3 portexpose_lite.py --demo
54
+ ```
55
+
56
+ ```
57
+ ======================================================================
58
+ portexpose-lite: Docker Compose published-port report
59
+ ======================================================================
60
+ [CRITICAL] db -> 0.0.0.0:5432 | Sensitive service (PostgreSQL) exposed publicly on wildcard 0.0.0.0:5432
61
+ [CRITICAL] redis -> 0.0.0.0:6379 | Sensitive service (Redis) exposed publicly on wildcard 0.0.0.0:6379
62
+ [SAFE ] web -> 127.0.0.1:8080 | Bound strictly to loopback 127.0.0.1:8080
63
+ [HIGH ] adminer -> 0.0.0.0:8081 | Port 8081 exposed publicly on wildcard 0.0.0.0
64
+ ======================================================================
65
+ Read-only: no files or firewall rules were changed.
66
+ ```
67
+
68
+ The demo uses a built-in sample Compose file. Captured on 25 November 2026, Europe/Rome; real command and output.
69
+
70
+ ## Audit your Compose file
71
+
72
+ ```bash
73
+ python3 portexpose_lite.py # docker-compose.yml / compose.yaml in the current directory
74
+ python3 portexpose_lite.py -f docker-compose.yml
75
+ python3 portexpose_lite.py -f compose.yaml compose.override.yaml
76
+ ```
77
+
78
+ ## What gets flagged
79
+
80
+ | Level | Meaning |
81
+ | --- | --- |
82
+ | `CRITICAL` | A sensitive port is published on a wildcard (`0.0.0.0` / `::`) or a public address. Sensitive ports in lite: 5432 PostgreSQL, 3306 MySQL/MariaDB, 6379 Redis, 27017 MongoDB, 2375/2376 Docker API |
83
+ | `HIGH` | Some other port is published on a wildcard or a public address |
84
+ | `LOW` | The port is bound to a private or VPN address (for example `10.0.0.0/8`, `192.168.0.0/16`, `172.16.0.0/12`) |
85
+ | `SAFE` | The port is bound only to loopback (`127.0.0.1` or `::1`) |
86
+
87
+ Omitted `host_ip` in Compose is treated as `0.0.0.0`, which is also Docker's default.
88
+
89
+ ## Exit codes for CI
90
+
91
+ | Exit code | Meaning |
92
+ | --- | --- |
93
+ | `0` | No `HIGH` or `CRITICAL` findings (only `SAFE` / `LOW`, or no published ports) |
94
+ | `1` | At least one `HIGH` or `CRITICAL` binding |
95
+ | `2` | The file could not be read or parsed |
96
+
97
+ ## portexpose-lite vs PortExpose
98
+
99
+ portexpose-lite reads Compose files and prints a plain-text report. That's it.
100
+
101
+ The full [PortExpose](https://py-forge.com/products/portexpose-docker-firewall-auditor?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) also reads `docker inspect` JSON, checks the host `DOCKER-USER` iptables chain, and writes JSON. One-time payment, yours to keep. No subscription.
102
+
103
+ Lite is not a strict subset: it exits `1` when a public binding is found (the paid tool exits `0` with findings). Lite also treats only database, cache and Docker API ports as sensitive; the paid tool also labels some web-admin ports (for example 8080, 3000, 9000) as sensitive.
104
+
105
+ | Capability | Lite (free) | Paid PortExpose |
106
+ | --- | --- | --- |
107
+ | Read Compose files (short and long `ports:` syntax, ranges, several files) | Yes | Yes |
108
+ | Rate bindings: public wildcard, loopback, private/VPN | Yes | Yes |
109
+ | Flag PostgreSQL, Redis, MongoDB, Docker API (and, in lite, MySQL/MariaDB) | Yes | Yes |
110
+ | Live `docker inspect` JSON (`--inspect-json`) | No | Yes |
111
+ | Host `DOCKER-USER` iptables chain (`--check-iptables`) | No | Yes |
112
+ | JSON output (`--json`) | No | Yes |
113
+ | Exit code `1` when a public binding is found | Yes | No (exits `0`) |
114
+ | Offline `--demo` | Yes | Yes, plus a built-in `--self-test` |
115
+
116
+ Neither version changes firewall rules, Compose files, or running containers.
117
+
118
+ Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=portexpose-lite) ($99, one payment).
119
+
120
+ ## Limits
121
+
122
+ - This is a Compose-file reader, not a live firewall audit. It does not look at running containers or iptables.
123
+ - The YAML parser is a Compose-sized subset: mappings, lists, quoted/plain scalars, comments, and flow `[...]` / `{...}`. Anchors, merge keys and multiline `\|` / `>` scalars are not supported; the tool exits `2` if it cannot parse the file.
124
+ - IPv4 and IPv6 addresses are classified with the Python standard library (`ipaddress`). Unusual Docker host-network setups are outside the scope of lite.
125
+
126
+ ## Tests
127
+
128
+ ```bash
129
+ python3 test_portexpose_lite.py
130
+ ```
131
+
132
+ The tests are offline. No Docker and no network needed.
133
+
134
+ ## Other free tools from the same author
135
+
136
+ - [agentconfig-audit-lite](https://github.com/alessio1999xx-debug/agentconfig-audit-lite) — Audit MCP config for secrets: plaintext tokens and unpinned npx/uvx servers in `.mcp.json` and `CLAUDE.md`.
137
+ - [agenttrail-scrub-lite](https://github.com/alessio1999xx-debug/agenttrail-scrub-lite) — Claude Code secret scanner: find API keys and tokens leaked in AI agent transcripts.
138
+ - [cronpulse-lite](https://github.com/alessio1999xx-debug/cronpulse-lite) — Cron job monitoring in one Python file: alerts on failure or hang.
139
+ - [depcooldown-lite](https://github.com/alessio1999xx-debug/depcooldown-lite) — Dependency cooldown check: fail CI when a pinned PyPI or npm package is newer than N days.
140
+ - [homelab-doctor-lite](https://github.com/alessio1999xx-debug/homelab-doctor-lite) — Read-only homelab health check: stale images, exposed ports, expiring certs, silent cron, disk.
141
+ - [imagenudge-lite](https://github.com/alessio1999xx-debug/imagenudge-lite) — Docker image update checker: find running containers with a newer image (digest or tag).
142
+ - [pthguard-lite](https://github.com/alessio1999xx-debug/pthguard-lite) — Scan Python site-packages for malicious `.pth` files and startup backdoors.
143
+ - [pulseping-lite](https://github.com/alessio1999xx-debug/pulseping-lite) — Check SSL certificate expiry and URL/port uptime from cron.
144
+ - [sbom-snapshot-lite](https://github.com/alessio1999xx-debug/sbom-snapshot-lite) — Snapshot installed Python packages to a CycloneDX 1.5 SBOM, offline.
145
+ - [secenv-lite](https://github.com/alessio1999xx-debug/secenv-lite) — Find `.env` files committed to git or missing from `.gitignore`, plus obvious API keys inside.
146
+ - [ssh-keyaudit-lite](https://github.com/alessio1999xx-debug/ssh-keyaudit-lite) — Audit authorized_keys: SHA256 fingerprints; flags DSA, weak RSA, no comment and invalid lines.
147
+
148
+ ## License
149
+
150
+ MIT (this lite version). The full PortExpose is sold separately under its own license.
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ portexpose_lite.py
5
+ pyproject.toml
6
+ test_portexpose_lite.py
7
+ portexpose_lite.egg-info/PKG-INFO
8
+ portexpose_lite.egg-info/SOURCES.txt
9
+ portexpose_lite.egg-info/dependency_links.txt
10
+ portexpose_lite.egg-info/entry_points.txt
11
+ portexpose_lite.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ portexpose-lite = portexpose_lite:main
@@ -0,0 +1 @@
1
+ portexpose_lite