@saptools/cf-live-trace 0.1.5 → 0.1.8
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.
- package/README.md +26 -7
- package/dist/cli.js +1267 -92
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +139 -7
- package/dist/index.js +1085 -76
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
- Runtime HTTP tracing for Node.js apps already running on Cloud Foundry.
|
|
21
21
|
- Automatic CF session setup, SSH enablement check, Node inspector startup, and SSH port forwarding.
|
|
22
22
|
- CDP-based JavaScript injection derived from the SAP Tools VS Code Live Trace flow.
|
|
23
|
-
- Request and response header capture, body
|
|
24
|
-
-
|
|
23
|
+
- Request and response header capture, bounded body capture, status, duration, byte counts, correlation id, and bounded queue drops.
|
|
24
|
+
- Compact stdout for scripts and agents: headers and app id stay out of live output, common credential query values are redacted, body previews are capped at 128 characters, and full captured events are saved locally.
|
|
25
|
+
- Per-request backup JSON files under `~/.saptools/cf-live-trace/sessions/` with two-hour retention and session inspection commands for large JSON bodies.
|
|
25
26
|
- Strict TypeScript, ESLint, unit coverage, and fake-backed E2E tests without live SAP access.
|
|
26
27
|
|
|
27
28
|
---
|
|
@@ -61,7 +62,7 @@ If you already know the CF API endpoint, replace `--region ap10` with `--api-end
|
|
|
61
62
|
By default the command streams one JSON object per captured HTTP request and runs until `Ctrl+C`.
|
|
62
63
|
|
|
63
64
|
```json
|
|
64
|
-
{"id":"1","method":"POST","normalizedUrl":"/orders","status":201,"durationMs":24}
|
|
65
|
+
{"id":"1","sessionId":"s1a2b3c4d5e6f7a8b","requestId":"r1a2b3c4d5e6f7a8","method":"POST","normalizedUrl":"/orders","status":201,"durationMs":24,"requestBodyFormat":"json","responseBodyFormat":"json"}
|
|
65
66
|
```
|
|
66
67
|
|
|
67
68
|
---
|
|
@@ -93,7 +94,7 @@ Trace flags:
|
|
|
93
94
|
| --- | --- |
|
|
94
95
|
| `--duration <seconds>` | Stop after N seconds |
|
|
95
96
|
| `--max-events <count>` | Stop after N captured trace events |
|
|
96
|
-
| `--max-body-bytes <bytes>` | Maximum request/response
|
|
97
|
+
| `--max-body-bytes <bytes>` | Maximum request/response capture bytes, default `4096`; must be greater than `0` |
|
|
97
98
|
| `--no-capture-headers` | Do not capture request/response headers |
|
|
98
99
|
| `--no-capture-request-body` | Do not capture request body previews |
|
|
99
100
|
| `--no-capture-response-body` | Do not capture response body previews |
|
|
@@ -103,6 +104,14 @@ Trace flags:
|
|
|
103
104
|
|
|
104
105
|
Prefer `SAP_EMAIL` and `SAP_PASSWORD` over inline credential flags. Process arguments can be visible to other users on the same machine.
|
|
105
106
|
|
|
107
|
+
Each captured request is also saved as a private JSON file under:
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
~/.saptools/cf-live-trace/sessions/<sessionId>/events/
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Files expire after two hours. Expired files are pruned while tracing and when session commands run. The path is based on Node's user home directory, so Windows uses the current user's profile directory.
|
|
114
|
+
|
|
106
115
|
---
|
|
107
116
|
|
|
108
117
|
## Examples
|
|
@@ -143,6 +152,15 @@ cf-live-trace \
|
|
|
143
152
|
--format json
|
|
144
153
|
```
|
|
145
154
|
|
|
155
|
+
Inspect a saved session after or during a trace run:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
cf-live-trace session events s1a2b3c4d5e6f7a8b --method POST --limit 20
|
|
159
|
+
cf-live-trace session search s1a2b3c4d5e6f7a8b orderId --body both --length 256
|
|
160
|
+
cf-live-trace session body s1a2b3c4d5e6f7a8b r1a2b3c4d5e6f7a8 --body response --path /data/items/0 --limit 4000 --rows 100
|
|
161
|
+
cf-live-trace session prune
|
|
162
|
+
```
|
|
163
|
+
|
|
146
164
|
---
|
|
147
165
|
|
|
148
166
|
## How It Works
|
|
@@ -155,7 +173,7 @@ cf-live-trace \
|
|
|
155
173
|
4. Open `cf ssh -L <local>:127.0.0.1:9229` for the selected app instance.
|
|
156
174
|
5. Attach to the Node inspector over CDP using `@saptools/cf-inspector`.
|
|
157
175
|
6. Evaluate a runtime hook that patches Node's `http` and `https` server prototypes.
|
|
158
|
-
7. Poll a bounded in-process queue and stream
|
|
176
|
+
7. Poll a bounded in-process queue with acknowledgement-based retries, save each drained trace event locally, and stream compact trace events back to stdout.
|
|
159
177
|
8. Disable or uninstall the hook and close the tunnel on exit.
|
|
160
178
|
|
|
161
179
|
The injected global is named `__SAPTOOLS_CF_LIVE_TRACE__` so CLI sessions do not collide with the VS Code extension's Live Trace runtime global.
|
|
@@ -198,8 +216,9 @@ The public API also exports helpers for payload parsing, runtime expression cons
|
|
|
198
216
|
## Security Notes
|
|
199
217
|
|
|
200
218
|
- This tool injects JavaScript into a running Node.js process through the Node inspector. Use it only for apps and spaces you are authorized to inspect.
|
|
201
|
-
- Captured headers and bodies can contain credentials, tokens, cookies, or personal data.
|
|
202
|
-
-
|
|
219
|
+
- Captured headers and bodies can contain credentials, tokens, cookies, or personal data. Backup files are private by default, but keep the user profile and CI artifacts protected.
|
|
220
|
+
- Live stdout intentionally omits request/response headers and app id, redacts common credential query values, and only prints 128 characters of each captured body. Backup JSON files retain the fuller captured event for two hours.
|
|
221
|
+
- `--max-body-bytes` bounds captured body data transported back from the app and must be greater than zero. Set it lower for sensitive or high-throughput services.
|
|
203
222
|
- The CLI avoids putting credentials in `cf auth` arguments; credentials are passed to the CF CLI through `CF_USERNAME` and `CF_PASSWORD`.
|
|
204
223
|
- If cleanup fails, the runtime hook can remain disabled or installed until the app process restarts. Progress events report this state.
|
|
205
224
|
|