cmdscope 0.1.0__py3-none-any.whl

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,353 @@
1
+ Metadata-Version: 2.4
2
+ Name: cmdscope
3
+ Version: 0.1.0
4
+ Summary: Run a command and see what it changed: files, processes, and network, locally and privately.
5
+ Author: CmdScope contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/SouzaF19/cmdscope
8
+ Project-URL: Repository, https://github.com/SouzaF19/cmdscope
9
+ Project-URL: Issues, https://github.com/SouzaF19/cmdscope/issues
10
+ Project-URL: Changelog, https://github.com/SouzaF19/cmdscope/blob/main/CHANGELOG.md
11
+ Keywords: observability,command-line,filesystem,process-monitoring,network-monitoring,audit
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 10
17
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 11
18
+ Classifier: Operating System :: POSIX :: Linux
19
+ Classifier: Operating System :: MacOS
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Topic :: Software Development :: Debuggers
26
+ Classifier: Topic :: System :: Monitoring
27
+ Classifier: Topic :: Utilities
28
+ Requires-Python: >=3.11
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: psutil<8,>=5.9
32
+ Requires-Dist: watchdog<8,>=4
33
+ Provides-Extra: dev
34
+ Requires-Dist: build>=1.2; extra == "dev"
35
+ Requires-Dist: mypy>=1.10; extra == "dev"
36
+ Requires-Dist: pytest>=8; extra == "dev"
37
+ Requires-Dist: pytest-cov>=5; extra == "dev"
38
+ Requires-Dist: ruff>=0.6; extra == "dev"
39
+ Requires-Dist: twine>=5; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # CmdScope
43
+
44
+ **Run a command and see what it changed — files, processes, and network — locally and privately.**
45
+
46
+ CmdScope executes a command inside an observation session and records what it can actually
47
+ see: files created, modified, or deleted under the directories you watch, the process tree
48
+ it spawns, and the network endpoints it opens. When the command finishes, CmdScope prints a
49
+ report and stores the session in a local SQLite database so you can compare runs later.
50
+
51
+ ```console
52
+ $ cmdscope run -- npm install
53
+
54
+ CMDSCOPE - EXECUTION REPORT
55
+ ======================================================================
56
+ Session: S000001
57
+ Command: npm install
58
+ Directory: C:\work\my-project
59
+ Platform: windows
60
+ Started: 2026-11-08 10:45:36 UTC
61
+ Duration: 12.43 s
62
+ Exit status: 0
63
+ Status: completed
64
+
65
+ FILESYSTEM
66
+ Watch roots: C:\work\my-project
67
+ Created: 184
68
+ Modified: 12
69
+ Deleted: 0
70
+ + node_modules\package\package.json (1.2 KB)
71
+ ~ package-lock.json (48.7 KB)
72
+
73
+ PROCESSES
74
+ Started: 2
75
+ Finished: 2
76
+ Still running: 0
77
+ [pid 8124] started: node C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js install
78
+
79
+ NETWORK
80
+ Connections observed: 1
81
+ [pid 8124] node: 10.0.0.14:52344 -> 104.16.24.35:443 (TCP, ESTABLISHED)
82
+
83
+ COLLECTORS
84
+ filesystem ok backend=native, watch_roots=['C:\\work\\my-project']
85
+ network ok connections_observed=1
86
+ processes ok observed_processes=4, still_running=0
87
+
88
+ SUMMARY
89
+ 199 events observed in this session.
90
+ 196 filesystem changes, 2 processes started, 1 network connection.
91
+
92
+ LIMITATIONS
93
+ - Only changes under the configured watch roots are observed.
94
+ - Processes and sockets are sampled; short-lived ones can be missed.
95
+ - File contents are never captured.
96
+ - CmdScope observability is not sandboxing or isolation.
97
+ - Runtime environment mutations are not observable externally.
98
+
99
+ Generated locally by CmdScope. No data was transmitted.
100
+ ```
101
+
102
+ > The numbers above are illustrative. Every value in a real report comes from an
103
+ > observation made during that session.
104
+
105
+ ## The problem
106
+
107
+ Installing a package, running a migration, or executing a build script usually leaves you
108
+ guessing. `strace` and `Procmon` are powerful but heavy, privileged, platform-specific, and
109
+ not session-oriented. CmdScope offers a small, honest, cross-platform tool for the common
110
+ question: *"what did that command actually do to my machine?"*
111
+
112
+ CmdScope is an **observability** tool. It is **not** a sandbox, a permission system, or a
113
+ malware detector. The monitored command runs with your normal permissions and is not
114
+ restricted in any way.
115
+
116
+ ## Main features
117
+
118
+ - **Filesystem observation** — metadata changes (created / modified / deleted) under explicit
119
+ watch roots, using native OS events (`ReadDirectoryChangesW`, `inotify`, `FSEvents`) with a
120
+ polling fallback.
121
+ - **Process tree observation** — the root process and the descendants it spawns, with
122
+ start/finish observations and command lines.
123
+ - **Network observation** — TCP/UDP endpoints attributed to the processes of the session.
124
+ - **Session history** — every run is stored in a local SQLite database.
125
+ - **Comparison** — `cmdscope compare` diffs two sessions by normalized paths and event
126
+ signatures.
127
+ - **Reports** — terminal, JSON, and self-contained HTML (no scripts, no external assets).
128
+ - **Privacy by default** — no telemetry, no uploads, no file contents, and automatic
129
+ redaction of sensitive flags and environment variables.
130
+ - **Honest capabilities** — every collector reports its state and blind spots in the report.
131
+
132
+ ## Installation
133
+
134
+ ```console
135
+ $ pip install cmdscope
136
+ ```
137
+
138
+ From a checkout:
139
+
140
+ ```console
141
+ $ python -m pip install -e ".[dev]"
142
+ $ cmdscope --version
143
+ ```
144
+
145
+ Python 3.11 or newer is required.
146
+
147
+ ## Requirements
148
+
149
+ | Requirement | Notes |
150
+ | --- | --- |
151
+ | Python | 3.11+ (tested on 3.13) |
152
+ | Dependencies | `psutil`, `watchdog` (installed automatically) |
153
+ | Privileges | none required; CmdScope never elevates on its own |
154
+
155
+ The database lives in the per-user data directory:
156
+
157
+ | Platform | Default database |
158
+ | --- | --- |
159
+ | Windows | `%LOCALAPPDATA%\cmdscope\cmdscope.db` |
160
+ | Linux | `$XDG_DATA_HOME/cmdscope/cmdscope.db` (or `~/.local/share/cmdscope/cmdscope.db`) |
161
+ | macOS | `~/Library/Application Support/cmdscope/cmdscope.db` |
162
+
163
+ Use `cmdscope doctor` to see the resolved paths and the capabilities of your machine.
164
+
165
+ ## Usage
166
+
167
+ ```console
168
+ # Observe a command in the current directory
169
+ cmdscope run -- npm install
170
+
171
+ # Watch extra directories (repeatable)
172
+ cmdscope run --watch ./src --watch ./config -- python app.py
173
+
174
+ # Ignore noisy paths
175
+ cmdscope run --ignore "*.log" --ignore "node_modules/**" -- pytest -q
176
+
177
+ # Pass environment variables to the command (values are redacted in reports)
178
+ cmdscope run --env API_TOKEN=secret -- node deploy.js
179
+
180
+ # Skip collectors you do not need
181
+ cmdscope run --no-network -- python build.py
182
+
183
+ # Session history
184
+ cmdscope sessions
185
+ cmdscope sessions --json
186
+
187
+ # Inspect one session
188
+ cmdscope show S000001
189
+ cmdscope show 1 --include-environment
190
+
191
+ # Reports
192
+ cmdscope report S000001
193
+ cmdscope report S000001 --format json
194
+ cmdscope report S000001 --format html --output report.html
195
+
196
+ # Compare two runs
197
+ cmdscope compare S000001 S000002
198
+ cmdscope compare S000001 S000002 --format json
199
+
200
+ # Environment diagnostics and configuration
201
+ cmdscope doctor
202
+ cmdscope config --path
203
+ cmdscope config --init
204
+ ```
205
+
206
+ Global options (`--config`, `--db`, `--no-color`, `--verbose`) must be placed **before** the
207
+ subcommand:
208
+
209
+ ```console
210
+ cmdscope --db ./local.db run -- python app.py
211
+ ```
212
+
213
+ ### What is observed, and where
214
+
215
+ - The **watch root** defaults to the current working directory. Use `--watch` or
216
+ `filesystem.watch` in the configuration file to add others.
217
+ - Files are observed **by metadata only**: path, size, modification time, and whether the
218
+ entry is a directory. Contents are never read.
219
+ - Events are *observed during the session* in the watched roots. CmdScope does not prove
220
+ causality: another process writing into the same directory at the same time will also
221
+ show up.
222
+ - CmdScope's own database files are automatically excluded from the report, even when the
223
+ database lives inside a watch root.
224
+
225
+ ## Supported systems
226
+
227
+ | Platform | Status in 0.1.x |
228
+ | --- | --- |
229
+ | Windows 10 / 11 | **Validated manually** on Windows 11 with Python 3.13, plus CI |
230
+ | Linux | Implemented and exercised by CI (Ubuntu); not manually validated in this release |
231
+ | macOS | Implemented and exercised by CI (macOS); experimental |
232
+
233
+ The collectors are portable, but the underlying observation mechanisms differ. See
234
+ [docs/collectors.md](docs/collectors.md) for the per-platform behaviour and the exact
235
+ blind spots of each collector.
236
+
237
+ ## Known limitations
238
+
239
+ - **Not a sandbox.** CmdScope does not restrict, isolate, or mediate the monitored command.
240
+ - **Not syscall tracing.** CmdScope does not use `ptrace`, eBPF, ETW, or a kernel driver. It
241
+ cannot see file access, registry writes, or syscalls that do not change observed state.
242
+ - **Limited filesystem coverage.** Only the configured watch roots are observed. Changes
243
+ anywhere else on the system are invisible.
244
+ - **Sampling.** Processes and sockets are discovered by polling. A child process or a
245
+ connection that lives entirely between two polls can be missed.
246
+ - **Network attribution needs privileges on macOS.** Unprivileged processes cannot see
247
+ socket owners there; CmdScope marks the network collector as `degraded` instead of
248
+ pretending it observed nothing.
249
+ - **No runtime environment visibility.** Only the initial environment diff handed to the
250
+ child is recorded. Mutating `environ` inside a running process cannot be observed.
251
+ - **No attribution of causes.** The report says what was observed, not which process caused
252
+ it, except for processes that CmdScope itself launched.
253
+ - **Partial snapshots.** If a watch root is larger than `filesystem.max_files`, CmdScope
254
+ reports a degraded collector instead of guessing which files were deleted.
255
+
256
+ ## Privacy and security
257
+
258
+ - All data stays on your machine. CmdScope has no network client, no telemetry, and no
259
+ analytics.
260
+ - File contents are never captured.
261
+ - Command lines and environment variables are redacted before they are stored
262
+ (`--token`, `--password`, `*_SECRET`, `*_TOKEN`, URL credentials, `Authorization`
263
+ headers, and similar).
264
+ - The monitored command runs with your permissions. CmdScope never elevates, never installs
265
+ drivers, and never modifies the files it watches.
266
+ - Details: [docs/privacy.md](docs/privacy.md).
267
+
268
+ ## Architecture
269
+
270
+ ```text
271
+ cli ──► core.engine ──► collectors ──► core.events (typed events)
272
+ │ │
273
+ └──────────► storage.sqlite ◄──┘
274
+ │
275
+ analysis ──► reports
276
+ ```
277
+
278
+ - `core/` — event models, session lifecycle, collector interface, runner.
279
+ - `collectors/` — filesystem, process, and network observation.
280
+ - `platforms/` — OS capabilities, data directories, command launch details.
281
+ - `storage/` — SQLite persistence and the event writer thread.
282
+ - `analysis/` — summaries and session comparison.
283
+ - `reports/` — terminal, JSON, and HTML rendering.
284
+ - `cli.py` — argument parsing and user-facing behaviour.
285
+
286
+ See [docs/architecture.md](docs/architecture.md) for details and
287
+ [docs/collectors.md](docs/collectors.md) for the guide to adding a new collector.
288
+
289
+ ## Configuration
290
+
291
+ Optional TOML file, searched in this order: `--config <path>`, `$CMDSCOPE_CONFIG`,
292
+ `./cmdscope.toml`, then the per-user config directory.
293
+
294
+ ```toml
295
+ [filesystem]
296
+ enabled = true
297
+ watch = []
298
+ ignore = [".git", "__pycache__", "*.pyc"]
299
+ max_files = 100000
300
+ poll_interval = 1.0
301
+ native_events = true
302
+
303
+ [processes]
304
+ enabled = true
305
+ poll_interval = 0.5
306
+
307
+ [network]
308
+ enabled = true
309
+ poll_interval = 0.25
310
+
311
+ [privacy]
312
+ capture_environment = true
313
+ show_environment = false
314
+
315
+ [storage]
316
+ max_sessions = 0
317
+ max_events = 100000
318
+
319
+ [report]
320
+ max_events = 500
321
+ format = "terminal"
322
+ ```
323
+
324
+ Run `cmdscope config --init` to write a commented template. Full reference:
325
+ [docs/configuration.md](docs/configuration.md).
326
+
327
+ ## Roadmap
328
+
329
+ - [x] Session runner with filesystem, process, and network collectors
330
+ - [x] Local SQLite history, session comparison, JSON/HTML reports
331
+ - [x] Privacy-first sanitization and `cmdscope doctor`
332
+ - [ ] Optional ETW/eBPF backends for deeper coverage (opt-in, clearly marked as elevated)
333
+ - [ ] Registry and environment-diff collectors on Windows
334
+ - [ ] Session diffing in HTML reports
335
+ - [ ] Signed releases and reproducible-build verification
336
+
337
+ ## Contributing
338
+
339
+ Contributions are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) first; it documents
340
+ the engineering rules, quality gates, and the workflow we use to keep CmdScope
341
+ dependable.
342
+
343
+ ```console
344
+ $ python -m pip install -e ".[dev]"
345
+ $ ruff check src tests
346
+ $ ruff format --check src tests
347
+ $ mypy src/cmdscope
348
+ $ pytest
349
+ ```
350
+
351
+ ## License
352
+
353
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,40 @@
1
+ cmdscope/__init__.py,sha256=7f8zUSNea4LLkcNM6fuRsQi1oiCQ7sJxFmTQ1BQVbe8,337
2
+ cmdscope/__main__.py,sha256=3Qwvw6Y8tOIZdQ3HIiefrqIs2FKKgvuqr0lBz9Qyn5A,221
3
+ cmdscope/cli.py,sha256=9NNZsHqc4eU3zNtwN8gFCKQN9s98skOFIihFUt1sd10,19180
4
+ cmdscope/config.py,sha256=XuV4TCMBIFwHKK_RLV8l5UU3pm2ln--3BWPOmfzeRCI,15752
5
+ cmdscope/diagnostics.py,sha256=dUcQgBi_KEyW8k9e9f0bnwIpFOcBzPposfiBsmTfK3c,6633
6
+ cmdscope/errors.py,sha256=0qpxtZ7TlWDS8BUTwWg7IXwbdwZ7k3Px9NhABf8ObH4,1048
7
+ cmdscope/privacy.py,sha256=Q5eiIqUWFSMSA-fMdCZ-tqwJ8cIq2MfitxaLR0lcdnU,4859
8
+ cmdscope/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ cmdscope/analysis/__init__.py,sha256=DZrAxHYuskzQqY9o3dGLldDrUlX07X_52CKdtw8XlSw,24
10
+ cmdscope/analysis/comparison.py,sha256=GxcNcG4gMz8qtvQYCWfveeVtxai1Llffx6pN5ZpdhAU,4515
11
+ cmdscope/analysis/summary.py,sha256=-KmjOl0vGnHW_FvW6aF4Z9MXAzkIQy4b4ps2jz87dGQ,1542
12
+ cmdscope/collectors/__init__.py,sha256=Z0_PSO7422kri9w6DT3HIBYA8_IxeSa6tQaRXQkyEy0,67
13
+ cmdscope/collectors/filesystem.py,sha256=xhAhcwPdfbOzzAy3hjsZ909ASvoE6rfn0uNg2rxNhgY,13776
14
+ cmdscope/collectors/network.py,sha256=zONQeHsMKKqh6W6yLLDmi6jP8ZcxzEFMeLOb_cGvlkw,6532
15
+ cmdscope/collectors/processes.py,sha256=mIEJR7rpkOMhZzYDV51OogzwJR5eHMrJa5Dht6aLrws,11583
16
+ cmdscope/core/__init__.py,sha256=h77irJhljY9ItqlJ8_flWEFmSWLge19YVByMlzHpp6Q,34
17
+ cmdscope/core/collector.py,sha256=GKlBT6XfT-XOsHcI1nR4bDNiFPEixuQP-47Ryx6RYUM,1433
18
+ cmdscope/core/engine.py,sha256=rFk6HxsJ65GcApY3ewckdTvavj8RcpjAVWARfzmyG2k,17498
19
+ cmdscope/core/events.py,sha256=zuAgnc8cFj1UJ8GVwzYDAlB1ZivHUGkRpCHMGq_gvdg,3029
20
+ cmdscope/core/ignore.py,sha256=a8xPp7ik9roSbBvm5AnBi_QZ_aHCSMGKFCzeqMbWPCw,1669
21
+ cmdscope/core/registry.py,sha256=wKT80arTPg6tDxx4rKZ1xoblKDegOvvBpVcAdTzrEPQ,910
22
+ cmdscope/core/session.py,sha256=XdfZ-2gIGLAboNTBtAVOWgwwGdjfrOobnemWnoF_cyw,2079
23
+ cmdscope/platforms/__init__.py,sha256=ib4PVWFNXqvOK8afQGo8aUxjG-SPKAAgjlsbJ-lX5sY,1423
24
+ cmdscope/platforms/base.py,sha256=Rl1-9u8pUOYGEDrc809MBcUx76n_PqHyMsr_M8jPbLc,4894
25
+ cmdscope/platforms/linux.py,sha256=R37Y6Rz4pt5hwb0XhtqZEwly50f-SAcsd11LRHpsmfM,1152
26
+ cmdscope/platforms/macos.py,sha256=_PpOSzF6EqK8efjxridC4Iy-MmxuWLXf9lezQYYLnxA,976
27
+ cmdscope/platforms/windows.py,sha256=A-YCHWhcob9nMYA2fyxqKJAexs6ViVIYVAMUikbVgXI,1136
28
+ cmdscope/reports/__init__.py,sha256=bmQ3dGBiHqSPwumamEebbTyZSdWgUDms_jPjo1MBB0Y,24
29
+ cmdscope/reports/html.py,sha256=z7N35vnAg77aSapzPVo3xDPFb2uoi0ADPZBzaJe7UoU,11202
30
+ cmdscope/reports/json_report.py,sha256=kjMbq6q087yDRWnlxCOAufSj-IoC2233IcG81YV62lM,4928
31
+ cmdscope/reports/terminal.py,sha256=SxKZTwy_i-E5wnYhPtK0fBcU1iBywktx6kQwevP5hWk,14819
32
+ cmdscope/storage/__init__.py,sha256=UvHvinbkEHGq7blHfhHQ52Axh47-MXDxCZcmJzuHxcI,192
33
+ cmdscope/storage/sqlite.py,sha256=ULBlEGI6OzC6lXNcOYSs8Wj0ykF-dfBp16tyPmgRn5o,16886
34
+ cmdscope/storage/writer.py,sha256=qFPORffiYvFjPmzE6twrvvfFVziusf_lBtUtfZmyuLY,3578
35
+ cmdscope-0.1.0.dist-info/licenses/LICENSE,sha256=7NgKnaKuHRUop_ykNm4PvXCJGCok_mRxNEu6a5oLIco,1078
36
+ cmdscope-0.1.0.dist-info/METADATA,sha256=Qt9oRk3SaY6bjb3TDMPvsbrLDnpJBocSi8zTwyO9ryQ,12766
37
+ cmdscope-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
38
+ cmdscope-0.1.0.dist-info/entry_points.txt,sha256=nYBR2OQyUajEDSmPz9NvbzDj_JcdWXUxD7N1p0pmx3I,47
39
+ cmdscope-0.1.0.dist-info/top_level.txt,sha256=h9UCflaMxhX5Pan9_et8Vvhj5f9UNPuGiSxziEtot9s,9
40
+ cmdscope-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cmdscope = cmdscope.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CmdScope 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.
@@ -0,0 +1 @@
1
+ cmdscope