@testsprite/testsprite-cli 0.6.0 → 0.8.0
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 +52 -31
- package/dist/commands/agent.js +91 -45
- package/dist/commands/ci.d.ts +88 -0
- package/dist/commands/ci.js +429 -0
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +104 -8
- package/dist/commands/init.js +8 -0
- package/dist/commands/project.d.ts +78 -0
- package/dist/commands/project.js +429 -5
- package/dist/commands/schedule.d.ts +120 -0
- package/dist/commands/schedule.js +487 -0
- package/dist/commands/test.d.ts +176 -2
- package/dist/commands/test.js +2235 -609
- package/dist/commands/testlist.d.ts +88 -0
- package/dist/commands/testlist.js +753 -0
- package/dist/commands/tunnel.d.ts +72 -0
- package/dist/commands/tunnel.js +367 -0
- package/dist/index.js +113 -40
- package/dist/lib/agent-targets.d.ts +13 -4
- package/dist/lib/agent-targets.js +11 -2
- package/dist/lib/conflict-reason.d.ts +30 -0
- package/dist/lib/conflict-reason.js +45 -0
- package/dist/lib/credentials.js +42 -1
- package/dist/lib/cron.d.ts +40 -0
- package/dist/lib/cron.js +190 -0
- package/dist/lib/dry-run/samples.d.ts +9 -0
- package/dist/lib/dry-run/samples.js +293 -55
- package/dist/lib/errors.d.ts +9 -0
- package/dist/lib/errors.js +11 -0
- package/dist/lib/gh-output.d.ts +33 -1
- package/dist/lib/gh-output.js +97 -27
- package/dist/lib/http.d.ts +119 -0
- package/dist/lib/http.js +243 -2
- package/dist/lib/interrupt.d.ts +38 -13
- package/dist/lib/interrupt.js +130 -15
- package/dist/lib/junit-report.d.ts +20 -2
- package/dist/lib/junit-report.js +38 -5
- package/dist/lib/local-target.d.ts +95 -0
- package/dist/lib/local-target.js +184 -0
- package/dist/lib/plan-poll.d.ts +171 -0
- package/dist/lib/plan-poll.js +442 -0
- package/dist/lib/plans.types.d.ts +130 -0
- package/dist/lib/plans.types.js +31 -0
- package/dist/lib/poll-support.d.ts +26 -0
- package/dist/lib/poll-support.js +65 -0
- package/dist/lib/poll.d.ts +1 -0
- package/dist/lib/poll.js +2 -40
- package/dist/lib/proxy.d.ts +16 -0
- package/dist/lib/proxy.js +19 -1
- package/dist/lib/response-schemas.d.ts +20 -0
- package/dist/lib/response-schemas.js +55 -1
- package/dist/lib/run-progress.d.ts +41 -0
- package/dist/lib/run-progress.js +56 -0
- package/dist/lib/runs.types.d.ts +32 -3
- package/dist/lib/secret-file.d.ts +15 -0
- package/dist/lib/secret-file.js +82 -0
- package/dist/lib/target-url-preflight.d.ts +91 -0
- package/dist/lib/target-url-preflight.js +259 -0
- package/dist/lib/target-url.d.ts +63 -9
- package/dist/lib/target-url.js +283 -62
- package/dist/lib/telemetry.d.ts +11 -0
- package/dist/lib/telemetry.js +1 -0
- package/dist/lib/testlist.types.d.ts +77 -0
- package/dist/lib/testlist.types.js +9 -0
- package/dist/lib/ticker.d.ts +8 -0
- package/dist/lib/ticker.js +3 -0
- package/dist/lib/tunnel-session.d.ts +129 -0
- package/dist/lib/tunnel-session.js +232 -0
- package/dist/lib/tunnel.types.d.ts +54 -0
- package/dist/lib/tunnel.types.js +8 -0
- package/dist/lib/v3-advisory.d.ts +35 -22
- package/dist/lib/v3-advisory.js +44 -24
- package/dist/lib/wait-exit.d.ts +29 -0
- package/dist/lib/wait-exit.js +103 -0
- package/dist/vendor/tunnel-client/client.d.ts +83 -0
- package/dist/vendor/tunnel-client/client.js +871 -0
- package/dist/vendor/tunnel-client/config.d.ts +41 -0
- package/dist/vendor/tunnel-client/config.js +42 -0
- package/dist/vendor/tunnel-client/index.d.ts +9 -0
- package/dist/vendor/tunnel-client/index.js +9 -0
- package/dist/vendor/tunnel-client/lodash-lite.d.ts +14 -0
- package/dist/vendor/tunnel-client/lodash-lite.js +24 -0
- package/dist/vendor/tunnel-client/protocol.d.ts +60 -0
- package/dist/vendor/tunnel-client/protocol.js +143 -0
- package/dist/vendor/tunnel-client/types.d.ts +96 -0
- package/dist/vendor/tunnel-client/types.js +10 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +206 -0
- package/dist/vendor/tunnel-client/ws-compat.js +316 -0
- package/dist/version-guard.d.ts +10 -7
- package/dist/version-guard.js +37 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/skills/testsprite-onboard.skill.md +60 -4
- package/skills/testsprite-verify.codex.md +22 -16
- package/skills/testsprite-verify.skill.md +27 -18
package/dist/lib/target-url.js
CHANGED
|
@@ -2,25 +2,52 @@
|
|
|
2
2
|
* CLI-side pre-flight guard for `--target-url`.
|
|
3
3
|
*
|
|
4
4
|
* Defense-in-depth: the backend is the trust boundary and performs DNS
|
|
5
|
-
* resolution.
|
|
6
|
-
* fast, friendly error before sending the request
|
|
7
|
-
* DNS rebinding (a public hostname that resolves to a private
|
|
8
|
-
*
|
|
5
|
+
* resolution. `assertNotLocal` below does **literal-only** checks
|
|
6
|
+
* to give a fast, friendly error before sending the request — it cannot by
|
|
7
|
+
* itself detect DNS rebinding (a public hostname that resolves to a private
|
|
8
|
+
* IP). That gap is closed one layer up: `target-url-preflight.ts` reuses
|
|
9
|
+
* `disallowedIpReason` (exported below) against the actually-*resolved*
|
|
10
|
+
* address before probing, so the same range list guards both the literal
|
|
11
|
+
* string and the DNS answer — not two drifting copies of it.
|
|
9
12
|
*
|
|
10
13
|
* CLI-side target-url guard (exit 5 on any rejection):
|
|
11
14
|
* - Reject non-http(s) schemes
|
|
12
|
-
* - Reject `localhost`, `127.0.0.0/8`, `0.0.0.0`, and IPv6 loopback/unspecified (`::1`, `::`)
|
|
15
|
+
* - Reject `localhost`, `127.0.0.0/8`, `0.0.0.0/8`, and IPv6 loopback/unspecified (`::1`, `::`)
|
|
13
16
|
* - Reject `169.254.0.0/16` link-local and the `169.254.169.254` metadata address
|
|
14
17
|
* - Reject RFC1918 literal IPv4 (10.x, 172.16-31.x, 192.168.x)
|
|
15
|
-
* - Reject
|
|
16
|
-
*
|
|
18
|
+
* - Reject carrier-grade NAT (`100.64.0.0/10`), multicast (`224.0.0.0/4`),
|
|
19
|
+
* and class E / limited broadcast (`240.0.0.0/4`)
|
|
20
|
+
* - Decode and re-classify the low 32 bits of standard embedded-IPv4 forms:
|
|
21
|
+
* IPv4-mapped/translated, RFC 6052 NAT64 (`64:ff9b::/96`), and deprecated
|
|
22
|
+
* IPv4-compatible (`::/96`); public embedded IPv4 addresses stay allowed
|
|
23
|
+
* - Reject RFC 8215's NAT64 local-use range (`64:ff9b:1::/48`) wholesale
|
|
24
|
+
* - Reject IPv6 link-local (`fe80::/10`), unique-local (`fc00::/7`), and
|
|
25
|
+
* deprecated site-local (`fec0::/10`)
|
|
17
26
|
*/
|
|
27
|
+
import * as net from 'node:net';
|
|
18
28
|
import { ApiError } from './errors.js';
|
|
19
|
-
|
|
29
|
+
// `--local-host` accepts EXACTLY `localhost`, `127.0.0.1`, `::1` (mirroring
|
|
30
|
+
// the server's `isLoopbackString`) — not "anything loopback-shaped". This
|
|
31
|
+
// hint is only honest for those three literal hosts (`0.0.0.0` and `::`
|
|
32
|
+
// join them below because binding to the unspecified address also answers
|
|
33
|
+
// on `127.0.0.1`/`::1`, so `--local`'s default dial reaches it) — NOT for
|
|
34
|
+
// the rest of `127.0.0.0/8`, which `--local` cannot dial by name at all. See
|
|
35
|
+
// `'loopback-other'` below for that distinction.
|
|
36
|
+
const LOCAL_DEV_HINT = "This looks like a local-dev target. Run it with `testsprite test run <test-id> --local <port>` instead — it tunnels this machine's loopback address to the test runner (frontend tests only; requires an API key with the `run:tunnel` scope).";
|
|
37
|
+
// Private, reserved, link-local, and metadata addresses are network-reachable from
|
|
38
|
+
// the caller's own machine in general (a LAN or VPN address usually answers)
|
|
39
|
+
// — what is actually true, and all this hint claims, is that TestSprite's
|
|
40
|
+
// execution modes cannot target them: `--target-url` refuses them outright,
|
|
41
|
+
// and `--local`'s tunnel only ever dials `localhost` / `127.0.0.1` / `::1`
|
|
42
|
+
// on THIS machine, never a LAN/VPC address. Embedded IPv4 addresses inherit
|
|
43
|
+
// this hint only after their decoded IPv4 address lands in this class.
|
|
44
|
+
const PRIVATE_NETWORK_HINT = 'This is a private/reserved network address (private, link-local, multicast, or metadata). ' +
|
|
45
|
+
'TestSprite cannot use it as --target-url, and --local cannot tunnel it either — --local only ' +
|
|
46
|
+
'reaches localhost, 127.0.0.1, or ::1 on this machine.';
|
|
20
47
|
/**
|
|
21
48
|
* Throws a local `VALIDATION_ERROR` (exit 5) when `rawUrl` is a
|
|
22
|
-
* disallowed target — localhost
|
|
23
|
-
*
|
|
49
|
+
* disallowed target — localhost or a private/reserved literal IP. Also rejects
|
|
50
|
+
* non-http(s) schemes.
|
|
24
51
|
*
|
|
25
52
|
* Silently returns on allowed URLs.
|
|
26
53
|
*/
|
|
@@ -44,79 +71,273 @@ export function assertNotLocal(rawUrl) {
|
|
|
44
71
|
// IP literals are already dot-normalized by the WHATWG URL parser, so this
|
|
45
72
|
// only affects named hosts.
|
|
46
73
|
const host = parsed.hostname.toLowerCase().replace(/\.$/, '');
|
|
47
|
-
//
|
|
48
|
-
|
|
74
|
+
// 'localhost' is a name, not an IP literal, so it sits outside
|
|
75
|
+
// `disallowedIpReason` below (which classifies IPv4/IPv6 address forms).
|
|
76
|
+
// It is also always loopback — the same class `--local` can reach.
|
|
77
|
+
if (host === 'localhost') {
|
|
49
78
|
throw localTargetError('target-url', 'localhost targets are not allowed', LOCAL_DEV_HINT);
|
|
50
79
|
}
|
|
80
|
+
const disallowed = disallowedIpReason(host);
|
|
81
|
+
if (disallowed !== undefined) {
|
|
82
|
+
throw localTargetError('target-url', disallowed.reason, hintFor(disallowed.hintKind));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Map a classification's `hintKind` to the hint text `assertNotLocal` attaches
|
|
87
|
+
* to the rejection — or no hint at all for `'loopback-other'`/`'undecided'`.
|
|
88
|
+
* Kept as its own function so the four-way mapping is a single, testable
|
|
89
|
+
* spot rather than a nested ternary repeated wherever a classification is
|
|
90
|
+
* consumed.
|
|
91
|
+
*/
|
|
92
|
+
function hintFor(hintKind) {
|
|
93
|
+
switch (hintKind) {
|
|
94
|
+
case 'loopback':
|
|
95
|
+
return LOCAL_DEV_HINT;
|
|
96
|
+
case 'loopback-other':
|
|
97
|
+
return undefined;
|
|
98
|
+
case 'private':
|
|
99
|
+
return PRIVATE_NETWORK_HINT;
|
|
100
|
+
case 'undecided':
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Classify a bare IP-address literal — IPv4 dotted form, or IPv6 optionally
|
|
106
|
+
* wrapped in the `[...]` bracket notation `URL.hostname` uses — against the
|
|
107
|
+
* private/loopback/link-local/metadata blocklist. Returns the disallowed
|
|
108
|
+
* classification, or `undefined` when the address is allowed.
|
|
109
|
+
*
|
|
110
|
+
* This is the single source of truth for the range list: `assertNotLocal`
|
|
111
|
+
* calls it for the literal `--target-url` string above, and the reachability
|
|
112
|
+
* preflight (`target-url-preflight.ts`) calls it again for a DNS-*resolved*
|
|
113
|
+
* address — a public-looking hostname whose A/AAAA record actually points
|
|
114
|
+
* at a private or metadata IP (DNS rebinding) is a distinct bypass from a
|
|
115
|
+
* literal private IP typed on the command line, and both need the same
|
|
116
|
+
* range list, not two drifting copies of it.
|
|
117
|
+
*/
|
|
118
|
+
export function disallowedIpReason(host) {
|
|
51
119
|
// IPv6 literals. Node's URL parser wraps IPv6 hosts in brackets and
|
|
52
120
|
// normalizes IPv4-mapped forms to hex (`http://[::ffff:127.0.0.1]` →
|
|
53
121
|
// hostname `[::ffff:7f00:1]`). A dotted-form string check alone would miss
|
|
54
122
|
// the normalized variant, so we strip the brackets and classify the
|
|
55
|
-
// address family explicitly.
|
|
56
|
-
|
|
57
|
-
|
|
123
|
+
// address family explicitly. A DNS-resolved IPv6 address arrives
|
|
124
|
+
// unbracketed already; stripping is a no-op for that shape.
|
|
125
|
+
const bare = host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host;
|
|
126
|
+
const addressFamily = net.isIP(bare);
|
|
127
|
+
if (addressFamily === 6) {
|
|
128
|
+
return disallowedIpv6Reason(bare.toLowerCase());
|
|
58
129
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
130
|
+
return addressFamily === 4 ? disallowedIpv4Reason(bare) : undefined;
|
|
131
|
+
}
|
|
132
|
+
function disallowedIpv4Reason(address) {
|
|
133
|
+
// Unspecified — binds every interface, including loopback.
|
|
134
|
+
if (address === '0.0.0.0') {
|
|
135
|
+
return { reason: 'localhost targets are not allowed', hintKind: 'loopback' };
|
|
62
136
|
}
|
|
63
|
-
//
|
|
64
|
-
if (
|
|
65
|
-
|
|
137
|
+
// Only the literal 127.0.0.1 is in `--local-host`'s exact accepted set.
|
|
138
|
+
if (ipv4LoopbackBlocklist.check(address, 'ipv4')) {
|
|
139
|
+
return {
|
|
140
|
+
reason: 'loopback addresses are not allowed',
|
|
141
|
+
hintKind: address === '127.0.0.1' ? 'loopback' : 'loopback-other',
|
|
142
|
+
};
|
|
66
143
|
}
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
144
|
+
// AWS instance-metadata service. Keep the specific diagnostic ahead of the
|
|
145
|
+
// enclosing link-local subnet rule.
|
|
146
|
+
if (address === '169.254.169.254') {
|
|
147
|
+
return {
|
|
148
|
+
reason: '169.254.169.254 (AWS metadata service) is not allowed',
|
|
149
|
+
hintKind: 'private',
|
|
150
|
+
};
|
|
70
151
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (isRfc1918Literal(host)) {
|
|
74
|
-
throw localTargetError('target-url', 'private/RFC1918 addresses are not allowed', LOCAL_DEV_HINT);
|
|
152
|
+
if (ipv4ThisNetworkBlocklist.check(address, 'ipv4')) {
|
|
153
|
+
return { reason: 'reserved "this network" addresses are not allowed', hintKind: 'private' };
|
|
75
154
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
return
|
|
155
|
+
if (ipv4LinkLocalBlocklist.check(address, 'ipv4')) {
|
|
156
|
+
return { reason: 'link-local addresses are not allowed', hintKind: 'private' };
|
|
157
|
+
}
|
|
158
|
+
if (ipv4Rfc1918Blocklist.check(address, 'ipv4')) {
|
|
159
|
+
return { reason: 'private/RFC1918 addresses are not allowed', hintKind: 'private' };
|
|
160
|
+
}
|
|
161
|
+
if (ipv4CgnatBlocklist.check(address, 'ipv4')) {
|
|
162
|
+
return { reason: 'carrier-grade NAT addresses are not allowed', hintKind: 'private' };
|
|
163
|
+
}
|
|
164
|
+
if (ipv4MulticastBlocklist.check(address, 'ipv4')) {
|
|
165
|
+
return { reason: 'multicast addresses are not allowed', hintKind: 'private' };
|
|
166
|
+
}
|
|
167
|
+
if (ipv4ClassEBlocklist.check(address, 'ipv4')) {
|
|
168
|
+
return { reason: 'reserved/class E addresses are not allowed', hintKind: 'private' };
|
|
169
|
+
}
|
|
170
|
+
return undefined;
|
|
92
171
|
}
|
|
93
172
|
/**
|
|
94
|
-
*
|
|
95
|
-
* IPv4-mapped (`::ffff
|
|
96
|
-
* (`
|
|
173
|
+
* Standard IPv6 forms that encode a literal IPv4 address in their low 32 bits —
|
|
174
|
+
* IPv4-mapped (`::ffff:a.b.c.d`), IPv4-translated (`::ffff:0:a.b.c.d`),
|
|
175
|
+
* RFC 6052's well-known NAT64 prefix (`64:ff9b::/96`), and IPv4-compatible
|
|
176
|
+
* (deprecated, `::a.b.c.d`). RFC 8215's local-use `64:ff9b:1::/48` is a
|
|
177
|
+
* separate blanket refusal because its embedded address is not in the low
|
|
178
|
+
* 32 bits.
|
|
179
|
+
*
|
|
180
|
+
* `net.BlockList` — binary subnet matching, not a per-spelling regex or
|
|
181
|
+
* `startsWith` — is what makes the spelling question go away entirely: the
|
|
182
|
+
* WHATWG URL parser COMPRESSES some of these forms
|
|
183
|
+
* (`0:0:0:0:0:ffff:a9fe:a9fe` → `::ffff:a9fe:a9fe`) while it PRESERVES others
|
|
184
|
+
* verbatim (`::ffff:0:a9fe:a9fe` stays exactly as typed), so a check tuned to
|
|
185
|
+
* one textual shape reliably misses the other — which is exactly how
|
|
186
|
+
* `64:ff9b::a9fe:a9fe` (NAT64-encoded AWS metadata) once reached the network
|
|
187
|
+
* unrejected. Binary matching also holds for NON-canonical input, which a
|
|
188
|
+
* `startsWith` check on a canonical-form assumption does not.
|
|
189
|
+
*
|
|
190
|
+
* Each class keeps its own list so it can be decoded only where its prefix
|
|
191
|
+
* defines the low 32 bits as IPv4. The three are checked mapped → NAT64 →
|
|
192
|
+
* compatible, preserving the established class precedence.
|
|
97
193
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
194
|
+
* This is the SAME primitive `src/vendor/tunnel-client/client.ts`'s
|
|
195
|
+
* `blockedTargetReason` already uses for the identical problem (see its
|
|
196
|
+
* VENDOR.md deltas #7/#10) — the two host classifiers in this repo now
|
|
197
|
+
* share one mechanism instead of two independently maintained spelling
|
|
198
|
+
* lists, so a future NAT64-shaped bypass can't reopen only one of them.
|
|
199
|
+
*
|
|
200
|
+
* The matched `/96` forms are decoded from their final two 16-bit groups and
|
|
201
|
+
* re-classified through the IPv4 blocklists. This makes an embedded public
|
|
202
|
+
* address public while preserving the decoded address's exact hint class.
|
|
203
|
+
*/
|
|
204
|
+
const IPV4_MAPPED_SUBNETS = [
|
|
205
|
+
// Exact `/96` prefixes whose canonical `::` head contains only zero/ffff
|
|
206
|
+
// groups. Keeping them exact avoids the old `/80` rule's false positives on
|
|
207
|
+
// a non-embedded group while covering mapped, translated, and repeated-ffff
|
|
208
|
+
// spellings on the same binary value seen by URL and DNS paths.
|
|
209
|
+
['0:0:0:0:0:ffff:0:0', 96],
|
|
210
|
+
['0:0:0:0:ffff:0:0:0', 96],
|
|
211
|
+
['0:0:0:0:ffff:ffff:0:0', 96],
|
|
212
|
+
['0:0:0:ffff:0:0:0:0', 96],
|
|
213
|
+
['0:0:0:ffff:0:ffff:0:0', 96],
|
|
214
|
+
['0:0:0:ffff:ffff:0:0:0', 96],
|
|
215
|
+
['0:0:0:ffff:ffff:ffff:0:0', 96],
|
|
216
|
+
['0:0:ffff:0:0:ffff:0:0', 96],
|
|
217
|
+
['0:0:ffff:0:ffff:0:0:0', 96],
|
|
218
|
+
['0:0:ffff:0:ffff:ffff:0:0', 96],
|
|
219
|
+
['0:0:ffff:ffff:0:0:0:0', 96],
|
|
220
|
+
['0:0:ffff:ffff:0:ffff:0:0', 96],
|
|
221
|
+
['0:0:ffff:ffff:ffff:0:0:0', 96],
|
|
222
|
+
['0:0:ffff:ffff:ffff:ffff:0:0', 96],
|
|
223
|
+
];
|
|
224
|
+
/**
|
|
225
|
+
* The RFC 6052 well-known prefix stores IPv4 in the final 32 bits, so it can
|
|
226
|
+
* be decoded. RFC 8215 local-use has a different bit layout and stays a
|
|
227
|
+
* separate, undecoded `/48` blanket refusal.
|
|
228
|
+
*/
|
|
229
|
+
const NAT64_SUBNETS = [['64:ff9b::', 96]];
|
|
230
|
+
const NAT64_LOCAL_USE_SUBNETS = [['64:ff9b:1::', 48]];
|
|
231
|
+
/**
|
|
232
|
+
* Deprecated IPv4-compatible addresses use `::/96`; a broader `::/32` would
|
|
233
|
+
* read genuine IPv6 interface bits as IPv4 and reject targets the backend
|
|
234
|
+
* accepts. `::` and `::1` are exact-matched before this list is consulted.
|
|
102
235
|
*/
|
|
103
|
-
|
|
236
|
+
const IPV4_COMPATIBLE_SUBNETS = [['::', 96]];
|
|
237
|
+
function blocklistOf(subnets, family) {
|
|
238
|
+
const list = new net.BlockList();
|
|
239
|
+
for (const [network, prefix] of subnets) {
|
|
240
|
+
list.addSubnet(network, prefix, family);
|
|
241
|
+
}
|
|
242
|
+
return list;
|
|
243
|
+
}
|
|
244
|
+
const ipv4ThisNetworkBlocklist = blocklistOf([['0.0.0.0', 8]], 'ipv4');
|
|
245
|
+
const ipv4LoopbackBlocklist = blocklistOf([['127.0.0.0', 8]], 'ipv4');
|
|
246
|
+
const ipv4Rfc1918Blocklist = blocklistOf([
|
|
247
|
+
['10.0.0.0', 8],
|
|
248
|
+
['172.16.0.0', 12],
|
|
249
|
+
['192.168.0.0', 16],
|
|
250
|
+
], 'ipv4');
|
|
251
|
+
const ipv4CgnatBlocklist = blocklistOf([['100.64.0.0', 10]], 'ipv4');
|
|
252
|
+
const ipv4LinkLocalBlocklist = blocklistOf([['169.254.0.0', 16]], 'ipv4');
|
|
253
|
+
const ipv4MulticastBlocklist = blocklistOf([['224.0.0.0', 4]], 'ipv4');
|
|
254
|
+
const ipv4ClassEBlocklist = blocklistOf([['240.0.0.0', 4]], 'ipv4');
|
|
255
|
+
const ipv4MappedBlocklist = blocklistOf(IPV4_MAPPED_SUBNETS, 'ipv6');
|
|
256
|
+
const nat64Blocklist = blocklistOf(NAT64_SUBNETS, 'ipv6');
|
|
257
|
+
const nat64LocalUseBlocklist = blocklistOf(NAT64_LOCAL_USE_SUBNETS, 'ipv6');
|
|
258
|
+
const ipv4CompatibleBlocklist = blocklistOf(IPV4_COMPATIBLE_SUBNETS, 'ipv6');
|
|
259
|
+
const ipv6LinkLocalBlocklist = blocklistOf([['fe80::', 10]], 'ipv6');
|
|
260
|
+
const ipv6UniqueLocalBlocklist = blocklistOf([['fc00::', 7]], 'ipv6');
|
|
261
|
+
const ipv6SiteLocalBlocklist = blocklistOf([['fec0::', 10]], 'ipv6');
|
|
262
|
+
function decodeLow32BitsAsIpv4(address) {
|
|
263
|
+
const groups = address.split(':');
|
|
264
|
+
const last = groups.at(-1);
|
|
265
|
+
if (last === undefined)
|
|
266
|
+
return undefined;
|
|
267
|
+
// A DNS result can preserve the human-written dotted tail even though the
|
|
268
|
+
// WHATWG URL path canonicalises it to two hex groups.
|
|
269
|
+
if (net.isIP(last) === 4)
|
|
270
|
+
return last;
|
|
271
|
+
const secondLast = groups.at(-2);
|
|
272
|
+
if (secondLast === undefined)
|
|
273
|
+
return undefined;
|
|
274
|
+
const high = Number.parseInt(secondLast, 16);
|
|
275
|
+
const low = Number.parseInt(last, 16);
|
|
276
|
+
if (!Number.isInteger(high) || !Number.isInteger(low))
|
|
277
|
+
return undefined;
|
|
278
|
+
return `${(high >> 8) & 0xff}.${high & 0xff}.${(low >> 8) & 0xff}.${low & 0xff}`;
|
|
279
|
+
}
|
|
280
|
+
function reclassifyEmbeddedIpv4(address, label) {
|
|
281
|
+
const decoded = decodeLow32BitsAsIpv4(address);
|
|
282
|
+
if (decoded === undefined) {
|
|
283
|
+
return {
|
|
284
|
+
reason: `${label} address could not be decoded safely`,
|
|
285
|
+
hintKind: 'undecided',
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
const decodedClassification = disallowedIpv4Reason(decoded);
|
|
289
|
+
if (decodedClassification === undefined)
|
|
290
|
+
return undefined;
|
|
291
|
+
return {
|
|
292
|
+
reason: `${label} address embeds disallowed IPv4 address ${decoded}: ${decodedClassification.reason}`,
|
|
293
|
+
hintKind: decodedClassification.hintKind,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Classify disallowed IPv6 literals: loopback (`::1`), unspecified (`::`),
|
|
298
|
+
* the embedded-IPv4 family (see {@link IPV4_MAPPED_SUBNETS}'s doc comment),
|
|
299
|
+
* link-local (`fe80::/10`), unique-local (`fc00::/7`), and deprecated
|
|
300
|
+
* site-local (`fec0::/10`). `inner` is the
|
|
301
|
+
* bracket-stripped, already-lowercased host — `disallowedIpReason` lowercases
|
|
302
|
+
* it on the way in rather than trusting every caller to.
|
|
303
|
+
*/
|
|
304
|
+
function disallowedIpv6Reason(inner) {
|
|
104
305
|
// Loopback (::1) and unspecified (::).
|
|
105
306
|
if (inner === '::1' || inner === '::') {
|
|
106
|
-
|
|
307
|
+
return { reason: 'localhost targets are not allowed', hintKind: 'loopback' };
|
|
308
|
+
}
|
|
309
|
+
// Embedded-IPv4 family, checked mapped → NAT64 → compatible. Standard /96
|
|
310
|
+
// forms inherit the decoded IPv4 classification; RFC 8215 local-use stays
|
|
311
|
+
// wholesale and undecided because its embedded address has a different bit
|
|
312
|
+
// position.
|
|
313
|
+
if (ipv4MappedBlocklist.check(inner, 'ipv6')) {
|
|
314
|
+
return reclassifyEmbeddedIpv4(inner, 'IPv4-mapped/translated IPv6');
|
|
315
|
+
}
|
|
316
|
+
if (nat64Blocklist.check(inner, 'ipv6')) {
|
|
317
|
+
return reclassifyEmbeddedIpv4(inner, 'NAT64-translated IPv6');
|
|
318
|
+
}
|
|
319
|
+
if (nat64LocalUseBlocklist.check(inner, 'ipv6')) {
|
|
320
|
+
return {
|
|
321
|
+
reason: 'NAT64 local-use addresses are not allowed',
|
|
322
|
+
hintKind: 'undecided',
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
if (ipv4CompatibleBlocklist.check(inner, 'ipv6')) {
|
|
326
|
+
return reclassifyEmbeddedIpv4(inner, 'IPv4-compatible/deprecated IPv6');
|
|
107
327
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
throw localTargetError('target-url', 'IPv4-mapped IPv6 addresses are not allowed; use the IPv4 form or a hostname', LOCAL_DEV_HINT);
|
|
328
|
+
if (ipv6LinkLocalBlocklist.check(inner, 'ipv6')) {
|
|
329
|
+
return { reason: 'link-local addresses are not allowed', hintKind: 'private' };
|
|
111
330
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
throw localTargetError('target-url', 'link-local addresses are not allowed', LOCAL_DEV_HINT);
|
|
331
|
+
if (ipv6UniqueLocalBlocklist.check(inner, 'ipv6')) {
|
|
332
|
+
return { reason: 'unique-local (private) addresses are not allowed', hintKind: 'private' };
|
|
115
333
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
334
|
+
if (ipv6SiteLocalBlocklist.check(inner, 'ipv6')) {
|
|
335
|
+
return {
|
|
336
|
+
reason: 'site-local (deprecated private) addresses are not allowed',
|
|
337
|
+
hintKind: 'private',
|
|
338
|
+
};
|
|
119
339
|
}
|
|
340
|
+
return undefined;
|
|
120
341
|
}
|
|
121
342
|
function localTargetError(field, reason, hint) {
|
|
122
343
|
return ApiError.fromEnvelope({
|
package/dist/lib/telemetry.d.ts
CHANGED
|
@@ -19,6 +19,15 @@ export interface TelemetryOutcomeInput {
|
|
|
19
19
|
endpointUrl?: string;
|
|
20
20
|
output?: string;
|
|
21
21
|
dryRun?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* True when the invocation requested a local tunnel target (`test run
|
|
24
|
+
* --local <port>`) — the flag's mere presence, never its port number or
|
|
25
|
+
* host. Reported regardless of outcome, including a zero-network refusal
|
|
26
|
+
* (dead port, `--local` combined with an incompatible flag): those are
|
|
27
|
+
* exactly the attempts nothing server-side ever sees, which is why this
|
|
28
|
+
* field is not redundant with a backend-side mint/attach analytics event.
|
|
29
|
+
*/
|
|
30
|
+
local?: boolean;
|
|
22
31
|
}
|
|
23
32
|
export interface TelemetryDeps {
|
|
24
33
|
env?: NodeJS.ProcessEnv;
|
|
@@ -51,6 +60,8 @@ export interface TelemetryEvent {
|
|
|
51
60
|
nodeVersion?: string;
|
|
52
61
|
output?: string;
|
|
53
62
|
ci?: boolean;
|
|
63
|
+
/** Present (always `true`) only for a `test run --local` invocation; absent otherwise. */
|
|
64
|
+
local?: boolean;
|
|
54
65
|
}
|
|
55
66
|
/**
|
|
56
67
|
* Map a thrown CLI error to its telemetry disposition — mirrors the exit-code
|
package/dist/lib/telemetry.js
CHANGED
|
@@ -88,6 +88,7 @@ export function buildTelemetryEvent(input, env, isTTY) {
|
|
|
88
88
|
nodeVersion: process.versions.node,
|
|
89
89
|
...(input.output === 'json' || input.output === 'text' ? { output: input.output } : {}),
|
|
90
90
|
ci: isTruthyEnv(env.CI) || !isTTY,
|
|
91
|
+
...(input.local ? { local: true } : {}),
|
|
91
92
|
};
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire shapes for the `/api/cli/v1/testlist/*` surface (CRUD).
|
|
3
|
+
*
|
|
4
|
+
* `testId` on a case IS the test's logical id (`test_case.key`) — the same id
|
|
5
|
+
* `test list` / `test get` return and `test run` accepts, so a case can be added
|
|
6
|
+
* to a list with no translation.
|
|
7
|
+
*/
|
|
8
|
+
import type { RunConflict } from './conflict-reason.js';
|
|
9
|
+
export interface CliProjectEnvironment {
|
|
10
|
+
projectId: string;
|
|
11
|
+
environmentName: string;
|
|
12
|
+
}
|
|
13
|
+
/** A test-list row (no cases) — `testlist list`. */
|
|
14
|
+
export interface CliTestList {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
orgId: string;
|
|
18
|
+
caseCount: number;
|
|
19
|
+
projectEnvironments: CliProjectEnvironment[];
|
|
20
|
+
lastExecutionId: string | null;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
}
|
|
24
|
+
/** One case inside a list — `testlist get`. */
|
|
25
|
+
export interface CliTestListCase {
|
|
26
|
+
/** The test's logical id (== `test_case.key`). */
|
|
27
|
+
testId: string;
|
|
28
|
+
type: 'frontend' | 'backend';
|
|
29
|
+
projectId: string;
|
|
30
|
+
projectName: string;
|
|
31
|
+
title: string | null;
|
|
32
|
+
category: string | null;
|
|
33
|
+
priority: string | null;
|
|
34
|
+
modified: string | null;
|
|
35
|
+
status: string | null;
|
|
36
|
+
}
|
|
37
|
+
/** Full detail incl. cases + stats — `testlist get` / after a mutation. */
|
|
38
|
+
export interface CliTestListDetail extends CliTestList {
|
|
39
|
+
cases: CliTestListCase[];
|
|
40
|
+
stats: {
|
|
41
|
+
total: number;
|
|
42
|
+
passed: number;
|
|
43
|
+
failed: number;
|
|
44
|
+
blocked: number;
|
|
45
|
+
running: number;
|
|
46
|
+
};
|
|
47
|
+
lastExecutionCreated: string | null;
|
|
48
|
+
}
|
|
49
|
+
export interface CliTestListListResponse {
|
|
50
|
+
items: CliTestList[];
|
|
51
|
+
}
|
|
52
|
+
export interface CliDeleteTestListResponse {
|
|
53
|
+
listId: string;
|
|
54
|
+
}
|
|
55
|
+
/** One dispatched run from `testlist run` — `runId` polls via `GET /runs/{runId}`. */
|
|
56
|
+
export interface CliTestListRunAccepted {
|
|
57
|
+
testId: string;
|
|
58
|
+
runId: string;
|
|
59
|
+
enqueuedAt: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `testlist run` result. Mirrors the batch-run-fresh envelope so `--wait` reuses
|
|
63
|
+
* the same poll/summary tail. `conflicts[]` carry the in-flight `currentRunId`
|
|
64
|
+
* (poll it instead of retrying). `deferred[]` carries the cases the per-key
|
|
65
|
+
* run-rate budget could not admit this call (retry after ~60s). `notFound[]` is
|
|
66
|
+
* present on a PARTIAL `--case` miss — ids not in this list, skipped (a FULL miss
|
|
67
|
+
* is a 404). `reason` is set only when nothing dispatched (empty list).
|
|
68
|
+
*/
|
|
69
|
+
export interface CliTestListRunResponse {
|
|
70
|
+
accepted: CliTestListRunAccepted[];
|
|
71
|
+
conflicts: RunConflict[];
|
|
72
|
+
deferred: Array<{
|
|
73
|
+
testId: string;
|
|
74
|
+
}>;
|
|
75
|
+
notFound?: string[];
|
|
76
|
+
reason?: 'no_matching_cases' | 'empty_list';
|
|
77
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire shapes for the `/api/cli/v1/testlist/*` surface (CRUD).
|
|
3
|
+
*
|
|
4
|
+
* `testId` on a case IS the test's logical id (`test_case.key`) — the same id
|
|
5
|
+
* `test list` / `test get` return and `test run` accepts, so a case can be added
|
|
6
|
+
* to a list with no translation.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=testlist.types.js.map
|
package/dist/lib/ticker.d.ts
CHANGED
|
@@ -25,6 +25,14 @@ export interface Ticker {
|
|
|
25
25
|
* doesn't run into the result block). No-op on non-TTY.
|
|
26
26
|
*/
|
|
27
27
|
finalize(line?: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* True only when `update()` redraws the SAME terminal line (TTY, ANSI
|
|
30
|
+
* allowed). False on a non-TTY (updates are no-ops) and under NO_COLOR
|
|
31
|
+
* (every update prints a new line). The one signal a between-polls
|
|
32
|
+
* refresher may key on — re-deriving it from process globals elsewhere
|
|
33
|
+
* is how the two decisions drift apart.
|
|
34
|
+
*/
|
|
35
|
+
readonly redrawsInPlace: boolean;
|
|
28
36
|
}
|
|
29
37
|
/**
|
|
30
38
|
* Returns true when NO_COLOR is present in the environment and is not
|
package/dist/lib/ticker.js
CHANGED
|
@@ -49,6 +49,7 @@ export function createTicker(stderrWrite, isTTY, stderrRaw, noColor) {
|
|
|
49
49
|
if (!tty) {
|
|
50
50
|
// Non-TTY: completely silent.
|
|
51
51
|
return {
|
|
52
|
+
redrawsInPlace: false,
|
|
52
53
|
update: () => undefined,
|
|
53
54
|
finalize: () => undefined,
|
|
54
55
|
};
|
|
@@ -56,6 +57,7 @@ export function createTicker(stderrWrite, isTTY, stderrRaw, noColor) {
|
|
|
56
57
|
if (suppressAnsi) {
|
|
57
58
|
// TTY but NO_COLOR: emit plain-text lines without ANSI escape sequences.
|
|
58
59
|
return {
|
|
60
|
+
redrawsInPlace: false,
|
|
59
61
|
update(line) {
|
|
60
62
|
const stamped = `${new Date().toISOString()} ${line}`;
|
|
61
63
|
stderrWrite(stamped);
|
|
@@ -72,6 +74,7 @@ export function createTicker(stderrWrite, isTTY, stderrRaw, noColor) {
|
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
return {
|
|
77
|
+
redrawsInPlace: true,
|
|
75
78
|
update(line) {
|
|
76
79
|
// ANSI ESC[2K clears the entire line; \r moves to column 0.
|
|
77
80
|
const stamped = `${new Date().toISOString()} ${line}`;
|