my-durable 0.0.114 → 0.0.116

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.
@@ -253,9 +253,20 @@ function diagnosticsDoctorIo(io: DiagnosticsIo): DoctorIo {
253
253
  env: io.env,
254
254
  nodeVersion: io.nodeVersion,
255
255
  // doctor's FetchLike wants json(); this io speaks text() — adapt, never reimplement.
256
+ // r10 h2-1: the adapter used to res.text() the WHOLE body — the doctor
257
+ // section was the one diagnostics read that bypassed the R9 byte caps
258
+ // ("duration is not a byte budget"). Route through the capped reader.
256
259
  fetchImpl: async (url, init) => {
257
260
  const res = await io.fetch(url, init);
258
- return { ok: res.ok, status: res.status, json: async () => JSON.parse(await res.text()) };
261
+ return {
262
+ ok: res.ok,
263
+ status: res.status,
264
+ json: async () => {
265
+ const raw = await readCappedBody(res, API_BODY_MAX_BYTES);
266
+ if (raw.length > API_BODY_MAX_BYTES) throw Error(`doctor body over ${API_BODY_MAX_BYTES} bytes`);
267
+ return JSON.parse(raw);
268
+ },
269
+ };
259
270
  },
260
271
  access: io.accessSync,
261
272
  exists: io.existsSync,
@@ -165,13 +165,20 @@ export function parseRemote(url?: string): ParsedRemote | undefined {
165
165
  path = path.replace(/\/+$/, "").replace(/\.git$/, "");
166
166
  if (!host || !path) return undefined;
167
167
  const h = host.toLowerCase();
168
- const forge: Forge = h === "github.com" || h.endsWith(".github.com") || /(^|\.)github\./.test(h)
169
- ? "github"
170
- : /gitlab/.test(h) || /(^|\.)gitlab\./.test(h)
171
- ? "gitlab"
172
- : /bitbucket/.test(h)
173
- ? "bitbucket"
174
- : "other";
168
+ // r10 h2-6: forge classification is EXACT (host or subdomain of the known
169
+ // forge, or a dedicated DNS label for self-hosted gitlab/bitbucket). The old
170
+ // substring regexes matched github.com.evil.com → GitHub-styled PR buttons
171
+ // on lookalike hosts. A host carrying '@' (scp-form with two @) is never real.
172
+ if (h.includes("@")) return undefined;
173
+ const labels = h.split(".").filter(Boolean);
174
+ const forge: Forge =
175
+ h === "github.com" || h.endsWith(".github.com")
176
+ ? "github"
177
+ : h === "gitlab.com" || h.endsWith(".gitlab.com") || labels.includes("gitlab")
178
+ ? "gitlab"
179
+ : h === "bitbucket.org" || h.endsWith(".bitbucket.org") || labels.includes("bitbucket")
180
+ ? "bitbucket"
181
+ : "other";
175
182
  const scheme = /^http:\/\//.test(raw) ? "http" : "https";
176
183
  return { host, path, forge, webUrl: `${scheme}://${host}/${path}` };
177
184
  }
@@ -569,7 +576,24 @@ async function statusOnce(path: string, key: string): Promise<GitStatus> {
569
576
  // resolve an identity at all. That is the only case worth warning about.
570
577
  out.identityComplete = Boolean(identMatch?.[1]?.trim() && identMatch?.[2]?.trim());
571
578
  if (!out.identityComplete) delete out.identity;
572
- if (remoteP.status === "fulfilled") out.remoteUrl = remoteP.value.trim() || undefined;
579
+ if (remoteP.status === "fulfilled") {
580
+ out.remoteUrl = remoteP.value.trim() || undefined;
581
+ // r10 h2-5: `git remote get-url origin` echoes credential-bearing URLs
582
+ // verbatim (https://user:PAT@forge/…) to every token-holding viewer.
583
+ // Strip userinfo before the value enters status responses and caches.
584
+ if (out.remoteUrl) {
585
+ try {
586
+ const u = new URL(out.remoteUrl);
587
+ if (u.username || u.password) {
588
+ u.username = "";
589
+ u.password = "";
590
+ out.remoteUrl = u.toString();
591
+ }
592
+ } catch {
593
+ /* ssh/scp form: no password syntax */
594
+ }
595
+ }
596
+ }
573
597
  const parsed = parseRemote(out.remoteUrl);
574
598
  if (parsed) {
575
599
  out.forge = parsed.forge;