portsweep 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.
- portsweep-0.1.0/CHANGELOG.md +25 -0
- portsweep-0.1.0/CONTRIBUTING.md +18 -0
- portsweep-0.1.0/LICENSE +21 -0
- portsweep-0.1.0/MANIFEST.in +4 -0
- portsweep-0.1.0/PKG-INFO +127 -0
- portsweep-0.1.0/README.md +109 -0
- portsweep-0.1.0/SECURITY.md +21 -0
- portsweep-0.1.0/docs/architecture.md +96 -0
- portsweep-0.1.0/docs/cli.md +19 -0
- portsweep-0.1.0/docs/delivery.md +111 -0
- portsweep-0.1.0/docs/management.md +56 -0
- portsweep-0.1.0/docs/platforms.md +11 -0
- portsweep-0.1.0/docs/product.md +31 -0
- portsweep-0.1.0/docs/release.md +61 -0
- portsweep-0.1.0/docs/report-schema.md +28 -0
- portsweep-0.1.0/docs/security-audit.md +26 -0
- portsweep-0.1.0/examples/README.md +35 -0
- portsweep-0.1.0/examples/demo.py +44 -0
- portsweep-0.1.0/examples/demo_windows.py +130 -0
- portsweep-0.1.0/pyproject.toml +34 -0
- portsweep-0.1.0/setup.cfg +4 -0
- portsweep-0.1.0/src/portsweep/__init__.py +1 -0
- portsweep-0.1.0/src/portsweep/__main__.py +6 -0
- portsweep-0.1.0/src/portsweep/cli.py +421 -0
- portsweep-0.1.0/src/portsweep/diagnostics.py +94 -0
- portsweep-0.1.0/src/portsweep/history_cli.py +402 -0
- portsweep-0.1.0/src/portsweep/inventory.py +338 -0
- portsweep-0.1.0/src/portsweep/linux_process.py +92 -0
- portsweep-0.1.0/src/portsweep/management.py +358 -0
- portsweep-0.1.0/src/portsweep/management_cli.py +282 -0
- portsweep-0.1.0/src/portsweep/monitor.py +171 -0
- portsweep-0.1.0/src/portsweep/output.py +223 -0
- portsweep-0.1.0/src/portsweep/paths.py +33 -0
- portsweep-0.1.0/src/portsweep/reports.py +199 -0
- portsweep-0.1.0/src/portsweep/review.py +392 -0
- portsweep-0.1.0/src/portsweep/review_cli.py +303 -0
- portsweep-0.1.0/src/portsweep/services.py +68 -0
- portsweep-0.1.0/src/portsweep/storage.py +518 -0
- portsweep-0.1.0/src/portsweep/windows_process.py +302 -0
- portsweep-0.1.0/src/portsweep.egg-info/PKG-INFO +127 -0
- portsweep-0.1.0/src/portsweep.egg-info/SOURCES.txt +59 -0
- portsweep-0.1.0/src/portsweep.egg-info/dependency_links.txt +1 -0
- portsweep-0.1.0/src/portsweep.egg-info/entry_points.txt +2 -0
- portsweep-0.1.0/src/portsweep.egg-info/requires.txt +8 -0
- portsweep-0.1.0/src/portsweep.egg-info/top_level.txt +1 -0
- portsweep-0.1.0/tests/test_cli.py +216 -0
- portsweep-0.1.0/tests/test_history_cli.py +149 -0
- portsweep-0.1.0/tests/test_integration.py +81 -0
- portsweep-0.1.0/tests/test_inventory.py +233 -0
- portsweep-0.1.0/tests/test_management.py +274 -0
- portsweep-0.1.0/tests/test_management_cli.py +155 -0
- portsweep-0.1.0/tests/test_management_windows.py +194 -0
- portsweep-0.1.0/tests/test_monitor.py +231 -0
- portsweep-0.1.0/tests/test_reports.py +175 -0
- portsweep-0.1.0/tests/test_review.py +196 -0
- portsweep-0.1.0/tests/test_review_windows.py +111 -0
- portsweep-0.1.0/tests/test_services.py +61 -0
- portsweep-0.1.0/tests/test_storage.py +273 -0
- portsweep-0.1.0/tests/test_watch_windows.py +152 -0
- portsweep-0.1.0/tools/normalize_sdist.py +76 -0
- portsweep-0.1.0/tools/smoke_wheel.py +153 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — release candidate
|
|
4
|
+
|
|
5
|
+
- Require exact flags for process and storage authorization, bind pruning to the previewed database, and reject unsafe history and Windows export paths.
|
|
6
|
+
- Preserve mapped IPv6 evidence across Python patch versions and keep redirected watch output free of cursor controls.
|
|
7
|
+
- Raise the build-system dependency floor, add clean-wheel CI smoke checks, and document platform validation and publication gates.
|
|
8
|
+
- Add `kill` with impact previews, dry run, explicit authorization, pinned process identity, and post-action socket verification.
|
|
9
|
+
- Add interactive `cleanup` with explicit PID selection and individual verified outcomes. Redirected cleanup remains preview-only.
|
|
10
|
+
- Validate native Windows process handling against disposable loopback listeners, including declined and stale authorizations.
|
|
11
|
+
- Add conservative `idle` findings with configurable evidence thresholds and an explanation for every classification.
|
|
12
|
+
- Add versioned JSON and spreadsheet-safe CSV reports for inventory, history, and review. Report files use exclusive creation and default redaction.
|
|
13
|
+
- Reduce repeat SQLite identity lookups and batch observation inserts while retaining the per-sample transaction.
|
|
14
|
+
- Add foreground `watch` with optional recording, conservative TCP matches, and coverage and change indicators.
|
|
15
|
+
- Add SQLite-backed `history` plus `storage status` and explicit, previewed `storage prune`.
|
|
16
|
+
- Verify real Windows TCP activity, UDP limitations, restart identity separation, and history across invocations.
|
|
17
|
+
- Add local IPv4 and IPv6 TCP listener and UDP binding inventory.
|
|
18
|
+
- Add `scan`, `inspect`, and `doctor` with permission diagnostics and responsive terminal output.
|
|
19
|
+
- Add verified process-instance metadata, deduplicated RSS totals, and evidence-based service hints.
|
|
20
|
+
- Verify Windows loopback discovery and build the wheel and source distribution.
|
|
21
|
+
|
|
22
|
+
## Phase 0 scaffold
|
|
23
|
+
|
|
24
|
+
- Document Phase 0 research, the MVP design and public release gates.
|
|
25
|
+
- Add package metadata, CLI help and version output, and a CI workflow.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Follow the [source setup](README.md#install-from-source), then install `-e ".[dev]"` in that environment. Run these checks with the virtual environment's Python:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
python -m ruff check .
|
|
7
|
+
python -m ruff format --check .
|
|
8
|
+
python -m pytest
|
|
9
|
+
python -m build
|
|
10
|
+
python -m twine check --strict "dist/*"
|
|
11
|
+
python tools/smoke_wheel.py
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
For collector changes, include the OS, backend and privilege level used to verify behavior. Use synthetic observations and loopback fixtures with ephemeral ports. Tests that use real sockets need permission to read the local socket table. On Windows, run those tests with a standard user token outside execution sandboxes that block kernel table queries. Document coverage gaps and permission behavior when they affect a command's output.
|
|
15
|
+
|
|
16
|
+
Use [security reporting](SECURITY.md) for vulnerabilities.
|
|
17
|
+
|
|
18
|
+
Review the [platform validation](docs/platforms.md) before changing support claims. Management tests must operate only on dedicated disposable children. Keep checks for authorization, identity revalidation, and post-action verification intact when optimizing.
|
portsweep-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PortSweep contributors
|
|
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.
|
portsweep-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: portsweep
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A local-first CLI for auditing listening ports and forgotten services.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Repository, https://github.com/yuckyou1/PortSweep
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: psutil>=6
|
|
11
|
+
Requires-Dist: rich>=13
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
14
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
15
|
+
Requires-Dist: ruff>=0.9; extra == "dev"
|
|
16
|
+
Requires-Dist: twine>=6; extra == "dev"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# PortSweep
|
|
20
|
+
|
|
21
|
+
Find the services you forgot were running.
|
|
22
|
+
|
|
23
|
+
When a development server says “address already in use,” PortSweep shows what is listening, which process owns it, and where it is bound. PortSweep is a lightweight, local-first CLI for discovering forgotten background services, auditing listening ports, tracking observed network activity, and safely reclaiming ports.
|
|
24
|
+
|
|
25
|
+
Use it on the machine you want to inspect. It reads local OS socket and process tables and sends no probes to remote hosts. A foreground watch can record local history so you can review a listener with evidence, then preview and explicitly authorize cleanup if you decide to stop it.
|
|
26
|
+
|
|
27
|
+
## Install from source
|
|
28
|
+
|
|
29
|
+
Use a current security-patched Python 3.11–3.14.
|
|
30
|
+
|
|
31
|
+
```console
|
|
32
|
+
git clone https://github.com/yuckyou1/PortSweep.git
|
|
33
|
+
cd PortSweep
|
|
34
|
+
python -m venv .venv
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
On Windows PowerShell:
|
|
38
|
+
|
|
39
|
+
```powershell
|
|
40
|
+
.\.venv\Scripts\python.exe -m pip install .
|
|
41
|
+
.\.venv\Scripts\portsweep.exe --version
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
On Linux or macOS:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
.venv/bin/python -m pip install .
|
|
48
|
+
.venv/bin/portsweep --version
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Activate the environment to use `portsweep` directly, or run `python -m portsweep` with the environment's Python. To install a locally built wheel, use `python -m pip install dist/portsweep-0.1.0-py3-none-any.whl`. See the [release checklist](docs/release.md) for the build commands. PortSweep 0.1.0 is available from source at this stage.
|
|
52
|
+
|
|
53
|
+
## See what owns a port
|
|
54
|
+
|
|
55
|
+
```console
|
|
56
|
+
portsweep scan
|
|
57
|
+
portsweep scan --non-loopback
|
|
58
|
+
portsweep inspect 5432/tcp
|
|
59
|
+
portsweep doctor
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The following is a condensed, redacted run of the [disposable Windows demo](examples/README.md). The port and PID are replaced with placeholders.
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
$ portsweep scan --tcp
|
|
66
|
+
TCP 127.0.0.1:<port> PID <pid> Loopback
|
|
67
|
+
$ portsweep inspect <port>/tcp
|
|
68
|
+
PID: <pid>
|
|
69
|
+
$ portsweep watch --tcp --port <port> --record --duration 0.1
|
|
70
|
+
TCP observed (1)
|
|
71
|
+
$ portsweep idle --port <port> --explain
|
|
72
|
+
Recent TCP activity observed
|
|
73
|
+
$ portsweep kill <port> --tcp --pid <pid> --dry-run
|
|
74
|
+
Dry run. No termination attempted.
|
|
75
|
+
$ portsweep kill <port> --tcp --pid <pid> --yes
|
|
76
|
+
Termination requested for PID <pid>. Verifying outcome.
|
|
77
|
+
Original process exited. The requested bindings are no longer observed.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Observe, review, and export
|
|
81
|
+
|
|
82
|
+
```console
|
|
83
|
+
portsweep watch --record --duration 60
|
|
84
|
+
portsweep history --port 5432 --days 7
|
|
85
|
+
portsweep idle --port 5432 --explain
|
|
86
|
+
portsweep report idle --format json
|
|
87
|
+
portsweep storage status
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- **Inventory** lists IPv4 and IPv6 TCP listeners and UDP bindings, with process ownership and binding scope where visible. `inspect` lists all visible owners on a port. A non-loopback binding alone cannot establish external reachability.
|
|
91
|
+
- **Watch and history** sample in the foreground every two seconds by default. Recording is opt-in. Short TCP connections can fall between samples, and a long connection can appear more than once. UDP activity is unmeasured. Restricted visibility can make activity unknown.
|
|
92
|
+
- **Service review** explains which verified listeners have recent TCP matches, enough recorded evidence for manual review, or insufficient evidence. An absence of sampled activity does not establish that a service is unused.
|
|
93
|
+
- **Reports** export JSON or CSV with local identifiers redacted by default. Ports, times, and resource usage may remain. An explicit output path creates a new file and protects an existing one.
|
|
94
|
+
|
|
95
|
+
## Preview before stopping a process
|
|
96
|
+
|
|
97
|
+
```console
|
|
98
|
+
portsweep kill 3000 --tcp --dry-run
|
|
99
|
+
portsweep kill 3000 --tcp
|
|
100
|
+
portsweep cleanup --dry-run
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The preview shows the selected process and its visible endpoints. Enter declines the operation. Type `yes` or use the explicit `--yes` flag to authorize `kill`. PortSweep revalidates the pinned process identity and the affected endpoints before acting. A changed target requires a fresh preview and authorization. Interactive `cleanup` requires individual PID selection. In a non-interactive shell, `cleanup` is preview-only.
|
|
104
|
+
|
|
105
|
+
**Windows termination is immediate and can lose unsaved data.** Review every endpoint in the preview. The post-action check reports process exit and what one subsequent socket snapshot can see. [Management safety and limits](docs/management.md)
|
|
106
|
+
|
|
107
|
+
## Platform compatibility
|
|
108
|
+
|
|
109
|
+
| Platform | Inventory, monitoring, history, review, and reports | Process management |
|
|
110
|
+
| --- | --- | --- |
|
|
111
|
+
| Windows | Validated under a standard user with disposable TCP and UDP endpoints | Validated on disposable processes in an interactive, non-service session |
|
|
112
|
+
| Linux | Read-only workflows tested in non-root Docker on WSL2. Restricted sockets may be omitted | Guarded pidfd backend. Native Linux user-scope actions remain unverified |
|
|
113
|
+
| macOS | Read-only commands handle backend restrictions. System-wide collection normally requires elevated privileges | Blocked |
|
|
114
|
+
|
|
115
|
+
See [platform validation](docs/platforms.md) for the environments and CI coverage. Use `--no-color` or `NO_COLOR` for plain output.
|
|
116
|
+
|
|
117
|
+
## Privacy and removal
|
|
118
|
+
|
|
119
|
+
PortSweep has no telemetry. It collects no process arguments, process environments, credentials, or packet payloads. Recorded history stays in local SQLite and excludes account names, executable paths, and peer endpoints. Live `inspect` can show local paths and account names. Keep local history and unredacted output private. [Storage paths and retention](docs/cli.md)
|
|
120
|
+
|
|
121
|
+
To remove PortSweep, run `python -m pip uninstall portsweep` in its installation environment. To remove recorded history too, stop active watches and obtain its path with `portsweep storage status` before uninstalling. Remove the identified database and any adjacent SQLite sidecars after backing up anything you want to keep.
|
|
122
|
+
|
|
123
|
+
## Contribute
|
|
124
|
+
|
|
125
|
+
Read the [CLI reference](docs/cli.md), [contribution guide](CONTRIBUTING.md), or [security reporting policy](SECURITY.md).
|
|
126
|
+
|
|
127
|
+
Released under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# PortSweep
|
|
2
|
+
|
|
3
|
+
Find the services you forgot were running.
|
|
4
|
+
|
|
5
|
+
When a development server says “address already in use,” PortSweep shows what is listening, which process owns it, and where it is bound. PortSweep is a lightweight, local-first CLI for discovering forgotten background services, auditing listening ports, tracking observed network activity, and safely reclaiming ports.
|
|
6
|
+
|
|
7
|
+
Use it on the machine you want to inspect. It reads local OS socket and process tables and sends no probes to remote hosts. A foreground watch can record local history so you can review a listener with evidence, then preview and explicitly authorize cleanup if you decide to stop it.
|
|
8
|
+
|
|
9
|
+
## Install from source
|
|
10
|
+
|
|
11
|
+
Use a current security-patched Python 3.11–3.14.
|
|
12
|
+
|
|
13
|
+
```console
|
|
14
|
+
git clone https://github.com/yuckyou1/PortSweep.git
|
|
15
|
+
cd PortSweep
|
|
16
|
+
python -m venv .venv
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
On Windows PowerShell:
|
|
20
|
+
|
|
21
|
+
```powershell
|
|
22
|
+
.\.venv\Scripts\python.exe -m pip install .
|
|
23
|
+
.\.venv\Scripts\portsweep.exe --version
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
On Linux or macOS:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
.venv/bin/python -m pip install .
|
|
30
|
+
.venv/bin/portsweep --version
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Activate the environment to use `portsweep` directly, or run `python -m portsweep` with the environment's Python. To install a locally built wheel, use `python -m pip install dist/portsweep-0.1.0-py3-none-any.whl`. See the [release checklist](docs/release.md) for the build commands. PortSweep 0.1.0 is available from source at this stage.
|
|
34
|
+
|
|
35
|
+
## See what owns a port
|
|
36
|
+
|
|
37
|
+
```console
|
|
38
|
+
portsweep scan
|
|
39
|
+
portsweep scan --non-loopback
|
|
40
|
+
portsweep inspect 5432/tcp
|
|
41
|
+
portsweep doctor
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The following is a condensed, redacted run of the [disposable Windows demo](examples/README.md). The port and PID are replaced with placeholders.
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
$ portsweep scan --tcp
|
|
48
|
+
TCP 127.0.0.1:<port> PID <pid> Loopback
|
|
49
|
+
$ portsweep inspect <port>/tcp
|
|
50
|
+
PID: <pid>
|
|
51
|
+
$ portsweep watch --tcp --port <port> --record --duration 0.1
|
|
52
|
+
TCP observed (1)
|
|
53
|
+
$ portsweep idle --port <port> --explain
|
|
54
|
+
Recent TCP activity observed
|
|
55
|
+
$ portsweep kill <port> --tcp --pid <pid> --dry-run
|
|
56
|
+
Dry run. No termination attempted.
|
|
57
|
+
$ portsweep kill <port> --tcp --pid <pid> --yes
|
|
58
|
+
Termination requested for PID <pid>. Verifying outcome.
|
|
59
|
+
Original process exited. The requested bindings are no longer observed.
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Observe, review, and export
|
|
63
|
+
|
|
64
|
+
```console
|
|
65
|
+
portsweep watch --record --duration 60
|
|
66
|
+
portsweep history --port 5432 --days 7
|
|
67
|
+
portsweep idle --port 5432 --explain
|
|
68
|
+
portsweep report idle --format json
|
|
69
|
+
portsweep storage status
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- **Inventory** lists IPv4 and IPv6 TCP listeners and UDP bindings, with process ownership and binding scope where visible. `inspect` lists all visible owners on a port. A non-loopback binding alone cannot establish external reachability.
|
|
73
|
+
- **Watch and history** sample in the foreground every two seconds by default. Recording is opt-in. Short TCP connections can fall between samples, and a long connection can appear more than once. UDP activity is unmeasured. Restricted visibility can make activity unknown.
|
|
74
|
+
- **Service review** explains which verified listeners have recent TCP matches, enough recorded evidence for manual review, or insufficient evidence. An absence of sampled activity does not establish that a service is unused.
|
|
75
|
+
- **Reports** export JSON or CSV with local identifiers redacted by default. Ports, times, and resource usage may remain. An explicit output path creates a new file and protects an existing one.
|
|
76
|
+
|
|
77
|
+
## Preview before stopping a process
|
|
78
|
+
|
|
79
|
+
```console
|
|
80
|
+
portsweep kill 3000 --tcp --dry-run
|
|
81
|
+
portsweep kill 3000 --tcp
|
|
82
|
+
portsweep cleanup --dry-run
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The preview shows the selected process and its visible endpoints. Enter declines the operation. Type `yes` or use the explicit `--yes` flag to authorize `kill`. PortSweep revalidates the pinned process identity and the affected endpoints before acting. A changed target requires a fresh preview and authorization. Interactive `cleanup` requires individual PID selection. In a non-interactive shell, `cleanup` is preview-only.
|
|
86
|
+
|
|
87
|
+
**Windows termination is immediate and can lose unsaved data.** Review every endpoint in the preview. The post-action check reports process exit and what one subsequent socket snapshot can see. [Management safety and limits](docs/management.md)
|
|
88
|
+
|
|
89
|
+
## Platform compatibility
|
|
90
|
+
|
|
91
|
+
| Platform | Inventory, monitoring, history, review, and reports | Process management |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| Windows | Validated under a standard user with disposable TCP and UDP endpoints | Validated on disposable processes in an interactive, non-service session |
|
|
94
|
+
| Linux | Read-only workflows tested in non-root Docker on WSL2. Restricted sockets may be omitted | Guarded pidfd backend. Native Linux user-scope actions remain unverified |
|
|
95
|
+
| macOS | Read-only commands handle backend restrictions. System-wide collection normally requires elevated privileges | Blocked |
|
|
96
|
+
|
|
97
|
+
See [platform validation](docs/platforms.md) for the environments and CI coverage. Use `--no-color` or `NO_COLOR` for plain output.
|
|
98
|
+
|
|
99
|
+
## Privacy and removal
|
|
100
|
+
|
|
101
|
+
PortSweep has no telemetry. It collects no process arguments, process environments, credentials, or packet payloads. Recorded history stays in local SQLite and excludes account names, executable paths, and peer endpoints. Live `inspect` can show local paths and account names. Keep local history and unredacted output private. [Storage paths and retention](docs/cli.md)
|
|
102
|
+
|
|
103
|
+
To remove PortSweep, run `python -m pip uninstall portsweep` in its installation environment. To remove recorded history too, stop active watches and obtain its path with `portsweep storage status` before uninstalling. Remove the identified database and any adjacent SQLite sidecars after backing up anything you want to keep.
|
|
104
|
+
|
|
105
|
+
## Contribute
|
|
106
|
+
|
|
107
|
+
Read the [CLI reference](docs/cli.md), [contribution guide](CONTRIBUTING.md), or [security reporting policy](SECURITY.md).
|
|
108
|
+
|
|
109
|
+
Released under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
PortSweep 0.1.0 is a release candidate. Public release support starts with a published release.
|
|
4
|
+
|
|
5
|
+
Report vulnerabilities through [GitHub private vulnerability reporting](https://github.com/yuckyou1/PortSweep/security/advisories/new) when enabled. If the form is unavailable, ask the maintainers for a private contact channel through a public issue containing only that request.
|
|
6
|
+
|
|
7
|
+
Include the affected version or commit, OS, relevant permissions, and a minimal reproduction. Use synthetic data in place of real usernames, executable paths, addresses or history.
|
|
8
|
+
|
|
9
|
+
Opt-in local history contains timestamps, local bindings, process instance identities and names, and sampled activity flags. Keep history databases and rollback journals private. Unix modes are set when PortSweep creates the data directory and database. Windows inherits the profile directory's ACLs. Account compromise, administrator access, backups, and user-created copies are outside those protections. Pruning removes selected logical records. It does not guarantee forensic erasure.
|
|
10
|
+
|
|
11
|
+
History opens regular local files in a private directory on Unix. It rejects linked database files, linked sidecars, and linked or reparse-point application directories. A prune confirmation is tied to the file identity observed in its preview. Windows uses inherited ACLs and rejects explicit network or device paths. Keep the state location under a private, trusted parent and treat imported databases as untrusted.
|
|
12
|
+
|
|
13
|
+
Reports redact local addresses, PIDs, process names, and process creation timestamps by default. Usernames, executable paths, peer addresses, process arguments, and packet payloads are excluded even when local identifiers are enabled. Reports can still reveal ports, timings, and resource usage. Keep exports private as appropriate. CSV text is guarded against spreadsheet formulas, and terminal views escape control characters.
|
|
14
|
+
|
|
15
|
+
PortSweep reads native process name and executable metadata without psutil's command-line fallback. Unavailable native fields stay unavailable.
|
|
16
|
+
|
|
17
|
+
Process termination is isolated to `kill` and interactive `cleanup`. A current local endpoint, an unambiguous selected owner, and a stable process handle are required. Checks cover PortSweep itself, its ancestors, OS protection and ownership, service ownership, and known shared infrastructure. These checks cannot establish application dependencies or guarantee service classification. Windows termination may cause immediate data loss. The action is abandoned if revalidation changes the authorized identity or footprint. A post-action socket snapshot confirms only what is visible at that time.
|
|
18
|
+
|
|
19
|
+
PortSweep writes no cleanup action log and does not modify monitoring history during cleanup. Report authorization, identity-reuse, or protection bypass issues privately.
|
|
20
|
+
|
|
21
|
+
See the [Phase 5 security audit](docs/security-audit.md) for findings, tests, reviewed boundaries, and residual risk.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Architecture and command design
|
|
2
|
+
|
|
3
|
+
## Phase 1 inventory
|
|
4
|
+
|
|
5
|
+
Python 3.11+ runs the argparse entry point. The `inventory` module handles psutil collection, normalization and permission failures. `services` assigns tentative hints. `output` renders Rich views, and `diagnostics` reports backend and state-directory capabilities. psutil and Rich are the two runtime dependencies.
|
|
6
|
+
|
|
7
|
+
Take one local `psutil.net_connections(kind="inet")` inventory per command and keep TCP listeners and UDP sockets with bound local endpoints. Group rows by protocol, family, canonical local address, port, and the PID from the socket table. The collector retains IPv6 scope identifiers where the OS backend supplies them. Shared bindings with different observed PIDs have separate rows. The same tuple can represent indistinguishable sockets, so summary totals count distinct observed rows.
|
|
8
|
+
|
|
9
|
+
Capture the start time and enrich each selected PID once. Read creation time, name, executable, account, and RSS inside a psutil oneshot block. Verify creation time again through a fresh process object after the reads. Reject metadata for an owner that started after enumeration began or whose identity cannot be corroborated. Preserve endpoints when owners exit, access fails, or a PID is reused. Socket and process reads are non-atomic. Uptime is relative to the start time. Totals count RSS once per verified PID and creation time. Summed RSS can include pages shared across processes.
|
|
10
|
+
|
|
11
|
+
Use `ipaddress` to classify loopback, wildcard, specific-interface and unknown binds. For IPv4-mapped IPv6, classify the mapped IPv4 address while preserving the socket's IPv6 family. A bind describes a local address. Cross-family acceptance, firewall policy, NAT and external reachability require other evidence. Service hints match executable or process names and cite a conventional TCP port when it supports the hint.
|
|
12
|
+
|
|
13
|
+
## Capability matrix
|
|
14
|
+
|
|
15
|
+
Windows behavior was checked with a standard user token. Linux and macOS behavior remains best effort.
|
|
16
|
+
|
|
17
|
+
| Capability | Windows, standard user | Linux, standard user | macOS, standard user |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| TCP listeners and UDP bindings | Verified with IPv4/IPv6 loopback sockets and IPv4 wildcard UDP. Sandboxes may deny system table reads. | Restricted sockets may be omitted silently. Visibility is confined to the current namespace. | psutil normally denies system-wide collection without root. Phase 1 reports the restriction. |
|
|
20
|
+
| PID, name, owner, executable, creation time and RSS | Best effort. Protected processes can expose fewer fields. | Depends on permissions and procfs visibility. | `doctor` probes the current process separately from the socket table. |
|
|
21
|
+
| Authorized process management | Verified on disposable processes using a native handle under a standard user. | Guarded pidfd backend, synthetic validation only. | Blocked. |
|
|
22
|
+
|
|
23
|
+
`doctor` reports the socket backend and its status, probes metadata on its own process, and checks SQLite import and the per-user history path. It uses built-in defaults and creates no configuration or state. An empty successful result and a failed collection remain distinct. [psutil API reference](https://psutil.io/api/)
|
|
24
|
+
|
|
25
|
+
## Phase 2 monitoring evidence
|
|
26
|
+
|
|
27
|
+
Watch uses the same OS inventory as scan and also considers established TCP rows. It matches same-family local endpoint, verified process instance, and a single compatible exact or wildcard listener. An ambiguous listener assignment, missing owner or peer, or possible cross-family match leaves the negative evidence unknown. Linux or other partial views can produce positive observations, but cannot establish that matching activity was absent. UDP appears only as a binding.
|
|
28
|
+
|
|
29
|
+
A poll can report several established rows, and a long-lived connection can appear at several polls. Snapshot evidence does not measure connection totals, traffic volume, direction, or activity between observations. Watch can compare consecutive available snapshots. It suppresses appearance or disappearance claims across failed or partial reads, missed slots, and wall-clock changes. A scope change requires one compatible departure and one arrival for the same verified process and port in the selected view.
|
|
30
|
+
|
|
31
|
+
The scheduler runs one collection at a time. It uses a monotonic clock for intervals and the session span, and UTC for recorded timestamps. A slow read, render, or write can advance the scheduler past a slot. It records skipped counts and attempts no catch-up backlog. A wall clock difference from the monotonic clock of at least one second flags the sample. This can also indicate a sleep boundary on systems whose monotonic clock pauses. A flagged sample can report positive TCP evidence and cannot supply a negative observation. Clean interruption finalizes a watch. A killed process or failed storage finalization can leave an unfinalized session.
|
|
32
|
+
|
|
33
|
+
## SQLite data model
|
|
34
|
+
|
|
35
|
+
Paths are `%LOCALAPPDATA%/PortSweep/history.sqlite3`, `$XDG_STATE_HOME/portsweep/history.sqlite3` (or `~/.local/state/portsweep/history.sqlite3`), and `~/Library/Application Support/PortSweep/history.sqlite3`.
|
|
36
|
+
|
|
37
|
+
| Table | Stored data |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `session` | UTC start and end, elapsed duration, interval, selected filter, finish status, and trailing missed slots. |
|
|
40
|
+
| `sample` | Session and slot, actual UTC timestamp and monotonic offset, collection duration, visibility and reason, preceding skipped slots, wall-clock flag and change counts. |
|
|
41
|
+
| `process_instance` | Verified PID and creation timestamp, with optional observed name. A process restart is a separate instance. |
|
|
42
|
+
| `endpoint` | Protocol, IP version, local binding, scope and owner reference. Unverified endpoints are kept separate by session. |
|
|
43
|
+
| `observation` | Endpoint visibility for a sample, owner status, and a TCP match, no match, or unknown flag. UDP has no activity flag. |
|
|
44
|
+
|
|
45
|
+
Schema version 2 uses an application ID and transactions for initialization and migrations. Each sample and its endpoint observations commit together. Indexes cover sample time, endpoint identity and port, and observation links. The main database uses a 64 MiB page budget. A full or locked database can stop recording while leaving committed observations intact. Readers open existing databases read-only. A rollback journal may exist briefly during a write. Finished sessions can be pruned once all their old observations qualify. Unfinalized session markers are kept, including while another process records. SQLite reuses pages from deleted observations.
|
|
46
|
+
|
|
47
|
+
History reports first and last observation, verified owner identity, successful/eligible/activity sample counts, the last positive timestamp, coverage gaps, and spans within the recorded sessions. Span sums include intervals between observed slots in each session. They exclude elapsed time between sessions. “No TCP activity observed” refers only to available samples. A missing sample never supplies a negative observation.
|
|
48
|
+
|
|
49
|
+
## Phase 3 review evidence
|
|
50
|
+
|
|
51
|
+
Match by protocol, IP version, canonical local address, port, verified PID, and process creation timestamp. A changed bind or restarted process needs its own observations. Unknown ownership never inherits prior evidence. An absent PID or a verified replacement can establish that a historical process instance is gone. Otherwise a historical endpoint outside the available snapshot is unconfirmed or no longer visible.
|
|
52
|
+
|
|
53
|
+
The default seven-day review reads history and takes one fresh inventory. Each TCP listener is evaluated against the latest recorded session that saw that exact identity. Begin the window at its first sighting in that session after the most recent recorded match in the lookback, and count every scheduled slot through the session tail. Eligible slots contain an attributable TCP observation from an available sample. A failed read, an unobserved binding, an ambiguous match or a skip supplies no negative evidence. Use the first-to-last eligible monotonic span and exclude disconnected sessions. Recent matches take priority, including positive evidence from the fresh inventory. Clock changes invalidate a review window. Current partial coverage suppresses candidates.
|
|
54
|
+
|
|
55
|
+
The default policy needs 100 eligible samples, at least 1,800 seconds of eligible span, 90% of scheduled slots eligible, no more than one consecutive slot without evidence, and a latest eligible sample within 300 seconds. Recent means a TCP match within 30 minutes and within the selected lookback for recorded matches. The coverage ratio measures observed slot eligibility. It is not a confidence score. See `idle --help` for policy flags.
|
|
56
|
+
|
|
57
|
+
| Classification | Evidence |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| Recent TCP activity observed | A matching established row was sampled recently. |
|
|
60
|
+
| Review candidate | The verified current listener has no observed matches and meets the one-session policy. Another visible TCP listener for the same PID with activity or inadequate evidence blocks this classification, even when filters hide it. |
|
|
61
|
+
| Insufficient observation coverage | History, span, eligible samples, gaps, freshness, current visibility or same-process evidence fail the policy. |
|
|
62
|
+
| Ambiguous ownership | Unverified identity, unresolved overlapping bindings or ambiguous TCP attribution prevent a safe match. |
|
|
63
|
+
| Historical process no longer present | The PID is absent or now belongs to a different verified process instance. |
|
|
64
|
+
| Historical endpoint not visible | The exact recorded binding is absent from the available snapshot and the process exit is unproven. |
|
|
65
|
+
| UDP activity not measured | Only the binding was observed. |
|
|
66
|
+
| Unknown | Current socket or bind evidence cannot support a narrower conclusion. |
|
|
67
|
+
|
|
68
|
+
Review candidates indicate a service worth manual review. Uptime, binding scope and RSS help users interpret findings. They do not supply evidence of inactivity or authorize a process action. Displayed RSS totals count each selected verified current process once.
|
|
69
|
+
|
|
70
|
+
## Commands
|
|
71
|
+
|
|
72
|
+
| Command | Behavior |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `scan [--tcp or --udp] [--non-loopback] [--sort port, memory, or uptime]` | Point-in-time inventory. |
|
|
75
|
+
| `inspect PORT[/tcp or /udp]` | Show matching visible endpoints and process details. |
|
|
76
|
+
| `doctor` | Report collector and storage capabilities. |
|
|
77
|
+
| `watch [--interval SECONDS] [--duration SECONDS] [--port PORT] [--tcp or --udp] [--non-loopback] [--record]` | Foreground polling, two seconds by default. Recording is opt-in. |
|
|
78
|
+
| `history [--days DAYS] [--port PORT]` | Summarize persisted evidence, seven days by default. |
|
|
79
|
+
| `storage status` | Report database path, size, counts, schema, capacity, and retention guidance. |
|
|
80
|
+
| `storage prune --days DAYS [--dry-run or --yes]` | Preview records older than the cutoff. Deletion requires interactive confirmation or the explicit flag. |
|
|
81
|
+
| `idle [--days DAYS] [--port PORT] [--non-loopback] [--explain]` | Compare current listeners against single-session evidence. Supports sorting and threshold options. |
|
|
82
|
+
| `report scan, history, or idle [--format json or csv] [--output PATH]` | Export [versioned records](report-schema.md), with local identifiers redacted by default. |
|
|
83
|
+
| `kill PORT [--tcp or --udp] [--pid PID] [--dry-run or --yes]` | Preview and authorize one verified process instance. |
|
|
84
|
+
| `cleanup [--days DAYS] [--non-loopback] [--dry-run]` | Preview review candidates and select individual instances interactively. |
|
|
85
|
+
|
|
86
|
+
Exit 0 for usable output, 1 for an unavailable collection, storage or report operation, 2 for invalid arguments, and 130 on a cleanly interrupted watch.
|
|
87
|
+
|
|
88
|
+
## Management boundary
|
|
89
|
+
|
|
90
|
+
`management` builds a plan from fresh inventory and compares identity and endpoint fingerprints immediately before executing. `management_cli` owns previews, selection and authorization. Platform backends pin the process through confirmation and provide the only APIs for sending an action and waiting for its exit. The post-action check uses the same passive inventory. Review and history supply context only. See the [management CLI and residual races](management.md).
|
|
91
|
+
|
|
92
|
+
## Threat model and privacy
|
|
93
|
+
|
|
94
|
+
Treat process-controlled strings as untrusted. PortSweep uses literal Rich text and escapes terminal control characters, including bidi controls. The collector calls no shell commands and performs no active network probes. It reads no process arguments, process environments, credentials, or packet payloads. Live inspection can display local account names and executable paths. Command output should be redacted before sharing.
|
|
95
|
+
|
|
96
|
+
Recorded history contains local binding addresses, verified process instance data, and collection evidence. Account names, executable paths, RSS and peer endpoints stay outside history. Watch skips explicit executable and account queries. Peer tuples distinguish established rows in memory during collection and are never emitted or persisted. SQLite uses parameterized values, a private per-user location, owner-only modes on Unix at creation, and inherited ACLs on Windows. Filesystem copies, backups and administrator access are outside these protections.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# CLI reference
|
|
2
|
+
|
|
3
|
+
Use `portsweep COMMAND --help` for arguments and defaults. All long options require their full spelling. `--no-color` disables color. Redirected watch writes plain snapshots rather than a live cursor display.
|
|
4
|
+
|
|
5
|
+
| Command | What it shows or changes |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| `scan [--tcp or --udp] [--non-loopback] [--sort port, memory, or uptime]` | Current local bindings and associated processes. Counts honor the filters, and memory totals count each verified process instance once. |
|
|
8
|
+
| `inspect PORT[/tcp or /udp]` | All visible matching owners, bindings, and available metadata. |
|
|
9
|
+
| `doctor` | Socket collection, metadata capabilities, and local history location. |
|
|
10
|
+
| `watch [--interval SECONDS] [--duration SECONDS] [--port PORT] [--tcp or --udp] [--non-loopback] [--record]` | Foreground samples. Two seconds by default. Only `--record` stores observations. |
|
|
11
|
+
| `history [--port PORT] [--days DAYS]` | Recorded evidence. Seven-day default. |
|
|
12
|
+
| `storage status` | History location, size, schema, and counts. |
|
|
13
|
+
| `storage prune --days DAYS [--dry-run or --yes]` | Preview removal and require an interactive confirmation or the exact `--yes` flag. |
|
|
14
|
+
| `idle [--port PORT] [--non-loopback] [--days DAYS] [--explain]` | Compare current verified listeners with recent single-session evidence. Use `--help` for configurable thresholds and sort options. |
|
|
15
|
+
| `report scan, history, or idle [--format json or csv] [--output PATH]` | Export [versioned records](report-schema.md) to stdout or a new file. Default output is redacted. |
|
|
16
|
+
| `kill PORT [--tcp or --udp] [--pid PID] [--dry-run or --yes] [--force] [--timeout SECONDS]` | [Preview and authorize](management.md) one current local process owner. |
|
|
17
|
+
| `cleanup [--days DAYS] [--non-loopback] [--dry-run]` | Use review evidence to preview current candidates. An interactive terminal is required to select and authorize individual PIDs. |
|
|
18
|
+
|
|
19
|
+
Exit 0 generally means usable output, a successful action, preview, or explicit cancellation. Exit 1 indicates an unavailable operation, a refusal, or incomplete management verification. Exit 2 indicates invalid arguments. An interrupted watch or management workflow returns 130 when interrupted by the CLI. An empty usable inventory or missing optional history can return 0 with an explanatory message.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Roadmap and release
|
|
2
|
+
|
|
3
|
+
## Implementation sequence
|
|
4
|
+
|
|
5
|
+
1. **Phase 1 — Windows inventory.** Delivered local socket discovery, PID-reuse-aware metadata, bind classification, tentative service hints, and the `scan`, `inspect`, and `doctor` commands. Verified standard-user Windows collection using owned sockets. Linux and macOS remain best effort.
|
|
6
|
+
2. **Phase 2 — Monitoring and history.** Add foreground `watch`, conservative TCP attribution, explicit opt-in SQLite recording, `history`, and previewed manual pruning.
|
|
7
|
+
3. **Phase 3 — Review and reporting.** Add verified, single-session review findings and versioned redacted JSON/CSV reports. Developer trials, cross-platform validation and naming checks remain public release gates.
|
|
8
|
+
4. **Phase 4 — Explicit cleanup.** Deliver current-owner impact previews, handle-bound authorization, native Windows process management, and independent post-action verification. Review suggestions alone never authorize an action.
|
|
9
|
+
5. **Phase 5 — Release hardening.** Audit authorization, storage and packaging. Validate Windows actions and Linux container behavior. Prepare the hosted compatibility matrix and publication checklist.
|
|
10
|
+
6. **Phase 6 — Publication gates.** Run hosted CI on the final commit, confirm naming and owner approval, and publish only the verified archives. Native Linux management and macOS claims require evidence from those environments.
|
|
11
|
+
|
|
12
|
+
## Testing strategy
|
|
13
|
+
|
|
14
|
+
- Phase 1 tests cover both address families, wildcard and scoped IPv6, shared endpoints, PID reuse, disappearing processes, inaccessible fields, permission failures, process totals, service hints, command behavior, and hostile terminal text.
|
|
15
|
+
- Live tests create loopback TCP listeners and UDP bindings on ephemeral IPv4 and IPv6 ports. The wildcard check briefly binds an IPv4 UDP socket and sends or receives no traffic. Tests assert owned fixtures and treat unrelated host rows as variable. Compare Linux and macOS results against native tooling before claiming broader coverage.
|
|
16
|
+
- Phase 2 uses a fake clock for missed slots, overrun, wall-clock changes, interruptions, and failures. SQLite tests cover schema migrations, rollback, concurrent access, corruption, capacity and confirmed pruning. Live Windows tests hold temporary loopback TCP connections and UDP binds, restart a controlled listener, and query recorded history from separate CLI invocations.
|
|
17
|
+
- Run Ruff, pytest, CLI smoke checks, wheel and sdist builds, and strict metadata checks in CI on Windows, Ubuntu and macOS with Python 3.11 and 3.14. Use explicit capability skips for genuinely unavailable host features and retain a supported Windows standard-user integration gate.
|
|
18
|
+
|
|
19
|
+
## Phase 1 performance
|
|
20
|
+
|
|
21
|
+
Measured on Windows 11 build 26300, AMD64, 16 logical CPUs, 15.7 GiB RAM, Python 3.12.3 and psutil 7.2.2, using a standard user token. The desktop had 159–161 distinct observed rows during collector measurements. There were 12 samples per measurement. Fresh CLI timing includes a new Python process, imports, collection, rendering to a null sink and process exit.
|
|
22
|
+
|
|
23
|
+
| Measurement | Median | Observed range |
|
|
24
|
+
| --- | ---: | ---: |
|
|
25
|
+
| Collector in an already running process | 696 ms | 476–1,153 ms |
|
|
26
|
+
| Fresh CLI scan | 1,510 ms | 1,125–2,742 ms |
|
|
27
|
+
| Fresh CLI peak Windows working set | 28.4 MiB | 28.1–28.9 MiB |
|
|
28
|
+
| Fresh Python with psutil memory measurement only | 16.8 MiB | 16.6–16.9 MiB |
|
|
29
|
+
|
|
30
|
+
The median peak difference against that baseline was 11.6 MiB. These are observations from one workstation. Process access costs and system load affect the result.
|
|
31
|
+
|
|
32
|
+
## Phase 2 performance
|
|
33
|
+
|
|
34
|
+
The Windows 11 build 26300 workstation had 16 logical CPUs and 15.7 GiB of RAM, running Python 3.12.3 and psutil 7.2.2. A 120-second foreground watch sampled every two seconds, rendered its views to a null sink, and recorded in a disposable database. It collected 60 usable samples, with 155–165 visible endpoints per sample, zero failed reads, and zero skipped slots. These are measurements on one workstation.
|
|
35
|
+
|
|
36
|
+
| Metric | Median | Observed range |
|
|
37
|
+
| --- | ---: | ---: |
|
|
38
|
+
| Collector | 336 ms | 203–750 ms |
|
|
39
|
+
| SQLite sample commit | 10.52 ms | 4.38–17.79 ms |
|
|
40
|
+
| Start offset from scheduled slot | 0 ms | 0–15 ms |
|
|
41
|
+
| Sampled RSS | 28.82 MiB | 27.89–29.15 MiB |
|
|
42
|
+
|
|
43
|
+
Peak working set was 32.23 MiB, with 26.51 MiB RSS before the watch. It used 20.23 CPU-seconds, an average of 16.9% of one logical CPU. The main database grew from 56 KiB to 356 KiB for 9,422 endpoint observations. The measured increase was 300 KiB, or 5 KiB per poll on this workload. Database growth depends on the interval, endpoint count, churn, and index page use. The configured main database cap is 64 MiB.
|
|
44
|
+
|
|
45
|
+
## Phase 3 before and after
|
|
46
|
+
|
|
47
|
+
Measured with the same Windows 11 workstation and Python 3.12.3 / psutil 7.2.2 setup as Phase 2. The fixed fixture recorded 160 bindings and 40 verified processes over 50 samples, repeated three times. The live tests each ran for 26 seconds with recording and Rich output directed to a null sink. Visible endpoint counts varied with the host.
|
|
48
|
+
|
|
49
|
+
| Fixed workload | Before | After |
|
|
50
|
+
| --- | ---: | ---: |
|
|
51
|
+
| Median SQLite sample write, 150 samples | 9.03 ms | 4.14 ms |
|
|
52
|
+
| Median history aggregation, three runs | 21.23 ms | 12.60 ms |
|
|
53
|
+
| SQLite `execute` calls across three profiled steady-state sample writes | 1,683 | 603 plus 3 `executemany` calls |
|
|
54
|
+
|
|
55
|
+
The storage path now checks for existing identities inside the write transaction, then batches observation inserts. History avoids a redundant endpoint join while retaining the indexed port filter. Per-sample process verification and one socket-table read remain in place.
|
|
56
|
+
|
|
57
|
+
| Live workload | Before, 2 s | After, 2 s | Before, 5 s | After, 5 s |
|
|
58
|
+
| --- | ---: | ---: | ---: | ---: |
|
|
59
|
+
| Usable samples, zero failures or skips in all runs | 13 | 13 | 6 | 6 |
|
|
60
|
+
| Median visible endpoints | 154 | 158 | 152 | 160 |
|
|
61
|
+
| Median collection | 375 ms | 422 ms | 344 ms | 437.5 ms |
|
|
62
|
+
| Median SQLite write | 7.40 ms | 8.31 ms | 7.29 ms | 8.05 ms |
|
|
63
|
+
| Median rendering | 5.83 ms | 8.20 ms | 6.21 ms | 7.88 ms |
|
|
64
|
+
| Average CPU, fraction of one logical core | 19.0% | 20.4% | 9.0% | 10.2% |
|
|
65
|
+
| Peak working set | 29.16 MiB | 29.68 MiB | 29.23 MiB | 29.68 MiB |
|
|
66
|
+
| Main database growth | 76 KiB | 80 KiB | 44 KiB | 44 KiB |
|
|
67
|
+
|
|
68
|
+
The fixed workload got faster. The short live runs show no end-to-end improvement, and collection remained the largest measured cost. Five-second polling reduced CPU and database growth with fewer opportunities to observe short connections. The default remains two seconds to preserve observation frequency and existing behavior.
|
|
69
|
+
|
|
70
|
+
## Phase 4 action timing
|
|
71
|
+
|
|
72
|
+
Seven disposable children, each with one TCP loopback listener and one UDP loopback binding, were created for the Windows 11 build 26300 benchmark. The host used Python 3.12.3, 16 logical CPUs, and a standard user token. The socket tables contained 166–168 visible endpoints. The first snapshot, pre-action snapshot, and post-action snapshot were all retained. Trials alternated the equivalent Windows normal and force modes and confirmed exit and requested TCP release in all seven runs. Timings exclude user input, history lookups, and CLI startup.
|
|
73
|
+
|
|
74
|
+
| Stage | Median | Observed range |
|
|
75
|
+
| --- | ---: | ---: |
|
|
76
|
+
| Initial inventory | 398 ms | 362–715 ms |
|
|
77
|
+
| Inventory, plan, and initial handle protections | 623 ms | 533–947 ms |
|
|
78
|
+
| Re-check, termination, and verified outcome | 1,063 ms | 953–1,375 ms |
|
|
79
|
+
| Exit wait and post-action inventory, included above | 407 ms | 375–625 ms |
|
|
80
|
+
| Total measured workflow | 1,700 ms | 1,502–2,096 ms |
|
|
81
|
+
|
|
82
|
+
## Phase 5 performance
|
|
83
|
+
|
|
84
|
+
Measured on Windows 11 build 26300 with Python 3.12.3, psutil 7.2.2, and 16 logical CPUs. Times are medians from short local runs. The fixed SQLite fixture used 160 bindings, 40 verified process instances, and 50 samples. Windows action measurements target five disposable loopback children and exclude user input and CLI startup.
|
|
85
|
+
|
|
86
|
+
| Workflow | Median |
|
|
87
|
+
| --- | ---: |
|
|
88
|
+
| Fresh CLI version / fresh scan | 423 ms / 874 ms |
|
|
89
|
+
| Kernel socket-table read / enriched collection | 1.26 ms / 374 ms |
|
|
90
|
+
| Per-PID metadata read, 340 calls | 10.59 ms |
|
|
91
|
+
| Fixed-fixture SQLite write / history aggregation | 3.63 ms / 11.72 ms |
|
|
92
|
+
| Fixed-fixture review classification / history JSON generation | 44.91 ms / 17.97 ms |
|
|
93
|
+
| Termination workflow / post-action verification | 959 ms / 250 ms |
|
|
94
|
+
|
|
95
|
+
Two-second foreground watch produced 13 samples in 26 seconds, at 18.69% of one logical core, 32.98 MiB median sampled RSS, and 5.55 ms median writes. Five-second watch produced six samples, at 7.45% CPU, 33.05 MiB median RSS, and 8.09 ms median writes. Both runs had zero failed or missed samples. Host load and visible endpoint counts varied. The results are broadly comparable to earlier phases, and the default stays at two seconds to preserve sampling frequency. Metadata lookup remains the largest measured collector cost. Identity checks remain intact and have no cross-snapshot cache.
|
|
96
|
+
|
|
97
|
+
## Acceptance criteria
|
|
98
|
+
|
|
99
|
+
- A standard Windows user can discover owned IPv4 and IPv6 TCP listeners and UDP bindings and inspect their associated process details. Missing metadata, disappearing PIDs and duplicate-looking rows produce usable, correctly qualified results.
|
|
100
|
+
- Loopback, wildcard and specific-address IPv4/IPv6 cases render correctly. Non-loopback filtering reports bind scope and makes no external reachability or vulnerability claims. Process memory totals count each verified instance once.
|
|
101
|
+
- A foreground watch with recording disabled leaves no history files. Recorded watches survive reopening with committed observations, coverage and gaps intact. A failed sample supplies no evidence of inactivity.
|
|
102
|
+
- Storage reads never initialize a database. Pruning previews selected records and requires confirmation. Inspection and recorded outputs exclude command lines, environment values, credentials, payloads and peer endpoints. Recorded rows also exclude executable paths, usernames and RSS.
|
|
103
|
+
- Review suggestions expose their single-session evidence and are suppressed when coverage is inadequate. JSON and CSV pass schema, redaction, spreadsheet-safety, and exclusive-output tests.
|
|
104
|
+
- Management actions require individual authorization, reverify the exact live owner and footprint, and distinguish process exit from port release. Windows integration exercises only disposable local listeners. Protected process test fixtures are synthetic.
|
|
105
|
+
- `doctor` and documentation agree with observed permissions and platform support. Public platform claims match tested standard-user capabilities.
|
|
106
|
+
|
|
107
|
+
## GitHub and PyPI release strategy
|
|
108
|
+
|
|
109
|
+
Phase 5 prepares the local 0.1.0 candidate. See the [release checklist](release.md), [security audit](security-audit.md), and [platform validation](platforms.md). Hosted CI and explicit owner approval remain required before publication.
|
|
110
|
+
|
|
111
|
+
Build a wheel and sdist from a reviewed release commit. Run strict metadata validation and install the resulting artifacts in clean environments to smoke-test both CLI entry points. Review artifact contents for unintended files and record checksums. Rehearse the publish-and-install path with TestPyPI on explicit approval. Use GitHub Releases with a matching version tag and changelog. For production PyPI, use a dedicated GitHub environment with review and PyPI Trusted Publishing via OIDC. Give identity-token permission only to that job and publish the same verified artifacts. Start public development releases only after the MVP acceptance gates are met. [PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/)
|